[Mesa-dev] [PATCH] mesa: Return 0 for XFB_VARYING_MAX_LENGTH if no varyings

Matt Turner mattst88 at gmail.com
Sun Nov 25 20:40:07 PST 2012


On Sun, Nov 25, 2012 at 9:14 AM, Brian Paul <brian.e.paul at gmail.com> wrote:
> On Fri, Nov 23, 2012 at 1:14 AM, Matt Turner <mattst88 at gmail.com> wrote:
>> We add one for the null terminator, but if we don't have any varyings,
>> it doesn't make sense to have a null terminator.
>>
>> Fixes part of es3conform's transform_feedback_init_defaults test.
>> ---
>>  src/mesa/main/shaderapi.c |    7 +++++--
>>  1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
>> index 7271150..19051d6 100644
>> --- a/src/mesa/main/shaderapi.c
>> +++ b/src/mesa/main/shaderapi.c
>> @@ -538,11 +538,14 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
>>           break;
>>        *params = shProg->TransformFeedback.NumVarying;
>>        return;
>> -   case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
>> +   case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH: {
>> +      GLint max_length;
>>        if (!has_xfb)
>>           break;
>> -      *params = longest_feedback_varying_name(shProg) + 1;
>> +      max_length = longest_feedback_varying_name(shProg);
>> +      *params = max_length == 0 ? 0 : max_length + 1;
>>        return;
>> +   }
>>     case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
>>        if (!has_xfb)
>>           break;
>
>
> We do this sort of "longest variable name" elsewhere in this file for
> uniforms, etc.  If we follow the example of those, the solution would
> be to add one here:
>
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -190,7 +190,7 @@ longest_feedback_varying_name(const struct gl_shader_program
>     GLuint i;
>     GLint max = 0;
>     for (i = 0; i < shProg->TransformFeedback.NumVarying; i++) {
> -      GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]);
> +      GLint len = strlen(shProg->TransformFeedback.VaryingNames[i]) + 1;
>        if (len > max)
>           max = len;
>     }
>
>
> -Brian

Thanks. Yeah, I noticed how the others work after I sent this patch.
I'll follow up with another patch to implement it the same way as
elsewhere.


More information about the mesa-dev mailing list