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

Brian Paul brian.e.paul at gmail.com
Sun Nov 25 09:14:59 PST 2012


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


More information about the mesa-dev mailing list