KhronosGroup / KhronosGroup/glslang

Incomplete validation for buffer_reference_align.

Open
#3,033 1 comment 0 reactions 0 assignees View on GitHub
bug GLSL/ESSL
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GLSL_EXT_buffer_reference.txt#L135
> Each buffer reference type has an alignment that can be specified via
> the "buffer_reference_align" layout qualifier. This must be a power of
> two and be greater than or equal to the largest scalar/component type
> in the block. If the layout qualifier is not specified, it defaults to
> 16 bytes. All buffer reference addresses used for a particular buffer
> reference type are assumed to be aligned to this alignment value. That
> is, the base of the block must be aligned, and members of the block can
> be aligned within the block using standard layouts and offset layout
> qualifiers.

glslang only validates the power of two requirement. The following declaration compiles:

```glsl
layout(buffer_reference, std430, buffer_reference_align = 1) buffer blockType {
uint64_t frog;
};
```

But this is invalid GLSL because `buffer_reference_align` is not larger than the largest scalar type (`uint64_t` has a size of 8).

Contributor guide

Open the contributing guide

Research direction

The requirement is defined in ext/GLSL_EXT_buffer_reference.txt at the cited section; start by reproducing the declaration with glslang. Trace validation of buffer_reference_align and add coverage showing align=1 is rejected for uint64_t; it is done when alignment must meet the largest scalar/component type.

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.