anv: using a single struct for kernel upload
A bit nicer than adding more and more arguments to the upload function. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: José Roberto de Souza <jose.souza@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27188>
This commit is contained in:

committed by
Marge Bot

parent
783e3c096f
commit
59b652f10f
@@ -60,19 +60,22 @@ upload_blorp_shader(struct blorp_batch *batch, uint32_t stage,
|
||||
struct blorp_context *blorp = batch->blorp;
|
||||
struct anv_device *device = blorp->driver_ctx;
|
||||
|
||||
struct anv_pipeline_bind_map bind_map = {
|
||||
.surface_count = 0,
|
||||
.sampler_count = 0,
|
||||
struct anv_pipeline_bind_map empty_bind_map = {};
|
||||
struct anv_push_descriptor_info empty_push_desc_info = {};
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = stage,
|
||||
.key_data = key,
|
||||
.key_size = key_size,
|
||||
.kernel_data = kernel,
|
||||
.kernel_size = kernel_size,
|
||||
.prog_data = prog_data,
|
||||
.prog_data_size = prog_data_size,
|
||||
.bind_map = &empty_bind_map,
|
||||
.push_desc_info = &empty_push_desc_info,
|
||||
};
|
||||
struct anv_push_descriptor_info push_desc_info = {};
|
||||
|
||||
struct anv_shader_bin *bin =
|
||||
anv_device_upload_kernel(device, device->internal_cache, stage,
|
||||
key, key_size, kernel, kernel_size,
|
||||
prog_data, prog_data_size,
|
||||
NULL, 0, NULL, &bind_map,
|
||||
&push_desc_info,
|
||||
0 /* dynamic_push_values */);
|
||||
anv_device_upload_kernel(device, device->internal_cache, &upload_params);
|
||||
|
||||
if (!bin)
|
||||
return false;
|
||||
|
@@ -302,21 +302,22 @@ compile_upload_spirv(struct anv_device *device,
|
||||
assert(stats.sends == sends_count_expectation);
|
||||
}
|
||||
|
||||
struct anv_pipeline_bind_map dummy_bind_map;
|
||||
memset(&dummy_bind_map, 0, sizeof(dummy_bind_map));
|
||||
|
||||
struct anv_push_descriptor_info push_desc_info = {};
|
||||
struct anv_pipeline_bind_map empty_bind_map = {};
|
||||
struct anv_push_descriptor_info empty_push_desc_info = {};
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = nir->info.stage,
|
||||
.key_data = hash_key,
|
||||
.key_size = hash_key_size,
|
||||
.kernel_data = program,
|
||||
.kernel_size = prog_data.base.program_size,
|
||||
.prog_data = &prog_data.base,
|
||||
.prog_data_size = sizeof(prog_data),
|
||||
.bind_map = &empty_bind_map,
|
||||
.push_desc_info = &empty_push_desc_info,
|
||||
};
|
||||
|
||||
struct anv_shader_bin *kernel =
|
||||
anv_device_upload_kernel(device,
|
||||
device->internal_cache,
|
||||
nir->info.stage,
|
||||
hash_key, hash_key_size, program,
|
||||
prog_data.base.program_size,
|
||||
&prog_data.base, sizeof(prog_data),
|
||||
NULL, 0, NULL, &dummy_bind_map,
|
||||
&push_desc_info,
|
||||
0 /* dynamic_push_values */);
|
||||
anv_device_upload_kernel(device, device->internal_cache, &upload_params);
|
||||
|
||||
ralloc_free(temp_ctx);
|
||||
ralloc_free(nir);
|
||||
|
@@ -2459,19 +2459,24 @@ anv_graphics_pipeline_compile(struct anv_graphics_base_pipeline *pipeline,
|
||||
anv_nir_validate_push_layout(&stage->prog_data.base,
|
||||
&stage->bind_map);
|
||||
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = s,
|
||||
.key_data = &stage->cache_key,
|
||||
.key_size = sizeof(stage->cache_key),
|
||||
.kernel_data = stage->code,
|
||||
.kernel_size = stage->prog_data.base.program_size,
|
||||
.prog_data = &stage->prog_data.base,
|
||||
.prog_data_size = brw_prog_data_size(s),
|
||||
.stats = stage->stats,
|
||||
.num_stats = stage->num_stats,
|
||||
.xfb_info = stage->nir->xfb_info,
|
||||
.bind_map = &stage->bind_map,
|
||||
.push_desc_info = &stage->push_desc_info,
|
||||
.dynamic_push_values = stage->dynamic_push_values,
|
||||
};
|
||||
|
||||
struct anv_shader_bin *bin =
|
||||
anv_device_upload_kernel(device, cache, s,
|
||||
&stage->cache_key,
|
||||
sizeof(stage->cache_key),
|
||||
stage->code,
|
||||
stage->prog_data.base.program_size,
|
||||
&stage->prog_data.base,
|
||||
brw_prog_data_size(s),
|
||||
stage->stats, stage->num_stats,
|
||||
stage->nir->xfb_info,
|
||||
&stage->bind_map,
|
||||
&stage->push_desc_info,
|
||||
stage->dynamic_push_values);
|
||||
anv_device_upload_kernel(device, cache, &upload_params);
|
||||
if (!bin) {
|
||||
ralloc_free(stage_ctx);
|
||||
result = vk_error(pipeline, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
@@ -2651,17 +2656,22 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
|
||||
stage.bind_map.surface_to_descriptor[0].set = ANV_DESCRIPTOR_SET_NULL;
|
||||
}
|
||||
|
||||
const unsigned code_size = stage.prog_data.base.program_size;
|
||||
bin = anv_device_upload_kernel(device, cache,
|
||||
MESA_SHADER_COMPUTE,
|
||||
&stage.cache_key, sizeof(stage.cache_key),
|
||||
stage.code, code_size,
|
||||
&stage.prog_data.base,
|
||||
sizeof(stage.prog_data.cs),
|
||||
stage.stats, stage.num_stats,
|
||||
NULL, &stage.bind_map,
|
||||
&stage.push_desc_info,
|
||||
stage.dynamic_push_values);
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = MESA_SHADER_COMPUTE,
|
||||
.key_data = &stage.cache_key,
|
||||
.key_size = sizeof(stage.cache_key),
|
||||
.kernel_data = stage.code,
|
||||
.kernel_size = stage.prog_data.base.program_size,
|
||||
.prog_data = &stage.prog_data.base,
|
||||
.prog_data_size = sizeof(stage.prog_data.cs),
|
||||
.stats = stage.stats,
|
||||
.num_stats = stage.num_stats,
|
||||
.bind_map = &stage.bind_map,
|
||||
.push_desc_info = &stage.push_desc_info,
|
||||
.dynamic_push_values = stage.dynamic_push_values,
|
||||
};
|
||||
|
||||
bin = anv_device_upload_kernel(device, cache, &upload_params);
|
||||
if (!bin) {
|
||||
ralloc_free(mem_ctx);
|
||||
return vk_error(pipeline, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
@@ -3378,19 +3388,23 @@ compile_upload_rt_shader(struct anv_ray_tracing_pipeline *pipeline,
|
||||
/* Ray-tracing shaders don't have a "real" bind map */
|
||||
struct anv_pipeline_bind_map empty_bind_map = {};
|
||||
|
||||
const unsigned code_size = stage->prog_data.base.program_size;
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = stage->stage,
|
||||
.key_data = &stage->cache_key,
|
||||
.key_size = sizeof(stage->cache_key),
|
||||
.kernel_data = stage->code,
|
||||
.kernel_size = stage->prog_data.base.program_size,
|
||||
.prog_data = &stage->prog_data.base,
|
||||
.prog_data_size = brw_prog_data_size(stage->stage),
|
||||
.stats = stage->stats,
|
||||
.num_stats = 1,
|
||||
.bind_map = &empty_bind_map,
|
||||
.push_desc_info = &stage->push_desc_info,
|
||||
.dynamic_push_values = stage->dynamic_push_values,
|
||||
};
|
||||
|
||||
struct anv_shader_bin *bin =
|
||||
anv_device_upload_kernel(pipeline->base.device,
|
||||
cache,
|
||||
stage->stage,
|
||||
&stage->cache_key, sizeof(stage->cache_key),
|
||||
stage->code, code_size,
|
||||
&stage->prog_data.base,
|
||||
sizeof(stage->prog_data.bs),
|
||||
stage->stats, 1,
|
||||
NULL, &empty_bind_map,
|
||||
&stage->push_desc_info,
|
||||
stage->dynamic_push_values);
|
||||
anv_device_upload_kernel(pipeline->base.device, cache, &upload_params);
|
||||
if (bin == NULL)
|
||||
return vk_error(pipeline, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
@@ -3823,6 +3837,8 @@ anv_device_init_rt_shaders(struct anv_device *device)
|
||||
|
||||
bool cache_hit;
|
||||
|
||||
struct anv_push_descriptor_info empty_push_desc_info = {};
|
||||
struct anv_pipeline_bind_map empty_bind_map = {};
|
||||
struct brw_rt_trampoline {
|
||||
char name[16];
|
||||
struct brw_cs_prog_key key;
|
||||
@@ -3841,11 +3857,6 @@ anv_device_init_rt_shaders(struct anv_device *device)
|
||||
|
||||
trampoline_nir->info.subgroup_size = SUBGROUP_SIZE_REQUIRE_16;
|
||||
|
||||
struct anv_push_descriptor_info push_desc_info = {};
|
||||
struct anv_pipeline_bind_map bind_map = {
|
||||
.surface_count = 0,
|
||||
.sampler_count = 0,
|
||||
};
|
||||
uint32_t dummy_params[4] = { 0, };
|
||||
struct brw_cs_prog_data trampoline_prog_data = {
|
||||
.base.nr_params = 4,
|
||||
@@ -3865,17 +3876,21 @@ anv_device_init_rt_shaders(struct anv_device *device)
|
||||
const unsigned *tramp_data =
|
||||
brw_compile_cs(device->physical->compiler, ¶ms);
|
||||
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = MESA_SHADER_COMPUTE,
|
||||
.key_data = &trampoline_key,
|
||||
.key_size = sizeof(trampoline_key),
|
||||
.kernel_data = tramp_data,
|
||||
.kernel_size = trampoline_prog_data.base.program_size,
|
||||
.prog_data = &trampoline_prog_data.base,
|
||||
.prog_data_size = sizeof(trampoline_prog_data),
|
||||
.bind_map = &empty_bind_map,
|
||||
.push_desc_info = &empty_push_desc_info,
|
||||
};
|
||||
|
||||
device->rt_trampoline =
|
||||
anv_device_upload_kernel(device, device->internal_cache,
|
||||
MESA_SHADER_COMPUTE,
|
||||
&trampoline_key, sizeof(trampoline_key),
|
||||
tramp_data,
|
||||
trampoline_prog_data.base.program_size,
|
||||
&trampoline_prog_data.base,
|
||||
sizeof(trampoline_prog_data),
|
||||
NULL, 0, NULL, &bind_map,
|
||||
&push_desc_info,
|
||||
0 /* dynamic_push_values */);
|
||||
&upload_params);
|
||||
|
||||
ralloc_free(tmp_ctx);
|
||||
|
||||
@@ -3905,11 +3920,6 @@ anv_device_init_rt_shaders(struct anv_device *device)
|
||||
|
||||
NIR_PASS_V(trivial_return_nir, brw_nir_lower_rt_intrinsics, device->info);
|
||||
|
||||
struct anv_push_descriptor_info push_desc_info = {};
|
||||
struct anv_pipeline_bind_map bind_map = {
|
||||
.surface_count = 0,
|
||||
.sampler_count = 0,
|
||||
};
|
||||
struct brw_bs_prog_data return_prog_data = { 0, };
|
||||
struct brw_compile_bs_params params = {
|
||||
.base = {
|
||||
@@ -3923,15 +3933,21 @@ anv_device_init_rt_shaders(struct anv_device *device)
|
||||
const unsigned *return_data =
|
||||
brw_compile_bs(device->physical->compiler, ¶ms);
|
||||
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = MESA_SHADER_CALLABLE,
|
||||
.key_data = &return_key,
|
||||
.key_size = sizeof(return_key),
|
||||
.kernel_data = return_data,
|
||||
.kernel_size = return_prog_data.base.program_size,
|
||||
.prog_data = &return_prog_data.base,
|
||||
.prog_data_size = sizeof(return_prog_data),
|
||||
.bind_map = &empty_bind_map,
|
||||
.push_desc_info = &empty_push_desc_info,
|
||||
};
|
||||
|
||||
device->rt_trivial_return =
|
||||
anv_device_upload_kernel(device, device->internal_cache,
|
||||
MESA_SHADER_CALLABLE,
|
||||
&return_key, sizeof(return_key),
|
||||
return_data, return_prog_data.base.program_size,
|
||||
&return_prog_data.base, sizeof(return_prog_data),
|
||||
NULL, 0, NULL, &bind_map,
|
||||
&push_desc_info,
|
||||
0 /* dynamic_push_values */);
|
||||
&upload_params);
|
||||
|
||||
ralloc_free(tmp_ctx);
|
||||
|
||||
|
@@ -386,31 +386,27 @@ anv_device_search_for_kernel(struct anv_device *device,
|
||||
struct anv_shader_bin *
|
||||
anv_device_upload_kernel(struct anv_device *device,
|
||||
struct vk_pipeline_cache *cache,
|
||||
gl_shader_stage stage,
|
||||
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,
|
||||
const struct brw_compile_stats *stats,
|
||||
uint32_t num_stats,
|
||||
const nir_xfb_info *xfb_info,
|
||||
const struct anv_pipeline_bind_map *bind_map,
|
||||
const struct anv_push_descriptor_info *push_desc_info,
|
||||
enum anv_dynamic_push_bits dynamic_push_values)
|
||||
const struct anv_shader_upload_params *params)
|
||||
{
|
||||
/* Use the default pipeline cache if none is specified */
|
||||
if (cache == NULL)
|
||||
cache = device->default_pipeline_cache;
|
||||
|
||||
struct anv_shader_bin *shader =
|
||||
anv_shader_bin_create(device, stage,
|
||||
key_data, key_size,
|
||||
kernel_data, kernel_size,
|
||||
prog_data, prog_data_size,
|
||||
stats, num_stats,
|
||||
xfb_info, bind_map,
|
||||
push_desc_info,
|
||||
dynamic_push_values);
|
||||
anv_shader_bin_create(device,
|
||||
params->stage,
|
||||
params->key_data,
|
||||
params->key_size,
|
||||
params->kernel_data,
|
||||
params->kernel_size,
|
||||
params->prog_data,
|
||||
params->prog_data_size,
|
||||
params->stats,
|
||||
params->num_stats,
|
||||
params->xfb_info,
|
||||
params->bind_map,
|
||||
params->push_desc_info,
|
||||
params->dynamic_push_values);
|
||||
if (shader == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@@ -1239,20 +1239,12 @@ anv_device_search_for_kernel(struct anv_device *device,
|
||||
const void *key_data, uint32_t key_size,
|
||||
bool *user_cache_bit);
|
||||
|
||||
struct anv_shader_upload_params;
|
||||
|
||||
struct anv_shader_bin *
|
||||
anv_device_upload_kernel(struct anv_device *device,
|
||||
struct vk_pipeline_cache *cache,
|
||||
gl_shader_stage stage,
|
||||
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,
|
||||
const struct brw_compile_stats *stats,
|
||||
uint32_t num_stats,
|
||||
const struct nir_xfb_info *xfb_info,
|
||||
const struct anv_pipeline_bind_map *bind_map,
|
||||
const struct anv_push_descriptor_info *push_desc_info,
|
||||
enum anv_dynamic_push_bits dynamic_push_values);
|
||||
const struct anv_shader_upload_params *params);
|
||||
|
||||
struct nir_shader;
|
||||
struct nir_shader_compiler_options;
|
||||
@@ -4179,6 +4171,30 @@ enum anv_dynamic_push_bits {
|
||||
ANV_DYNAMIC_PUSH_INPUT_VERTICES = BITFIELD_BIT(0),
|
||||
};
|
||||
|
||||
struct anv_shader_upload_params {
|
||||
gl_shader_stage stage;
|
||||
|
||||
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;
|
||||
|
||||
const struct brw_compile_stats *stats;
|
||||
uint32_t num_stats;
|
||||
|
||||
const struct nir_xfb_info *xfb_info;
|
||||
|
||||
const struct anv_pipeline_bind_map *bind_map;
|
||||
|
||||
const struct anv_push_descriptor_info *push_desc_info;
|
||||
|
||||
enum anv_dynamic_push_bits dynamic_push_values;
|
||||
};
|
||||
|
||||
struct anv_shader_bin {
|
||||
struct vk_pipeline_cache_object base;
|
||||
|
||||
|
@@ -45,23 +45,27 @@ get_shader_bin(struct anv_device *device,
|
||||
assert(kernel_data.prog_data.base.nr_params <= ARRAY_SIZE(dummy_param));
|
||||
kernel_data.prog_data.base.param = dummy_param;
|
||||
|
||||
struct anv_push_descriptor_info push_desc_info = {};
|
||||
struct anv_push_descriptor_info empty_push_desc_info = {};
|
||||
struct anv_pipeline_bind_map bind_map = {
|
||||
.kernel_args_size = kernel_data.args_size,
|
||||
.kernel_arg_count = kernel_data.arg_count,
|
||||
.kernel_args = (struct brw_kernel_arg_desc *)kernel_data.args,
|
||||
};
|
||||
|
||||
struct anv_shader_upload_params upload_params = {
|
||||
.stage = MESA_SHADER_KERNEL,
|
||||
.key_data = key,
|
||||
.key_size = key_len,
|
||||
.kernel_data = kernel_data.code,
|
||||
.kernel_size = kernel_data.prog_data.base.program_size,
|
||||
.prog_data = &kernel_data.prog_data.base,
|
||||
.prog_data_size = sizeof(kernel_data.prog_data),
|
||||
.bind_map = &bind_map,
|
||||
.push_desc_info = &empty_push_desc_info,
|
||||
};
|
||||
|
||||
bin = anv_device_upload_kernel(device, device->internal_cache,
|
||||
MESA_SHADER_KERNEL,
|
||||
key, key_len,
|
||||
kernel_data.code,
|
||||
kernel_data.prog_data.base.program_size,
|
||||
&kernel_data.prog_data.base,
|
||||
sizeof(kernel_data.prog_data),
|
||||
NULL, 0, NULL, &bind_map,
|
||||
&push_desc_info,
|
||||
0 /* dynamic_push_values */);
|
||||
&upload_params);
|
||||
|
||||
/* The cache already has a reference and it's not going anywhere so there
|
||||
* is no need to hold a second reference.
|
||||
|
Reference in New Issue
Block a user