broadcom/compiler: add driver_location_map at vs prog data
authorAlejandro Piñeiro <apinheiro@igalia.com>
Thu, 30 Jul 2020 23:09:03 +0000 (01:09 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 22 Mar 2021 17:10:47 +0000 (17:10 +0000)
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 <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9403>

src/broadcom/compiler/v3d_compiler.h
src/broadcom/compiler/vir.c

index e80845d..1a2134c 100644 (file)
@@ -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 {
index e06aaa1..45453a6 100644 (file)
@@ -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,