From f745971cc8e85d8f71622c9e6ce25437febb50a9 Mon Sep 17 00:00:00 2001 From: kd-11 <15904127+kd-11@users.noreply.github.com> Date: Sat, 7 Aug 2021 00:49:50 +0300 Subject: [PATCH] rsx: Fix coordinate scaling for shadow access (#10668) - For shadow2DProj the 3rd coordinate is actually the depth value, do not scale --- rpcs3/Emu/RSX/Common/texture_cache.h | 13 ++++++++++--- rpcs3/Emu/RSX/Program/GLSLCommon.cpp | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 745179516f..76aac4eb60 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -2010,11 +2010,18 @@ namespace rsx if (is_unnormalized) { - if (extended_dimension <= rsx::texture_dimension_extended::texture_dimension_2d) + switch (extended_dimension) { - scale.width /= attributes.width; - scale.height /= attributes.height; + case rsx::texture_dimension_extended::texture_dimension_3d: + case rsx::texture_dimension_extended::texture_dimension_cubemap: scale.depth /= attributes.depth; + [[ fallthrough ]]; + case rsx::texture_dimension_extended::texture_dimension_2d: + scale.height /= attributes.height; + [[ fallthrough ]]; + default: + scale.width /= attributes.width; + break; } } diff --git a/rpcs3/Emu/RSX/Program/GLSLCommon.cpp b/rpcs3/Emu/RSX/Program/GLSLCommon.cpp index 6f3983ac42..f2f627ad34 100644 --- a/rpcs3/Emu/RSX/Program/GLSLCommon.cpp +++ b/rpcs3/Emu/RSX/Program/GLSLCommon.cpp @@ -881,7 +881,7 @@ namespace glsl OS << "#define TEX2D_SHADOW(index, coord3) texture(TEX_NAME(index), vec3(COORD_SCALE2(index, coord3.xy), coord3.z))\n" "#define TEX2D_SHADOWCUBE(index, coord4) texture(TEX_NAME(index), vec4(COORD_SCALE3(index, coord4.xyz), coord4.w))\n" - "#define TEX2D_SHADOWPROJ(index, coord4) textureProj(TEX_NAME(index), vec4(COORD_SCALE3(index, coord4.xyz), coord4.w))\n"; + "#define TEX2D_SHADOWPROJ(index, coord4) textureProj(TEX_NAME(index), vec4(COORD_SCALE2(index, coord4.xy), coord4.zw))\n"; } OS <<