From 47c15995b0a92b55272accea2b4033bc4872c46c Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 31 Aug 2023 23:51:19 +0300 Subject: [PATCH] gpu: handle wrapping somewhat instead of crashing outright --- plugins/gpu_neon/psx_gpu/psx_gpu.c | 22 ++++++++++++++++++++-- plugins/gpu_neon/psx_gpu_if.c | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.c b/plugins/gpu_neon/psx_gpu/psx_gpu.c index 370d8f2a..af24e770 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu.c @@ -260,8 +260,8 @@ u32 invalidate_texture_cache_region_viewport(psx_gpu_struct *psx_gpu, u32 x1, return mask; } -void update_texture_cache_region(psx_gpu_struct *psx_gpu, u32 x1, u32 y1, - u32 x2, u32 y2) +static void update_texture_cache_region_(psx_gpu_struct *psx_gpu, + u32 x1, u32 y1, u32 x2, u32 y2) { u32 mask = texture_region_mask(x1, y1, x2, y2); u32 texture_page; @@ -313,6 +313,22 @@ void update_texture_cache_region(psx_gpu_struct *psx_gpu, u32 x1, u32 y1, } } +void update_texture_cache_region(psx_gpu_struct *psx_gpu, u32 x1, u32 y1, + u32 x2, u32 y2) +{ + s32 w = x2 - x1; + do + { + x2 = x1 + w; + if (x2 > 1023) + x2 = 1023; + update_texture_cache_region_(psx_gpu, x1, y1, x2, y2); + w -= x2 - x1; + x1 = 0; + } + while (unlikely(w > 0)); +} + #ifndef NEON_BUILD void update_texture_4bpp_cache(psx_gpu_struct *psx_gpu) @@ -5057,3 +5073,5 @@ void triangle_benchmark(psx_gpu_struct *psx_gpu) #endif #include "psx_gpu_4x.c" + +// vim:ts=2:sw=2:expandtab diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c index 69a2a1bb..4a8b76fc 100644 --- a/plugins/gpu_neon/psx_gpu_if.c +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -151,6 +151,7 @@ sync_enhancement_buffers(int x, int y, int w, int h) } x += (w1 + s) * step_x; + x &= 0x3ff; x_buf = 0; } } -- 2.39.2