diff options
author | FernandoS27 <fsahmkow27@gmail.com> | 2018-10-10 15:20:13 +0200 |
---|---|---|
committer | FernandoS27 <fsahmkow27@gmail.com> | 2018-10-22 21:07:30 +0200 |
commit | 7b39107e3ae056a857e1780b2123e757b8deab26 (patch) | |
tree | 41837991e80339ace30754f832af05c451b2fd3e /src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |
parent | Implemented Alpha Testing (diff) | |
download | yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.tar yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.tar.gz yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.tar.bz2 yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.tar.lz yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.tar.xz yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.tar.zst yuzu-7b39107e3ae056a857e1780b2123e757b8deab26.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 36 |
1 files changed, 34 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 e890cfe57..cbf501cc7 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1280,13 +1280,13 @@ private: header.ps.IsColorComponentOutputEnabled(render_target, 1) || header.ps.IsColorComponentOutputEnabled(render_target, 2) || header.ps.IsColorComponentOutputEnabled(render_target, 3)) { - shader.AddLine(fmt::format("if ({} < alpha_testing_ref) discard;", + shader.AddLine(fmt::format("if (AlphaFunc({}, alpha_testing_ref, alpha_testing_func)) discard;", regs.GetRegisterAsFloat(current_reg))); current_reg += 4; } } --shader.scope; - shader.AddLine("}"); + shader.AddLine('}'); // Write the color outputs using the data in the shader registers, disabled // rendertargets/components are skipped in the register assignment. @@ -3505,6 +3505,38 @@ private: declarations.AddLine("bool " + pred + " = false;"); } declarations.AddNewLine(); + GenerateFunctionDeclarations(); + } + + void GenerateFunctionDeclarations() { + if (stage == Maxwell3D::Regs::ShaderStage::Fragment) { + declarations.AddLine("bool AlphaFunc(in float value, in float ref, in uint func) {"); + declarations.scope++; + declarations.AddLine("switch (func) {"); + declarations.scope++; + declarations.AddLine("case 1:"); + declarations.AddLine("return false;"); + declarations.AddLine("case 2:"); + declarations.AddLine("return value < ref;"); + declarations.AddLine("case 3:"); + declarations.AddLine("return value == ref;"); + declarations.AddLine("case 4:"); + declarations.AddLine("return value <= ref;"); + declarations.AddLine("case 5:"); + declarations.AddLine("return value > ref;"); + declarations.AddLine("case 6:"); + declarations.AddLine("return value != ref;"); + declarations.AddLine("case 7:"); + declarations.AddLine("return value >= ref;"); + declarations.AddLine("case 8:"); + declarations.AddLine("return true;"); + declarations.AddLine("default:"); + declarations.AddLine("return false;"); + declarations.scope--; + declarations.AddLine('}'); + declarations.scope--; + declarations.AddLine('}'); + } } private: |