diff options
| author | Darren Wihandi <65404740+fairywreath@users.noreply.github.com> | 2025-05-23 02:22:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-23 06:22:21 +0000 |
| commit | d108bfa677c70808b32bd77e93637ed34c19c75d (patch) | |
| tree | e88b2ac2fc05970d10afd539bd096007cc85fbe7 /source/slang/slang-emit-spirv.cpp | |
| parent | 6209f69f335a604604a5032b0f5c38b4b8bc861a (diff) | |
Add CoopVec load/store pointer overloads (#6822)
* Add pointer/T* variants for coop vec load/store
* fix stride decoration and improved test
* fix compile warnings
* Improve test
* Use `coopVecLoad` function in test
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
| -rw-r--r-- | source/slang/slang-emit-spirv.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 5dfa1c76c..ba238985b 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -2069,10 +2069,25 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex inst->getOp() == kIROp_ArrayType ? emitOpTypeArray(inst, elementType, irArrayType->getElementCount()) : emitOpTypeRuntimeArray(inst, elementType); - auto strideInst = irArrayType->getArrayStride(); - if (strideInst && shouldEmitArrayStride(irArrayType->getElementType())) + if (shouldEmitArrayStride(irArrayType->getElementType())) { - int stride = (int)getIntVal(strideInst); + auto stride = 0; + if (auto strideInst = irArrayType->getArrayStride()) + { + stride = (int)getIntVal(strideInst); + } + else + { + // Stride may not have been calculated for basic element types. Calculate it + // here. + IRSizeAndAlignment sizeAndAlignment; + getNaturalSizeAndAlignment( + m_targetProgram->getOptionSet(), + elementType, + &sizeAndAlignment); + stride = (int)sizeAndAlignment.getStride(); + } + emitOpDecorateArrayStride( getSection(SpvLogicalSectionID::Annotations), nullptr, |
