KhronosGroup / KhronosGroup/glslang
Setting the wrong alignment value when loading a Buffer Reference through a Buffer Reference
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
https://godbolt.org/z/j8jGvsnMh
```glsl
layout(buffer_reference) buffer S4;
layout(buffer_reference, buffer_reference_align = 8, std430) readonly buffer S3 {
S4 e;
};
// Set buffer_reference_align to 8 and it generates valid code
layout(buffer_reference, buffer_reference_align = 4, std430) readonly buffer S4 {
uint f;
};
void main() {
S3 x;
S4 y = x.e;
}
```
Seems currently glslang sets the `x.e` as an `OpLoad` with a result type of `OpTypePointer` but the `Aligned 4` is wrong and should be `8` and produces a spirv-val error (https://godbolt.org/z/sxT1asEdv)
Contributor guide
Research direction
Start with the GLSL reproducer in the Godbolt link and inspect the generated SPIR-V for the OpLoad of x.e. Compare its alignment operand with the buffer_reference_align values, then validate the output with spirv-val. Done means the generated load uses alignment 8 and the validator accepts the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100