From 0ae8fcced305a721d98b7caa1a1d30503a6705b5 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 25 Nov 2024 13:15:07 +1000 Subject: [PATCH] GPU/HW: Fix incorrect sampling at 1x with TC --- src/core/gpu_hw_shadergen.cpp | 16 ++++++++++------ src/core/shader_cache_version.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index 997cd86e9..e85738c17 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -880,13 +880,17 @@ float4 SampleFromVRAM(TEXPAGE_VALUE texpage, float2 coords) float4 SampleFromPageTexture(float2 coords) { // Cached textures. -#if UPSCALED == 0 - float2 fpart = coords - roundEven(coords); -#else - float2 fpart = frac(coords); -#endif uint2 icoord = ApplyTextureWindow(FloatToIntegerCoords(coords)); - coords = (float2(icoord) + fpart) * (1.0f / 256.0f); +#if UPSCALED + float2 fpart = frac(coords); + coords = (float2(icoord) + fpart); +#else + // Drop fractional part. + coords = float2(icoord); +#endif + + // Normalize. + coords = coords * (1.0f / 256.0f); return SAMPLE_TEXTURE(samp0, coords); } diff --git a/src/core/shader_cache_version.h b/src/core/shader_cache_version.h index 9d926866a..89fec6d32 100644 --- a/src/core/shader_cache_version.h +++ b/src/core/shader_cache_version.h @@ -5,4 +5,4 @@ #include "common/types.h" -static constexpr u32 SHADER_CACHE_VERSION = 20; +static constexpr u32 SHADER_CACHE_VERSION = 21;