From b71fd5587e0611057bccc170bcaf356fc3afb4a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alejandro=20Pi=C3=B1eiro?= Date: Fri, 31 Jul 2020 01:09:03 +0200 Subject: [PATCH] broadcom/compiler: add driver_location_map at vs prog data This maps the nir shader data.location to its final data.driver_location. In general we are using the driver location as index (like vattr_sizes on the same struct), so having this map is useful if what we have is the data.location, and we don't have available the original nir shader. v2: use memset instead of for loop, and nir_foreach_shader_in_variable instead of nir_foreach_variable_with_modes (Iago) Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/compiler/v3d_compiler.h | 9 +++++++++ src/broadcom/compiler/vir.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/broadcom/compiler/v3d_compiler.h b/src/broadcom/compiler/v3d_compiler.h index e80845d..1a2134c 100644 --- a/src/broadcom/compiler/v3d_compiler.h +++ b/src/broadcom/compiler/v3d_compiler.h @@ -834,6 +834,15 @@ struct v3d_vs_prog_data { /* Value to be programmed in VCM_CACHE_SIZE. */ uint8_t vcm_cache_size; + + /* Maps the nir->data.location to its + * nir->data.driver_location. In general we are using the + * driver location as index (like vattr_sizes above), so this + * map is useful when what we have is the location + * + * Returns -1 if the location is not used + */ + int32_t driver_location_map[V3D_MAX_VS_INPUTS]; }; struct v3d_gs_prog_data { diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index e06aaa1..45453a6 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -651,6 +651,14 @@ v3d_vs_set_prog_data(struct v3d_compile *c, prog_data->vpm_input_size += c->vattr_sizes[i]; } + memset(prog_data->driver_location_map, -1, + sizeof(prog_data->driver_location_map)); + + nir_foreach_shader_in_variable(var, c->s) { + prog_data->driver_location_map[var->data.location] = + var->data.driver_location; + } + prog_data->uses_vid = BITSET_TEST(c->s->info.system_values_read, SYSTEM_VALUE_VERTEX_ID) || BITSET_TEST(c->s->info.system_values_read, -- 2.7.4