From a5f58bcbcbf1c06fae51e94dd7442b4b7c6044c3 Mon Sep 17 00:00:00 2001 From: VHANTOMI Date: Wed, 7 Oct 2026 00:21:04 +0200 Subject: [PATCH] Handle sprites smaller than one texture stripe ## Summary `gsKit_prim_sprite_striped_texture_3d` can calculate a zero or negative `stripcount` when the sprite covers no complete 64-pixel stripe. The function then divides by zero or enters its strip loop with a negative count, which can corrupt the render queue. Fall back to the regular textured-sprite primitive when there are no complete interior stripes, while keeping nearest-neighbor filtering for this path. ## Testing - Build gsKit with the PS2 toolchain. - Draw sprites spanning x=2..30 and x=60..65; verify they render once and the render queue remains usable. - Draw a sprite spanning multiple 64-pixel boundaries, such as x=2..200; verify the existing striped path still renders correctly. --- ee/gs/src/gsTexture.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ee/gs/src/gsTexture.c b/ee/gs/src/gsTexture.c index 73ef218..4bd10ed 100644 --- a/ee/gs/src/gsTexture.c +++ b/ee/gs/src/gsTexture.c @@ -543,6 +543,8 @@ void gsKit_prim_sprite_striped_texture_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *T u64 Tex0; u64 Prim; + + GSTEXTURE nearestTexture; int extracount; @@ -604,6 +606,16 @@ void gsKit_prim_sprite_striped_texture_3d(GSGLOBAL *gsGlobal, const GSTEXTURE *T stripcount = ((ix2 - ix1) / 64); + if (stripcount <= 0) +{ + nearestTexture = *Texture; + nearestTexture.Filter = GS_FILTER_NEAREST; + gsKit_prim_sprite_texture_3d(gsGlobal, &nearestTexture, + x1, y1, iz1, u1, v1, + x2, y2, iz2, u2, v2, color); + return; +} + if(!(stripcount + extracount)) { return;