From fc5b489b0f6db5bfb6b04c50071b161fed6bf7fa Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 20 Aug 2018 20:44:56 -0500 Subject: [PATCH 1/2] Shaders: Log and crash when using an unimplemented texture type in a texture sampling instruction. --- .../renderer_opengl/gl_shader_decompiler.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index ac6ccfec7..c8ff1cdf5 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1526,7 +1526,9 @@ private: break; } default: - UNIMPLEMENTED(); + LOG_CRITICAL(HW_GPU, "Unhandled texture type {}", + static_cast(instr.tex.texture_type.Value())); + UNREACHABLE(); } const std::string sampler = @@ -1576,7 +1578,9 @@ private: break; } default: - UNIMPLEMENTED(); + LOG_CRITICAL(HW_GPU, "Unhandled texture type {}", + static_cast(instr.texs.GetTextureType())); + UNREACHABLE(); } const std::string sampler = GetSampler(instr.sampler, instr.texs.GetTextureType(), instr.texs.IsArrayTexture()); @@ -1593,7 +1597,8 @@ private: switch (instr.tlds.GetTextureType()) { case Tegra::Shader::TextureType::Texture2D: { if (instr.tlds.IsArrayTexture()) { - UNIMPLEMENTED(); + LOG_CRITICAL(HW_GPU, "Unhandled 2d array texture"); + UNREACHABLE(); } else { std::string x = regs.GetRegisterAsInteger(instr.gpr8); std::string y = regs.GetRegisterAsInteger(instr.gpr20); @@ -1602,7 +1607,9 @@ private: break; } default: - UNIMPLEMENTED(); + LOG_CRITICAL(HW_GPU, "Unhandled texture type {}", + static_cast(instr.tlds.GetTextureType())); + UNREACHABLE(); } const std::string sampler = GetSampler(instr.sampler, instr.tlds.GetTextureType(), instr.tlds.IsArrayTexture()); @@ -1623,7 +1630,9 @@ private: break; } default: - UNIMPLEMENTED(); + LOG_CRITICAL(HW_GPU, "Unhandled texture type {}", + static_cast(instr.tld4.texture_type.Value())); + UNREACHABLE(); } const std::string sampler = From eac3cf301c60d178164ed51cf84c098b06e6db54 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 20 Aug 2018 20:45:46 -0500 Subject: [PATCH 2/2] Shaders: Fixed the coords in TEX with Texture2D. The X and Y coordinates should be in gpr8 and gpr8+1, respectively. This fixes the cutscene rendering in Sonic Mania. --- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index c8ff1cdf5..b7b3fbc17 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1514,7 +1514,7 @@ private: switch (instr.tex.texture_type) { case Tegra::Shader::TextureType::Texture2D: { std::string x = regs.GetRegisterAsFloat(instr.gpr8); - std::string y = regs.GetRegisterAsFloat(instr.gpr20); + std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); coord = "vec2 coords = vec2(" + x + ", " + y + ");"; break; }