diff options
Diffstat (limited to '')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl.cpp | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp index 32c4f1da2..5867a04ab 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp | |||
| @@ -227,7 +227,7 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR | |||
| 227 | ctx.header += "void main(){\n"; | 227 | ctx.header += "void main(){\n"; |
| 228 | DefineVariables(ctx, ctx.header); | 228 | DefineVariables(ctx, ctx.header); |
| 229 | if (ctx.uses_cc_carry) { | 229 | if (ctx.uses_cc_carry) { |
| 230 | ctx.header += "uint carry;"; | 230 | ctx.header += "uint carry;uint iadd_op_b;"; |
| 231 | } | 231 | } |
| 232 | if (program.info.uses_subgroup_shuffles) { | 232 | if (program.info.uses_subgroup_shuffles) { |
| 233 | ctx.header += "bool shfl_in_bounds;"; | 233 | ctx.header += "bool shfl_in_bounds;"; |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp index 983e6d95d..fcc9afd85 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp | |||
| @@ -33,8 +33,8 @@ void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 33 | const auto result{ctx.var_alloc.Define(inst, GlslVarType::U32)}; | 33 | const auto result{ctx.var_alloc.Define(inst, GlslVarType::U32)}; |
| 34 | if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) { | 34 | if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) { |
| 35 | ctx.uses_cc_carry = true; | 35 | ctx.uses_cc_carry = true; |
| 36 | ctx.Add("{}=uaddCarry({},{},carry);", result, a, b); | 36 | ctx.Add("iadd_op_b={};{}=uaddCarry({},{},carry);", b, result, a, b); |
| 37 | ctx.AddU1("{}=carry!=0;", *carry, result); | 37 | ctx.AddU1("{}=carry!=0;", *carry); |
| 38 | carry->Invalidate(); | 38 | carry->Invalidate(); |
| 39 | } else { | 39 | } else { |
| 40 | ctx.Add("{}={}+{};", result, a, b); | 40 | ctx.Add("{}={}+{};", result, a, b); |
| @@ -44,8 +44,10 @@ void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin | |||
| 44 | if (IR::Inst * overflow{inst.GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp)}) { | 44 | if (IR::Inst * overflow{inst.GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp)}) { |
| 45 | // https://stackoverflow.com/questions/55468823/how-to-detect-integer-overflow-in-c | 45 | // https://stackoverflow.com/questions/55468823/how-to-detect-integer-overflow-in-c |
| 46 | constexpr u32 s32_max{static_cast<u32>(std::numeric_limits<s32>::max())}; | 46 | constexpr u32 s32_max{static_cast<u32>(std::numeric_limits<s32>::max())}; |
| 47 | ctx.AddU1("{}=int({})>=0?int({})>int({}-{}):int({})<int({}-{});", *overflow, a, b, s32_max, | 47 | const auto sub_a{fmt::format("{}u-{}", s32_max, a)}; |
| 48 | a, b, s32_max, a); | 48 | const auto op_b{ctx.uses_cc_carry ? "iadd_op_b" : b}; |
| 49 | ctx.AddU1("{}=int({})>=0?int({})>int({}):int({})<int({});", *overflow, a, op_b, sub_a, op_b, | ||
| 50 | sub_a); | ||
| 49 | overflow->Invalidate(); | 51 | overflow->Invalidate(); |
| 50 | } | 52 | } |
| 51 | } | 53 | } |