diff options
| author | 2021-04-02 19:27:30 +0200 | |
|---|---|---|
| committer | 2021-07-22 21:51:26 -0400 | |
| commit | 655f7a570a10218ffb2ed175bb7f0b84530ccae0 (patch) | |
| tree | bb95bc316718bd5c746a0b28084b3548a4aea222 /src/shader_recompiler/backend | |
| parent | shader: Improve VOTE.VTG stub (diff) | |
| download | yuzu-655f7a570a10218ffb2ed175bb7f0b84530ccae0.tar.gz yuzu-655f7a570a10218ffb2ed175bb7f0b84530ccae0.tar.xz yuzu-655f7a570a10218ffb2ed175bb7f0b84530ccae0.zip | |
shader: Implement MEMBAR
Diffstat (limited to 'src/shader_recompiler/backend')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv.h | 1 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_barriers.cpp | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv.h b/src/shader_recompiler/backend/spirv/emit_spirv.h index d2eda1f8e..749ad1240 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv.h +++ b/src/shader_recompiler/backend/spirv/emit_spirv.h | |||
| @@ -28,6 +28,7 @@ void EmitSelectionMerge(EmitContext& ctx, Id merge_label); | |||
| 28 | void EmitReturn(EmitContext& ctx); | 28 | void EmitReturn(EmitContext& ctx); |
| 29 | void EmitUnreachable(EmitContext& ctx); | 29 | void EmitUnreachable(EmitContext& ctx); |
| 30 | void EmitDemoteToHelperInvocation(EmitContext& ctx, Id continue_label); | 30 | void EmitDemoteToHelperInvocation(EmitContext& ctx, Id continue_label); |
| 31 | void EmitMemoryBarrier(EmitContext& ctx, IR::Inst* inst); | ||
| 31 | void EmitPrologue(EmitContext& ctx); | 32 | void EmitPrologue(EmitContext& ctx); |
| 32 | void EmitEpilogue(EmitContext& ctx); | 33 | void EmitEpilogue(EmitContext& ctx); |
| 33 | void EmitGetRegister(EmitContext& ctx); | 34 | void EmitGetRegister(EmitContext& ctx); |
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_barriers.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_barriers.cpp new file mode 100644 index 000000000..413ac25a0 --- /dev/null +++ b/src/shader_recompiler/backend/spirv/emit_spirv_barriers.cpp | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "shader_recompiler/backend/spirv/emit_spirv.h" | ||
| 6 | #include "shader_recompiler/frontend/ir/modifiers.h" | ||
| 7 | |||
| 8 | namespace Shader::Backend::SPIRV { | ||
| 9 | namespace { | ||
| 10 | spv::Scope MemoryScopeToSpirVScope(IR::MemoryScope scope) { | ||
| 11 | switch (scope) { | ||
| 12 | case IR::MemoryScope::Warp: | ||
| 13 | return spv::Scope::Subgroup; | ||
| 14 | case IR::MemoryScope::Workgroup: | ||
| 15 | return spv::Scope::Workgroup; | ||
| 16 | case IR::MemoryScope::Device: | ||
| 17 | return spv::Scope::Device; | ||
| 18 | case IR::MemoryScope::System: | ||
| 19 | return spv::Scope::CrossDevice; | ||
| 20 | case IR::MemoryScope::DontCare: | ||
| 21 | return spv::Scope::Invocation; | ||
| 22 | default: | ||
| 23 | throw NotImplementedException("Unknown memory scope!"); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | } // namespace | ||
| 28 | |||
| 29 | void EmitMemoryBarrier(EmitContext& ctx, IR::Inst* inst) { | ||
| 30 | const auto info{inst->Flags<IR::BarrierInstInfo>()}; | ||
| 31 | const auto semantics = | ||
| 32 | spv::MemorySemanticsMask::AcquireRelease | spv::MemorySemanticsMask::UniformMemory | | ||
| 33 | spv::MemorySemanticsMask::WorkgroupMemory | spv::MemorySemanticsMask::AtomicCounterMemory | | ||
| 34 | spv::MemorySemanticsMask::ImageMemory; | ||
| 35 | const auto scope = MemoryScopeToSpirVScope(info.scope); | ||
| 36 | ctx.OpMemoryBarrier(ctx.Constant(ctx.U32[1], static_cast<u32>(scope)), | ||
| 37 | ctx.Constant(ctx.U32[1], static_cast<u32>(semantics))); | ||
| 38 | } | ||
| 39 | |||
| 40 | } // namespace Shader::Backend::SPIRV | ||