diff options
| author | 2021-03-25 11:31:37 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | 32c5483beb2f79f5d55eb2906f2bfdfa1698bca3 (patch) | |
| tree | bca00dad85f6823746aee66f43dc0cbe2f337481 /src/shader_recompiler/backend/spirv/emit_spirv_vote.cpp | |
| parent | shader: Track first bindless argument instead of the instruction itself (diff) | |
| download | yuzu-32c5483beb2f79f5d55eb2906f2bfdfa1698bca3.tar.gz yuzu-32c5483beb2f79f5d55eb2906f2bfdfa1698bca3.tar.xz yuzu-32c5483beb2f79f5d55eb2906f2bfdfa1698bca3.zip | |
shader: Implement SHFL
Diffstat (limited to 'src/shader_recompiler/backend/spirv/emit_spirv_vote.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_spirv_vote.cpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_vote.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_vote.cpp deleted file mode 100644 index a63677ef2..000000000 --- a/src/shader_recompiler/backend/spirv/emit_spirv_vote.cpp +++ /dev/null | |||
| @@ -1,58 +0,0 @@ | |||
| 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 | |||
| 7 | namespace Shader::Backend::SPIRV { | ||
| 8 | namespace { | ||
| 9 | Id LargeWarpBallot(EmitContext& ctx, Id ballot) { | ||
| 10 | const Id shift{ctx.Constant(ctx.U32[1], 5)}; | ||
| 11 | const Id local_index{ctx.OpLoad(ctx.U32[1], ctx.subgroup_local_invocation_id)}; | ||
| 12 | return ctx.OpVectorExtractDynamic(ctx.U32[1], ballot, local_index); | ||
| 13 | } | ||
| 14 | } // Anonymous namespace | ||
| 15 | |||
| 16 | Id EmitVoteAll(EmitContext& ctx, Id pred) { | ||
| 17 | if (!ctx.profile.warp_size_potentially_larger_than_guest) { | ||
| 18 | return ctx.OpSubgroupAllKHR(ctx.U1, pred); | ||
| 19 | } | ||
| 20 | const Id mask_ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], ctx.true_value)}; | ||
| 21 | const Id active_mask{LargeWarpBallot(ctx, mask_ballot)}; | ||
| 22 | const Id ballot{LargeWarpBallot(ctx, ctx.OpSubgroupBallotKHR(ctx.U32[4], pred))}; | ||
| 23 | const Id lhs{ctx.OpBitwiseAnd(ctx.U32[1], ballot, active_mask)}; | ||
| 24 | return ctx.OpIEqual(ctx.U1, lhs, active_mask); | ||
| 25 | } | ||
| 26 | |||
| 27 | Id EmitVoteAny(EmitContext& ctx, Id pred) { | ||
| 28 | if (!ctx.profile.warp_size_potentially_larger_than_guest) { | ||
| 29 | return ctx.OpSubgroupAnyKHR(ctx.U1, pred); | ||
| 30 | } | ||
| 31 | const Id mask_ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], ctx.true_value)}; | ||
| 32 | const Id active_mask{LargeWarpBallot(ctx, mask_ballot)}; | ||
| 33 | const Id ballot{LargeWarpBallot(ctx, ctx.OpSubgroupBallotKHR(ctx.U32[4], pred))}; | ||
| 34 | const Id lhs{ctx.OpBitwiseAnd(ctx.U32[1], ballot, active_mask)}; | ||
| 35 | return ctx.OpINotEqual(ctx.U1, lhs, ctx.u32_zero_value); | ||
| 36 | } | ||
| 37 | |||
| 38 | Id EmitVoteEqual(EmitContext& ctx, Id pred) { | ||
| 39 | if (!ctx.profile.warp_size_potentially_larger_than_guest) { | ||
| 40 | return ctx.OpSubgroupAllEqualKHR(ctx.U1, pred); | ||
| 41 | } | ||
| 42 | const Id mask_ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], ctx.true_value)}; | ||
| 43 | const Id active_mask{LargeWarpBallot(ctx, mask_ballot)}; | ||
| 44 | const Id ballot{LargeWarpBallot(ctx, ctx.OpSubgroupBallotKHR(ctx.U32[4], pred))}; | ||
| 45 | const Id lhs{ctx.OpBitwiseXor(ctx.U32[1], ballot, active_mask)}; | ||
| 46 | return ctx.OpLogicalOr(ctx.U1, ctx.OpIEqual(ctx.U1, lhs, ctx.u32_zero_value), | ||
| 47 | ctx.OpIEqual(ctx.U1, lhs, active_mask)); | ||
| 48 | } | ||
| 49 | |||
| 50 | Id EmitSubgroupBallot(EmitContext& ctx, Id pred) { | ||
| 51 | const Id ballot{ctx.OpSubgroupBallotKHR(ctx.U32[4], pred)}; | ||
| 52 | if (!ctx.profile.warp_size_potentially_larger_than_guest) { | ||
| 53 | return ctx.OpCompositeExtract(ctx.U32[1], ballot, 0U); | ||
| 54 | } | ||
| 55 | return LargeWarpBallot(ctx, ballot); | ||
| 56 | } | ||
| 57 | |||
| 58 | } // namespace Shader::Backend::SPIRV | ||