Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper handling of namespace in HLSL #1375

Open
BenoitAmbry opened this issue Oct 12, 2023 · 0 comments
Open

Proper handling of namespace in HLSL #1375

BenoitAmbry opened this issue Oct 12, 2023 · 0 comments

Comments

@BenoitAmbry
Copy link

The hlsl parser fails to parse type names when they are prefixed by a namespace, for example Test::TestS ts; will fail, but TestS ts; will parse (improperly).

The following code reproduces the issue with the command line:

/usr/local/bin/glslc -x hlsl -fentry-point=pixelShader -fshader-stage=fragment --target-env=vulkan1.2 -o x.spirv ./example.hlsl
struct v2p {
    float4 p : SV_POSITION;
    float2 uv : TEXCOORD0;
    float4 c : TEXCOORD1;
};

namespace Test {
    struct TestS {
        float4 t;
        float4 v;
    };
    
    float4 testF(TestS ts) {
        return ts.t * ts.v;
    }
    
}

sampler2D MyTexture;

float4 pixelShader(v2p i) : SV_TARGET {
    Test::TestS ts; // FAILS HERE, /*Test::*/TestS ts; works, but should fail.
    ts.v = i.c;
    ts.t = tex2D(MyTexture, i.uv);
    return Test::testF(ts);
}

Note: glslc version tested:

/usr/local/bin/glslc --version
shaderc v2023.6 v2023.6
spirv-tools v2023.4 v2022.4-296-ge553b884
glslang 11.1.0-763-g76b52ebf

Target: SPIR-V 1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant