From f521fe824e8cfc827a6fc625b5e8881540865882 Mon Sep 17 00:00:00 2001
From: ifcaro <[EMAIL REDACTED]>
Date: Thu, 1 Oct 2026 18:36:20 +0200
Subject: [PATCH] PS2: Align texel origin with pixel center in textured draws
(#16425)
Texel (0,0) is the corner of the top-left texel, but pixel (0,0) is
the center of the top-left pixel - every textured draw landed half a
pixel off in X/Y. Align them (ps2dev/gsKit#11).
---
src/render/ps2/SDL_render_ps2.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c
index 411d192318e4b..6bf99cd3c4be3 100644
--- a/src/render/ps2/SDL_render_ps2.c
+++ b/src/render/ps2/SDL_render_ps2.c
@@ -298,7 +298,10 @@ static bool PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
col_ = (SDL_FColor *)((char *)color + j * color_stride);
uv_ = (float *)((char *)uv + j * uv_stride);
- vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0);
+ /* Texel (0,0) is the corner of the top-left texel, but pixel
+ (0,0) is the center of the top-left pixel - align them so
+ textured draws land 1:1 (ps2dev/gsKit#11). */
+ vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x - 0.5f, xy_[1] * scale_y - 0.5f, 0);
vertices->rgbaq = float_color_to_RGBAQ_tex(col_, color_scale);
vertices->uv = vertex_to_UV(ps2_tex, uv_[0] * ps2_tex->Width, uv_[1] * ps2_tex->Height);