diff options
author | bunnei <bunneidev@gmail.com> | 2018-04-26 05:10:41 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-04-26 20:38:41 +0200 |
commit | 37fa9a15cdb99510748df39f2a823f766c4b0049 (patch) | |
tree | d8da515a4fd768efb94adbf02518dc183e1b9486 /src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |
parent | Merge pull request #401 from lioncash/gdbstub (diff) | |
download | yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.tar yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.tar.gz yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.tar.bz2 yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.tar.lz yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.tar.xz yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.tar.zst yuzu-37fa9a15cdb99510748df39f2a823f766c4b0049.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 | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 3dffb205d..82fd7a0de 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -221,14 +221,11 @@ private: /// Generates code representing a temporary (GPR) register. std::string GetRegister(const Register& reg, unsigned elem = 0) { - if (reg == Register::ZeroIndex) + if (reg == Register::ZeroIndex) { return "0"; - if (stage == Maxwell3D::Regs::ShaderStage::Fragment && reg < 4) { - // GPRs 0-3 are output color for the fragment shader - return std::string{"color."} + "rgba"[(reg + elem) & 3]; } - - return *declr_register.insert("register_" + std::to_string(reg + elem)).first; + return *declr_register.insert("register_" + std::to_string(reg.GetSwizzledIndex(elem))) + .first; } /// Generates code representing a uniform (C buffer) register. @@ -628,6 +625,15 @@ private: case OpCode::Id::EXIT: { ASSERT_MSG(instr.pred.pred_index == static_cast<u64>(Pred::UnusedIndex), "Predicated exits not implemented"); + + // Final color output is currently hardcoded to GPR0-3 for fragment shaders + if (stage == Maxwell3D::Regs::ShaderStage::Fragment) { + shader.AddLine("color.r = " + GetRegister(0) + ";"); + shader.AddLine("color.g = " + GetRegister(1) + ";"); + shader.AddLine("color.b = " + GetRegister(2) + ";"); + shader.AddLine("color.a = " + GetRegister(3) + ";"); + } + shader.AddLine("return true;"); offset = PROGRAM_END - 1; break; |