KhronosGroup / KhronosGroup/SPIRV-Tools

spirv-opt: VK_EXT_scalar_block_layout is not supported properly

Open
#3,153 4 comments 4 reactions 0 assignees View on GitHub
component:optimization
Dominant language
C++
Stars
1.4k
Forks
709
Avg merge
1d 22h
Merged PRs (30d)
28

Description

The following shader `pathtrace.rchit.glsl`
```glsl
#extension GL_EXT_scalar_block_layout : require

layout(scalar, set=DSRender, binding=BindingRdSeqBuffer) uniform UBO {
uint rd_seq[1056];
} ubo;

void main() {
if (ubo.rd_seq[1] != 2447445414u) {
return;
}
if (ubo.rd_seq[1055] != 2159022709u) {
return;
}
}
```
compiled by `glslangValidator -g -V pathtrace.rchit.glsl -o pathtrace.rchit.debug.spv`. Output is to be optimized as `spirv-opt -O pathtrace.rchit.debug.spv -o pathtrace.rchit.spv`, but the following error is occured:
```
/home/user/Projects/render/shaders/pathtrace.rchit.glsl
error: line 1046: Structure id 2601 decorated as Block for variable in Uniform storage class must follow standard uniform buffer layout rules: member 0 contains an array with stride 4 not satisfying alignment to 16
%UBO = OpTypeStruct %_arr_uint_uint_1056
```
As I can see `--scalar-block-layout` is the option of `spirv-val`, not `spirv-opt`. So I can't tell to `spirv-opt` that extension is enabled.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with pathtrace.rchit.glsl, glslangValidator, and spirv-opt -O, then compare how spirv-val handles --scalar-block-layout. Trace the validation or optimization entry points responsible for the Block layout diagnostic. Done means the scalar-layout shader can be optimized without the incorrect standard-alignment error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.