KhronosGroup / KhronosGroup/glslang

Expressions in specialization constants

Open
#3,748 2 comments 0 reactions 1 assignee Claimed by @arcady-lunarg View on GitHub
bug GLSL/ESSL SPIR-V
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

Both glslang and glslangValidator compile the following code without any diagnostics
```glsl
#version 450 core

layout(constant_id = 0) const int baz = 1;
layout(constant_id = 1) const int buz = baz + 1;

void main () { }
```

And produce
```
; SPIR-V
; Version: 1.6
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 10
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main"
OpSource GLSL 450
OpName %main "main"
OpName %baz "baz"
OpName %buz "buz"
OpDecorate %baz SpecId 0
OpDecorate %buz SpecId 1
%void = OpTypeVoid
%3 = OpTypeFunction %void
%int = OpTypeInt 32 1
%baz = OpSpecConstant %int 1
%int_1 = OpConstant %int 1
%buz = OpSpecConstantOp %int IAdd %baz %int_1
%main = OpFunction %void None %3
%5 = OpLabel
OpReturn
OpFunctionEnd
```

but spirv-val produces the following error:
```
error: line 10: SpecId decoration on target '9[%buz]' must be a scalar specialization constant
OpDecorate %buz SpecId 1
```

The spec (2.12) does seem to indicate that spirv-val is correct and glslanValidator is producing incorrect code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.