summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-30 00:53:26 -0400
committerGravatar ameerj2021-07-22 21:51:36 -0400
commite35ffbbeb0f85f676416fcb8f0bb0207671f379d (patch)
treed33fca2f27f8c680c43dfb34da8abd738b0a5705 /src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
parentglsl: Implement VOTE (diff)
downloadyuzu-e35ffbbeb0f85f676416fcb8f0bb0207671f379d.tar.gz
yuzu-e35ffbbeb0f85f676416fcb8f0bb0207671f379d.tar.xz
yuzu-e35ffbbeb0f85f676416fcb8f0bb0207671f379d.zip
glsl: Implement VOTE for subgroup size potentially larger
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
index e462c977c..8a018acb5 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
@@ -42,31 +42,42 @@ void EmitLaneId([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& in
42} 42}
43 43
44void EmitVoteAll(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { 44void EmitVoteAll(EmitContext& ctx, IR::Inst& inst, std::string_view pred) {
45 ctx.AddU1("{}=allInvocationsEqualARB({});", inst, pred); 45 if (!ctx.profile.warp_size_potentially_larger_than_guest) {
46 // TODO: 46 ctx.AddU1("{}=allInvocationsEqualARB({});", inst, pred);
47 // if (ctx.profile.warp_size_potentially_larger_than_guest) { 47 } else {
48 // } 48 const auto active_mask{fmt::format("uvec2(ballotARB(true))[gl_SubgroupInvocationID]")};
49 const auto ballot{fmt::format("uvec2(ballotARB({}))[gl_SubgroupInvocationID]", pred)};
50 ctx.AddU1("{}=({}&{})=={};", inst, ballot, active_mask, active_mask);
51 }
49} 52}
50 53
51void EmitVoteAny(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { 54void EmitVoteAny(EmitContext& ctx, IR::Inst& inst, std::string_view pred) {
52 ctx.AddU1("{}=anyInvocationARB({});", inst, pred); 55 if (!ctx.profile.warp_size_potentially_larger_than_guest) {
53 // TODO: 56 ctx.AddU1("{}=anyInvocationARB({});", inst, pred);
54 // if (ctx.profile.warp_size_potentially_larger_than_guest) { 57 } else {
55 // } 58 const auto active_mask{fmt::format("uvec2(ballotARB(true))[gl_SubgroupInvocationID]")};
59 const auto ballot{fmt::format("uvec2(ballotARB({}))[gl_SubgroupInvocationID]", pred)};
60 ctx.AddU1("{}=({}&{})!=0u;", inst, ballot, active_mask, active_mask);
61 }
56} 62}
57 63
58void EmitVoteEqual(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { 64void EmitVoteEqual(EmitContext& ctx, IR::Inst& inst, std::string_view pred) {
59 ctx.AddU1("{}=allInvocationsEqualARB({});", inst, pred); 65 if (!ctx.profile.warp_size_potentially_larger_than_guest) {
60 // TODO: 66 ctx.AddU1("{}=allInvocationsEqualARB({});", inst, pred);
61 // if (ctx.profile.warp_size_potentially_larger_than_guest) { 67 } else {
62 // } 68 const auto active_mask{fmt::format("uvec2(ballotARB(true))[gl_SubgroupInvocationID]")};
69 const auto ballot{fmt::format("uvec2(ballotARB({}))[gl_SubgroupInvocationID]", pred)};
70 const auto value{fmt::format("({}^{})", ballot, active_mask)};
71 ctx.AddU1("{}=({}==0)||({}=={});", inst, value, value, active_mask);
72 }
63} 73}
64 74
65void EmitSubgroupBallot(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { 75void EmitSubgroupBallot(EmitContext& ctx, IR::Inst& inst, std::string_view pred) {
66 ctx.AddU32("{}=uvec2(ballotARB({})).x;", inst, pred); 76 if (!ctx.profile.warp_size_potentially_larger_than_guest) {
67 // TODO: 77 ctx.AddU32("{}=uvec2(ballotARB({})).x;", inst, pred);
68 // if (ctx.profile.warp_size_potentially_larger_than_guest) { 78 } else {
69 // } 79 ctx.AddU32("{}=uvec2(ballotARB({}))[gl_SubgroupInvocationID];", inst, pred);
80 }
70} 81}
71 82
72void EmitSubgroupEqMask(EmitContext& ctx, IR::Inst& inst) { 83void EmitSubgroupEqMask(EmitContext& ctx, IR::Inst& inst) {