diff options
| author | 2021-05-28 21:24:52 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:36 -0400 | |
| commit | 8ba814efb295f0b8494b3679c484c7ceab31c392 (patch) | |
| tree | 7c81176bc12ea7b99309d2748e03c61aa2bf64b8 /src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp | |
| parent | glsl: Fix integer conversions, implement clamp CC (diff) | |
| download | yuzu-8ba814efb295f0b8494b3679c484c7ceab31c392.tar.gz yuzu-8ba814efb295f0b8494b3679c484c7ceab31c392.tar.xz yuzu-8ba814efb295f0b8494b3679c484c7ceab31c392.zip | |
glsl: Better Storage access and wip warps
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp | 53 |
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 | ||
| 10 | namespace Shader::Backend::GLSL { | 10 | namespace Shader::Backend::GLSL { |
| 11 | namespace { | ||
| 12 | void 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 | |||
| 23 | void 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 | |||
| 33 | void 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 | |||
| 44 | void 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 | |||
| 54 | void 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 | |||
| 11 | void EmitFSwizzleAdd([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, | 64 | void 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) { |