From: notaz Date: Thu, 31 Aug 2023 20:51:19 +0000 (+0300) Subject: gpu: handle wrapping somewhat X-Git-Tag: r24l~204 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c279d224ecc6e397bfe1932599be69f02071bdd;p=pcsx_rearmed.git gpu: handle wrapping somewhat instead of crashing outright --- 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 868f7b72..a4b18ab1 100644 --- a/plugins/gpu_neon/psx_gpu_if.c +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -150,6 +150,7 @@ sync_enhancement_buffers(int x, int y, int w, int h) } x += (w1 + s) * step_x; + x &= 0x3ff; x_buf = 0; } }