summaryrefslogtreecommitdiff
path: root/src/shader_recompiler
diff options
context:
space:
mode:
authorGravatar liamwhite2023-10-23 10:33:24 -0400
committerGravatar GitHub2023-10-23 10:33:24 -0400
commitda5c49f22d5c8308aa751e7702e1b64e18b833da (patch)
tree80a920d7f29d5885744852670c607e50eabf9631 /src/shader_recompiler
parentMerge pull request #11854 from german77/vibration-ui (diff)
parentemit_glsl_warp: Fix shfl_in_bounds conditional (diff)
downloadyuzu-da5c49f22d5c8308aa751e7702e1b64e18b833da.tar.gz
yuzu-da5c49f22d5c8308aa751e7702e1b64e18b833da.tar.xz
yuzu-da5c49f22d5c8308aa751e7702e1b64e18b833da.zip
Merge pull request #11847 from ameerj/glsl-shfl-fix
emit_glsl_warp: Fix shfl_in_bounds conditional
Diffstat (limited to 'src/shader_recompiler')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl.cpp1
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp12
2 files changed, 9 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp
index d91e04446..66ecfc9f7 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp
@@ -242,6 +242,7 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR
242 } 242 }
243 if (program.info.uses_subgroup_shuffles) { 243 if (program.info.uses_subgroup_shuffles) {
244 ctx.header += "bool shfl_in_bounds;"; 244 ctx.header += "bool shfl_in_bounds;";
245 ctx.header += "uint shfl_result;";
245 } 246 }
246 ctx.code.insert(0, ctx.header); 247 ctx.code.insert(0, ctx.header);
247 ctx.code += '}'; 248 ctx.code += '}';
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
index 1245c9429..f9be5de1c 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
@@ -141,7 +141,8 @@ void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, std::string_view value,
141 const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)}; 141 const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)};
142 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); 142 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
143 SetInBoundsFlag(ctx, inst); 143 SetInBoundsFlag(ctx, inst);
144 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value); 144 ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
145 ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
145} 146}
146 147
147void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index, 148void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index,
@@ -158,7 +159,8 @@ void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std
158 const auto src_thread_id{fmt::format("({}-{})", THREAD_ID, index)}; 159 const auto src_thread_id{fmt::format("({}-{})", THREAD_ID, index)};
159 ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id); 160 ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id);
160 SetInBoundsFlag(ctx, inst); 161 SetInBoundsFlag(ctx, inst);
161 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value); 162 ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
163 ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
162} 164}
163 165
164void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value, 166void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
@@ -175,7 +177,8 @@ void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
175 const auto src_thread_id{fmt::format("({}+{})", THREAD_ID, index)}; 177 const auto src_thread_id{fmt::format("({}+{})", THREAD_ID, index)};
176 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); 178 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
177 SetInBoundsFlag(ctx, inst); 179 SetInBoundsFlag(ctx, inst);
178 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value); 180 ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
181 ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
179} 182}
180 183
181void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value, 184void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value,
@@ -193,7 +196,8 @@ void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view val
193 const auto src_thread_id{fmt::format("({}^{})", THREAD_ID, index)}; 196 const auto src_thread_id{fmt::format("({}^{})", THREAD_ID, index)};
194 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); 197 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
195 SetInBoundsFlag(ctx, inst); 198 SetInBoundsFlag(ctx, inst);
196 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value); 199 ctx.Add("shfl_result=readInvocationARB({},{});", value, src_thread_id);
200 ctx.AddU32("{}=shfl_in_bounds?shfl_result:{};", inst, value);
197} 201}
198 202
199void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, std::string_view op_a, std::string_view op_b, 203void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, std::string_view op_a, std::string_view op_b,