Mesa (master): v3dv/pipeline: use driver_location_map instead of nir utilities

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 22 17:22:34 UTC 2021


Module: Mesa
Branch: master
Commit: dd72c99d7745f0f2f442316d1fc7c0b6836e7371
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd72c99d7745f0f2f442316d1fc7c0b6836e7371

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Tue Mar  2 22:14:07 2021 +0100

v3dv/pipeline: use driver_location_map instead of nir utilities

If we were able to get a shader variant from the pipeline cache, we
will not have the nir shader available.

Note that this is what we were doing on the driver before the nir io
helpers were available.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9403>

---

 src/broadcom/vulkan/v3dv_pipeline.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c
index 953066fe8f3..ab86ec88381 100644
--- a/src/broadcom/vulkan/v3dv_pipeline.c
+++ b/src/broadcom/vulkan/v3dv_pipeline.c
@@ -2815,18 +2815,23 @@ pipeline_init(struct v3dv_pipeline *pipeline,
    }
 
    pipeline->va_count = 0;
-   nir_shader *shader = pipeline->vs->nir;
+   struct v3d_vs_prog_data *prog_data_vs =
+      pipeline->vs->current_variant->prog_data.vs;
 
    for (uint32_t i = 0; i < vi_info->vertexAttributeDescriptionCount; i++) {
       const VkVertexInputAttributeDescription *desc =
          &vi_info->pVertexAttributeDescriptions[i];
       uint32_t location = desc->location + VERT_ATTRIB_GENERIC0;
 
-      nir_variable *var = nir_find_variable_with_location(shader, nir_var_shader_in, location);
-
-      if (var != NULL) {
-         unsigned driver_location = var->data.driver_location;
+      /* We use a custom driver_location_map instead of
+       * nir_find_variable_with_location because if we were able to get the
+       * shader variant from the cache, we would not have the nir shader
+       * available.
+       */
+      uint32_t driver_location =
+         prog_data_vs->driver_location_map[location];
 
+      if (driver_location != -1) {
          assert(driver_location < MAX_VERTEX_ATTRIBS);
          pipeline->va[driver_location].offset = desc->offset;
          pipeline->va[driver_location].binding = desc->binding;



More information about the mesa-commit mailing list