summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
index aebdf8a3a..0a488188b 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
@@ -8,6 +8,59 @@
8#include "shader_recompiler/frontend/ir/value.h" 8#include "shader_recompiler/frontend/ir/value.h"
9 9
10namespace Shader::Backend::GLSL { 10namespace Shader::Backend::GLSL {
11namespace {
12void SetInBoundsFlag(EmitContext& ctx, IR::Inst& inst) {
13 IR::Inst* const in_bounds{inst.GetAssociatedPseudoOperation(IR::Opcode::GetInBoundsFromOp)};
14 if (!in_bounds) {
15 return;
16 }
17
18 ctx.AddU1("{}=shfl_in_bounds;", *in_bounds);
19 in_bounds->Invalidate();
20}
21} // namespace
22
23void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, std::string_view value,
24 std::string_view index, std::string_view clamp,
25 std::string_view segmentation_mask) {
26 ctx.Add("shfl_in_bounds=int(gl_SubGroupInvocationARB-{})>=int((gl_SubGroupInvocationARB&{})|({}"
27 "&~{}));",
28 index, segmentation_mask, clamp, segmentation_mask);
29 SetInBoundsFlag(ctx, inst);
30 ctx.AddU32("{}=shfl_in_bounds?{}:gl_SubGroupInvocationARB-{};", inst, value, index);
31}
32
33void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index,
34 std::string_view clamp, std::string_view segmentation_mask) {
35 ctx.Add("shfl_in_bounds=int(gl_SubGroupInvocationARB-{})>=int((gl_SubGroupInvocationARB&{})|({}"
36 "&~{}));",
37 index, segmentation_mask, clamp, segmentation_mask);
38 SetInBoundsFlag(ctx, inst);
39 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},gl_SubGroupInvocationARB-{}):"
40 "{};",
41 inst, value, index, value);
42}
43
44void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
45 std::string_view index, std::string_view clamp,
46 std::string_view segmentation_mask) {
47 ctx.Add("shfl_in_bounds=int(gl_SubGroupInvocationARB-{})>=int((gl_SubGroupInvocationARB&{})|({}"
48 "&~{}));",
49 index, segmentation_mask, clamp, segmentation_mask);
50 SetInBoundsFlag(ctx, inst);
51 ctx.AddU32("{}=shfl_in_bounds?{}:gl_SubGroupInvocationARB-{};", inst, value, index);
52}
53
54void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value,
55 std::string_view index, std::string_view clamp,
56 std::string_view segmentation_mask) {
57 ctx.Add("shfl_in_bounds=int(gl_SubGroupInvocationARB-{})>=int((gl_SubGroupInvocationARB&{})|({}"
58 "&~{}));",
59 index, segmentation_mask, clamp, segmentation_mask);
60 SetInBoundsFlag(ctx, inst);
61 ctx.AddU32("{}=shfl_in_bounds?{}:gl_SubGroupInvocationARB-{};", inst, value, index);
62}
63
11void EmitFSwizzleAdd([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 64void EmitFSwizzleAdd([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
12 [[maybe_unused]] std::string_view op_a, [[maybe_unused]] std::string_view op_b, 65 [[maybe_unused]] std::string_view op_a, [[maybe_unused]] std::string_view op_b,
13 [[maybe_unused]] std::string_view swizzle) { 66 [[maybe_unused]] std::string_view swizzle) {