diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-04-10 23:03:52 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-04-14 10:13:19 +0200 |
commit | f15c59a164a7c4deafb77e9fc698cdf9a08691ce (patch) | |
tree | f232add61779165ba2d03773384b9df86c2f7af0 /src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |
parent | gl_device: Implement interface and add uniform offset alignment (diff) | |
download | yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.tar yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.tar.gz yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.tar.bz2 yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.tar.lz yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.tar.xz yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.tar.zst yuzu-f15c59a164a7c4deafb77e9fc698cdf9a08691ce.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 18 |
1 files changed, 13 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 28e490b3c..aee9939db 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -15,6 +15,7 @@ #include "common/assert.h" #include "common/common_types.h" #include "video_core/engines/maxwell_3d.h" +#include "video_core/renderer_opengl/gl_device.h" #include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/renderer_opengl/gl_shader_decompiler.h" #include "video_core/shader/shader_ir.h" @@ -141,8 +142,9 @@ bool IsPrecise(Node node) { class GLSLDecompiler final { public: - explicit GLSLDecompiler(const ShaderIR& ir, ShaderStage stage, std::string suffix) - : ir{ir}, stage{stage}, suffix{suffix}, header{ir.GetHeader()} {} + explicit GLSLDecompiler(const Device& device, const ShaderIR& ir, ShaderStage stage, + std::string suffix) + : device{device}, ir{ir}, stage{stage}, suffix{suffix}, header{ir.GetHeader()} {} void Decompile() { DeclareVertex(); @@ -819,8 +821,12 @@ private: // Inline the string as an immediate integer in GLSL (AOFFI arguments are required // to be constant by the standard). expr += std::to_string(static_cast<s32>(immediate->GetValue())); - } else { + } else if (device.HasVariableAoffi()) { + // Avoid using variable AOFFI on unsupported devices. expr += "ftoi(" + Visit(operand) + ')'; + } else { + // Insert 0 on devices not supporting variable AOFFI. + expr += '0'; } if (index + 1 < aoffi.size()) { expr += ", "; @@ -1609,6 +1615,7 @@ private: return name + '_' + std::to_string(index) + '_' + suffix; } + const Device& device; const ShaderIR& ir; const ShaderStage stage; const std::string suffix; @@ -1636,8 +1643,9 @@ std::string GetCommonDeclarations() { "}\n"; } -ProgramResult Decompile(const ShaderIR& ir, Maxwell::ShaderStage stage, const std::string& suffix) { - GLSLDecompiler decompiler(ir, stage, suffix); +ProgramResult Decompile(const Device& device, const ShaderIR& ir, Maxwell::ShaderStage stage, + const std::string& suffix) { + GLSLDecompiler decompiler(device, ir, stage, suffix); decompiler.Decompile(); return {decompiler.GetResult(), decompiler.GetShaderEntries()}; } |