diff options
| author | 2021-05-25 01:35:30 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:36 -0400 | |
| commit | 11ba190462c7b69a47598b2d1572fac3bccc4adc (patch) | |
| tree | e24682860686eba5710716579a583312c1db2652 /src/shader_recompiler/backend/glsl/emit_context.cpp | |
| parent | glsl: implement phi nodes (diff) | |
| download | yuzu-11ba190462c7b69a47598b2d1572fac3bccc4adc.tar.gz yuzu-11ba190462c7b69a47598b2d1572fac3bccc4adc.tar.xz yuzu-11ba190462c7b69a47598b2d1572fac3bccc4adc.zip | |
glsl: Revert ssbo aliasing. Storage Atomics impl
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index 3c610a08a..7986bf78f 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -59,27 +59,8 @@ void EmitContext::DefineStorageBuffers() { | |||
| 59 | } | 59 | } |
| 60 | u32 binding{}; | 60 | u32 binding{}; |
| 61 | for (const auto& desc : info.storage_buffers_descriptors) { | 61 | for (const auto& desc : info.storage_buffers_descriptors) { |
| 62 | if (info.uses_s32_atomics) { | 62 | Add("layout(std430,binding={}) buffer ssbo_{}{{uint ssbo{}[];}};", binding, binding, |
| 63 | Add("layout(std430,binding={}) buffer ssbo_{}_s32{{int ssbo{}_s32[];}};", binding, | 63 | desc.cbuf_index, desc.count); |
| 64 | binding, desc.cbuf_index, desc.count); | ||
| 65 | } | ||
| 66 | if (True(info.used_storage_buffer_types & IR::Type::U32)) { | ||
| 67 | Add("layout(std430,binding={}) buffer ssbo_{}_u32{{uint ssbo{}_u32[];}};", binding, | ||
| 68 | binding, desc.cbuf_index, desc.count); | ||
| 69 | } | ||
| 70 | if (True(info.used_storage_buffer_types & IR::Type::F32)) { | ||
| 71 | Add("layout(std430,binding={}) buffer ssbo_{}_f32{{float ssbo{}_f32[];}};", binding, | ||
| 72 | binding, desc.cbuf_index, desc.count); | ||
| 73 | } | ||
| 74 | if (True(info.used_storage_buffer_types & IR::Type::U32x2)) { | ||
| 75 | Add("layout(std430,binding={}) buffer ssbo_{}_u32x2{{uvec2 ssbo{}_u32x2[];}};", binding, | ||
| 76 | binding, desc.cbuf_index, desc.count); | ||
| 77 | } | ||
| 78 | if (True(info.used_storage_buffer_types & IR::Type::U64) || | ||
| 79 | True(info.used_storage_buffer_types & IR::Type::F64)) { | ||
| 80 | Add("layout(std430,binding={}) buffer ssbo_{}_u64{{uint64_t ssbo{}_u64[];}};", binding, | ||
| 81 | binding, desc.cbuf_index, desc.count); | ||
| 82 | } | ||
| 83 | ++binding; | 64 | ++binding; |
| 84 | } | 65 | } |
| 85 | } | 66 | } |
| @@ -92,6 +73,25 @@ void EmitContext::DefineHelperFunctions() { | |||
| 92 | code += | 73 | code += |
| 93 | "uint CasDecrement(uint op_a,uint op_b){return(op_a==0||op_a>op_b)?op_b:(op_a-1u);}\n"; | 74 | "uint CasDecrement(uint op_a,uint op_b){return(op_a==0||op_a>op_b)?op_b:(op_a-1u);}\n"; |
| 94 | } | 75 | } |
| 76 | if (info.uses_atomic_f32_add) { | ||
| 77 | code += "uint CasFloatAdd(uint op_a,uint op_b){return " | ||
| 78 | "floatBitsToUint(uintBitsToFloat(op_a)+uintBitsToFloat(op_b));}\n"; | ||
| 79 | } | ||
| 80 | if (info.uses_atomic_f32x2_add) { | ||
| 81 | code += "uint CasFloatAdd32x2(uint op_a,uint op_b){return " | ||
| 82 | "packHalf2x16(unpackHalf2x16(op_a)+unpackHalf2x16(op_b));}\n"; | ||
| 83 | } | ||
| 84 | if (info.uses_atomic_f32x2_min) { | ||
| 85 | code += "uint CasFloatMin32x2(uint op_a,uint op_b){return " | ||
| 86 | "packHalf2x16(min(unpackHalf2x16(op_a),unpackHalf2x16(op_b)));}\n"; | ||
| 87 | } | ||
| 88 | if (info.uses_atomic_f32x2_max) { | ||
| 89 | code += "uint CasFloatMax32x2(uint op_a,uint op_b){return " | ||
| 90 | "packHalf2x16(max(unpackHalf2x16(op_a),unpackHalf2x16(op_b)));}\n"; | ||
| 91 | } | ||
| 92 | // TODO: Track this usage | ||
| 93 | code += "uint CasMinS32(uint op_a,uint op_b){return uint(min(int(op_a),int(op_b)));}"; | ||
| 94 | code += "uint CasMaxS32(uint op_a,uint op_b){return uint(max(int(op_a),int(op_b)));}"; | ||
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | } // namespace Shader::Backend::GLSL | 97 | } // namespace Shader::Backend::GLSL |