From 8b512c49d163af1df33e940acc3c4a230f0d00b7 Mon Sep 17 00:00:00 2001 From: Julius Ikkala Date: Mon, 8 Sep 2025 20:07:53 +0300 Subject: Don't emit ArrayStride 0 for RWStructuredBuffer pointers (#8397) Fixes #8396 by not emitting the `ArrayStride` when it would've been zero. The problem is caused by #7848, more details in the issue description. I checked that with equivalent GLSL code, glslangValidator does not emit any `ArrayStride`. I assume that the addition of `storageClass == SpvStorageClassStorageBuffer` to line 1848 is not a mistake. If it is, that addition could also be simply reverted to fix this issue, I tested that option as well. With these changes, Slang tests work locally on my PC again. Related to this; it'd be nice to have GPUs from multiple vendors in the CI to avoid this kind of thing happening again. Or even just llvmpipe; that doesn't even require a GPU and would add at least one more driver to test with. --- source/slang/slang-emit-spirv.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 5036333c1..e8bcad1c1 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -1876,11 +1876,14 @@ struct SPIRVEmitContext : public SourceEmitterBase, public SPIRVEmitSharedContex stride = (valueSize >= (uint64_t)sizeAndAlignment.kIndeterminateSize) ? 0xFFFF : (uint32_t)sizeAndAlignment.getStride(); - emitOpDecorateArrayStride( - getSection(SpvLogicalSectionID::Annotations), - nullptr, - resultSpvType, - SpvLiteralInteger::from32(stride)); + if (stride != 0) + { + emitOpDecorateArrayStride( + getSection(SpvLogicalSectionID::Annotations), + nullptr, + resultSpvType, + SpvLiteralInteger::from32(stride)); + } } } return resultSpvType; -- cgit v1.2.3