KhronosGroup / KhronosGroup/glslang

[[vk::push_constant]] variables are emitted as uniforms in SPIR-V

Open
#1,629 6 comments 3 reactions 0 assignees View on GitHub
enhancement HLSL
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

I am using HLSL for a project that uses vulkan and when trying to make use of push constants in a compute shader I noticed that the emitted SPIR-V code is incorrect.

Instead of annotating the push constant data as such it is marked as `Uniform`, which makes the creation of a compute pipeline fail.

The corresponding GLSL code emits the correct SPIR-V code.

HLSL code (not working) playground

```hlsl
struct PushData {
float val;
};

[[vk::push_constant]]
PushData pushData;

[[vk::binding(0)]]
RWStructuredBuffer data;

void CSMain()
{
data[0] = pushData.val;
}
```

GLSL code (working) playground

```glsl
#version 450

layout(push_constant) uniform PushData {
float val;
} push_data;

layout(binding = 0) buffer Output {
float data[];
};

void main() {
data[0] = push_data.val;
}

```

Contributor guide

Open the contributing guide

Research direction

Run the linked HLSL playground example and compare its generated SPIR-V with the linked GLSL example. Trace the HLSL-to-SPIR-V handling of [[vk::push_constant]] and verify that the emitted push-constant data is annotated correctly rather than as Uniform, so compute pipeline creation succeeds.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.