From 6fa17f33727526fbfcf83120bc6e30cbcc25163a Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 17 Mar 2022 22:09:31 -0400 Subject: [PATCH 1/3] shader_recompiler/EXIT: increment output register on failed enable test --- .../frontend/maxwell/translate/impl/exit_program.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp index c2443c886..1abe0dda6 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp @@ -15,6 +15,7 @@ void ExitFragment(TranslatorVisitor& v) { const std::array mask{sph.ps.EnabledOutputComponents(render_target)}; for (u32 component = 0; component < 4; ++component) { if (!mask[component]) { + ++src_reg; continue; } v.ir.SetFragColor(render_target, component, v.F(src_reg)); From d400b618a76ab0b08adfcb808ca8a8e336e1d573 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 18 Mar 2022 09:26:25 -0400 Subject: [PATCH 2/3] shader_recompiler/EXIT: skip render targets with no outputs --- .../frontend/maxwell/translate/impl/exit_program.cpp | 3 +++ src/shader_recompiler/program_header.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp index 1abe0dda6..537b5bde2 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/exit_program.cpp @@ -12,6 +12,9 @@ void ExitFragment(TranslatorVisitor& v) { const ProgramHeader sph{v.env.SPH()}; IR::Reg src_reg{IR::Reg::R0}; for (u32 render_target = 0; render_target < 8; ++render_target) { + if (!sph.ps.HasOutputComponents(render_target)) { + continue; + } const std::array mask{sph.ps.EnabledOutputComponents(render_target)}; for (u32 component = 0; component < 4; ++component) { if (!mask[component]) { diff --git a/src/shader_recompiler/program_header.h b/src/shader_recompiler/program_header.h index bd6c2bfb5..5e42ab5a3 100644 --- a/src/shader_recompiler/program_header.h +++ b/src/shader_recompiler/program_header.h @@ -196,6 +196,11 @@ struct ProgramHeader { return {(bits & 1) != 0, (bits & 2) != 0, (bits & 4) != 0, (bits & 8) != 0}; } + [[nodiscard]] bool HasOutputComponents(u32 rt) const noexcept { + const u32 bits{omap.target >> (rt * 4)}; + return bits & (1 | 2 | 4 | 8); + } + [[nodiscard]] std::array GenericInputMap(u32 attribute) const { const auto& vector{imap_generic_vector[attribute]}; return {vector.x, vector.y, vector.z, vector.w}; From 536d7ed7b1b42fcae94505318d9bbee30ae21222 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 18 Mar 2022 15:55:46 -0400 Subject: [PATCH 3/3] Address review comments --- src/shader_recompiler/program_header.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shader_recompiler/program_header.h b/src/shader_recompiler/program_header.h index 5e42ab5a3..0cd6597ef 100644 --- a/src/shader_recompiler/program_header.h +++ b/src/shader_recompiler/program_header.h @@ -198,7 +198,7 @@ struct ProgramHeader { [[nodiscard]] bool HasOutputComponents(u32 rt) const noexcept { const u32 bits{omap.target >> (rt * 4)}; - return bits & (1 | 2 | 4 | 8); + return (bits & 0xf) != 0; } [[nodiscard]] std::array GenericInputMap(u32 attribute) const {