diff --git a/port/src/pdsched.c b/port/src/pdsched.c index 4501b15a5..1f8800565 100644 --- a/port/src/pdsched.c +++ b/port/src/pdsched.c @@ -104,6 +104,7 @@ bool g_SchedIsFirstTask = true; s32 g_PrevFrameFb = -1; s32 g_BlurFb = -1; s32 g_BlurFbCapTimer = -1; +bool g_BlurFbDirty = true; void schedSetCrashEnable1(bool enable) { @@ -390,8 +391,12 @@ void schedConsiderScreenshot(void) if (g_BlurFbCapTimer == 0) { videoCopyFramebuffer(g_BlurFb, 0, -1, -1); g_BlurFbCapTimer = -1; + g_BlurFbDirty = false; } else if (g_BlurFbCapTimer > 0) { --g_BlurFbCapTimer; + } else if (g_BlurFbCapTimer < 0) { + // no blur requested this frame, mark blur fb dirty + g_BlurFbDirty = true; } if (g_MenuData.screenshottimer >= 2) { diff --git a/src/game/bondview.c b/src/game/bondview.c index 2a086c614..af101fa37 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -289,6 +289,14 @@ Gfx *bviewDrawMotionBlur(Gfx *gdl, u32 colour, u32 alpha) if (!videoFramebuffersSupported()) { return gdl; } + + // capture fb at the end of this frame + g_BlurFbCapTimer = 0; + + // don't render first blur frame as we haven't captured the fb yet + if (g_BlurFbDirty) { + return gdl; + } #endif mainOverrideVariable("sfxxx", &sfxxx); @@ -312,7 +320,6 @@ Gfx *bviewDrawMotionBlur(Gfx *gdl, u32 colour, u32 alpha) viewleft << 2, viewtop << 2, viewleft, viewtop, (viewleft + viewwidth) << 2, (viewtop + viewheight) << 2, viewleft + viewwidth, viewtop + viewheight, 0, videoGetNativeWidth(), videoGetNativeHeight()); - g_BlurFbCapTimer = 0; #endif return gdl; @@ -521,6 +528,14 @@ Gfx *bviewDrawZoomBlur(Gfx *gdl, u32 colour, s32 alpha, f32 arg3, f32 arg4) if (!videoFramebuffersSupported()) { return gdl; } + + // capture fb at the end of this frame + g_BlurFbCapTimer = 0; + + // don't render first blur frame as we haven't captured the fb yet + if (g_BlurFbDirty) { + return gdl; + } #endif strcpy(var800a41c0, "stretchBlurGfx"); @@ -550,7 +565,6 @@ Gfx *bviewDrawZoomBlur(Gfx *gdl, u32 colour, s32 alpha, f32 arg3, f32 arg4) left << 2, top << 2, viewleft, viewtop, right << 2, bottom << 2, viewleft + viewwidth, viewtop + viewheight, 0, videoGetNativeWidth(), videoGetNativeHeight()); - g_BlurFbCapTimer = 0; #endif return gdl; diff --git a/src/game/texreset.c b/src/game/texreset.c index 4bf444113..1daf8c737 100644 --- a/src/game/texreset.c +++ b/src/game/texreset.c @@ -139,6 +139,9 @@ void texReset(void) // get backend texture settings g_TexFilter2D = videoGetTextureFilter2D() ? G_TF_BILERP : G_TF_POINT; + + // notify blur code that the blur framebuffer is probably full of garbage + g_BlurFbDirty = true; #endif g_TexWords = mempAlloc(ALIGN16(g_TexNumConfigs * 4), MEMPOOL_STAGE); diff --git a/src/include/data.h b/src/include/data.h index 0b93a521f..2f0afbe88 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -545,6 +545,7 @@ extern u32 g_HudAlignModeR; extern s32 g_PrevFrameFb; extern s32 g_BlurFb; extern s32 g_BlurFbCapTimer; +extern bool g_BlurFbDirty; extern s32 g_TickRateDiv; extern s32 g_MusicDisableMpDeath;