[Mesa-dev] [PATCH 25/28] glsl: move packed varying creation code to a helper

Anuj Phogat anuj.phogat at gmail.com
Thu Jan 14 12:24:16 PST 2016


On Mon, Dec 28, 2015 at 9:00 PM, Timothy Arceri
<timothy.arceri at collabora.com> wrote:
> This will also be used by tessellation packing code
> in a following patch.
> ---
>  src/glsl/lower_packed_varyings.cpp | 45 +++++++++++++++++++++++++-------------
>  1 file changed, 30 insertions(+), 15 deletions(-)
>
> diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp
> index 08d6447..b606cc8 100644
> --- a/src/glsl/lower_packed_varyings.cpp
> +++ b/src/glsl/lower_packed_varyings.cpp
> @@ -180,6 +180,31 @@ needs_lowering(ir_variable *var, bool has_enhanced_layouts,
>     return true;
>  }
>
> +static ir_variable *
> +create_packed_var(void * const mem_ctx, const char *packed_name,
> +                  const glsl_type *packed_type, ir_variable *unpacked_var,
> +                  ir_variable_mode mode, unsigned location,
> +                  bool is_outer_array_vert_idx)
> +{
> +   ir_variable *packed_var = new(mem_ctx)
> +      ir_variable(packed_type, packed_name, mode);
> +   if (is_outer_array_vert_idx) {
> +      /* Prevent update_array_sizes() from messing with the size of the
> +       * array.
> +       */
> +      packed_var->data.max_array_access = unpacked_var->type->length - 1;
> +   }
> +   packed_var->data.centroid = unpacked_var->data.centroid;
> +   packed_var->data.sample = unpacked_var->data.sample;
> +   packed_var->data.patch = unpacked_var->data.patch;
> +   packed_var->data.interpolation = unpacked_var->data.interpolation;
> +   packed_var->data.location = location;
> +   packed_var->data.precision = unpacked_var->data.precision;
> +   packed_var->data.always_active_io = unpacked_var->data.always_active_io;
> +
> +   return packed_var;
> +}
> +
>  namespace {
>
>  /**
> @@ -665,21 +690,11 @@ lower_packed_varyings_visitor::get_packed_varying_deref(
>              glsl_type::get_array_instance(packed_type,
>                                            unpacked_var->type->length);
>        }
> -      ir_variable *packed_var = new(this->mem_ctx)
> -         ir_variable(packed_type, packed_name, this->mode);
> -      if (this->is_outer_array_vert_idx) {
> -         /* Prevent update_array_sizes() from messing with the size of the
> -          * array.
> -          */
> -         packed_var->data.max_array_access = unpacked_var->type->length - 1;
> -      }
> -      packed_var->data.centroid = unpacked_var->data.centroid;
> -      packed_var->data.sample = unpacked_var->data.sample;
> -      packed_var->data.patch = unpacked_var->data.patch;
> -      packed_var->data.interpolation = unpacked_var->data.interpolation;
> -      packed_var->data.location = location;
> -      packed_var->data.precision = unpacked_var->data.precision;
> -      packed_var->data.always_active_io = unpacked_var->data.always_active_io;
> +
> +      ir_variable *packed_var =
> +         create_packed_var(mem_ctx, packed_name, packed_type, unpacked_var,
> +                           this->mode, location,
> +                           this->is_outer_array_vert_idx);
>        unpacked_var->insert_before(packed_var);
>        this->packed_varyings[slot] = packed_var;
>     } else {
> --
> 2.4.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list