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 anv_pipeline_bind_map *bind_map)
if (cache) {
return anv_pipeline_cache_upload_kernel(cache, key_data, key_size,
kernel_data, kernel_size,
+ constant_data, constant_data_size,
prog_data, prog_data_size,
bind_map);
} else {
return anv_shader_bin_create(pipeline->device, key_data, key_size,
kernel_data, kernel_size,
+ constant_data, constant_data_size,
prog_data, prog_data_size,
prog_data->param, bind_map);
}
unsigned code_size = prog_data.base.base.program_size;
bin = anv_pipeline_upload_kernel(pipeline, cache, sha1, 20,
shader_code, code_size,
+ nir->constant_data,
+ nir->constant_data_size,
&prog_data.base.base, sizeof(prog_data),
&map);
if (!bin) {
tcs_bin = anv_pipeline_upload_kernel(pipeline, cache,
tcs_sha1, sizeof(tcs_sha1),
shader_code, code_size,
+ tcs_nir->constant_data,
+ tcs_nir->constant_data_size,
&tcs_prog_data.base.base,
sizeof(tcs_prog_data),
&tcs_map);
tes_bin = anv_pipeline_upload_kernel(pipeline, cache,
tes_sha1, sizeof(tes_sha1),
shader_code, code_size,
+ tes_nir->constant_data,
+ tes_nir->constant_data_size,
&tes_prog_data.base.base,
sizeof(tes_prog_data),
&tes_map);
const unsigned code_size = prog_data.base.base.program_size;
bin = anv_pipeline_upload_kernel(pipeline, cache, sha1, 20,
shader_code, code_size,
+ nir->constant_data,
+ nir->constant_data_size,
&prog_data.base.base, sizeof(prog_data),
&map);
if (!bin) {
unsigned code_size = prog_data.base.program_size;
bin = anv_pipeline_upload_kernel(pipeline, cache, sha1, 20,
shader_code, code_size,
+ nir->constant_data,
+ nir->constant_data_size,
&prog_data.base, sizeof(prog_data),
&map);
if (!bin) {
const unsigned code_size = prog_data.base.program_size;
bin = anv_pipeline_upload_kernel(pipeline, cache, sha1, 20,
shader_code, code_size,
+ nir->constant_data,
+ nir->constant_data_size,
&prog_data.base, sizeof(prog_data),
&map);
if (!bin) {
anv_shader_bin_create(struct anv_device *device,
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 void *prog_data_param_in,
const struct anv_pipeline_bind_map *bind_map)
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);
memcpy(prog_data_param, prog_data_param_in,
prog_data->nr_params * sizeof(*prog_data_param));
{
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->alloc, shader);
}
ok = blob_write_uint32(blob, shader->kernel_size);
ok = blob_write_bytes(blob, shader->kernel.map, shader->kernel_size);
+ ok = blob_write_uint32(blob, shader->constant_data_size);
+ ok = blob_write_bytes(blob, shader->constant_data.map,
+ shader->constant_data_size);
+
ok = blob_write_uint32(blob, shader->prog_data_size);
ok = blob_write_bytes(blob, shader->prog_data, shader->prog_data_size);
ok = blob_write_bytes(blob, shader->prog_data->param,
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);
return anv_shader_bin_create(device,
key_data, key_size,
kernel_data, kernel_size,
+ constant_data, constant_data_size,
prog_data, prog_data_size, prog_data_param,
&bind_map);
}
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 *constant_data,
+ uint32_t constant_data_size,
const struct brw_stage_prog_data *prog_data,
uint32_t prog_data_size,
const void *prog_data_param,
struct anv_shader_bin *bin =
anv_shader_bin_create(cache->device, key_data, key_size,
kernel_data, kernel_size,
+ constant_data, constant_data_size,
prog_data, prog_data_size, prog_data_param,
bind_map);
if (!bin)
anv_pipeline_cache_upload_kernel(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 anv_pipeline_bind_map *bind_map)
struct anv_shader_bin *bin =
anv_pipeline_cache_add_shader(cache, key_data, key_size,
kernel_data, kernel_size,
+ constant_data, constant_data_size,
prog_data, prog_data_size,
prog_data->param, bind_map);
/* 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,
+ constant_data, constant_data_size,
prog_data, prog_data_size,
prog_data->param, bind_map);
}
anv_pipeline_cache_upload_kernel(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 anv_pipeline_bind_map *bind_map);
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;
anv_shader_bin_create(struct anv_device *device,
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 void *prog_data_param,
const struct anv_pipeline_bind_map *bind_map);