Shader_Minifier icon indicating copy to clipboard operation
Shader_Minifier copied to clipboard

`precise` modifier in HLSL function return type crashes parser

Open new-cassellito opened this issue 1 year ago • 0 comments

Minimal example HLSL compute shader:

RWTexture2D<float4> res;

precise float MakePrecise(in precise float v) {
    precise float pv = v;
    return pv;
}

[numthreads(8, 8, 4)]
void Main (uint3 dtid : SV_DispatchThreadID)
{
    res[dtid.xy] = float4(MakePrecise(1), 0, 0, 1);
}

Crashes with the error

precise float MakePrecise(in precise float v) {
        ^
Expecting: Type qualifier or ';'

Removing the precise modifier from the return type causes the shader to parse correctly e.g. this works as expected

RWTexture2D<float4> res;

float MakePrecise(in precise float v) {
    precise float pv = v;
    return pv;
}

[numthreads(8, 8, 4)]
void Main (uint3 dtid : SV_DispatchThreadID)
{
    res[dtid.xy] = float4(MakePrecise(1), 0, 0, 1);
}

new-cassellito avatar Jul 23 '24 19:07 new-cassellito