KhronosGroup / KhronosGroup/glslang
glslang allocates the overlapped uniform location with 'location auto-map-locations' option
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
Hi All,
I am trying to compile a OpenGL shader with glslang, OGL spec allows to declare uniform symbol with or without explicit location, the shader compiler should be responsible to allocate a valid location if the symbol is declared without location, but for glslang with '--aml' option, the uniform 'b[3]' is allocated with location 0, each member of array of struct will consume one location, and b[1].srcColor will consume location 3, but location 3 is already declared by symbol 'index', the overlapped location will cause the shader returns incorrect result. Is there any option in glslang to handle such case?
Thanks
#version 430
struct A
{
vec4 srcColor;
float alpha;
};
struct B
{
A a;
vec4 backGroundColor;
};
uniform B b[3];
layout(location = 3) uniform int index;
void main()
{
gl_FragColor = b[index].a.srcColor*b[index].a.alpha + (1-b[index].a.alpha)*b[index].backGroundColor;
}
Contributor guide
Research direction
Start by reproducing the GLSL shader with the --aml (auto-map-locations) option and inspect how uniform locations are allocated for b[3] and the explicit index location. Confirm that the generated locations do not overlap and that the shader produces the correct result for the reported case.
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
- 35/100