diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/core.meta.slang | 5 | ||||
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index 2c6bf04d1..3306403f5 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -2349,6 +2349,11 @@ struct OutputIndices case spirv: __setIndices(this, index, newValue); } } + + // If a 'OutputIndices[index]' is referred to by a '__ref', call 'kIROp_MeshOutputRef(index)' + [require(glsl_hlsl_metal_spirv, meshshading)] + __intrinsic_op($(kIROp_MeshOutputRef)) + ref; } }; diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index d6f4ac176..0facaac3f 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -4032,6 +4032,9 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex case kIROp_GetOffsetPtr: result = emitGetOffsetPtr(parent, inst); break; + case kIROp_MeshOutputRef: + result = emitMeshOutputRef(parent, inst); + break; case kIROp_GetElement: result = emitGetElement(parent, as<IRGetElement>(inst)); break; @@ -7002,6 +7005,19 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex makeArray(inst->getIndex())); } + SpvInst* emitMeshOutputRef(SpvInstParent* parent, IRInst* inst) + { + // MeshOutputRef takes two operands: the mesh output array and the index + // It should return a reference (address) to the element at that index + auto base = inst->getOperand(0); + auto index = inst->getOperand(1); + + const SpvWord baseId = getID(ensureInst(base)); + + // Use OpAccessChain to get the address of the element + return emitOpAccessChain(parent, inst, inst->getFullType(), baseId, makeArray(index)); + } + SpvInst* emitGetElement(SpvInstParent* parent, IRGetElement* inst) { requireVariableBufferCapabilityIfNeeded(inst->getDataType()); |
