Skip to content

Commit

Permalink
gpulib: (maybe) rework buffering to reduce flickering
Browse files Browse the repository at this point in the history
was originally made for GPU NEON but i think it should work on current GPU too :P

notaz/pcsx_rearmed#324

notaz/pcsx_rearmed@2da2fc7
  • Loading branch information
saulfabregwiivc committed Apr 9, 2024
1 parent 4ad517f commit 40f9653
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SoftGPU/gpulib_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
2 changes: 1 addition & 1 deletion gpulib/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 13 additions & 9 deletions gpulib/gpulib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 40f9653

Please sign in to comment.