summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-04-23 04:14:02 +0200
committerGitHub <noreply@github.com>2019-04-23 04:14:02 +0200
commit4fad91ca4501af51822a35d5f251c6cf486f5041 (patch)
treeadd83242d7d748f3ca0eb7136470c762218fdf74 /src/video_core/renderer_opengl/gl_shader_decompiler.cpp
parentMerge pull request #2420 from lioncash/audctl (diff)
parentgl_shader_decompiler: Use variable AOFFI on supported hardware (diff)
downloadyuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.tar
yuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.tar.gz
yuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.tar.bz2
yuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.tar.lz
yuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.tar.xz
yuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.tar.zst
yuzu-4fad91ca4501af51822a35d5f251c6cf486f5041.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp18
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 cd462621d..ef1a1995f 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"
@@ -135,8 +136,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();
@@ -802,8 +804,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 += ", ";
@@ -1645,6 +1651,7 @@ private:
return name + '_' + std::to_string(index) + '_' + suffix;
}
+ const Device& device;
const ShaderIR& ir;
const ShaderStage stage;
const std::string suffix;
@@ -1676,8 +1683,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()};
}