From dd72c99d7745f0f2f442316d1fc7c0b6836e7371 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alejandro=20Pi=C3=B1eiro?= Date: Tue, 2 Mar 2021 22:14:07 +0100 Subject: [PATCH] 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 Part-of: --- 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 953066f..ab86ec8 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; -- 2.7.4