diff options
| author | 2021-05-30 00:53:26 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:36 -0400 | |
| commit | e35ffbbeb0f85f676416fcb8f0bb0207671f379d (patch) | |
| tree | d33fca2f27f8c680c43dfb34da8abd738b0a5705 /src/shader_recompiler/backend/glsl | |
| parent | glsl: Implement VOTE (diff) | |
| download | yuzu-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')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.cpp | 12 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp | 43 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index 5456d4e5b..c6325e55f 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -122,9 +122,11 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 122 | 122 | ||
| 123 | void EmitContext::SetupExtensions(std::string&) { | 123 | void EmitContext::SetupExtensions(std::string&) { |
| 124 | header += "#extension GL_ARB_separate_shader_objects : enable\n"; | 124 | header += "#extension GL_ARB_separate_shader_objects : enable\n"; |
| 125 | header += "#extension GL_ARB_sparse_texture2 : enable\n"; | 125 | if (stage != Stage::Compute) { |
| 126 | header += "#extension GL_EXT_texture_shadow_lod : enable\n"; | 126 | // TODO: track this usage |
| 127 | // header += "#extension GL_ARB_texture_cube_map_array : enable\n"; | 127 | header += "#extension GL_ARB_sparse_texture2 : enable\n"; |
| 128 | header += "#extension GL_EXT_texture_shadow_lod : enable\n"; | ||
| 129 | } | ||
| 128 | if (info.uses_int64) { | 130 | if (info.uses_int64) { |
| 129 | header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; | 131 | header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; |
| 130 | } | 132 | } |
| @@ -149,6 +151,10 @@ void EmitContext::SetupExtensions(std::string&) { | |||
| 149 | info.uses_subgroup_shuffles || info.uses_fswzadd) { | 151 | info.uses_subgroup_shuffles || info.uses_fswzadd) { |
| 150 | header += "#extension GL_ARB_shader_ballot : enable\n"; | 152 | header += "#extension GL_ARB_shader_ballot : enable\n"; |
| 151 | header += "#extension GL_ARB_shader_group_vote : enable\n"; | 153 | header += "#extension GL_ARB_shader_group_vote : enable\n"; |
| 154 | header += "#extension GL_KHR_shader_subgroup_basic : enable\n"; | ||
| 155 | if (!info.uses_int64) { | ||
| 156 | header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; | ||
| 157 | } | ||
| 152 | } | 158 | } |
| 153 | } | 159 | } |
| 154 | 160 | ||
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 | ||
| 44 | void EmitVoteAll(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { | 44 | void 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 | ||
| 51 | void EmitVoteAny(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { | 54 | void 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 | ||
| 58 | void EmitVoteEqual(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { | 64 | void 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 | ||
| 65 | void EmitSubgroupBallot(EmitContext& ctx, IR::Inst& inst, std::string_view pred) { | 75 | void 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 | ||
| 72 | void EmitSubgroupEqMask(EmitContext& ctx, IR::Inst& inst) { | 83 | void EmitSubgroupEqMask(EmitContext& ctx, IR::Inst& inst) { |