KhronosGroup / KhronosGroup/glslang

Can not get struct member location from reflection

Open
#1,802 0 comments 0 reactions 0 assignees View on GitHub
reflection
Dominant language
C++
Stars
3.6k
Forks
989
Avg merge
1d 2h
Merged PRs (30d)
31

Description

The shader is from OpenGL4.6 CTS, the uniform data type is struct S, the uniform variable 's' is assigned with location 0 at link time, after build the reflection, all the locations of s.a, s.b, and s.c are 0xfff, but I expect I can get the real location from reflection(s.a is expected to be 0, s.b[0] is expected 1, and s.c is expected to be 4), how can I get the correct location for the struct member? I saw the struct was blown up to the simple items in TReflectionTraverser::blowUpActiveAggregate(), but the location information was lost when the struct is expanded to simple items.

Thanks

##########################
#version 330
in highp vec4 a_position;
in highp vec4 a_coords;
out mediump vec4 v_color;
uniform int ui_one;

struct S {
mediump float a;
mediump float b[3];
int c;
};
uniform S s;

void main (void)
{
v_color = vec4(s.a, s.b[0], s.b[1], s.c);
gl_Position = a_position;
}
##########################

Contributor guide

Open the contributing guide

Research direction

Reproduce the OpenGL 4.6 CTS shader and inspect reflection handling around TReflectionTraverser::blowUpActiveAggregate(), where the issue reports that struct-member locations are lost. Trace how s.a, s.b[0], and s.c are expanded and represented, then verify that reflection reports locations 0, 1, and 4 for the provided shader.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.