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

Constant not supported in GLSL shader binding style declaration #5690

Open
theblackunknown opened this issue Nov 26, 2024 · 2 comments
Open

Comments

@theblackunknown
Copy link

Hi team,

I am trying to compile some of our GLSL shaders using slangc and I am running into issues because we are using constant in shader bindings declaration.
Currently we are using google/shaderc to compile our shader and we do not run into this compiler issue.

See below for a minimal repro case.
If you can point me to how to port it as a Slang test I would gladly contribute it if that helps.

Given the following constant-in-layout.slang file

#version 450 core

const uint DescriptorSet = 0;

const uint BindingPoint_Sampler = 0;
const uint BindingPoint_Scale = 1;
const uint BindingPoint_Bias = 2;

layout(location = 0) out mediump vec4 o_color;
layout(location = 0) in highp vec2 v_texCoord;
layout(location = 1) in highp float v_lodBias;
layout(set = DescriptorSet, binding = BindingPoint_Sampler) uniform highp usampler2D u_sampler;
layout(set = DescriptorSet, binding = BindingPoint_Scale) uniform buf0
{
    highp vec4 u_scale;
};
layout(set = DescriptorSet, binding = BindingPoint_Bias) uniform buf1
{
    highp vec4 u_bias;
};

void main()
{
    o_color = vec4(texelFetch(u_sampler, ivec2(v_texCoord), int(v_lodBias))) * u_scale + u_bias;
}

compiling the above file using the following command line
slangc.exe -target spirv -stage fragment -entry main constant-in-layout.slang

Will produce the following errors

tests\glsl\constant-in-layout.slang(15): error 20001: unexpected identifier, expected integer literal
layout(set = DescriptorSet, binding = BindingPoint_Sampler) uniform highp usampler2D u_sampler;
             ^~~~~~~~~~~~~
tests\glsl\constant-in-layout.slang(15): error 20001: unexpected identifier, expected integer literal
layout(set = DescriptorSet, binding = BindingPoint_Sampler) uniform highp usampler2D u_sampler;
                                      ^~~~~~~~~~~~~~~~~~~~
tests\glsl\constant-in-layout.slang(16): error 20001: unexpected identifier, expected integer literal
layout(set = DescriptorSet, binding = BindingPoint_Scale) uniform buf0
             ^~~~~~~~~~~~~
tests\glsl\constant-in-layout.slang(16): error 20001: unexpected identifier, expected integer literal
layout(set = DescriptorSet, binding = BindingPoint_Scale) uniform buf0
                                      ^~~~~~~~~~~~~~~~~~
tests\glsl\constant-in-layout.slang(20): error 20001: unexpected identifier, expected integer literal
layout(set = DescriptorSet, binding = BindingPoint_Bias) uniform buf1
             ^~~~~~~~~~~~~
tests\glsl\constant-in-layout.slang(20): error 20001: unexpected identifier, expected integer literal
layout(set = DescriptorSet, binding = BindingPoint_Bias) uniform buf1
                                      ^~~~~~~~~~~~~~~~~
@jkwak-work
Copy link
Collaborator

This appears to be a missing feature support for GLSL.
Slang doesn't support this way of using const variables at the moment.

@theblackunknown
Copy link
Author

Thanks @jkwak-work, would you be able to point me at few places if I want to contribute to add this feature ?

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

2 participants