[Mesa-dev] [PATCH] ACTIVE_UNIFORM_MAX_LENGTH should include 3 extra characters for arrays.

Haixia Shi hshi at chromium.org
Sat Mar 30 10:32:19 PDT 2013


No for this particular length, it only needs to account for the 3 chars in
"[0]". That suffix is required by spec to be appended (hard-coded string),
see the bottom of mesa/src/mesa/main/uniforms.c where the function
glGetActiveUniform is (I believe Ian added the code in early 2012).


On Sat, Mar 30, 2013 at 4:26 AM, Dragomir Ivanov <drago.ivanov at gmail.com>
 wrote:

> I don't know OpenGL very much, but can uniforms be more than 10? So you
> can have "[24]" where you will need +4, not +3.
>
>
> On Sat, Mar 30, 2013 at 3:22 AM, Haixia Shi <hshi at chromium.org> wrote:
>
>> If the active uniform is an array, then the length of the uniform name
>> should
>> include the three extra characters for the "[0]" suffix, which is
>> required by
>> the GL 4.2 spec to be appended to the uniform name in
>> glGetActiveUniform().
>>
>> This avoids the situation where the output buffer does not have enough
>> space
>> to hold the "[0]" suffix, resulting in an incomplete array specification
>> like
>> "foobar[0".
>>
>> Change-Id: Icd58cd6a73c9de7bbe5659d757b8009021846019
>> Signed-off-by: Haixia Shi <hshi at chromium.org>
>> Reviewed-by: Stéphane Marchesin <marcheu at chromium.org>
>> ---
>>  src/mesa/main/shaderapi.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
>> index be69467..68767f4 100644
>> --- a/src/mesa/main/shaderapi.c
>> +++ b/src/mesa/main/shaderapi.c
>> @@ -519,8 +519,11 @@ get_programiv(struct gl_context *ctx, GLuint
>> program, GLenum pname, GLint *param
>>
>>        for (i = 0; i < shProg->NumUserUniformStorage; i++) {
>>          /* Add one for the terminating NUL character.
>> +         * However if the uniform is an array, then add three extra
>> characters
>> +         * for the appended "[0]" suffix, in addition to the terminating
>> NUL.
>>           */
>> -        const GLint len = strlen(shProg->UniformStorage[i].name) + 1;
>> +        const GLint len = strlen(shProg->UniformStorage[i].name) + 1 +
>> +            ((shProg->UniformStorage[i].array_elements != 0) ? 3 : 0);
>>
>>          if (len > max_len)
>>             max_len = len;
>> --
>> 1.8.1.3
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130330/72d12867/attachment.html>


More information about the mesa-dev mailing list