aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-05-27 22:28:33 -0400
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-22 21:51:36 -0400
commit2a713337165df4d5c4228458999a680e9ab65369 (patch)
tree0e820cbfcedaaffafc34b334bd04107a51e2a24d /src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
parent6674637853009115833e132efce19c8e210f0471 (diff)
glsl: Fix bindings, add some CC ops
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
index ce6e12623f..84e01b1518 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp
@@ -8,8 +8,30 @@
#include "shader_recompiler/frontend/ir/value.h"
namespace Shader::Backend::GLSL {
+namespace {
+void SetZeroFlag(EmitContext& ctx, IR::Inst& inst, std::string_view result) {
+ IR::Inst* const zero{inst.GetAssociatedPseudoOperation(IR::Opcode::GetZeroFromOp)};
+ if (!zero) {
+ return;
+ }
+ ctx.AddU1("{}={}==0;", *zero, result);
+ zero->Invalidate();
+}
+
+void SetSignFlag(EmitContext& ctx, IR::Inst& inst, std::string_view result) {
+ IR::Inst* const sign{inst.GetAssociatedPseudoOperation(IR::Opcode::GetSignFromOp)};
+ if (!sign) {
+ return;
+ }
+ ctx.AddU1("{}=int({})<0;", *sign, result);
+ sign->Invalidate();
+}
+} // Anonymous namespace
void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
- ctx.AddU32("{}={}+{};", inst, a, b);
+ const auto result{ctx.reg_alloc.Define(inst)};
+ ctx.Add("uint {}={}+{};", result, a, b);
+ SetZeroFlag(ctx, inst, result);
+ SetSignFlag(ctx, inst, result);
}
void EmitIAdd64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
@@ -98,7 +120,10 @@ void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view bas
void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
std::string_view offset, std::string_view count) {
- ctx.AddU32("{}=bitfieldExtract({}, int({}), int({}));", inst, base, offset, count);
+ const auto result{ctx.reg_alloc.Define(inst)};
+ ctx.Add("uint {}=bitfieldExtract({},int({}),int({}));", result, base, offset, count);
+ SetZeroFlag(ctx, inst, result);
+ SetSignFlag(ctx, inst, result);
}
void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {