From 5b513cac5b467640f76e9b806e1a7834eb55ed5f Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 21 Jan 2025 18:18:05 +0100 Subject: [PATCH] gl: use textureProj for palette texture sampling when possible/available Fixes UV precision issue when doing the Z-divide manually. Issue #1804 --- core/rend/gles/gles.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/rend/gles/gles.cpp b/core/rend/gles/gles.cpp index d2d7b7ffd..59e3fc8ea 100644 --- a/core/rend/gles/gles.cpp +++ b/core/rend/gles/gles.cpp @@ -202,10 +202,12 @@ lowp vec4 getPaletteEntry(highp float colorIndex) lowp vec4 palettePixel(highp vec3 coords) { -#if TARGET_GL != GLES2 && TARGET_GL != GL2 && DIV_POS_Z != 1 - coords.xy /= coords.z; -#endif +#if TARGET_GL == GLES2 || TARGET_GL == GL2 || DIV_POS_Z == 1 return getPaletteEntry(texture(tex, coords.xy).FOG_CHANNEL); +#else + return getPaletteEntry(textureProj(tex, coords).FOG_CHANNEL); +#endif + } #elif pp_Palette == 2 // Bi-linear filtering