From 40f9653b1c8eb79fcb5356e381fe15019bbbceb4 Mon Sep 17 00:00:00 2001 From: saulfabreg Wii VC Project Date: Tue, 9 Apr 2024 14:03:21 -0500 Subject: [PATCH] gpulib: (maybe) rework buffering to reduce flickering was originally made for GPU NEON but i think it should work on current GPU too :P https://github.com/notaz/pcsx_rearmed/issues/324 https://github.com/notaz/pcsx_rearmed/commit/2da2fc7676c1fc40d26226a7a4c43728d9a2eedf --- SoftGPU/gpulib_if.c | 2 +- gpulib/gpu.h | 2 +- gpulib/gpulib.c | 22 +++++++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/SoftGPU/gpulib_if.c b/SoftGPU/gpulib_if.c index af04d279..31311341 100644 --- a/SoftGPU/gpulib_if.c +++ b/SoftGPU/gpulib_if.c @@ -277,7 +277,7 @@ void renderer_notify_res_change(uint32_t gdata) PSXDisplay.Interlaced = ((gdata & 0x24) ^ 0x24)?FALSE:TRUE; // if 0 - Interlace } -void renderer_notify_scanout_x_change(int x, int w) +void renderer_notify_scanout_change(int x, int y) { } diff --git a/gpulib/gpu.h b/gpulib/gpu.h index 719ec4bd..a6f0314e 100644 --- a/gpulib/gpu.h +++ b/gpulib/gpu.h @@ -179,7 +179,7 @@ void renderer_set_config(const struct rearmed_cbs *config); void renderer_notify_res_change(uint32_t data); void renderer_notify_update_lace(int updated); void renderer_sync(void); -void renderer_notify_scanout_x_change(int x, int w); +void renderer_notify_scanout_change(int x, int y); int vout_init(void); int vout_finish(void); diff --git a/gpulib/gpulib.c b/gpulib/gpulib.c index 4ac36e42..818e3766 100644 --- a/gpulib/gpulib.c +++ b/gpulib/gpulib.c @@ -307,6 +307,7 @@ long LIB_GPUshutdown(void) void LIB_GPUwriteStatus(uint32_t data) { uint32_t cmd = data >> 24; + int src_x, src_y; if (cmd < ARRAY_SIZE(gpu.regs)) { if (cmd > 1 && cmd != 5 && gpu.regs[cmd] == data) @@ -341,14 +342,17 @@ void LIB_GPUwriteStatus(uint32_t data) break; // setting display position case 0x05: - gpu.screen.src_x = data & 0x3ff; - gpu.screen.src_y = (data >> 10) & 0x1ff; - renderer_notify_scanout_x_change(gpu.screen.src_x, gpu.screen.hres); - if (gpu.frameskip.set) { - decide_frameskip_allow(gpu.ex_regs[3]); - if (gpu.frameskip.last_flip_frame != *gpu.state.frame_count) { - decide_frameskip(); - gpu.frameskip.last_flip_frame = *gpu.state.frame_count; + src_x = data & 0x3ff; src_y = (data >> 10) & 0x1ff; + if (src_x != gpu.screen.src_x || src_y != gpu.screen.src_y) { + gpu.screen.src_x = src_x; + gpu.screen.src_y = src_y; + renderer_notify_scanout_change(src_x, src_y); + if (gpu.frameskip.set) { + decide_frameskip_allow(gpu.ex_regs[3]); + if (gpu.frameskip.last_flip_frame != *gpu.state.frame_count) { + decide_frameskip(); + gpu.frameskip.last_flip_frame = *gpu.state.frame_count; + } } } break; @@ -888,7 +892,7 @@ long LIB_GPUfreeze(uint32_t type, struct GPUFreeze *freeze) LIB_GPUwriteStatus((i << 24) | (gpu.regs[i] ^ 1)); } renderer_sync_ecmds(gpu.ex_regs); - renderer_update_caches(0, 0, 1024, 512, 1); + renderer_update_caches(0, 0, 1024, 512, 0); break; }