I’ve been working through Piglit tests lately and hit a roadblock with the test cases related to GL_ACTIVE_RESOURCE. Specifically, I’m confused about how to calculate or interpret GL_ACTIVE_RESOURCE when dealing with aggregate types (like structs, arrays of structs, or other composite types). The test results don’t align with my current understanding, and I can’t find clear documentation explaining the calculation logic for these non-basic types.
To make this more concrete, here are two simplified example of the code I’m testing :
Case 1
#version 450
layout (binding = 0, offset = 4) uniform atomic_uint a[2][3];
layout (location = 0) uniform uint a0_expected;
layout (location = 1) uniform uint a1_expected;
layout (location = 2) uniform uint a2_expected;
layout (location = 0) out vec4 color;
void main()
{
uint a0_out = atomicCounter(a[0][0]);
if (a0_out != a0_expected) {
color = vec4(1.0, 0.0, float(a0_out) / 255.0, 1.0);
return;
}
uint a1_out = atomicCounterIncrement(a[1][1]);
if (a1_out != a1_expected) {
color = vec4(1.0, 0.1, float(a1_out) / 255.0, 1.0);
return;
}
uint a2_out = atomicCounterDecrement(a[1][2]);
if (a2_out != a2_expected) {
color = vec4(1.0, 0.2, float(a2_out) / 255.0, 1.0);
return;
}
color = vec4(0.0, 1.0, 0.0, 1.0);
}
In this specific case, I believe the GL_ACTIVE_RESOURCE count is 5, and here’s how I broke it down:
- The array elements
a[0]anda[1](counted as two separate active resources) - The individual variables
a0_expected,a1_expected, anda2_expected(counted as three separate active resources)
Case 2
#version 450
struct parts {
vec4 u1;
vec4 u2;
};
layout (location = 1) uniform parts u;
layout (location = 0) out vec4 outColor;
layout (binding = 5, std140) uniform ComponentsBlock
{
vec4 c1[2][3][2];
vec4 c2[2][2];
} components[2];
layout (binding = 0) buffer SSBOComponentsBlock
{
parts s1;
} ssbo_components;
void main()
{
outColor = u.u1 +
components[0].c1[1][1][1] +
components[1].c2[1][1] +
ssbo_components.s1.u2;
}
Why does this case require verifying that, for the program_interface_query with the interface set to GL_UNIFORM , the value of GL_ACTIVE_RESOURCES is 10?
- Whether aggregate types are counted as a single GL_ACTIVE_RESOURCE or split into their individual members, and if they are split, how the splitting should be done (e.g., whether nested struct members or array elements are broken down level by level).
- Are there specific rules for nested aggregates (e.g., structs inside structs) when querying this value?
- Any edge cases I might be missing, like arrays of aggregate types or partially used aggregates in the shader.
- Is there a clear requirement in the spec, and where can I find its source (as I haven’t been able to locate it myself)?
Thanks in advance for any insights or references to relevant specs!