PDA

View Full Version : glGetActiveUniform + uniform arrays



gemsenhuber
12-05-2013, 01:14 AM
assuming I have an array of uniform values in my shader code, i.e.:



#version 330 core

uniform vec3 samplePositions[ 16 ]

...


in my current glsl wrapper class, i query all active uniforms right after linking a program object & store the locations in a lookup table.
Now, with regards to arrays of uniforms like the above example, I've noticed sth. weird:
I'll get different active uniform names depending on the graphics card; on my PC ( Radeon 6900 ) i would get an active unform named "samplePositions[0]"
while on my notebook ( Radeon 8970M ) I'd get an active uniform named just "samplePositions".

ok, so I can easily work around this problem by just looking for both names - "samplePositions" and "samplePositions[0]" - in my table;
however, i'd still like to know if this is a driver bug on one of those cards, or if the OpenGL specification is just so vague that both results are ok,
or if using glGetActiveUniform itself is maybe problematic?

tonyo_au
12-05-2013, 03:58 PM
or if the OpenGL specification is just so vague that both results

To my reading it seems vague

Getting active uniform names for arrays with glGetActiveUniform does seems problematic. On nVidia driver I get name[0] but not any other names like name[1] if the object is a simple one like vec3 but if the object is a
structure I get name[0].structure _member and name[1].structure _member etc.


You might like to look at glGetProgramResourceiv which is designed to more information GLSL objects.