diff options
author | bunnei <bunneidev@gmail.com> | 2018-09-10 03:39:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-10 03:39:39 +0200 |
commit | e58855c7a4596f8a2a69adfb1e4c3464a15f03a2 (patch) | |
tree | f10985b77f34a6d907bde37122d0d6353ba17091 /src/video_core/renderer_opengl | |
parent | Merge pull request #1272 from Subv/dma_2d (diff) | |
parent | Implemented TMML (diff) | |
download | yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.tar yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.tar.gz yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.tar.bz2 yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.tar.lz yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.tar.xz yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.tar.zst yuzu-e58855c7a4596f8a2a69adfb1e4c3464a15f03a2.zip |
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 034b9459c..762e58aad 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1945,6 +1945,54 @@ private: } break; } + case OpCode::Id::TMML: { + const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8); + const std::string op_b = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); + const bool is_array = instr.tmml.array != 0; + auto texture_type = instr.tmml.texture_type.Value(); + const std::string sampler = GetSampler(instr.sampler, texture_type, is_array); + + // TODO: add coordinates for different samplers once other texture types are + // implemented. + std::string coord; + switch (texture_type) { + case Tegra::Shader::TextureType::Texture1D: { + std::string x = regs.GetRegisterAsFloat(instr.gpr8); + coord = "float coords = " + x + ';'; + break; + } + case Tegra::Shader::TextureType::Texture2D: { + std::string x = regs.GetRegisterAsFloat(instr.gpr8); + std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); + coord = "vec2 coords = vec2(" + x + ", " + y + ");"; + break; + } + default: + LOG_CRITICAL(HW_GPU, "Unhandled texture type {}", + static_cast<u32>(texture_type)); + UNREACHABLE(); + + // Fallback to interpreting as a 2D texture for now + std::string x = regs.GetRegisterAsFloat(instr.gpr8); + std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); + coord = "vec2 coords = vec2(" + x + ", " + y + ");"; + texture_type = Tegra::Shader::TextureType::Texture2D; + } + // 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 = "textureQueryLod(" + sampler + ", coords)"; + const std::string tmp = "vec2 tmp = " + texture + "*vec2(256.0, 256.0);"; + shader.AddLine(tmp); + + regs.SetRegisterToInteger(instr.gpr0, true, 0, "int(tmp.y)", 1, 1); + regs.SetRegisterToInteger(instr.gpr0.Value() + 1, false, 0, "uint(tmp.x)", 1, 1); + --shader.scope; + shader.AddLine('}'); + break; + } default: { LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName()); UNREACHABLE(); |