From c1ad9738810d312ec38beccd709ce0853641a94a Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 11 Aug 2018 16:00:14 -0500 Subject: GPU/Shader: Don't predicate instructions that don't have a predicate field (SSY). --- src/video_core/engines/shader_bytecode.h | 7 +++++++ src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 3d4557b7e..42c6ea5fd 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h @@ -598,6 +598,13 @@ public: Unknown, }; + /// Returns whether an opcode has an execution predicate field or not (ie, whether it can be + /// conditionally executed). + static bool IsPredicatedInstruction(Id opcode) { + // TODO(Subv): Add the rest of unpredicated instructions. + return opcode != Id::SSY; + } + class Matcher { public: Matcher(const char* const name, u16 mask, u16 expected, OpCode::Id id, OpCode::Type type) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 532a47037..8954deb81 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -837,7 +837,11 @@ private: ASSERT_MSG(instr.pred.full_pred != Pred::NeverExecute, "NeverExecute predicate not implemented"); - if (instr.pred.pred_index != static_cast(Pred::UnusedIndex)) { + // Some instructions (like SSY) don't have a predicate field, they are always + // unconditionally executed. + bool can_be_predicated = OpCode::IsPredicatedInstruction(opcode->GetId()); + + if (can_be_predicated && instr.pred.pred_index != static_cast(Pred::UnusedIndex)) { shader.AddLine("if (" + GetPredicateCondition(instr.pred.pred_index, instr.negate_pred != 0) + ')'); @@ -1709,7 +1713,7 @@ private: } // Close the predicate condition scope. - if (instr.pred.pred_index != static_cast(Pred::UnusedIndex)) { + if (can_be_predicated && instr.pred.pred_index != static_cast(Pred::UnusedIndex)) { --shader.scope; shader.AddLine('}'); } -- cgit v1.2.3