From b8e10225f9e3227422c4b3ec5d43ed89b26de34a Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Wed, 13 Jan 2016 19:25:28 +0100 Subject: [PATCH] d3d12: Use first color output for alpha discard instead of 0. Fix Naruto 2 shader miscompilation. --- rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp index b14e9046b1..f40c238929 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12FragmentProgramDecompiler.cpp @@ -222,21 +222,21 @@ void D3D12FragmentDecompiler::insertMainEnd(std::stringstream & OS) { "ocol3", m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS ? "r4" : "h8" }, }; - size_t num_output = 0; + std::string first_output_name; OS << " PixelOutput Out = (PixelOutput)0;" << std::endl; for (int i = 0; i < sizeof(table) / sizeof(*table); ++i) { if (m_parr.HasParam(PF_PARAM_NONE, "float4", table[i].second)) { OS << " Out." << table[i].first << " = " << table[i].second << ";" << std::endl; - num_output++; + if (first_output_name.empty()) first_output_name = table[i].first; } } if (m_ctrl & CELL_GCM_SHADER_CONTROL_DEPTH_EXPORT) OS << " Out.depth = " << ((m_ctrl & CELL_GCM_SHADER_CONTROL_32_BITS_EXPORTS) ? "r1.z;" : "h0.z;") << std::endl; // Shaders don't always output colors (for instance if they write to depth only) - if (num_output > 0) - OS << " if (isAlphaTested && Out.ocol0.a <= alphaRef) discard;" << std::endl; + if (!first_output_name.empty()) + OS << " if (isAlphaTested && Out." << first_output_name << ".a <= alphaRef) discard;\n"; OS << " return Out;" << std::endl; OS << "}" << std::endl; }