[Mesa-dev] [PATCH] mesa: fix program resource queries for atomic counter buffers

Lofstedt, Marta marta.lofstedt at intel.com
Fri Oct 30 03:36:08 PDT 2015


> -----Original Message-----
> From: Palli, Tapani
> Sent: Friday, October 30, 2015 11:03 AM
> To: mesa-dev at lists.freedesktop.org
> Cc: Lofstedt, Marta; currojerez at riseup.net; Palli, Tapani
> Subject: [PATCH] mesa: fix program resource queries for atomic counter
> buffers
> 
> gl_active_atomic_buffer contains index to UniformStorage, we need to
> calculate resource index for that gl_uniform_storage.
> 
> Fixes following CTS tests:
>    ES31-CTS.program_interface_query.atomic-counters
>    ES31-CTS.program_interface_query.atomic-counters-one-buffer
> 
> No Piglit regressions.
> 
> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
>  src/mesa/main/shader_query.cpp | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/main/shader_query.cpp
> b/src/mesa/main/shader_query.cpp index 59ec3d7..6e0251a 100644
> --- a/src/mesa/main/shader_query.cpp
> +++ b/src/mesa/main/shader_query.cpp
> @@ -668,6 +668,20 @@ _mesa_program_resource_index(struct
> gl_shader_program *shProg,
>     }
>  }
> 
> +/**
> + * Find a program resource that points to given data.
> + */
> +static struct gl_program_resource*
> +program_resource_find_data(struct gl_shader_program *shProg, void
> +*data) {
> +   struct gl_program_resource *res = shProg->ProgramResourceList;
> +   for (unsigned i = 0; i < shProg->NumProgramResourceList; i++, res++) {
> +      if (res->Data == data)
> +         return res;
> +   }
> +   return NULL;
> +}
> +
>  /* Find a program resource with specific index in given interface.
>   */
>  struct gl_program_resource *
> @@ -1065,8 +1079,18 @@ get_buffer_property(struct gl_shader_program
> *shProg,
>           *val = RESOURCE_ATC(res)->NumUniforms;
>           return 1;
>        case GL_ACTIVE_VARIABLES:
> -         for (unsigned i = 0; i < RESOURCE_ATC(res)->NumUniforms; i++)
> -            *val++ = RESOURCE_ATC(res)->Uniforms[i];
> +         for (unsigned i = 0; i < RESOURCE_ATC(res)->NumUniforms; i++) {
> +            /* Active atomic buffer contains index to UniformStorage. Find
> +             * out gl_program_resource via data pointer and then calculate
> +             * index of that uniform.
> +             */
> +            unsigned idx = RESOURCE_ATC(res)->Uniforms[i];
> +            struct gl_program_resource *uni =
> +               program_resource_find_data(shProg,
> +                                          &shProg->UniformStorage[idx]);
> +            assert(uni);
> +            *val++ = _mesa_program_resource_index(shProg, uni);
> +         }

The parts GL_SHADER_STORAGE_BLOCK looks very similar to the GL_UNIFORM_BLOCK above. Should this code duplication, be avoided?

>           return RESOURCE_ATC(res)->NumUniforms;
>        }
>     }
> --
> 2.4.3



More information about the mesa-dev mailing list