[Mesa-dev] [PATCH 16/21] anv/pipeline: Grow the param array for images

Jason Ekstrand jason at jlekstrand.net
Fri Sep 29 21:25:16 UTC 2017


Before, we were calculating up-front and then filling in later.  Now we
just grow as needed in anv_nir_apply_pipeline_layout.
---
 src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 5 ++++-
 src/intel/vulkan/anv_pipeline.c                  | 7 +------
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index 6ace7be..12f45b7 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -401,8 +401,10 @@ anv_nir_apply_pipeline_layout(struct anv_pipeline *pipeline,
          }
       }
 
+      uint32_t *param = brw_stage_prog_data_add_params(prog_data,
+                                                       map->image_count *
+                                                       BRW_IMAGE_PARAM_SIZE);
       struct anv_push_constants *null_data = NULL;
-      uint32_t *param = prog_data->param + (shader->num_uniforms / 4);
       const struct brw_image_param *image_param = null_data->images;
       for (uint32_t i = 0; i < map->image_count; i++) {
          setup_vec4_uniform_value(param + BRW_IMAGE_PARAM_SURFACE_IDX_OFFSET,
@@ -421,6 +423,7 @@ anv_nir_apply_pipeline_layout(struct anv_pipeline *pipeline,
          param += BRW_IMAGE_PARAM_SIZE;
          image_param ++;
       }
+      assert(param == prog_data->param + prog_data->nr_params);
 
       shader->num_uniforms += map->image_count * BRW_IMAGE_PARAM_SIZE * 4;
    }
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 691cdf8..b0fa7b3 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -403,12 +403,7 @@ anv_pipeline_compile(struct anv_pipeline *pipeline,
       prog_data->nr_params += MAX_PUSH_CONSTANTS_SIZE / sizeof(float);
    }
 
-   if (nir->info.num_images > 0) {
-      prog_data->nr_params += nir->info.num_images * BRW_IMAGE_PARAM_SIZE;
-      pipeline->needs_data_cache = true;
-   }
-
-   if (nir->info.num_ssbos > 0)
+   if (nir->info.num_ssbos > 0 || nir->info.num_images > 0)
       pipeline->needs_data_cache = true;
 
    if (prog_data->nr_params > 0) {
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list