summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorJulius Ikkala <julius.ikkala@gmail.com>2025-09-08 20:07:53 +0300
committerGitHub <noreply@github.com>2025-09-08 17:07:53 +0000
commit8b512c49d163af1df33e940acc3c4a230f0d00b7 (patch)
tree25580be0692e41f82af90aaf615a59617da51641 /source
parentc0d7405d831faa6208b27fe56bf66fb0b138dcc5 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit-spirv.cpp13
1 files changed, 8 insertions, 5 deletions
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;