Result of program interface query of shader storage block

Hi,

this is my first post here so I hope I get it right :slight_smile:

I have two machines one with an AMD and one with a NVidia graphic board. I have written a simple program to query a shader storage block with respect to the ARB_program_interface_query. I got two different results and I would like to know what would be the correct expected result from an implementation conforming to the ARB_program_interface_query.

In my shader I have the following uniform block:


struct S0
{
    float t;
    ivec3 v[3];
    int w;
};

struct S1
{
    int d;
    bvec2 e;
};

struct S2
{
    uvec3 j;
    vec2 k;
    float l[2];
    vec2 m;
    mat3 n[2];
};

struct S3
{
    dvec2 r;
    int s;
    S0 x[4];
};

layout(shared) buffer ExampleBlock {
    float a;
    vec2 b;
    vec3 c;
    S1 f;
    float g;
    float h[2];
    mat2x3 i;
    S2 o[2];
    double p;
    bool q;
    S3 y;
} example;

And in my c++ code I have the following lines of query code:


GLint index = glGetProgramResourceIndex(_shader.GetProgram(), GL_SHADER_STORAGE_BLOCK, "ExampleBlock");

const GLenum       block_prop_query[2] = { GL_BUFFER_DATA_SIZE, GL_NUM_ACTIVE_VARIABLES };
std::vector<GLint> block_prop_query_result(2);

glGetProgramResourceiv(_shader.GetProgram(), GL_SHADER_STORAGE_BLOCK, index, 2, block_prop_query, 2, NULL, &block_prop_query_result[0]);

GLint size            = block_prop_query_result[0];
GLint num_active_vars = block_prop_query_result[1];

std::vector<GLuint> indices(num_active_vars);
const GLenum indices_query[1] = { GL_ACTIVE_VARIABLES };

glGetProgramResourceiv(_shader.GetProgram(), GL_SHADER_STORAGE_BLOCK, index, 1, indices_query, num_active_vars, NULL, reinterpret_cast<GLint*>(&indices[0]));

std::vector<GLint> offsets(num_active_vars), name_lenght(num_active_vars);

for(int idx = 0; idx < num_active_vars; ++idx)
{
    const GLint num_queries = 2;
    const GLenum query[num_queries] = { GL_OFFSET, GL_NAME_LENGTH };
    GLint query_result[num_queries];
    glGetProgramResourceiv(_shader.GetProgram(), GL_BUFFER_VARIABLE, indices[idx], num_queries, query, num_queries, NULL, query_result);

    offsets[idx]     = query_result[1];
    name_lenght[idx] = query_result[8];
}

std::vector<std::string> variable_names;

for(int idx = 0; idx < num_active_vars; ++idx)
{
    std::vector<char> nameData(name_lenght[idx]);
    glGetProgramResourceName(_shader.GetProgram(), GL_BUFFER_VARIABLE, indices[idx], nameData.size(), NULL, &nameData[0]);
    std::string name(nameData.begin(), nameData.end() - 1);

    variable_names.push_back(name);
}

Now, on AMD I got the follwing content for the variable_names:


"ExampleBlock.a"
"ExampleBlock.b"
"ExampleBlock.c"
"ExampleBlock.f.d"
"ExampleBlock.f.e"
"ExampleBlock.g"
"ExampleBlock.h[0]"
"ExampleBlock.i"
"ExampleBlock.o[0].j"
"ExampleBlock.o[1].j"
"ExampleBlock.o[0].k"
"ExampleBlock.o[1].k"
"ExampleBlock.o[0].l[0]"
"ExampleBlock.o[1].l[0]"
"ExampleBlock.o[0].m"
"ExampleBlock.o[1].m"
"ExampleBlock.o[0].n[0]"
"ExampleBlock.o[1].n[0]"
"ExampleBlock.p"
"ExampleBlock.q"
"ExampleBlock.y.r"
"ExampleBlock.y.s"
"ExampleBlock.y.x[0].t"
"ExampleBlock.y.x[1].t"
"ExampleBlock.y.x[2].t"
"ExampleBlock.y.x[3].t"
"ExampleBlock.y.x[0].v[0]"
"ExampleBlock.y.x[1].v[0]"
"ExampleBlock.y.x[2].v[0]"
"ExampleBlock.y.x[3].v[0]"
"ExampleBlock.y.x[0].w"
"ExampleBlock.y.x[1].w"
"ExampleBlock.y.x[2].w"
"ExampleBlock.y.x[3].w"

but on NVidia I got:


"ExampleBlock.a"
"ExampleBlock.b"
"ExampleBlock.c"
"ExampleBlock.f.d"
"ExampleBlock.f.e"
"ExampleBlock.g"
"ExampleBlock.h[0]"
"ExampleBlock.i"
"ExampleBlock.o[0].j"
"ExampleBlock.o[0].k"
"ExampleBlock.o[0].l[0]"
"ExampleBlock.o[0].m"
"ExampleBlock.o[0].n[0]"
"ExampleBlock.p"
"ExampleBlock.q"
"ExampleBlock.y.r"
"ExampleBlock.y.s"
"ExampleBlock.y.x[0].t"
"ExampleBlock.y.x[0].v[0]"
"ExampleBlock.y.x[0].w"
"ExampleBlock.y.x[1].t"
"ExampleBlock.y.x[1].v[0]"
"ExampleBlock.y.x[1].w"
"ExampleBlock.y.x[2].t"
"ExampleBlock.y.x[2].v[0]"
"ExampleBlock.y.x[2].w"
"ExampleBlock.y.x[3].t"
"ExampleBlock.y.x[3].v[0]"
"ExampleBlock.y.x[3].w"

missing the "ExampleBlock.o[1].xxx entries.

Is this a driver bug or do I have to modify my query code somehow to get the same results on both platforms?

Hope the post was not to longโ€ฆ

Best,
Johannes