diff options
Diffstat (limited to 'src')
6 files changed, 15 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 @@ | |||
| 7 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" | 7 | #include "shader_recompiler/backend/glsl/emit_glsl_instructions.h" |
| 8 | #include "shader_recompiler/backend/glsl/glsl_emit_context.h" | 8 | #include "shader_recompiler/backend/glsl/glsl_emit_context.h" |
| 9 | #include "shader_recompiler/frontend/ir/value.h" | 9 | #include "shader_recompiler/frontend/ir/value.h" |
| 10 | #include "shader_recompiler/profile.h" | ||
| 10 | 11 | ||
| 11 | namespace Shader::Backend::GLSL { | 12 | namespace Shader::Backend::GLSL { |
| 12 | namespace { | 13 | namespace { |
| @@ -30,8 +31,9 @@ void EmitConditionRef(EmitContext& ctx, IR::Inst& inst, const IR::Value& value) | |||
| 30 | inst.DestructiveAddUsage(1); | 31 | inst.DestructiveAddUsage(1); |
| 31 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U1)}; | 32 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U1)}; |
| 32 | const auto input{ctx.var_alloc.Consume(value)}; | 33 | const auto input{ctx.var_alloc.Consume(value)}; |
| 34 | const auto suffix{ctx.profile.has_gl_bool_ref_bug ? "?true:false" : ""}; | ||
| 33 | if (ret != input) { | 35 | if (ret != input) { |
| 34 | ctx.Add("{}={};", ret, input); | 36 | ctx.Add("{}={}{};", ret, input, suffix); |
| 35 | } | 37 | } |
| 36 | } | 38 | } |
| 37 | 39 | ||
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& | |||
| 90 | if (phi_reg == val_reg) { | 90 | if (phi_reg == val_reg) { |
| 91 | return; | 91 | return; |
| 92 | } | 92 | } |
| 93 | ctx.Add("{}={};", phi_reg, val_reg); | 93 | const bool needs_workaround{ctx.profile.has_gl_bool_ref_bug && phi_type == IR::Type::U1}; |
| 94 | const auto suffix{needs_workaround ? "?true:false" : ""}; | ||
| 95 | ctx.Add("{}={}{};", phi_reg, val_reg, suffix); | ||
| 94 | } | 96 | } |
| 95 | 97 | ||
| 96 | void EmitPrologue(EmitContext& ctx) { | 98 | 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 { | |||
| 67 | bool has_gl_precise_bug{}; | 67 | bool has_gl_precise_bug{}; |
| 68 | /// Some drivers do not properly support floatBitsToUint when used on cbufs | 68 | /// Some drivers do not properly support floatBitsToUint when used on cbufs |
| 69 | bool has_gl_cbuf_ftou_bug{}; | 69 | bool has_gl_cbuf_ftou_bug{}; |
| 70 | /// Some drivers poorly optimize boolean variable references | ||
| 71 | bool has_gl_bool_ref_bug{}; | ||
| 70 | /// Ignores SPIR-V ordered vs unordered using GLSL semantics | 72 | /// Ignores SPIR-V ordered vs unordered using GLSL semantics |
| 71 | bool ignore_nan_fp_comparisons{}; | 73 | bool ignore_nan_fp_comparisons{}; |
| 72 | 74 | ||
diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp index 32736126f..e62912a22 100644 --- a/src/video_core/renderer_opengl/gl_device.cpp +++ b/src/video_core/renderer_opengl/gl_device.cpp | |||
| @@ -188,6 +188,7 @@ Device::Device() { | |||
| 188 | std::atoi(driver_version.substr(0, driver_version.find(".")).data()); | 188 | std::atoi(driver_version.substr(0, driver_version.find(".")).data()); |
| 189 | if (version_major >= 495) { | 189 | if (version_major >= 495) { |
| 190 | has_cbuf_ftou_bug = true; | 190 | has_cbuf_ftou_bug = true; |
| 191 | has_bool_ref_bug = true; | ||
| 191 | } | 192 | } |
| 192 | } | 193 | } |
| 193 | 194 | ||
diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h index fe53ef991..95c2e8d38 100644 --- a/src/video_core/renderer_opengl/gl_device.h +++ b/src/video_core/renderer_opengl/gl_device.h | |||
| @@ -156,6 +156,10 @@ public: | |||
| 156 | return has_cbuf_ftou_bug; | 156 | return has_cbuf_ftou_bug; |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | bool HasBoolRefBug() const { | ||
| 160 | return has_bool_ref_bug; | ||
| 161 | } | ||
| 162 | |||
| 159 | Settings::ShaderBackend GetShaderBackend() const { | 163 | Settings::ShaderBackend GetShaderBackend() const { |
| 160 | return shader_backend; | 164 | return shader_backend; |
| 161 | } | 165 | } |
| @@ -205,6 +209,7 @@ private: | |||
| 205 | bool warp_size_potentially_larger_than_guest{}; | 209 | bool warp_size_potentially_larger_than_guest{}; |
| 206 | bool need_fastmath_off{}; | 210 | bool need_fastmath_off{}; |
| 207 | bool has_cbuf_ftou_bug{}; | 211 | bool has_cbuf_ftou_bug{}; |
| 212 | bool has_bool_ref_bug{}; | ||
| 208 | 213 | ||
| 209 | std::string vendor_name; | 214 | std::string vendor_name; |
| 210 | }; | 215 | }; |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 1efcc3562..ec558a9af 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -215,6 +215,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo | |||
| 215 | .has_gl_component_indexing_bug = device.HasComponentIndexingBug(), | 215 | .has_gl_component_indexing_bug = device.HasComponentIndexingBug(), |
| 216 | .has_gl_precise_bug = device.HasPreciseBug(), | 216 | .has_gl_precise_bug = device.HasPreciseBug(), |
| 217 | .has_gl_cbuf_ftou_bug = device.HasCbufFtouBug(), | 217 | .has_gl_cbuf_ftou_bug = device.HasCbufFtouBug(), |
| 218 | .has_gl_bool_ref_bug = device.HasBoolRefBug(), | ||
| 218 | .ignore_nan_fp_comparisons = true, | 219 | .ignore_nan_fp_comparisons = true, |
| 219 | .gl_max_compute_smem_size = device.GetMaxComputeSharedMemorySize(), | 220 | .gl_max_compute_smem_size = device.GetMaxComputeSharedMemorySize(), |
| 220 | }, | 221 | }, |