diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-23 05:49:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-23 20:49:33 +0800 |
| commit | 6437c38e0a3c2c1daf36cb5e543dc0b467fa4b15 (patch) | |
| tree | c117b964ada397d9cac01ff4759bcd16d35c7e20 /source/slang/slang-emit-spirv.cpp | |
| parent | cdd5e6666f98903d61118ada5cba51424fd1577c (diff) | |
Lower all ByteAddressBuffer uses for SPIRV. (#3143)
Co-authored-by: Yong He <yhe@nvidia.com>
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) |
