diff options
Diffstat (limited to 'source/slang/emit.cpp')
| -rw-r--r-- | source/slang/emit.cpp | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 0c1896c0c..d2de479b4 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -3621,6 +3621,33 @@ struct EmitVisitor } } + void emitNot(EmitContext* ctx, IRInst* inst, IREmitMode mode, EOpInfo& ioOuterPrec, bool* outNeedClose) + { + IRInst* operand = inst->getOperand(0); + + if (getTarget(ctx) == CodeGenTarget::GLSL) + { + if (auto vectorType = as<IRVectorType>(operand->getDataType())) + { + // Handle as a function call + auto prec = kEOp_Postfix; + *outNeedClose = maybeEmitParens(ioOuterPrec, prec); + + emit("not("); + emitIROperand(ctx, operand, mode, kEOp_General); + emit(")"); + return; + } + } + + auto prec = kEOp_Prefix; + *outNeedClose = maybeEmitParens(ioOuterPrec, prec); + + emit("!"); + emitIROperand(ctx, operand, mode, rightSide(prec, ioOuterPrec)); + } + + void emitComparison(EmitContext* ctx, IRInst* inst, IREmitMode mode, EOpInfo& ioOuterPrec, const EOpInfo& opPrec, bool* needCloseOut) { if (getTarget(ctx) == CodeGenTarget::GLSL) @@ -3839,11 +3866,7 @@ struct EmitVisitor case kIROp_Not: { - auto prec = kEOp_Prefix; - needClose = maybeEmitParens(outerPrec, prec); - - emit("!"); - emitIROperand(ctx, inst->getOperand(0), mode, rightSide(prec, outerPrec)); + emitNot(ctx, inst, mode, outerPrec, &needClose); } break; |
