From 83a155fa49be8568ec1f5f8c9752e6d50e955438 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 12 Nov 2023 15:05:21 +0100 Subject: [PATCH] port: fix #210 by using a separate fullscreen fb for blur effects --- port/src/pdsched.c | 14 ++++++++------ src/game/bondview.c | 8 ++++---- src/include/data.h | 3 ++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/port/src/pdsched.c b/port/src/pdsched.c index bd51c13f4..4501b15a5 100644 --- a/port/src/pdsched.c +++ b/port/src/pdsched.c @@ -102,7 +102,8 @@ OSScMsg g_SchedRspMsg = {OS_SC_RSP_MSG}; bool g_SchedIsFirstTask = true; s32 g_PrevFrameFb = -1; -s32 g_PrevFrameCapTimer = -1; +s32 g_BlurFb = -1; +s32 g_BlurFbCapTimer = -1; void schedSetCrashEnable1(bool enable) { @@ -180,6 +181,7 @@ void osCreateScheduler(OSSched *sc, OSThread *thread, u8 mode, u32 numFields) schedInitCrashLastRendered(); g_PrevFrameFb = videoCreateFramebuffer(0, 0, false, true); + g_BlurFb = videoCreateFramebuffer(0, 0, false, true); } void osScAddClient(OSSched *sc, OSScClient *c, OSMesgQueue *msgQ, bool is30fps) @@ -385,11 +387,11 @@ void schedConsiderScreenshot(void) g_MenuData.screenshottimer = 0; } - if (g_PrevFrameCapTimer == 0) { - videoCopyFramebuffer(g_PrevFrameFb, 0, -1, -1); - g_PrevFrameCapTimer = -1; - } else if (g_PrevFrameCapTimer > 0) { - --g_PrevFrameCapTimer; + if (g_BlurFbCapTimer == 0) { + videoCopyFramebuffer(g_BlurFb, 0, -1, -1); + g_BlurFbCapTimer = -1; + } else if (g_BlurFbCapTimer > 0) { + --g_BlurFbCapTimer; } if (g_MenuData.screenshottimer >= 2) { diff --git a/src/game/bondview.c b/src/game/bondview.c index 1b6935ce0..7101e21d1 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -307,12 +307,12 @@ Gfx *bviewDrawMotionBlur(Gfx *gdl, u32 colour, u32 alpha) somefloat += 1.0f / fyyy; } #else - gDPSetFramebufferTextureEXT(gdl++, 0, 0, 0, g_PrevFrameFb); + gDPSetFramebufferTextureEXT(gdl++, 0, 0, 0, g_BlurFb); gSPImageRectangleEXT(gdl++, viewleft << 2, viewtop << 2, viewleft, viewtop, (viewleft + viewwidth) << 2, (viewtop + viewheight) << 2, viewleft + viewwidth, viewtop + viewheight, 0, videoGetNativeWidth(), videoGetNativeHeight()); - g_PrevFrameCapTimer = 0; + g_BlurFbCapTimer = 0; #endif return gdl; @@ -545,12 +545,12 @@ Gfx *bviewDrawZoomBlur(Gfx *gdl, u32 colour, s32 alpha, f32 arg3, f32 arg4) const s32 top = ycenter - halfh; const s32 right = xcenter + halfw; const s32 bottom = ycenter + halfh; - gDPSetFramebufferTextureEXT(gdl++, 0, 0, 0, g_PrevFrameFb); + gDPSetFramebufferTextureEXT(gdl++, 0, 0, 0, g_BlurFb); gSPImageRectangleEXT(gdl++, left << 2, top << 2, viewleft, viewtop, right << 2, bottom << 2, viewleft + viewwidth, viewtop + viewheight, 0, videoGetNativeWidth(), videoGetNativeHeight()); - g_PrevFrameCapTimer = 0; + g_BlurFbCapTimer = 0; #endif return gdl; diff --git a/src/include/data.h b/src/include/data.h index 9d73ab162..5a897577d 100644 --- a/src/include/data.h +++ b/src/include/data.h @@ -543,7 +543,8 @@ extern s32 g_HudCenter; extern u32 g_HudAlignModeL; extern u32 g_HudAlignModeR; extern s32 g_PrevFrameFb; -extern s32 g_PrevFrameCapTimer; +extern s32 g_BlurFb; +extern s32 g_BlurFbCapTimer; #define PLAYER_EXTCFG() g_PlayerExtCfg[g_Vars.currentplayerstats->mpindex & 3] #define PLAYER_DEFAULT_FOV (PLAYER_EXTCFG().fovy)