summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-12-30 00:55:42 +0100
committerameerj <52414509+ameerj@users.noreply.github.com>2021-12-30 01:03:50 +0100
commit8c907c620d830bdaef30ff4316489443775b3ea4 (patch)
tree1d4fdda0429c8999d615e981a6e79384a223823a /src/shader_recompiler
parentglsl_context_get_set: Add alternative cbuf type for broken drivers (diff)
downloadyuzu-8c907c620d830bdaef30ff4316489443775b3ea4.tar
yuzu-8c907c620d830bdaef30ff4316489443775b3ea4.tar.gz
yuzu-8c907c620d830bdaef30ff4316489443775b3ea4.tar.bz2
yuzu-8c907c620d830bdaef30ff4316489443775b3ea4.tar.lz
yuzu-8c907c620d830bdaef30ff4316489443775b3ea4.tar.xz
yuzu-8c907c620d830bdaef30ff4316489443775b3ea4.tar.zst
yuzu-8c907c620d830bdaef30ff4316489443775b3ea4.zip
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_bitwise_conversion.cpp4
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_special.cpp4
-rw-r--r--src/shader_recompiler/profile.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_bitwise_conversion.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_bitwise_conversion.cpp
index 0f2668d9e..e0ead7a53 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_bitwise_conversion.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_bitwise_conversion.cpp
@@ -7,6 +7,7 @@
#include "shader_recompiler/backend/glsl/emit_glsl_instructions.h"
#include "shader_recompiler/backend/glsl/glsl_emit_context.h"
#include "shader_recompiler/frontend/ir/value.h"
+#include "shader_recompiler/profile.h"
namespace Shader::Backend::GLSL {
namespace {
@@ -30,8 +31,9 @@ void EmitConditionRef(EmitContext& ctx, IR::Inst& inst, const IR::Value& value)
inst.DestructiveAddUsage(1);
const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U1)};
const auto input{ctx.var_alloc.Consume(value)};
+ const auto suffix{ctx.profile.has_gl_bool_ref_bug ? "?true:false" : ""};
if (ret != input) {
- ctx.Add("{}={};", ret, input);
+ ctx.Add("{}={}{};", ret, input, suffix);
}
}
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
index b8ddafe48..fcf620b79 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_special.cpp
@@ -90,7 +90,9 @@ void EmitPhiMove(EmitContext& ctx, const IR::Value& phi_value, const IR::Value&
if (phi_reg == val_reg) {
return;
}
- ctx.Add("{}={};", phi_reg, val_reg);
+ const bool needs_workaround{ctx.profile.has_gl_bool_ref_bug && phi_type == IR::Type::U1};
+ const auto suffix{needs_workaround ? "?true:false" : ""};
+ ctx.Add("{}={}{};", phi_reg, val_reg, suffix);
}
void EmitPrologue(EmitContext& ctx) {
diff --git a/src/shader_recompiler/profile.h b/src/shader_recompiler/profile.h
index 9deb3f4bb..dc4c806ff 100644
--- a/src/shader_recompiler/profile.h
+++ b/src/shader_recompiler/profile.h
@@ -67,6 +67,8 @@ struct Profile {
bool has_gl_precise_bug{};
/// Some drivers do not properly support floatBitsToUint when used on cbufs
bool has_gl_cbuf_ftou_bug{};
+ /// Some drivers poorly optimize boolean variable references
+ bool has_gl_bool_ref_bug{};
/// Ignores SPIR-V ordered vs unordered using GLSL semantics
bool ignore_nan_fp_comparisons{};