#include "anv_private.h"
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)
{
const uint32_t binding_data_size =
return align_u32(sizeof(struct anv_shader_bin), 8) +
align_u32(prog_data_size, 8) +
+ align_u32(nr_params * sizeof(void *), 8) +
align_u32(sizeof(uint32_t) + key_size, 8) +
align_u32(binding_data_size, 8);
}
const void *key_data, uint32_t key_size,
const void *kernel_data, uint32_t kernel_size,
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 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);
struct anv_shader_bin *shader =
data += align_u32(sizeof(struct anv_shader_bin), 8);
shader->prog_data = data;
+ struct brw_stage_prog_data *new_prog_data = data;
memcpy(data, prog_data, prog_data_size);
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;
struct anv_shader_bin_key *key = data;
key->size = key_size;
anv_shader_bin_data_size(const struct anv_shader_bin *shader)
{
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.sampler_count) +
align_u32(shader->kernel_size, 8);
{
size_t struct_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.sampler_count);
anv_pipeline_cache_add_shader(struct anv_pipeline_cache *cache,
const void *key_data, uint32_t key_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)
{
struct anv_shader_bin *shader =
struct anv_shader_bin *bin =
anv_shader_bin_create(cache->device, key_data, key_size,
kernel_data, kernel_size,
- prog_data, prog_data_size, bind_map);
+ prog_data, prog_data_size, prog_data_param,
+ bind_map);
if (!bin)
return NULL;
struct anv_shader_bin *bin =
anv_pipeline_cache_add_shader(cache, key_data, key_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);
/* 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,
kernel_data, kernel_size,
- prog_data, prog_data_size, bind_map);
+ prog_data, prog_data_size,
+ prog_data->param, bind_map);
}
}
memcpy(&bin, p, sizeof(bin));
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);
+ 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;
if (p + sizeof(key) > end)
anv_pipeline_cache_add_shader(cache, key_data, key.size,
kernel_data, bin.kernel_size,
prog_data, bin.prog_data_size,
- &bin.bind_map);
+ prog_data_param, &bin.bind_map);
}
}