diff options
author | FernandoS27 <fsahmkow27@gmail.com> | 2018-10-28 02:09:26 +0200 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2018-10-28 02:09:26 +0200 |
commit | d8d557df86139ea0011fee0665d76e740681f7c0 (patch) | |
tree | b1b1ab38cbaead09de2e986d65aaeb9fcb15ec76 /src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |
parent | Merge pull request #1596 from FearlessTobi/port-4367 (diff) | |
download | yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.tar yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.tar.gz yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.tar.bz2 yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.tar.lz yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.tar.xz yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.tar.zst yuzu-d8d557df86139ea0011fee0665d76e740681f7c0.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index dec291a7d..002ae90a7 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1510,8 +1510,25 @@ private: ASSERT_MSG(instr.fmul.cc == 0, "FMUL cc is not implemented"); op_b = GetOperandAbsNeg(op_b, false, instr.fmul.negate_b); - regs.SetRegisterToFloat(instr.gpr0, 0, op_a + " * " + op_b, 1, 1, + + shader.AddLine('{'); + ++shader.scope; + + // This avoids optimizations of constant propagation and keeps the code as the original + // Sadly using the precise keyword causes "linking" errors on fragment shaders. + if (stage == Maxwell3D::Regs::ShaderStage::Fragment) { + shader.AddLine("float tmp = " + op_a + " * " + op_b + ';'); + } else { + shader.AddLine("precise float tmp = " + op_a + " * " + op_b + ';'); + } + + + regs.SetRegisterToFloat(instr.gpr0, 0, "tmp", 1, 1, instr.alu.saturate_d); + + + --shader.scope; + shader.AddLine('}'); break; } case OpCode::Id::FADD_C: @@ -1519,8 +1536,25 @@ private: case OpCode::Id::FADD_IMM: { op_a = GetOperandAbsNeg(op_a, instr.alu.abs_a, instr.alu.negate_a); op_b = GetOperandAbsNeg(op_b, instr.alu.abs_b, instr.alu.negate_b); - regs.SetRegisterToFloat(instr.gpr0, 0, op_a + " + " + op_b, 1, 1, + + shader.AddLine('{'); + ++shader.scope; + + // This avoids optimizations of constant propagation and keeps the code as the original + // Sadly using the precise keyword causes "linking" errors on fragment shaders. + if (stage == Maxwell3D::Regs::ShaderStage::Fragment) { + shader.AddLine("float tmp = " + op_a + " + " + op_b + ';'); + } else { + shader.AddLine("precise float tmp = " + op_a + " + " + op_b + ';'); + } + regs.SetRegisterToFloat(instr.gpr0, 0, "tmp", 1, 1, instr.alu.saturate_d); + + + --shader.scope; + shader.AddLine('}'); + + break; } case OpCode::Id::MUFU: { @@ -2087,8 +2121,23 @@ private: } } - regs.SetRegisterToFloat(instr.gpr0, 0, op_a + " * " + op_b + " + " + op_c, 1, 1, + shader.AddLine('{'); + ++shader.scope; + + // This avoids optimizations of constant propagation and keeps the code as the original + // Sadly using the precise keyword causes "linking" errors on fragment shaders. + if (stage == Maxwell3D::Regs::ShaderStage::Fragment) { + shader.AddLine("float tmp = fma(" + op_a + ", " + op_b + ", " + op_c + ");"); + } else { + shader.AddLine("precise float tmp = fma(" + op_a + ", " + op_b + ", " + op_c + ");"); + } + + regs.SetRegisterToFloat(instr.gpr0, 0, "tmp", 1, 1, instr.alu.saturate_d); + + + --shader.scope; + shader.AddLine('}'); break; } case OpCode::Type::Hfma2: { |