anv/pipeline: Properly cache prog_data::param

Before we were caching the prog data but we weren't doing anything with
brw_stage_prog_data::param so anything with push constants wasn't getting
cached properly.  This commit fixes that.

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98012
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Cc: "13.0" <mesa-stable@lists.freedesktop.org>
This commit is contained in:
Jason Ekstrand
2016-11-01 15:10:29 -07:00
parent ff3185e3ba
commit 71cc1e188d
3 changed files with 36 additions and 14 deletions

View File

@@ -400,7 +400,8 @@ anv_pipeline_upload_kernel(struct anv_pipeline *pipeline,
} else { } else {
return anv_shader_bin_create(pipeline->device, key_data, key_size, return anv_shader_bin_create(pipeline->device, key_data, key_size,
kernel_data, kernel_size, kernel_data, kernel_size,
prog_data, prog_data_size, bind_map); prog_data, prog_data_size,
prog_data->param, bind_map);
} }
} }

View File

@@ -27,7 +27,8 @@
#include "anv_private.h" #include "anv_private.h"
static size_t static size_t
anv_shader_bin_size(uint32_t prog_data_size, uint32_t key_size, anv_shader_bin_size(uint32_t prog_data_size, uint32_t nr_params,
uint32_t key_size,
uint32_t surface_count, uint32_t sampler_count) uint32_t surface_count, uint32_t sampler_count)
{ {
const uint32_t binding_data_size = const uint32_t binding_data_size =
@@ -35,6 +36,7 @@ anv_shader_bin_size(uint32_t prog_data_size, uint32_t key_size,
return align_u32(sizeof(struct anv_shader_bin), 8) + return align_u32(sizeof(struct anv_shader_bin), 8) +
align_u32(prog_data_size, 8) + align_u32(prog_data_size, 8) +
align_u32(nr_params * sizeof(void *), 8) +
align_u32(sizeof(uint32_t) + key_size, 8) + align_u32(sizeof(uint32_t) + key_size, 8) +
align_u32(binding_data_size, 8); align_u32(binding_data_size, 8);
} }
@@ -44,11 +46,11 @@ anv_shader_bin_create(struct anv_device *device,
const void *key_data, uint32_t key_size, const void *key_data, uint32_t key_size,
const void *kernel_data, uint32_t kernel_size, const void *kernel_data, uint32_t kernel_size,
const struct brw_stage_prog_data *prog_data, const struct brw_stage_prog_data *prog_data,
uint32_t prog_data_size, uint32_t prog_data_size, const void *prog_data_param,
const struct anv_pipeline_bind_map *bind_map) const struct anv_pipeline_bind_map *bind_map)
{ {
const size_t size = const size_t size =
anv_shader_bin_size(prog_data_size, key_size, anv_shader_bin_size(prog_data_size, prog_data->nr_params, key_size,
bind_map->surface_count, bind_map->sampler_count); bind_map->surface_count, bind_map->sampler_count);
struct anv_shader_bin *shader = struct anv_shader_bin *shader =
@@ -70,9 +72,17 @@ anv_shader_bin_create(struct anv_device *device,
data += align_u32(sizeof(struct anv_shader_bin), 8); data += align_u32(sizeof(struct anv_shader_bin), 8);
shader->prog_data = data; shader->prog_data = data;
struct brw_stage_prog_data *new_prog_data = data;
memcpy(data, prog_data, prog_data_size); memcpy(data, prog_data, prog_data_size);
data += align_u32(prog_data_size, 8); data += align_u32(prog_data_size, 8);
assert(prog_data->nr_pull_params == 0);
assert(prog_data->nr_image_params == 0);
new_prog_data->param = data;
uint32_t param_size = prog_data->nr_params * sizeof(void *);
memcpy(data, prog_data_param, param_size);
data += align_u32(param_size, 8);
shader->key = data; shader->key = data;
struct anv_shader_bin_key *key = data; struct anv_shader_bin_key *key = data;
key->size = key_size; key->size = key_size;
@@ -104,7 +114,7 @@ static size_t
anv_shader_bin_data_size(const struct anv_shader_bin *shader) anv_shader_bin_data_size(const struct anv_shader_bin *shader)
{ {
return anv_shader_bin_size(shader->prog_data_size, return anv_shader_bin_size(shader->prog_data_size,
shader->key->size, shader->prog_data->nr_params, shader->key->size,
shader->bind_map.surface_count, shader->bind_map.surface_count,
shader->bind_map.sampler_count) + shader->bind_map.sampler_count) +
align_u32(shader->kernel_size, 8); align_u32(shader->kernel_size, 8);
@@ -115,7 +125,7 @@ anv_shader_bin_write_data(const struct anv_shader_bin *shader, void *data)
{ {
size_t struct_size = size_t struct_size =
anv_shader_bin_size(shader->prog_data_size, anv_shader_bin_size(shader->prog_data_size,
shader->key->size, shader->prog_data->nr_params, shader->key->size,
shader->bind_map.surface_count, shader->bind_map.surface_count,
shader->bind_map.sampler_count); shader->bind_map.sampler_count);
@@ -255,7 +265,9 @@ static struct anv_shader_bin *
anv_pipeline_cache_add_shader(struct anv_pipeline_cache *cache, anv_pipeline_cache_add_shader(struct anv_pipeline_cache *cache,
const void *key_data, uint32_t key_size, const void *key_data, uint32_t key_size,
const void *kernel_data, uint32_t kernel_size, const void *kernel_data, uint32_t kernel_size,
const void *prog_data, uint32_t prog_data_size, const struct brw_stage_prog_data *prog_data,
uint32_t prog_data_size,
const void *prog_data_param,
const struct anv_pipeline_bind_map *bind_map) const struct anv_pipeline_bind_map *bind_map)
{ {
struct anv_shader_bin *shader = struct anv_shader_bin *shader =
@@ -266,7 +278,8 @@ anv_pipeline_cache_add_shader(struct anv_pipeline_cache *cache,
struct anv_shader_bin *bin = struct anv_shader_bin *bin =
anv_shader_bin_create(cache->device, key_data, key_size, anv_shader_bin_create(cache->device, key_data, key_size,
kernel_data, kernel_size, kernel_data, kernel_size,
prog_data, prog_data_size, bind_map); prog_data, prog_data_size, prog_data_param,
bind_map);
if (!bin) if (!bin)
return NULL; return NULL;
@@ -289,7 +302,8 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
struct anv_shader_bin *bin = struct anv_shader_bin *bin =
anv_pipeline_cache_add_shader(cache, key_data, key_size, anv_pipeline_cache_add_shader(cache, key_data, key_size,
kernel_data, kernel_size, kernel_data, kernel_size,
prog_data, prog_data_size, bind_map); prog_data, prog_data_size,
prog_data->param, bind_map);
pthread_mutex_unlock(&cache->mutex); pthread_mutex_unlock(&cache->mutex);
@@ -301,7 +315,8 @@ anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache *cache,
/* In this case, we're not caching it so the caller owns it entirely */ /* In this case, we're not caching it so the caller owns it entirely */
return anv_shader_bin_create(cache->device, key_data, key_size, return anv_shader_bin_create(cache->device, key_data, key_size,
kernel_data, kernel_size, kernel_data, kernel_size,
prog_data, prog_data_size, bind_map); prog_data, prog_data_size,
prog_data->param, bind_map);
} }
} }
@@ -356,8 +371,14 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
memcpy(&bin, p, sizeof(bin)); memcpy(&bin, p, sizeof(bin));
p += align_u32(sizeof(struct anv_shader_bin), 8); p += align_u32(sizeof(struct anv_shader_bin), 8);
const void *prog_data = p; const struct brw_stage_prog_data *prog_data = p;
p += align_u32(bin.prog_data_size, 8); p += align_u32(bin.prog_data_size, 8);
if (p > end)
break;
uint32_t param_size = prog_data->nr_params * sizeof(void *);
const void *prog_data_param = p;
p += align_u32(param_size, 8);
struct anv_shader_bin_key key; struct anv_shader_bin_key key;
if (p + sizeof(key) > end) if (p + sizeof(key) > end)
@@ -382,7 +403,7 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
anv_pipeline_cache_add_shader(cache, key_data, key.size, anv_pipeline_cache_add_shader(cache, key_data, key.size,
kernel_data, bin.kernel_size, kernel_data, bin.kernel_size,
prog_data, bin.prog_data_size, prog_data, bin.prog_data_size,
&bin.bind_map); prog_data_param, &bin.bind_map);
} }
} }

View File

@@ -1316,7 +1316,7 @@ struct anv_shader_bin {
struct anv_pipeline_bind_map bind_map; struct anv_pipeline_bind_map bind_map;
/* Prog data follows, then the key, both aligned to 8-bytes */ /* Prog data follows, then params, then the key, all aligned to 8-bytes */
}; };
struct anv_shader_bin * struct anv_shader_bin *
@@ -1324,7 +1324,7 @@ anv_shader_bin_create(struct anv_device *device,
const void *key, uint32_t key_size, const void *key, uint32_t key_size,
const void *kernel, uint32_t kernel_size, const void *kernel, uint32_t kernel_size,
const struct brw_stage_prog_data *prog_data, const struct brw_stage_prog_data *prog_data,
uint32_t prog_data_size, uint32_t prog_data_size, const void *prog_data_param,
const struct anv_pipeline_bind_map *bind_map); const struct anv_pipeline_bind_map *bind_map);
void void