Shader_Minifier icon indicating copy to clipboard operation
Shader_Minifier copied to clipboard

Constant buffer variable renaming issue (HLSL)

Open mrdooz opened this issue 10 months ago • 1 comments

I'm running into a weird issue where the minified code is containing non-ascii characters. I can repro the issue with the following HLSL shader (just pasting this into the CS example program and adding --hlsl will repro):

cbuffer cbMain : register(b0)
{
    float g_test;
};

float4 Test() : SV_Target
{
    float tmp = 0.0f;
    for (int i = 0; i < 1; i++)
    {
        tmp++;
    }
    tmp += g_test;
    return tmp;
}

where g_test gets renamed to something invalid on the return statement. If the for-loop is removed, then this doesn't happen, but that's the extent of my debugging efforts..

mrdooz avatar Jan 14 '25 14:01 mrdooz

Thanks for the report. I can repro the issue on https://ctrl-alt-test.fr/minifier/

I even have a simpler repro (with inlining disabled):

int Test()
{
    int tmp = 0;
    for (int i = 0; i < 1; i++);
    return tmp;
}

The renaming bug happens only with --hlsl.

Unfortunately, I don't have a workaround to suggest. We'll need to investigate.

laurentlb avatar Jan 14 '25 15:01 laurentlb