diff options
| author | Yong He <yonghe@outlook.com> | 2024-12-16 22:10:10 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-16 22:10:10 -0800 |
| commit | 9c9e1f701242b59dead94426a25f2ad5d3bcf66d (patch) | |
| tree | a5ebe51754ab40ea300177b2cc56a979337d2e80 /source | |
| parent | 0a6ffee0c633e28a42a676fb7ddeb5f7d151a6db (diff) | |
Support matrix negation in metal backend. (#5891)
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit-metal.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/slang/slang-emit-metal.cpp b/source/slang/slang-emit-metal.cpp index e6e2a3ec5..45a9e60ad 100644 --- a/source/slang/slang-emit-metal.cpp +++ b/source/slang/slang-emit-metal.cpp @@ -701,6 +701,21 @@ bool MetalSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inO m_writer->emit(")"); return true; } + case kIROp_Neg: + { + if (as<IRMatrixType>(inst->getOperand(0)->getDataType())) + { + // Metal does not support negate operator on matrices, + // we should emit "(matrix(0) - op0)" instead. + m_writer->emit("("); + emitType(inst->getDataType()); + m_writer->emit("(0) - "); + emitOperand(inst->getOperand(0), getInfo(EmitOp::General)); + m_writer->emit(")"); + return true; + } + break; + } case kIROp_Mul: { // Component-wise multiplication needs to be special cased, |
