KhronosGroup / KhronosGroup/glslang

Not putting runtime arrays at the end of Buffer Reference blocks

Open
#4,078 0 comments 0 reactions 0 assignees View on GitHub
bug SPIR-V
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

The following GLSL will produce incorrect offsets

```glsl
layout(buffer_reference, buffer_reference_align = 8, scalar) readonly buffer Payload {
uint count; // offset 0
Metadata meta[]; // offset 8
uint extra; // offset 8
uint extra2; // offset 12
};
```

such that you will generate invalid SPIR-V

> [VUID-StandaloneSpirv-OpTypeRuntimeArray-04680] In Vulkan, OpTypeRuntimeArray must only be used for the last member of an OpTypeStruct

Full GLSL example - https://godbolt.org/z/Kcd1a8jE7
spirv-val error - https://godbolt.org/z/chKdefbT5

... If glslang doesn't want to do this, it should at least yell at the user here as an error

Contributor guide

Open the contributing guide

Research direction

Start with the full GLSL example linked in the issue and compare glslang's output with the linked spirv-val error. Trace how the buffer reference block layout handles the runtime array and ensure the result is either valid SPIR-V with the array last or an error reported to the user.

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
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.