From 17318112ebbea68fb432d6178062d5a0fa0d7df2 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Thu, 22 Jun 2017 20:09:05 +0300 Subject: [PATCH] rsx: Do not sample as pcf shader if writing a vector result --- .../Emu/RSX/Common/FragmentProgramDecompiler.cpp | 15 ++++++++++++++- rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp index 177cde5019..64bbb5589c 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.cpp @@ -224,6 +224,18 @@ std::string FragmentProgramDecompiler::NoOverflow(const std::string& code) return code; } +bool FragmentProgramDecompiler::DstExpectsSca() +{ + int writes = 0; + + if (dst.mask_x) writes++; + if (dst.mask_y) writes++; + if (dst.mask_z) writes++; + if (dst.mask_w) writes++; + + return (writes == 1); +} + std::string FragmentProgramDecompiler::Format(const std::string& code) { const std::pair> repl_list[] = @@ -542,7 +554,8 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode) return true; case rsx::texture_dimension_extended::texture_dimension_2d: SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ)); - if (m_prog.shadow_textures & (1 << dst.tex_num)) + //Note shadow comparison only returns a true/false result! + if (DstExpectsSca() && (m_prog.shadow_textures & (1 << dst.tex_num))) m_shadow_sampled_textures |= (1 << dst.tex_num); return true; case rsx::texture_dimension_extended::texture_dimension_cubemap: diff --git a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h index a66a716b15..7b66c1b84d 100644 --- a/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h +++ b/rpcs3/Emu/RSX/Common/FragmentProgramDecompiler.h @@ -58,6 +58,11 @@ class FragmentProgramDecompiler //Prevents operations from overflowing the max range (tested with fp_dynamic3 autotest sample) std::string NoOverflow(const std::string& code); + /** + * Returns true if the dst set is not a vector (i.e only a single component) + */ + bool DstExpectsSca(); + void AddCodeCond(const std::string& dst, const std::string& src); std::string GetRawCond(); std::string GetCond();