From 27552891addc415537f739e61f29f79e616d4cf6 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 13 Mar 2018 13:49:28 +0300 Subject: [PATCH] rsx/fp: Improvements - Export some debug information in the free texture register space components zw Very useful when analysing renderdoc captures - Enable shadow comparison on depth as long as compare function is active and texture is uploaded for depth read Some engines (UE3) read all the components in the shader and use mul/mad with the result --- rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp | 8 ++++---- rpcs3/Emu/RSX/Common/ProgramStateCache.h | 7 ++++--- rpcs3/Emu/RSX/RSXThread.cpp | 2 ++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index 2c31f31a90..9195872dd2 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -644,10 +644,10 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE1D)); return true; case rsx::texture_dimension_extended::texture_dimension_2d: - if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num))) + if (m_prog.shadow_textures & (1 << dst.tex_num)) { m_shadow_sampled_textures |= (1 << dst.tex_num); - SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D) + ".r", false); //No swizzle mask on shadow lookup + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D) + ".xxxx"); return true; } if (m_prog.redirected_textures & (1 << dst.tex_num)) @@ -676,10 +676,10 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) return true; case rsx::texture_dimension_extended::texture_dimension_2d: //Note shadow comparison only returns a true/false result! - if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num))) + if (m_prog.shadow_textures & (1 << dst.tex_num)) { m_shadow_sampled_textures |= (1 << dst.tex_num); - SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ) + ".r", false); //No swizzle mask on shadow lookup + SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ) + ".xxxx"); } else SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ)); diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index 66dd111204..519f3a5ba4 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -349,9 +349,10 @@ public: } else if (sanitize) { - //Lower NaNs to 0 - const auto mask = _mm_cmpunord_ps((__m128&)shuffled_vector, _mm_set1_ps(1.f)); - const auto result = _mm_andnot_ps(mask, (__m128&)shuffled_vector); + //Convert NaNs and Infs to 0 + const auto masked = _mm_and_si128((__m128i&)shuffled_vector, _mm_set1_epi32(0x7fffffff)); + const auto valid = _mm_cmplt_epi32(masked, _mm_set1_epi32(0x7f800000)); + const auto result = _mm_and_si128((__m128i&)shuffled_vector, valid); _mm_stream_si128((__m128i*)dst, (__m128i&)result); } else diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 4efde0f100..dc0d19ad56 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1517,6 +1517,8 @@ namespace rsx auto &tex = rsx::method_registers.fragment_textures[i]; result.texture_scale[i][0] = sampler_descriptors[i]->scale_x; result.texture_scale[i][1] = sampler_descriptors[i]->scale_y; + result.texture_scale[i][2] = (f32)tex.remap(); //Debug value + result.texture_scale[i][3] = (f32)tex.format(); //Debug value result.textures_alpha_kill[i] = 0; result.textures_zfunc[i] = 0;