diff options
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 9a7f5ad31..9d8c4d89a 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -1822,6 +1822,8 @@ struct SPIRVEmitContext return emitStore(parent, as<IRStore>(inst)); case kIROp_RWStructuredBufferGetElementPtr: return emitStructuredBufferGetElementPtr(parent, inst); + case kIROp_StructuredBufferGetDimensions: + return emitStructuredBufferGetDimensions(parent, inst); case kIROp_swizzle: return emitSwizzle(parent, as<IRSwizzle>(inst)); case kIROp_IntCast: @@ -2915,6 +2917,21 @@ struct SPIRVEmitContext return addr; } + SpvInst* emitStructuredBufferGetDimensions(SpvInstParent* parent, IRInst* inst) + { + IRBuilder builder(inst); + auto arrayLength = emitInst(parent, nullptr, SpvOpArrayLength, builder.getUIntType(), kResultID, inst->getOperand(0), SpvLiteralInteger::from32(0)); + auto elementType = as<IRPtrType>(inst->getOperand(0)->getDataType())->getValueType(); + IRIntegerValue stride = 0; + if (auto sizeDecor = elementType->findDecoration<IRSizeAndAlignmentDecoration>()) + { + stride = align(sizeDecor->getSize(), (int)sizeDecor->getAlignment()); + } + auto strideOperand = emitIntConstant(stride, builder.getUIntType()); + auto result = emitOpCompositeConstruct(parent, inst, inst->getDataType(), arrayLength, strideOperand); + return result; + } + SpvInst* emitSwizzle(SpvInstParent* parent, IRSwizzle* inst) { if (inst->getElementCount() == 1) |
