KhronosGroup / KhronosGroup/GLSL

Clarify compilation of unbound array

Open
#231 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
458
Forks
114
Avg merge
4m
Merged PRs (30d)
1

Description

In GLSL it's possible to declare 'unbound' array of descriptors, by writing something like:
```
layout(binding = 0) uniform sampler2D texture[];
```

This has about 3 different behaviors in glslang compiler:
1. compiler deduces size automatically, based of largest array index used in shader code
1.1 `OpTypeArray` with size of one is emitted, if array was never used in code
2. if `GL_EXT_nonuniform_qualifier` enabled usually `OpTypeRuntimeArray` will be used - resulting into 'true' unbound array
3. if `GL_EXT_nonuniform_qualifier` enabled and array not been used - `OpTypeArray` with size of `1` will be emitted

Behavior 3, may cause different shader stages to be incompatible with each-other, when array declared in both vertex&fragment but used only in one of stages.

Proposal:
When `GL_EXT_nonuniform_qualifier` is in use, only `OpTypeRuntimeArray` must be used, for unbound array.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the glslang compiler handling for unbound descriptor arrays and the emitted SPIR-V OpTypeArray versus OpTypeRuntimeArray forms described in the issue. Compare unused and indexed arrays with GL_EXT_nonuniform_qualifier enabled across shader stages; done means the proposed runtime-array behavior is specified and consistently implemented without stage incompatibility.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.