[Mesa-dev] [PATCH V2] mesa: stop assigning unused storage for non-bindless opaque types

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Jun 15 08:00:03 UTC 2017



On 06/15/2017 03:56 AM, Timothy Arceri wrote:
> The storage was once used by get_sampler_uniform_value() but that
> was fixed long ago to use the uniform storage assigned by the
> linker.
> 
> By not assigning storage for images/samplers the constant buffer
> for gallium drivers will be reduced which could result in small
> perf improvements.
> 
> V2: rebase on ARB_bindless_texture
> ---
>   src/mesa/program/ir_to_mesa.cpp | 42 ++++++-----------------------------------
>   1 file changed, 6 insertions(+), 36 deletions(-)
> 
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 775211c..54b848a 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -2440,62 +2440,32 @@ private:
>   
>   } /* anonymous namespace */
>   
>   void
>   add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
>                                      bool /* row_major */,
>                                      const glsl_type * /* record_type */,
>                                      const enum glsl_interface_packing,
>                                      bool /* last_field */)
>   {
> -   /* atomics don't get real storage */
> -   if (type->contains_atomic())
> +   /* opaque types don't use storage in the param list unless they are
> +    * bindless textures or images.

samplers

Other than that, looks good to me.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

> +    */
> +   if (type->contains_opaque() && !var->data.bindless)
>         return;
>   
> -   gl_register_file file;
> -   if (type->without_array()->is_sampler() && !var->data.bindless) {
> -      file = PROGRAM_SAMPLER;
> -   } else {
> -      file = PROGRAM_UNIFORM;
> -   }
> -
>      int index = _mesa_lookup_parameter_index(params, name);
>      if (index < 0) {
>         unsigned size = type_size(type) * 4;
>   
> -      index = _mesa_add_parameter(params, file, name, size, type->gl_type,
> -				  NULL, NULL);
> -
> -      /* Sampler uniform values are stored in prog->SamplerUnits,
> -       * and the entry in that array is selected by this index we
> -       * store in ParameterValues[].
> -       */
> -      if (file == PROGRAM_SAMPLER) {
> -	 unsigned location;
> -	 const bool found =
> -	    this->shader_program->UniformHash->get(location,
> -						   params->Parameters[index].Name);
> -	 assert(found);
> -
> -	 if (!found)
> -	    return;
> -
> -	 struct gl_uniform_storage *storage =
> -            &this->shader_program->data->UniformStorage[location];
> -
> -         assert(storage->type->is_sampler() &&
> -                storage->opaque[shader_type].active);
> -
> -	 for (unsigned int j = 0; j < size / 4; j++)
> -            params->ParameterValues[index + j][0].f =
> -               storage->opaque[shader_type].index + j;
> -      }
> +      index = _mesa_add_parameter(params, PROGRAM_UNIFORM, name, size,
> +                                  type->gl_type, NULL, NULL);
>      }
>   
>      /* The first part of the uniform that's processed determines the base
>       * location of the whole uniform (for structures).
>       */
>      if (this->idx < 0)
>         this->idx = index;
>   }
>   
>   /**
> 


More information about the mesa-dev mailing list