summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
diff options
context:
space:
mode:
authorGravatar ameerj2021-05-29 20:00:06 -0400
committerGravatar ameerj2021-07-22 21:51:36 -0400
commit1542f31e7979a7bae465d299774268533a130f9b (patch)
tree18163b9bf88cb7c37582173a8c0c6e7ec053c812 /src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
parentglsl: Fix and implement rest of cbuf access (diff)
downloadyuzu-1542f31e7979a7bae465d299774268533a130f9b.tar.gz
yuzu-1542f31e7979a7bae465d299774268533a130f9b.tar.xz
yuzu-1542f31e7979a7bae465d299774268533a130f9b.zip
glsl: minor cleanup
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
index 73ceb06d9..4a3d66c90 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
@@ -31,6 +31,7 @@ void SetSignFlag(EmitContext& ctx, IR::Inst& inst, std::string_view result) {
31void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 31void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
32 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 32 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
33 if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) { 33 if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) {
34 ctx.uses_cc_carry = true;
34 ctx.Add("{}=uaddCarry({},{},carry);", result, a, b); 35 ctx.Add("{}=uaddCarry({},{},carry);", result, a, b);
35 ctx.AddU1("{}=carry!=0;", *carry, result); 36 ctx.AddU1("{}=carry!=0;", *carry, result);
36 carry->Invalidate(); 37 carry->Invalidate();
@@ -61,11 +62,11 @@ void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin
61} 62}
62 63
63void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 64void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
64 ctx.AddU32("{}={}*{};", inst, a, b); 65 ctx.AddU32("{}=uint({}*{});", inst, a, b);
65} 66}
66 67
67void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { 68void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
68 ctx.AddU32("{}=-({});", inst, value); 69 ctx.AddU32("{}=uint(-({}));", inst, value);
69} 70}
70 71
71void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { 72void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
@@ -124,7 +125,7 @@ void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std:
124 125
125void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base, 126void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
126 std::string_view insert, std::string_view offset, std::string_view count) { 127 std::string_view insert, std::string_view offset, std::string_view count) {
127 ctx.AddU32("{}=bitfieldInsert({}, {}, int({}), int({}));", inst, base, insert, offset, count); 128 ctx.AddU32("{}=bitfieldInsert({},{},int({}),int({}));", inst, base, insert, offset, count);
128} 129}
129 130
130void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 131void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
@@ -166,25 +167,25 @@ void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst
166} 167}
167 168
168void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 169void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
169 ctx.AddU32("{}=min(int({}), int({}));", inst, a, b); 170 ctx.AddU32("{}=min(int({}),int({}));", inst, a, b);
170} 171}
171 172
172void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 173void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
173 ctx.AddU32("{}=min(uint({}), uint({}));", inst, a, b); 174 ctx.AddU32("{}=min(uint({}),uint({}));", inst, a, b);
174} 175}
175 176
176void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 177void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
177 ctx.AddU32("{}=max(int({}), int({}));", inst, a, b); 178 ctx.AddU32("{}=max(int({}),int({}));", inst, a, b);
178} 179}
179 180
180void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) { 181void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
181 ctx.AddU32("{}=max(uint({}), uint({}));", inst, a, b); 182 ctx.AddU32("{}=max(uint({}),uint({}));", inst, a, b);
182} 183}
183 184
184void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 185void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
185 std::string_view max) { 186 std::string_view max) {
186 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 187 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
187 ctx.Add("{}=clamp(int({}), int({}), int({}));", result, value, min, max); 188 ctx.Add("{}=clamp(int({}),int({}),int({}));", result, value, min, max);
188 SetZeroFlag(ctx, inst, result); 189 SetZeroFlag(ctx, inst, result);
189 SetSignFlag(ctx, inst, result); 190 SetSignFlag(ctx, inst, result);
190} 191}
@@ -192,7 +193,7 @@ void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std:
192void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 193void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
193 std::string_view max) { 194 std::string_view max) {
194 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 195 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
195 ctx.Add("{}=clamp(uint({}), uint({}), uint({}));", result, value, min, max); 196 ctx.Add("{}=clamp(uint({}),uint({}),uint({}));", result, value, min, max);
196 SetZeroFlag(ctx, inst, result); 197 SetZeroFlag(ctx, inst, result);
197 SetSignFlag(ctx, inst, result); 198 SetSignFlag(ctx, inst, result);
198} 199}