summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-31 00:25:54 -0400
committerGravatar ameerj2021-07-22 21:51:37 -0400
commitb7561226edaefc79eadcfbd3df1b0344b7c4b673 (patch)
tree49515563855b3585e6d23ceec7274a8e69340615 /src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
parentglsl: Implement precise fp variable allocation (diff)
downloadyuzu-b7561226edaefc79eadcfbd3df1b0344b7c4b673.tar.gz
yuzu-b7561226edaefc79eadcfbd3df1b0344b7c4b673.tar.xz
yuzu-b7561226edaefc79eadcfbd3df1b0344b7c4b673.zip
glsl: SHFL fix and prefer shift operations over divide in glsl shader
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
index 4286f29c7..0b6c5ad82 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_warp.cpp
@@ -112,7 +112,7 @@ void EmitShuffleIndex(EmitContext& ctx, IR::Inst& inst, std::string_view value,
112 const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)}; 112 const auto src_thread_id{fmt::format("({})|({})", lhs, min_thread_id)};
113 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); 113 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
114 SetInBoundsFlag(ctx, inst); 114 SetInBoundsFlag(ctx, inst);
115 ctx.AddU32("{}=shfl_in_bounds?{}:{};", inst, value, src_thread_id); 115 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
116} 116}
117 117
118void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index, 118void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view index,
@@ -122,7 +122,7 @@ void EmitShuffleUp(EmitContext& ctx, IR::Inst& inst, std::string_view value, std
122 const auto src_thread_id{fmt::format("({}-{})", thread_id, index)}; 122 const auto src_thread_id{fmt::format("({}-{})", thread_id, index)};
123 ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id); 123 ctx.Add("shfl_in_bounds=int({})>=int({});", src_thread_id, max_thread_id);
124 SetInBoundsFlag(ctx, inst); 124 SetInBoundsFlag(ctx, inst);
125 ctx.AddU32("{}=shfl_in_bounds?{}:{};", inst, value, src_thread_id); 125 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
126} 126}
127 127
128void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value, 128void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
@@ -133,7 +133,7 @@ void EmitShuffleDown(EmitContext& ctx, IR::Inst& inst, std::string_view value,
133 const auto src_thread_id{fmt::format("({}+{})", thread_id, index)}; 133 const auto src_thread_id{fmt::format("({}+{})", thread_id, index)};
134 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); 134 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
135 SetInBoundsFlag(ctx, inst); 135 SetInBoundsFlag(ctx, inst);
136 ctx.AddU32("{}=shfl_in_bounds?{}:{};", inst, value, src_thread_id); 136 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
137} 137}
138 138
139void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value, 139void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view value,
@@ -144,7 +144,7 @@ void EmitShuffleButterfly(EmitContext& ctx, IR::Inst& inst, std::string_view val
144 const auto src_thread_id{fmt::format("({}^{})", thread_id, index)}; 144 const auto src_thread_id{fmt::format("({}^{})", thread_id, index)};
145 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id); 145 ctx.Add("shfl_in_bounds=int({})<=int({});", src_thread_id, max_thread_id);
146 SetInBoundsFlag(ctx, inst); 146 SetInBoundsFlag(ctx, inst);
147 ctx.AddU32("{}=shfl_in_bounds?{}:{};", inst, value, src_thread_id); 147 ctx.AddU32("{}=shfl_in_bounds?readInvocationARB({},{}):{};", inst, value, src_thread_id, value);
148} 148}
149 149
150void EmitFSwizzleAdd([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, 150void EmitFSwizzleAdd([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,