diff options
author | bunnei <bunneidev@gmail.com> | 2018-06-05 02:47:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-05 02:47:11 +0200 |
commit | f564822e781ade1fe16ecd3cf93f1ffa247ed82e (patch) | |
tree | c51f197ddaac4a0c9df01b87aef6d5bdbb6a0e2f /src/video_core | |
parent | Merge pull request #512 from Subv/fset (diff) | |
parent | GPU: Use explicit types when retrieving the uniform values for fsetp/fset and isetp instead of the type of an invalid output register. (diff) | |
download | yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.tar yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.tar.gz yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.tar.bz2 yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.tar.lz yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.tar.xz yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.tar.zst yuzu-f564822e781ade1fe16ecd3cf93f1ffa247ed82e.zip |
Diffstat (limited to 'src/video_core')
-rw-r--r-- | src/video_core/engines/shader_bytecode.h | 10 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 59 |
2 files changed, 63 insertions, 6 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index e7ef7e71f..3add56155 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h @@ -239,6 +239,16 @@ union Instruction { } fsetp; union { + BitField<0, 3, u64> pred0; + BitField<3, 3, u64> pred3; + BitField<39, 3, u64> pred39; + BitField<42, 1, u64> neg_pred; + BitField<45, 2, PredOperation> op; + BitField<48, 1, u64> is_signed; + BitField<49, 3, PredCondition> cond; + } isetp; + + union { BitField<39, 3, u64> pred39; BitField<42, 1, u64> neg_pred; BitField<43, 1, u64> neg_a; diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 45d120757..8c263f15f 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -219,6 +219,11 @@ public: return active_type == Type::Integer; } + /// Returns the current active type of the register + Type GetActiveType() const { + return active_type; + } + /// Returns the index of the register size_t GetIndex() const { return index; @@ -350,22 +355,28 @@ public: shader.AddLine(dest + " = " + src + ';'); } - /// Generates code representing a uniform (C buffer) register. - std::string GetUniform(const Uniform& uniform, const Register& dest_reg) { + /// Generates code representing a uniform (C buffer) register, interpreted as the input type. + std::string GetUniform(const Uniform& uniform, GLSLRegister::Type type) { declr_const_buffers[uniform.index].MarkAsUsed(static_cast<unsigned>(uniform.index), static_cast<unsigned>(uniform.offset), stage); std::string value = 'c' + std::to_string(uniform.index) + '[' + std::to_string(uniform.offset) + ']'; - if (regs[dest_reg].IsFloat()) { + if (type == GLSLRegister::Type::Float) { return value; - } else if (regs[dest_reg].IsInteger()) { + } else if (type == GLSLRegister::Type::Integer) { return "floatBitsToInt(" + value + ')'; } else { UNREACHABLE(); } } + /// Generates code representing a uniform (C buffer) register, interpreted as the type of the + /// destination register. + std::string GetUniform(const Uniform& uniform, const Register& dest_reg) { + return GetUniform(uniform, regs[dest_reg].GetActiveType()); + } + /// Add declarations for registers void GenerateDeclarations() { for (const auto& reg : regs) { @@ -1018,7 +1029,7 @@ private: if (instr.is_b_gpr) { op_b += regs.GetRegisterAsFloat(instr.gpr20); } else { - op_b += regs.GetUniform(instr.uniform, instr.gpr0); + op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Float); } } @@ -1049,6 +1060,42 @@ private: } break; } + case OpCode::Type::IntegerSetPredicate: { + std::string op_a = regs.GetRegisterAsInteger(instr.gpr8, 0, instr.isetp.is_signed); + + std::string op_b{}; + + ASSERT_MSG(!instr.is_b_imm, "ISETP_IMM not implemented"); + + if (instr.is_b_gpr) { + op_b += regs.GetRegisterAsInteger(instr.gpr20, 0, instr.isetp.is_signed); + } else { + op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Integer); + } + + using Tegra::Shader::Pred; + // We can't use the constant predicate as destination. + ASSERT(instr.isetp.pred3 != static_cast<u64>(Pred::UnusedIndex)); + + std::string second_pred = + GetPredicateCondition(instr.isetp.pred39, instr.isetp.neg_pred != 0); + + std::string comparator = GetPredicateComparison(instr.isetp.cond); + std::string combiner = GetPredicateCombiner(instr.isetp.op); + + std::string predicate = '(' + op_a + ") " + comparator + " (" + op_b + ')'; + // Set the primary predicate to the result of Predicate OP SecondPredicate + SetPredicate(instr.isetp.pred3, + '(' + predicate + ") " + combiner + " (" + second_pred + ')'); + + if (instr.isetp.pred0 != static_cast<u64>(Pred::UnusedIndex)) { + // Set the secondary predicate to the result of !Predicate OP SecondPredicate, + // if enabled + SetPredicate(instr.isetp.pred0, + "!(" + predicate + ") " + combiner + " (" + second_pred + ')'); + } + break; + } case OpCode::Type::FloatSet: { std::string op_a = instr.fset.neg_a ? "-" : ""; op_a += regs.GetRegisterAsFloat(instr.gpr8); @@ -1069,7 +1116,7 @@ private: if (instr.is_b_gpr) { op_b += regs.GetRegisterAsFloat(instr.gpr20); } else { - op_b += regs.GetUniform(instr.uniform, instr.gpr0); + op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Float); } } |