diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp index 918f90058..db4c60002 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | |||
| @@ -11,8 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | namespace Shader::Backend::GLSL { | 12 | namespace Shader::Backend::GLSL { |
| 13 | namespace { | 13 | namespace { |
| 14 | static constexpr std::string_view cas_loop{R"({}; | 14 | static constexpr std::string_view cas_loop{R"(for (;;){{ |
| 15 | for (;;){{ | ||
| 16 | uint old_value={}; | 15 | uint old_value={}; |
| 17 | {}=atomicCompSwap({},old_value,{}({},{})); | 16 | {}=atomicCompSwap({},old_value,{}({},{})); |
| 18 | if ({}==old_value){{break;}} | 17 | if ({}==old_value){{break;}} |
| @@ -22,14 +21,14 @@ void SharedCasFunction(EmitContext& ctx, IR::Inst& inst, std::string_view offset | |||
| 22 | std::string_view value, std::string_view function) { | 21 | std::string_view value, std::string_view function) { |
| 23 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; | 22 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 24 | const std::string smem{fmt::format("smem[{}/4]", offset)}; | 23 | const std::string smem{fmt::format("smem[{}/4]", offset)}; |
| 25 | ctx.Add(cas_loop.data(), ret, smem, ret, smem, function, smem, value, ret); | 24 | ctx.Add(cas_loop.data(), smem, ret, smem, function, smem, value, ret); |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | void SsboCasFunction(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 27 | void SsboCasFunction(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 29 | const IR::Value& offset, std::string_view value, std::string_view function) { | 28 | const IR::Value& offset, std::string_view value, std::string_view function) { |
| 30 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; | 29 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 31 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; | 30 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; |
| 32 | ctx.Add(cas_loop.data(), ret, ssbo, ret, ssbo, function, ssbo, value, ret); | 31 | ctx.Add(cas_loop.data(), ssbo, ret, ssbo, function, ssbo, value, ret); |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | void SsboCasFunctionF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 34 | void SsboCasFunctionF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| @@ -37,7 +36,7 @@ void SsboCasFunctionF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindi | |||
| 37 | std::string_view function) { | 36 | std::string_view function) { |
| 38 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; | 37 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; |
| 39 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; | 38 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 40 | ctx.Add(cas_loop.data(), ret, ssbo, ret, ssbo, function, ssbo, value, ret); | 39 | ctx.Add(cas_loop.data(), ssbo, ret, ssbo, function, ssbo, value, ret); |
| 41 | ctx.AddF32("{}=uintBitsToFloat({});", inst, ret); | 40 | ctx.AddF32("{}=uintBitsToFloat({});", inst, ret); |
| 42 | } | 41 | } |
| 43 | } // namespace | 42 | } // namespace |