diff options
| author | 2021-04-18 20:47:31 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:28 -0400 | |
| commit | 5b8afed87115c82cb48913fd47dfbfa347e4faa5 (patch) | |
| tree | 84eff714b71e1f3e5f1b9436e877327480144b0b /src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp | |
| parent | shader: Address feedback (diff) | |
| download | yuzu-5b8afed87115c82cb48913fd47dfbfa347e4faa5.tar.gz yuzu-5b8afed87115c82cb48913fd47dfbfa347e4faa5.tar.xz yuzu-5b8afed87115c82cb48913fd47dfbfa347e4faa5.zip | |
spirv: Replace Constant/ConstantComposite with Const helper
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp index c2c879a6c..6e17d1c7e 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_atomic.cpp | |||
| @@ -7,10 +7,10 @@ | |||
| 7 | namespace Shader::Backend::SPIRV { | 7 | namespace Shader::Backend::SPIRV { |
| 8 | namespace { | 8 | namespace { |
| 9 | Id SharedPointer(EmitContext& ctx, Id offset, u32 index_offset = 0) { | 9 | Id SharedPointer(EmitContext& ctx, Id offset, u32 index_offset = 0) { |
| 10 | const Id shift_id{ctx.Constant(ctx.U32[1], 2U)}; | 10 | const Id shift_id{ctx.Const(2U)}; |
| 11 | Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; | 11 | Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; |
| 12 | if (index_offset > 0) { | 12 | if (index_offset > 0) { |
| 13 | index = ctx.OpIAdd(ctx.U32[1], index, ctx.Constant(ctx.U32[1], index_offset)); | 13 | index = ctx.OpIAdd(ctx.U32[1], index, ctx.Const(index_offset)); |
| 14 | } | 14 | } |
| 15 | return ctx.profile.support_explicit_workgroup_layout | 15 | return ctx.profile.support_explicit_workgroup_layout |
| 16 | ? ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, ctx.u32_zero_value, index) | 16 | ? ctx.OpAccessChain(ctx.shared_u32, ctx.shared_memory_u32, ctx.u32_zero_value, index) |
| @@ -20,14 +20,14 @@ Id SharedPointer(EmitContext& ctx, Id offset, u32 index_offset = 0) { | |||
| 20 | Id StorageIndex(EmitContext& ctx, const IR::Value& offset, size_t element_size) { | 20 | Id StorageIndex(EmitContext& ctx, const IR::Value& offset, size_t element_size) { |
| 21 | if (offset.IsImmediate()) { | 21 | if (offset.IsImmediate()) { |
| 22 | const u32 imm_offset{static_cast<u32>(offset.U32() / element_size)}; | 22 | const u32 imm_offset{static_cast<u32>(offset.U32() / element_size)}; |
| 23 | return ctx.Constant(ctx.U32[1], imm_offset); | 23 | return ctx.Const(imm_offset); |
| 24 | } | 24 | } |
| 25 | const u32 shift{static_cast<u32>(std::countr_zero(element_size))}; | 25 | const u32 shift{static_cast<u32>(std::countr_zero(element_size))}; |
| 26 | const Id index{ctx.Def(offset)}; | 26 | const Id index{ctx.Def(offset)}; |
| 27 | if (shift == 0) { | 27 | if (shift == 0) { |
| 28 | return index; | 28 | return index; |
| 29 | } | 29 | } |
| 30 | const Id shift_id{ctx.Constant(ctx.U32[1], shift)}; | 30 | const Id shift_id{ctx.Const(shift)}; |
| 31 | return ctx.OpShiftRightLogical(ctx.U32[1], index, shift_id); | 31 | return ctx.OpShiftRightLogical(ctx.U32[1], index, shift_id); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| @@ -43,7 +43,7 @@ Id StoragePointer(EmitContext& ctx, const StorageTypeDefinition& type_def, | |||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | std::pair<Id, Id> AtomicArgs(EmitContext& ctx) { | 45 | std::pair<Id, Id> AtomicArgs(EmitContext& ctx) { |
| 46 | const Id scope{ctx.Constant(ctx.U32[1], static_cast<u32>(spv::Scope::Device))}; | 46 | const Id scope{ctx.Const(static_cast<u32>(spv::Scope::Device))}; |
| 47 | const Id semantics{ctx.u32_zero_value}; | 47 | const Id semantics{ctx.u32_zero_value}; |
| 48 | return {scope, semantics}; | 48 | return {scope, semantics}; |
| 49 | } | 49 | } |
| @@ -103,13 +103,13 @@ Id EmitSharedAtomicUMax32(EmitContext& ctx, Id offset, Id value) { | |||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | Id EmitSharedAtomicInc32(EmitContext& ctx, Id offset, Id value) { | 105 | Id EmitSharedAtomicInc32(EmitContext& ctx, Id offset, Id value) { |
| 106 | const Id shift_id{ctx.Constant(ctx.U32[1], 2U)}; | 106 | const Id shift_id{ctx.Const(2U)}; |
| 107 | const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; | 107 | const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; |
| 108 | return ctx.OpFunctionCall(ctx.U32[1], ctx.increment_cas_shared, index, value); | 108 | return ctx.OpFunctionCall(ctx.U32[1], ctx.increment_cas_shared, index, value); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | Id EmitSharedAtomicDec32(EmitContext& ctx, Id offset, Id value) { | 111 | Id EmitSharedAtomicDec32(EmitContext& ctx, Id offset, Id value) { |
| 112 | const Id shift_id{ctx.Constant(ctx.U32[1], 2U)}; | 112 | const Id shift_id{ctx.Const(2U)}; |
| 113 | const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; | 113 | const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; |
| 114 | return ctx.OpFunctionCall(ctx.U32[1], ctx.decrement_cas_shared, index, value); | 114 | return ctx.OpFunctionCall(ctx.U32[1], ctx.decrement_cas_shared, index, value); |
| 115 | } | 115 | } |
| @@ -132,7 +132,7 @@ Id EmitSharedAtomicExchange32(EmitContext& ctx, Id offset, Id value) { | |||
| 132 | 132 | ||
| 133 | Id EmitSharedAtomicExchange64(EmitContext& ctx, Id offset, Id value) { | 133 | Id EmitSharedAtomicExchange64(EmitContext& ctx, Id offset, Id value) { |
| 134 | if (ctx.profile.support_int64_atomics && ctx.profile.support_explicit_workgroup_layout) { | 134 | if (ctx.profile.support_int64_atomics && ctx.profile.support_explicit_workgroup_layout) { |
| 135 | const Id shift_id{ctx.Constant(ctx.U32[1], 3U)}; | 135 | const Id shift_id{ctx.Const(3U)}; |
| 136 | const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; | 136 | const Id index{ctx.OpShiftRightArithmetic(ctx.U32[1], offset, shift_id)}; |
| 137 | const Id pointer{ | 137 | const Id pointer{ |
| 138 | ctx.OpAccessChain(ctx.shared_u64, ctx.shared_memory_u64, ctx.u32_zero_value, index)}; | 138 | ctx.OpAccessChain(ctx.shared_u64, ctx.shared_memory_u64, ctx.u32_zero_value, index)}; |