KhronosGroup / KhronosGroup/glslang

Assert when using spirv_literal parameter in spirv_instruction with set

Open
#4,317 2 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

Using `spirv_instruction(set=)` (from `GL_EXT_spirv_intrinsics`) with a `spirv_literal` parameter results in an assertion error, whereas the spec doesn't specifically forbid this combination. I first thought this was a spec oversight and that only ids were allowed, but according to extension author @Tobski (see KhronosGroup/GLSL#330) it is intended to be allowed.

```glsl
#version 450

#extension GL_EXT_spirv_intrinsics : enable

spirv_instruction(set = "GLSL.std.450", id = 1)
vec4 testExtInst(vec4 x, spirv_literal int lit);

layout(location = 0) in vec4 vecIn;
layout(location = 1) out vec4 vecOut;

void main()
{
vecOut = testExtInst(vecIn, 1);
}
```

Run:
```
glslang -V --target-env vulkan1.0 test.vert
```

Result:
```
glslang: SPIRV/spvIR.h:110: void spv::Instruction::addIdOperand(spv::Id): Assertion `id' failed.
Aborted (core dumped)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the GLSLang command and test.vert example from the report, then inspect SPIRV/spvIR.h around the reported addIdOperand assertion. Trace how spirv_literal and spirv_instruction(set=) operands are handled, and verify the command completes without an assertion while preserving valid SPIR-V generation.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.