From 2880f88d88b40f2c9f2e49a9f259e478b9e78518 Mon Sep 17 00:00:00 2001 From: crashGG <80488411+crashGG@users.noreply.github.com> Date: Fri, 10 Jul 2026 11:51:51 +0300 Subject: [PATCH] MMPX Enhanced/Advanced clamp-to-transparent out-of-bounds mapping (#3774) MMPX Enhanced/Advanced clamp-to-transparent out-of-bounds mapping --- src/core/gpu_hw_shadergen.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw_shadergen.cpp b/src/core/gpu_hw_shadergen.cpp index c049e50d5..6bca3d5e7 100644 --- a/src/core/gpu_hw_shadergen.cpp +++ b/src/core/gpu_hw_shadergen.cpp @@ -836,7 +836,11 @@ void FilteredSampleFromVRAM(TEXPAGE_VALUE texpage, float2 coords, float4 uv_limi else if (texture_filter == GPUTextureFilter::MMPXEnhanced) { ss << R"( - #define srcf(xoffs,yoffs) SampleFromVRAM(texpage, bcoords + float2((xoffs), (yoffs)), uv_limits) + #define srcf(xoffs,yoffs) \ + SampleFromVRAM(texpage, bcoords + float2(xoffs, yoffs), uv_limits) * \ + step(abs(bcoords.x + xoffs - clamp(bcoords.x + xoffs, uv_limits.x, uv_limits.z)), 0.001) * \ + step(abs(bcoords.y + yoffs - clamp(bcoords.y + yoffs, uv_limits.y, uv_limits.w)), 0.001) + #define src(xoffs,yoffs) packUnorm4x8(srcf(xoffs,yoffs)) )"; @@ -1047,7 +1051,11 @@ skiprest = skiprest||slope1||slope2||slope3||slope4||E==0u||B==0u||D==0u||F==0u| else if (texture_filter == GPUTextureFilter::MMPXAdvanced) { ss << R"( - #define srcf(xoffs,yoffs) SampleFromVRAM(texpage, bcoords + float2((xoffs), (yoffs)), uv_limits) + #define srcf(xoffs,yoffs) \ + SampleFromVRAM(texpage, bcoords + float2(xoffs, yoffs), uv_limits) * \ + step(abs(bcoords.x + xoffs - clamp(bcoords.x + xoffs, uv_limits.x, uv_limits.z)), 0.001) * \ + step(abs(bcoords.y + yoffs - clamp(bcoords.y + yoffs, uv_limits.y, uv_limits.w)), 0.001) + #define src(xoffs,yoffs) packUnorm4x8(srcf(xoffs,yoffs)) )"; @@ -3406,4 +3414,4 @@ std::string GPU_HW_ShaderGen::GenerateReplacementMergeFragmentShader(bool replac )"; return std::move(ss).str(); -} \ No newline at end of file +}