[Mesa-dev] [PATCH] st/glsl_to_nir: add patch support to st_nir_assign_var_locations()

Dieter Nützel Dieter at nuetzel-hh.de
Fri Dec 15 04:19:25 UTC 2017


Tested-by: Dieter Nützel <Dieter at nuetzel-hh.de>

Dieter

Am 14.12.2017 00:14, schrieb Timothy Arceri:
> ---
>  src/mesa/state_tracker/st_glsl_to_nir.cpp | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> index 70c5daaa225..be34031bfb5 100644
> --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
> @@ -119,46 +119,58 @@ st_nir_assign_vs_in_locations(struct gl_program
> *prog, nir_shader *nir)
>           exec_list_push_tail(&nir->globals, &var->node);
>        }
>     }
>  }
> 
>  static void
>  st_nir_assign_var_locations(struct exec_list *var_list, unsigned 
> *size,
>                              gl_shader_stage stage)
>  {
>     unsigned location = 0;
> -   unsigned assigned_locations[VARYING_SLOT_MAX];
> +   unsigned assigned_locations[VARYING_SLOT_TESS_MAX];
>     uint64_t processed_locs = 0;
> +   uint32_t processed_patch_locs = 0;
> 
>     nir_foreach_variable(var, var_list) {
> 
>        const struct glsl_type *type = var->type;
>        if (nir_is_per_vertex_io(var, stage)) {
>           assert(glsl_type_is_array(type));
>           type = glsl_get_array_element(type);
>        }
> 
> +      bool processed = false;
> +      if (var->data.patch) {
> +         unsigned patch_loc = var->data.location - VARYING_SLOT_VAR0;
> +         if (processed_patch_locs & (1 << patch_loc))
> +            processed = true;
> +
> +         processed_patch_locs |= (1 << patch_loc);
> +      } else {
> +         if (processed_locs & ((uint64_t)1 << var->data.location))
> +            processed = true;
> +
> +         processed_locs |= ((uint64_t)1 << var->data.location);
> +      }
> +
>        /* Because component packing allows varyings to share the same 
> location
>         * we may have already have processed this location.
>         */
> -      if (var->data.location >= VARYING_SLOT_VAR0 &&
> -          processed_locs & ((uint64_t)1 << var->data.location)) {
> +      if (processed && var->data.location >= VARYING_SLOT_VAR0) {
>           var->data.driver_location = 
> assigned_locations[var->data.location];
>           *size += type_size(type);
>           continue;
>        }
> 
>        assigned_locations[var->data.location] = location;
>        var->data.driver_location = location;
>        location += type_size(type);
> -
> -      processed_locs |= ((uint64_t)1 << var->data.location);
>     }
> 
>     *size += location;
>  }
> 
>  static int
>  st_nir_lookup_parameter_index(const struct gl_program_parameter_list 
> *params,
>                                const char *name)
>  {
>     int loc = _mesa_lookup_parameter_index(params, name);


More information about the mesa-dev mailing list