anv: Stop storing the shader constant data side-band
authorJason Ekstrand <jason@jlekstrand.net>
Sat, 8 Aug 2020 03:31:44 +0000 (22:31 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 2 Sep 2020 19:48:44 +0000 (19:48 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6244>

src/intel/vulkan/anv_blorp.c
src/intel/vulkan/anv_pipeline.c
src/intel/vulkan/anv_pipeline_cache.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c

index 8570879f37abe221ee3e0edf0fd8978d9c6954e9..af7f7cb9416a53cfc6553ccd97c1b24bfd9d867b 100644 (file)
@@ -72,7 +72,6 @@ upload_blorp_shader(struct blorp_batch *batch, uint32_t stage,
    struct anv_shader_bin *bin =
       anv_pipeline_cache_upload_kernel(&device->default_pipeline_cache, stage,
                                        key, key_size, kernel, kernel_size,
-                                       NULL, 0,
                                        prog_data, prog_data_size,
                                        NULL, 0, NULL, &bind_map);
 
index 8313f471a67c12f6ebb5d43be713f6a5c7c0c578..664a916033bfca2e9f7516691b9656692b69db17 100644 (file)
@@ -1580,8 +1580,6 @@ anv_pipeline_compile_graphics(struct anv_graphics_pipeline *pipeline,
                                   sizeof(stages[s].cache_key),
                                   stages[s].code,
                                   stages[s].prog_data.base.program_size,
-                                  stages[s].nir->constant_data,
-                                  stages[s].nir->constant_data_size,
                                   &stages[s].prog_data.base,
                                   brw_prog_data_size(s),
                                   stages[s].stats, stages[s].num_stats,
@@ -1770,8 +1768,6 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
                                      MESA_SHADER_COMPUTE,
                                      &stage.cache_key, sizeof(stage.cache_key),
                                      stage.code, code_size,
-                                     stage.nir->constant_data,
-                                     stage.nir->constant_data_size,
                                      &stage.prog_data.base,
                                      sizeof(stage.prog_data.cs),
                                      stage.stats, stage.num_stats,
index fa9cfe4f777968ec09428b9e00ef820ae52daff0..12257dd76417e161b12f4c6a62f8cf2571ac9298 100644 (file)
@@ -36,7 +36,6 @@ anv_shader_bin_create(struct anv_device *device,
                       gl_shader_stage stage,
                       const void *key_data, uint32_t key_size,
                       const void *kernel_data, uint32_t kernel_size,
-                      const void *constant_data, uint32_t constant_data_size,
                       const struct brw_stage_prog_data *prog_data_in,
                       uint32_t prog_data_size,
                       const struct brw_compile_stats *stats, uint32_t num_stats,
@@ -81,16 +80,6 @@ anv_shader_bin_create(struct anv_device *device,
    memcpy(shader->kernel.map, kernel_data, kernel_size);
    shader->kernel_size = kernel_size;
 
-   if (constant_data_size) {
-      shader->constant_data =
-         anv_state_pool_alloc(&device->dynamic_state_pool,
-                              constant_data_size, 32);
-      memcpy(shader->constant_data.map, constant_data, constant_data_size);
-   } else {
-      shader->constant_data = ANV_STATE_NULL;
-   }
-   shader->constant_data_size = constant_data_size;
-
    memcpy(prog_data, prog_data_in, prog_data_size);
    memset(prog_data_param, 0,
           prog_data->nr_params * sizeof(*prog_data_param));
@@ -128,7 +117,6 @@ anv_shader_bin_destroy(struct anv_device *device,
 {
    assert(shader->ref_cnt == 0);
    anv_state_pool_free(&device->instruction_state_pool, shader->kernel);
-   anv_state_pool_free(&device->dynamic_state_pool, shader->constant_data);
    vk_free(&device->vk.alloc, shader);
 }
 
@@ -144,10 +132,6 @@ anv_shader_bin_write_to_blob(const struct anv_shader_bin *shader,
    blob_write_uint32(blob, shader->kernel_size);
    blob_write_bytes(blob, shader->kernel.map, shader->kernel_size);
 
-   blob_write_uint32(blob, shader->constant_data_size);
-   blob_write_bytes(blob, shader->constant_data.map,
-                    shader->constant_data_size);
-
    blob_write_uint32(blob, shader->prog_data_size);
    blob_write_bytes(blob, shader->prog_data, shader->prog_data_size);
 
@@ -196,9 +180,6 @@ anv_shader_bin_create_from_blob(struct anv_device *device,
    uint32_t kernel_size = blob_read_uint32(blob);
    const void *kernel_data = blob_read_bytes(blob, kernel_size);
 
-   uint32_t constant_data_size = blob_read_uint32(blob);
-   const void *constant_data = blob_read_bytes(blob, constant_data_size);
-
    uint32_t prog_data_size = blob_read_uint32(blob);
    const struct brw_stage_prog_data *prog_data =
       blob_read_bytes(blob, prog_data_size);
@@ -234,7 +215,6 @@ anv_shader_bin_create_from_blob(struct anv_device *device,
    return anv_shader_bin_create(device, stage,
                                 key_data, key_size,
                                 kernel_data, kernel_size,
-                                constant_data, constant_data_size,
                                 prog_data, prog_data_size,
                                 stats, num_stats, xfb_info, &bind_map);
 }
@@ -403,8 +383,6 @@ anv_pipeline_cache_add_shader_locked(struct anv_pipeline_cache *cache,
                                      const void *key_data, uint32_t key_size,
                                      const void *kernel_data,
                                      uint32_t kernel_size,
-                                     const void *constant_data,
-                                     uint32_t constant_data_size,
                                      const struct brw_stage_prog_data *prog_data,
                                      uint32_t prog_data_size,
                                      const struct brw_compile_stats *stats,
@@ -421,7 +399,6 @@ anv_pipeline_cache_add_shader_locked(struct anv_pipeline_cache *cache,
       anv_shader_bin_create(cache->device, stage,
                             key_data, key_size,
                             kernel_data, kernel_size,
-                            constant_data, constant_data_size,
                             prog_data, prog_data_size,
                             stats, num_stats, xfb_info, bind_map);
    if (!bin)
@@ -437,8 +414,6 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
                                  gl_shader_stage stage,
                                  const void *key_data, uint32_t key_size,
                                  const void *kernel_data, uint32_t kernel_size,
-                                 const void *constant_data,
-                                 uint32_t constant_data_size,
                                  const struct brw_stage_prog_data *prog_data,
                                  uint32_t prog_data_size,
                                  const struct brw_compile_stats *stats,
@@ -452,7 +427,6 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
       struct anv_shader_bin *bin =
          anv_pipeline_cache_add_shader_locked(cache, stage, key_data, key_size,
                                               kernel_data, kernel_size,
-                                              constant_data, constant_data_size,
                                               prog_data, prog_data_size,
                                               stats, num_stats,
                                               xfb_info, bind_map);
@@ -469,7 +443,6 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
       return anv_shader_bin_create(cache->device, stage,
                                    key_data, key_size,
                                    kernel_data, kernel_size,
-                                   constant_data, constant_data_size,
                                    prog_data, prog_data_size,
                                    stats, num_stats,
                                    xfb_info, bind_map);
@@ -703,8 +676,6 @@ anv_device_upload_kernel(struct anv_device *device,
                          gl_shader_stage stage,
                          const void *key_data, uint32_t key_size,
                          const void *kernel_data, uint32_t kernel_size,
-                         const void *constant_data,
-                         uint32_t constant_data_size,
                          const struct brw_stage_prog_data *prog_data,
                          uint32_t prog_data_size,
                          const struct brw_compile_stats *stats,
@@ -716,14 +687,12 @@ anv_device_upload_kernel(struct anv_device *device,
    if (cache) {
       bin = anv_pipeline_cache_upload_kernel(cache, stage, key_data, key_size,
                                              kernel_data, kernel_size,
-                                             constant_data, constant_data_size,
                                              prog_data, prog_data_size,
                                              stats, num_stats,
                                              xfb_info, bind_map);
    } else {
       bin = anv_shader_bin_create(device, stage, key_data, key_size,
                                   kernel_data, kernel_size,
-                                  constant_data, constant_data_size,
                                   prog_data, prog_data_size,
                                   stats, num_stats,
                                   xfb_info, bind_map);
index 46f64cfd8b2bacb877f29a539250c51f932a904c..f73b695ab99a2e51dd1dab69fcc98098850a167c 100644 (file)
@@ -1293,8 +1293,6 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
                                  gl_shader_stage stage,
                                  const void *key_data, uint32_t key_size,
                                  const void *kernel_data, uint32_t kernel_size,
-                                 const void *constant_data,
-                                 uint32_t constant_data_size,
                                  const struct brw_stage_prog_data *prog_data,
                                  uint32_t prog_data_size,
                                  const struct brw_compile_stats *stats,
@@ -1314,8 +1312,6 @@ anv_device_upload_kernel(struct anv_device *device,
                          gl_shader_stage stage,
                          const void *key_data, uint32_t key_size,
                          const void *kernel_data, uint32_t kernel_size,
-                         const void *constant_data,
-                         uint32_t constant_data_size,
                          const struct brw_stage_prog_data *prog_data,
                          uint32_t prog_data_size,
                          const struct brw_compile_stats *stats,
@@ -3351,9 +3347,6 @@ struct anv_shader_bin {
    struct anv_state kernel;
    uint32_t kernel_size;
 
-   struct anv_state constant_data;
-   uint32_t constant_data_size;
-
    const struct brw_stage_prog_data *prog_data;
    uint32_t prog_data_size;
 
@@ -3370,7 +3363,6 @@ anv_shader_bin_create(struct anv_device *device,
                       gl_shader_stage stage,
                       const void *key, uint32_t key_size,
                       const void *kernel, uint32_t kernel_size,
-                      const void *constant_data, uint32_t constant_data_size,
                       const struct brw_stage_prog_data *prog_data,
                       uint32_t prog_data_size,
                       const struct brw_compile_stats *stats, uint32_t num_stats,
index d65da902ce80700df485d663b86431a0ab69b43c..8bcb4f4affdc9e04b3586dafb27cbc0608aa8cfc 100644 (file)
@@ -2512,10 +2512,11 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
             anv_cmd_buffer_alloc_surface_state(cmd_buffer);
 
          struct anv_address constant_data = {
-            .bo = cmd_buffer->device->dynamic_state_pool.block_pool.bo,
-            .offset = shader->constant_data.offset,
+            .bo = cmd_buffer->device->instruction_state_pool.block_pool.bo,
+            .offset = shader->kernel.offset +
+                      shader->prog_data->const_data_offset,
          };
-         unsigned constant_data_size = shader->constant_data_size;
+         unsigned constant_data_size = shader->prog_data->const_data_size;
 
          const enum isl_format format =
             anv_isl_format_for_descriptor_type(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);