diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-03-14 16:21:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-14 16:21:03 -0400 |
| commit | c8e36bd128a29654b2ec145038da9e132330581b (patch) | |
| tree | 950ce7c3bb1cc235f97ceb982643e99245c87e16 /source/slang/emit.cpp | |
| parent | 04416431993b1d5efa8eac759a16832d40c2a159 (diff) | |
Hotfix/bool fix (#907)
* * Handle ! for bool vector in glsl
* Handle operators that have a boolean return value
* || or && take bool
* * Add comment in bool-op.slang test about doing || or && on vector types not supported for GLSL targets
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; |
