microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Cannot have short, ushort, uint64_t, int64_t or double spec constant
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
The compiler issues an error for spec constants whose type is a 16-bit integer, 64-bit integer, or double.
There is no fundamental reason this cannot be done for Vulkan.
Steps to Reproduce
https://godbolt.org/z/Pdx7W4srW
compile command: dxc -spirv -T cs_6_8 -enable-16bit-types t.hlsl
Shader:
// double
[[vk::constant_id(0)]]
const double spec_double = 0.0;
RWStructuredBuffer<double> OutDouble : register(u0, space0);
// short
[[vk::constant_id(1)]]
const int16_t spec_short = 0;
RWStructuredBuffer<int16_t> OutShort : register(u1, space0);
// ushort
[[vk::constant_id(2)]]
const uint16_t spec_ushort = 0;
RWStructuredBuffer<uint16_t> OutUShort : register(u2, space0);
// long
[[vk::constant_id(1)]]
const int64_t spec_long = 0;
RWStructuredBuffer<int64_t> OutLong : register(u1, space0);
// ulong
[[vk::constant_id(2)]]
const uint64_t spec_ulong = 0;
RWStructuredBuffer<uint64_t> OutULong : register(u2, space0);
[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
OutDouble[GI] = spec_double;
OutShort[GI] = spec_short;
OutUShort[GI] = spec_ushort;
OutLong[GI] = spec_long;
OutULong[GI] = spec_ulong;
}
Actual Behavior
Errors saying:
error: unsupported specialization constant type
Environment
- DXC version: latest
- Host Operating System: all
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the provided HLSL shader, Godbolt link, and dxc -spirv -T cs_6_8 -enable-16bit-types command. Trace the compiler path that reports unsupported specialization constant type for the listed 16-bit, 64-bit, and double types. Done means these specialization constants compile successfully for Vulkan SPIR-V without that error.
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
- 45/100