diff options
author | Jason Ekstrand <[email protected]> | 2016-06-04 15:10:22 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-06-06 00:44:32 -0700 |
commit | ffcef720b74737b07086db86f34aa2f4b8c58a50 (patch) | |
tree | 111f9ca709111919f1a3f9c5d0b5fcd5f05bcb86 /src/intel | |
parent | 78659ade404a0761968ab5240c812e4c3119d669 (diff) |
anv/pipeline: Add support for caching the push constant map
Signed-off-by: Jason Ekstrand <[email protected]>
Reviewed-by: Kristian Høgsberg <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/vulkan/anv_pipeline_cache.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/intel/vulkan/anv_pipeline_cache.c b/src/intel/vulkan/anv_pipeline_cache.c index 62dbe3eda74..f75c4233d47 100644 --- a/src/intel/vulkan/anv_pipeline_cache.c +++ b/src/intel/vulkan/anv_pipeline_cache.c @@ -89,11 +89,15 @@ entry_size(struct cache_entry *entry) * doesn't include the alignment padding bytes. */ + struct brw_stage_prog_data *prog_data = (void *)entry->prog_data; + const uint32_t param_size = + prog_data->nr_params * sizeof(*prog_data->param); + const uint32_t map_size = entry->surface_count * sizeof(struct anv_pipeline_binding) + entry->sampler_count * sizeof(struct anv_pipeline_binding); - return sizeof(*entry) + entry->prog_data_size + map_size; + return sizeof(*entry) + entry->prog_data_size + param_size + map_size; } void @@ -141,6 +145,7 @@ anv_pipeline_cache_search_unlocked(struct anv_pipeline_cache *cache, void *p = entry->prog_data; *prog_data = p; p += entry->prog_data_size; + p += (*prog_data)->nr_params * sizeof(*(*prog_data)->param); map->surface_count = entry->surface_count; map->sampler_count = entry->sampler_count; map->image_count = entry->image_count; @@ -267,12 +272,18 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache, struct cache_entry *entry; + assert((*prog_data)->nr_pull_params == 0); + assert((*prog_data)->nr_image_params == 0); + + const uint32_t param_size = + (*prog_data)->nr_params * sizeof(*(*prog_data)->param); + const uint32_t map_size = map->surface_count * sizeof(struct anv_pipeline_binding) + map->sampler_count * sizeof(struct anv_pipeline_binding); const uint32_t preamble_size = - align_u32(sizeof(*entry) + prog_data_size + map_size, 64); + align_u32(sizeof(*entry) + prog_data_size + param_size + map_size, 64); const uint32_t size = preamble_size + kernel_size; @@ -291,6 +302,10 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache, memcpy(p, *prog_data, prog_data_size); p += prog_data_size; + memcpy(p, (*prog_data)->param, param_size); + ((struct brw_stage_prog_data *)entry->prog_data)->param = p; + p += param_size; + memcpy(p, map->surface_to_descriptor, map->surface_count * sizeof(struct anv_pipeline_binding)); map->surface_to_descriptor = p; @@ -358,9 +373,17 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache, struct cache_entry *entry = p; void *data = entry->prog_data; - const struct brw_stage_prog_data *prog_data = data; + + /* Make a copy of prog_data so that it's mutable */ + uint8_t prog_data_tmp[512]; + assert(entry->prog_data_size <= sizeof(prog_data_tmp)); + memcpy(prog_data_tmp, data, entry->prog_data_size); + struct brw_stage_prog_data *prog_data = (void *)prog_data_tmp; data += entry->prog_data_size; + prog_data->param = data; + data += prog_data->nr_params * sizeof(*prog_data->param); + struct anv_pipeline_binding *surface_to_descriptor = data; data += entry->surface_count * sizeof(struct anv_pipeline_binding); struct anv_pipeline_binding *sampler_to_descriptor = data; @@ -375,9 +398,11 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache, .sampler_to_descriptor = sampler_to_descriptor }; + const struct brw_stage_prog_data *const_prog_data = prog_data; + anv_pipeline_cache_upload_kernel(cache, entry->sha1, kernel, entry->kernel_size, - &prog_data, + &const_prog_data, entry->prog_data_size, &map); p = kernel + entry->kernel_size; } |