summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Subv2018-04-19 13:33:17 -0500
committerGravatar Subv2018-04-19 13:33:17 -0500
commit5367935d359361c3c361c48fa02860a83ea5490f (patch)
tree6039f431d3a4d015302bbd23bb5a7c0ed88f8790
parentMerge pull request #353 from Subv/compressed_formats (diff)
downloadyuzu-5367935d359361c3c361c48fa02860a83ea5490f.tar.gz
yuzu-5367935d359361c3c361c48fa02860a83ea5490f.tar.xz
yuzu-5367935d359361c3c361c48fa02860a83ea5490f.zip
ShaderGen: Fixed a case where the TEXS instruction would use the same registers for the input and the output.
It will now save the coords before writing the outputs in a subscope.
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 6233ee358..b18f25026 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -399,11 +399,18 @@ private:
399 const std::string op_a = GetRegister(instr.gpr8); 399 const std::string op_a = GetRegister(instr.gpr8);
400 const std::string op_b = GetRegister(instr.gpr20); 400 const std::string op_b = GetRegister(instr.gpr20);
401 const std::string sampler = GetSampler(instr.sampler); 401 const std::string sampler = GetSampler(instr.sampler);
402 const std::string coord = "vec2(" + op_a + ", " + op_b + ")"; 402 const std::string coord = "vec2 coords = vec2(" + op_a + ", " + op_b + ");";
403 const std::string texture = "texture(" + sampler + ", " + coord + ")"; 403 // Add an extra scope and declare the texture coords inside to prevent overwriting
404 // them in case they are used as outputs of the texs instruction.
405 shader.AddLine("{");
406 ++shader.scope;
407 shader.AddLine(coord);
408 const std::string texture = "texture(" + sampler + ", coords)";
404 for (unsigned elem = 0; elem < instr.attribute.fmt20.size; ++elem) { 409 for (unsigned elem = 0; elem < instr.attribute.fmt20.size; ++elem) {
405 SetDest(elem, GetRegister(instr.gpr0, elem), texture, 1, 4); 410 SetDest(elem, GetRegister(instr.gpr0, elem), texture, 1, 4);
406 } 411 }
412 --shader.scope;
413 shader.AddLine("}");
407 break; 414 break;
408 } 415 }
409 default: { 416 default: {