microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Invalid SPIR-V when mutating struct using method and vk::BufferPointer
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
Trying to mutate a struct using a method through a vk::BufferPointer causes invalid SPIR-V with non-aligned load ops to be generated.
Steps to Reproduce
https://godbolt.org/z/1vPTjjn6n
struct Foo {
uint a;
void increment() {
a += 1;
}
};
[[vk::push_constant]]
struct Pc {
vk::BufferPointer<Foo> ptr;
} pc;
[numthreads(1, 1, 1)]
void main() {
pc.ptr.Get().increment();
}
Actual Behavior
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708] Memory accesses with PhysicalStorageBuffer must use Aligned.
%20 = OpLoad %uint %19
Environment
- DXC trunk
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the HLSL example from the linked Godbolt case with DXC trunk and inspect the generated SPIR-V around the reported OpLoad. Use the PhysicalStorageBuffer64-04708 validation error as the completion criterion: the mutation through vk::BufferPointer should no longer generate invalid, non-aligned load operations.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100