summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
index 6ff0f9248..34f880f1b 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
@@ -72,11 +72,11 @@ void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
72} 72}
73 73
74void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value) { 74void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
75 ctx.AddU32("{}=abs({});", inst, value); 75 ctx.AddU32("{}=abs(int({}));", inst, value);
76} 76}
77 77
78void EmitIAbs64(EmitContext& ctx, IR::Inst& inst, std::string_view value) { 78void EmitIAbs64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
79 ctx.AddU64("{}=abs({});", inst, value); 79 ctx.AddU64("{}=abs(int64_t({}));", inst, value);
80} 80}
81 81
82void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, std::string_view base, 82void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, std::string_view base,
@@ -128,13 +128,16 @@ void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
128 128
129void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 129void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
130 std::string_view offset, std::string_view count) { 130 std::string_view offset, std::string_view count) {
131 ctx.AddU32("{}=bitfieldExtract(int({}), int({}), int({}));", inst, base, offset, count); 131 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
132 ctx.Add("{}=uint(bitfieldExtract(int({}),int({}),int({})));", result, base, offset, count);
133 SetZeroFlag(ctx, inst, result);
134 SetSignFlag(ctx, inst, result);
132} 135}
133 136
134void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base, 137void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
135 std::string_view offset, std::string_view count) { 138 std::string_view offset, std::string_view count) {
136 const auto result{ctx.reg_alloc.Define(inst, Type::U32)}; 139 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
137 ctx.Add("{}=bitfieldExtract({},int({}),int({}));", result, base, offset, count); 140 ctx.Add("{}=uint(bitfieldExtract(uint({}),int({}),int({})));", result, base, offset, count);
138 SetZeroFlag(ctx, inst, result); 141 SetZeroFlag(ctx, inst, result);
139 SetSignFlag(ctx, inst, result); 142 SetSignFlag(ctx, inst, result);
140} 143}
@@ -179,12 +182,18 @@ void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin
179 182
180void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 183void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
181 std::string_view max) { 184 std::string_view max) {
182 ctx.AddU32("{}=clamp(int({}), int({}), int({}));", inst, value, min, max); 185 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
186 ctx.Add("{}=clamp(int({}), int({}), int({}));", result, value, min, max);
187 SetZeroFlag(ctx, inst, result);
188 SetSignFlag(ctx, inst, result);
183} 189}
184 190
185void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min, 191void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
186 std::string_view max) { 192 std::string_view max) {
187 ctx.AddU32("{}=clamp(uint({}), uint({}), uint({}));", inst, value, min, max); 193 const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
194 ctx.Add("{}=clamp(uint({}), uint({}), uint({}));", result, value, min, max);
195 SetZeroFlag(ctx, inst, result);
196 SetSignFlag(ctx, inst, result);
188} 197}
189 198
190void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs) { 199void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, std::string_view lhs, std::string_view rhs) {