summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-06-01 05:22:21 +0200
committerbunnei <bunneidev@gmail.com>2018-06-01 05:36:45 +0200
commit888eb345c0d06c58da40afa5619fe6a0da10ffa5 (patch)
tree7a736b1976d2248c5f620686a70fdc3d6aff310d /src/video_core/renderer_opengl/gl_shader_decompiler.cpp
parentgl_shader_decompiler: Support multi-destination for TEXS. (diff)
downloadyuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.tar
yuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.tar.gz
yuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.tar.bz2
yuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.tar.lz
yuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.tar.xz
yuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.tar.zst
yuzu-888eb345c0d06c58da40afa5619fe6a0da10ffa5.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index f6a60c920..88502a8a7 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -891,6 +891,32 @@ private:
instr.gpr0);
break;
}
+ case OpCode::Id::TEX: {
+ ASSERT_MSG(instr.attribute.fmt20.size == 4, "untested");
+ const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8);
+ const std::string op_b = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
+ const std::string sampler = GetSampler(instr.sampler);
+ const std::string coord = "vec2 coords = vec2(" + op_a + ", " + op_b + ");";
+ // Add an extra scope and declare the texture coords inside to prevent overwriting
+ // them in case they are used as outputs of the texs instruction.
+ shader.AddLine("{");
+ ++shader.scope;
+ shader.AddLine(coord);
+ const std::string texture = "texture(" + sampler + ", coords)";
+
+ size_t dest_elem{};
+ for (size_t elem = 0; elem < instr.attribute.fmt20.size; ++elem) {
+ if (!instr.tex.IsComponentEnabled(elem)) {
+ // Skip disabled components
+ continue;
+ }
+ regs.SetRegisterToFloat(instr.gpr0, elem, texture, 1, 4, false, dest_elem);
+ ++dest_elem;
+ }
+ --shader.scope;
+ shader.AddLine("}");
+ break;
+ }
case OpCode::Id::TEXS: {
ASSERT_MSG(instr.attribute.fmt20.size == 4, "untested");
const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8);
@@ -921,7 +947,6 @@ private:
}
offset += 2;
}
-
--shader.scope;
shader.AddLine("}");
break;