[Mesa-dev] [PATCH] mesa: count uniform against storage when its bindless

Marek Olšák maraeo at gmail.com
Tue Aug 15 13:07:07 UTC 2017


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Aug 15, 2017 at 12:42 PM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> Gallium drivers use this code path so we need to account for
> bindless after all.
>
> Fixes:  365d34540f33 ("mesa: correctly calculate the storage offset for i915")
> ---
>  src/mesa/program/ir_to_mesa.cpp | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 87999ea317..0e6a95ce99 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -492,21 +492,21 @@ ir_to_mesa_visitor::src_reg_for_float(float val)
>  {
>     src_reg src(PROGRAM_CONSTANT, -1, NULL);
>
>     src.index = _mesa_add_unnamed_constant(this->prog->Parameters,
>                                           (const gl_constant_value *)&val, 1, &src.swizzle);
>
>     return src;
>  }
>
>  static int
> -type_size(const struct glsl_type *type)
> +storage_type_size(const struct glsl_type *type, bool bindless)
>  {
>     unsigned int i;
>     int size;
>
>     switch (type->base_type) {
>     case GLSL_TYPE_UINT:
>     case GLSL_TYPE_INT:
>     case GLSL_TYPE_FLOAT:
>     case GLSL_TYPE_BOOL:
>        if (type->is_matrix()) {
> @@ -534,44 +534,52 @@ type_size(const struct glsl_type *type)
>        }
>        break;
>     case GLSL_TYPE_UINT64:
>     case GLSL_TYPE_INT64:
>        if (type->vector_elements > 2)
>           return 2;
>        else
>           return 1;
>     case GLSL_TYPE_ARRAY:
>        assert(type->length > 0);
> -      return type_size(type->fields.array) * type->length;
> +      return storage_type_size(type->fields.array, bindless) * type->length;
>     case GLSL_TYPE_STRUCT:
>        size = 0;
>        for (i = 0; i < type->length; i++) {
> -        size += type_size(type->fields.structure[i].type);
> +        size += storage_type_size(type->fields.structure[i].type, bindless);
>        }
>        return size;
>     case GLSL_TYPE_SAMPLER:
>     case GLSL_TYPE_IMAGE:
> -      return 0;
> +      if (!bindless)
> +         return 0;
> +      /* fall through */
>     case GLSL_TYPE_SUBROUTINE:
>        return 1;
>     case GLSL_TYPE_ATOMIC_UINT:
>     case GLSL_TYPE_VOID:
>     case GLSL_TYPE_ERROR:
>     case GLSL_TYPE_INTERFACE:
>     case GLSL_TYPE_FUNCTION:
>        assert(!"Invalid type in type_size");
>        break;
>     }
>
>     return 0;
>  }
>
> +static int
> +type_size(const struct glsl_type *type)
> +{
> +   return storage_type_size(type, false);
> +}
> +
>  /**
>   * In the initial pass of codegen, we assign temporary numbers to
>   * intermediate results.  (not SSA -- variable assignments will reuse
>   * storage).  Actual register allocation for the Mesa VM occurs in a
>   * pass over the Mesa IR later.
>   */
>  src_reg
>  ir_to_mesa_visitor::get_temp(const glsl_type *type)
>  {
>     src_reg src;
> @@ -2445,21 +2453,21 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
>                                     bool /* last_field */)
>  {
>     /* opaque types don't use storage in the param list unless they are
>      * bindless samplers or images.
>      */
>     if (type->contains_opaque() && !var->data.bindless)
>        return;
>
>     assert(_mesa_lookup_parameter_index(params, name) < 0);
>
> -   unsigned size = type_size(type) * 4;
> +   unsigned size = storage_type_size(type, var->data.bindless) * 4;
>
>     int 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;
>  }
> --
> 2.13.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list