diff options
| author | 2021-05-30 17:27:00 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:37 -0400 | |
| commit | 1269a0cf8b3844c1a9bb06c843a7698b0a9643d5 (patch) | |
| tree | a0716589fa3952bdeb0f1d19b4bb455d9cdd86e5 /src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | |
| parent | glsl: Fix ATOM and implement ATOMS (diff) | |
| download | yuzu-1269a0cf8b3844c1a9bb06c843a7698b0a9643d5.tar.gz yuzu-1269a0cf8b3844c1a9bb06c843a7698b0a9643d5.tar.xz yuzu-1269a0cf8b3844c1a9bb06c843a7698b0a9643d5.zip | |
glsl: Rework variable allocator to allow for variable reuse
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp index 16791be84..918f90058 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_atomic.cpp | |||
| @@ -20,14 +20,14 @@ for (;;){{ | |||
| 20 | 20 | ||
| 21 | void SharedCasFunction(EmitContext& ctx, IR::Inst& inst, std::string_view offset, | 21 | void SharedCasFunction(EmitContext& ctx, IR::Inst& inst, std::string_view offset, |
| 22 | std::string_view value, std::string_view function) { | 22 | std::string_view value, std::string_view function) { |
| 23 | const auto ret{ctx.reg_alloc.Define(inst, Type::U32)}; | 23 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 24 | const std::string smem{fmt::format("smem[{}/4]", offset)}; | 24 | const std::string smem{fmt::format("smem[{}/4]", offset)}; |
| 25 | ctx.Add(cas_loop.data(), ret, smem, ret, smem, function, smem, value, ret); | 25 | ctx.Add(cas_loop.data(), ret, smem, ret, smem, function, smem, value, ret); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | void SsboCasFunction(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, | 28 | void SsboCasFunction(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding, |
| 29 | const IR::Value& offset, std::string_view value, std::string_view function) { | 29 | const IR::Value& offset, std::string_view value, std::string_view function) { |
| 30 | const auto ret{ctx.reg_alloc.Define(inst, Type::U32)}; | 30 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 31 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; | 31 | 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); | 32 | ctx.Add(cas_loop.data(), ret, ssbo, ret, ssbo, function, ssbo, value, ret); |
| 33 | } | 33 | } |
| @@ -36,7 +36,7 @@ void SsboCasFunctionF32(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindi | |||
| 36 | const IR::Value& offset, std::string_view value, | 36 | const IR::Value& offset, std::string_view value, |
| 37 | std::string_view function) { | 37 | std::string_view function) { |
| 38 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; | 38 | const std::string ssbo{fmt::format("ssbo{}[{}]", binding.U32(), offset.U32())}; |
| 39 | const auto ret{ctx.reg_alloc.Define(inst, Type::U32)}; | 39 | const auto ret{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 40 | ctx.Add(cas_loop.data(), ret, ssbo, ret, ssbo, function, ssbo, value, ret); | 40 | ctx.Add(cas_loop.data(), ret, ssbo, ret, ssbo, function, ssbo, value, ret); |
| 41 | ctx.AddF32("{}=uintBitsToFloat({});", inst, ret); | 41 | ctx.AddF32("{}=uintBitsToFloat({});", inst, ret); |
| 42 | } | 42 | } |
| @@ -102,9 +102,8 @@ void EmitSharedAtomicExchange32(EmitContext& ctx, IR::Inst& inst, std::string_vi | |||
| 102 | void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset, | 102 | void EmitSharedAtomicExchange64(EmitContext& ctx, IR::Inst& inst, std::string_view pointer_offset, |
| 103 | std::string_view value) { | 103 | std::string_view value) { |
| 104 | // LOG_WARNING("Int64 Atomics not supported, fallback to non-atomic"); | 104 | // LOG_WARNING("Int64 Atomics not supported, fallback to non-atomic"); |
| 105 | const auto ret{ctx.reg_alloc.Define(inst, Type::U64)}; | 105 | ctx.AddU64("{}=packUint2x32(uvec2(smem[{}/4],smem[({}+4)/4]));", inst, pointer_offset, |
| 106 | ctx.Add("{}=packUint2x32(uvec2(smem[{}/4],smem[({}+4)/4]));", ret, pointer_offset, | 106 | pointer_offset); |
| 107 | pointer_offset); | ||
| 108 | ctx.Add("smem[{}/4]=unpackUint2x32({}).x;smem[({}+4)/4]=unpackUint2x32({}).y;", pointer_offset, | 107 | ctx.Add("smem[{}/4]=unpackUint2x32({}).x;smem[({}+4)/4]=unpackUint2x32({}).y;", pointer_offset, |
| 109 | value, pointer_offset, value); | 108 | value, pointer_offset, value); |
| 110 | } | 109 | } |