[Mesa-dev] [PATCH 13/18] mesa: Fix add_index_to_name logic

Timothy Arceri timothy.arceri at collabora.com
Tue Aug 2 00:42:59 UTC 2016


On Mon, 2016-08-01 at 10:29 -0700, Kenneth Graunke wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> Our piglit tests for geometry and tessellation shader inputs were
> incorrect.  Array shader inputs and output should have '[0]' on the
> end
> regardless of stage.  In addtion, transform feedback varyings should
> not.
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> Cc: "12.0" <mesa-stable at lists.freedesktop.org>
> ---
>  src/mesa/main/shader_query.cpp | 23 ++++++++++-------------
>  1 file changed, 10 insertions(+), 13 deletions(-)
> 
> diff --git a/src/mesa/main/shader_query.cpp
> b/src/mesa/main/shader_query.cpp
> index 0eae39a..e806f38 100644
> --- a/src/mesa/main/shader_query.cpp
> +++ b/src/mesa/main/shader_query.cpp
> @@ -697,20 +697,17 @@ _mesa_program_resource_find_index(struct
> gl_shader_program *shProg,
>  static bool
>  add_index_to_name(struct gl_program_resource *res)
>  {
> -   bool add_index = !((res->Type == GL_PROGRAM_INPUT &&
> -                       res->StageReferences & (1 <<
> MESA_SHADER_GEOMETRY |
> -                                               1 <<
> MESA_SHADER_TESS_CTRL |
> -                                               1 <<
> MESA_SHADER_TESS_EVAL)) ||
> -                      (res->Type == GL_PROGRAM_OUTPUT &&
> -                       res->StageReferences & 1 <<
> MESA_SHADER_TESS_CTRL));
> -
> -   /* Transform feedback varyings have array index already appended
> -    * in their names.
> -    */
> -   if (res->Type == GL_TRANSFORM_FEEDBACK_VARYING)
> -      add_index = false;
> +   if (res->Type != GL_PROGRAM_INPUT && res->Type !=
> GL_PROGRAM_OUTPUT)
> +      return res->Type != GL_TRANSFORM_FEEDBACK_VARYING;
> +
> +   const gl_shader_variable *const var = RESOURCE_VAR(res);
>  
> -   return add_index;
> +   assert(var->type->is_array());
> +
> +   if (var->interface_type != NULL && var->interface_type-
> >is_array())
> +      return var->type->fields.array->is_array();
> +
> +   return true;
>  }


I suggested to Ian at the time he sent this that it seems to me that
the change should be made in _mesa_program_resource_array_size() rather
than here:

e.g

   case GL_PROGRAM_INPUT:
   case GL_PROGRAM_OUTPUT: {
      const gl_shader_variable *const var = RESOURCE_VAR(res);
      if (var->interface_type != NULL && var->interface_type-
>is_array())
         /* TODO: Add support for AoA interface blocks */
         return var->type->fields.array->length;
      else 
         return var->type->length;
   }
      
Then this whole function could just be:

return res->Type != GL_TRANSFORM_FEEDBACK_VARYING;

>  
>  /* Get name length of a program resource. This consists of


More information about the mesa-dev mailing list