anv: allocate pipeline bindings tables dynamically on the heap

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28290>
This commit is contained in:
Lionel Landwerlin 2024-03-20 10:52:52 +02:00 committed by Marge Bot
parent 7730fa5683
commit 4fbdfdce9c

View file

@ -411,9 +411,6 @@ struct anv_pipeline_stage {
enum brw_robustness_flags robust_flags;
struct anv_pipeline_binding surface_to_descriptor[256];
struct anv_pipeline_binding sampler_to_descriptor[256];
struct anv_pipeline_embedded_sampler_binding embedded_sampler_to_binding[2048];
struct anv_pipeline_bind_map bind_map;
bool uses_bt_for_push_descs;
@ -434,6 +431,29 @@ struct anv_pipeline_stage {
struct anv_shader_bin *bin;
};
static void
anv_stage_allocate_bind_map_tables(struct anv_pipeline *pipeline,
struct anv_pipeline_stage *stage,
void *mem_ctx)
{
struct anv_pipeline_binding *surface_bindings =
brw_shader_stage_requires_bindless_resources(stage->stage) ? NULL :
rzalloc_array(mem_ctx, struct anv_pipeline_binding, 256);
struct anv_pipeline_binding *sampler_bindings =
brw_shader_stage_requires_bindless_resources(stage->stage) ? NULL :
rzalloc_array(mem_ctx, struct anv_pipeline_binding, 256);
struct anv_pipeline_embedded_sampler_binding *embedded_sampler_bindings =
rzalloc_array(mem_ctx, struct anv_pipeline_embedded_sampler_binding,
anv_pipeline_sets_layout_embedded_sampler_count(
&pipeline->layout));
stage->bind_map = (struct anv_pipeline_bind_map) {
.surface_to_descriptor = surface_bindings,
.sampler_to_descriptor = sampler_bindings,
.embedded_sampler_to_binding = embedded_sampler_bindings,
};
}
static enum brw_robustness_flags
anv_get_robust_flags(const struct vk_pipeline_robustness_state *rstate)
{
@ -2004,12 +2024,6 @@ anv_graphics_pipeline_load_nir(struct anv_graphics_base_pipeline *pipeline,
assert(stages[s].stage == s);
stages[s].bind_map = (struct anv_pipeline_bind_map) {
.surface_to_descriptor = stages[s].surface_to_descriptor,
.sampler_to_descriptor = stages[s].sampler_to_descriptor,
.embedded_sampler_to_binding = stages[s].embedded_sampler_to_binding,
};
/* Only use the create NIR from the pStages[] element if we don't have
* an imported library for the same stage.
*/
@ -2273,6 +2287,8 @@ anv_graphics_pipeline_compile(struct anv_graphics_base_pipeline *pipeline,
link_optimize, s))
continue;
anv_stage_allocate_bind_map_tables(&pipeline->base, &stages[s], tmp_ctx);
anv_pipeline_nir_preprocess(&pipeline->base, &stages[s]);
}
@ -2614,11 +2630,7 @@ anv_pipeline_compile_cs(struct anv_compute_pipeline *pipeline,
if (stage.bin == NULL) {
int64_t stage_start = os_time_get_nano();
stage.bind_map = (struct anv_pipeline_bind_map) {
.surface_to_descriptor = stage.surface_to_descriptor,
.sampler_to_descriptor = stage.sampler_to_descriptor,
.embedded_sampler_to_binding = stage.embedded_sampler_to_binding,
};
anv_stage_allocate_bind_map_tables(&pipeline->base, &stage, mem_ctx);
/* Set up a binding for the gl_NumWorkGroups */
stage.bind_map.surface_count = 1;
@ -3018,12 +3030,6 @@ anv_graphics_pipeline_import_lib(struct anv_graphics_base_pipeline *pipeline,
stages[s].subgroup_size_type = lib->retained_shaders[s].subgroup_size_type;
stages[s].imported.nir = lib->retained_shaders[s].nir;
stages[s].imported.bin = lib->base.shaders[s];
stages[s].bind_map = (struct anv_pipeline_bind_map) {
.surface_to_descriptor = stages[s].surface_to_descriptor,
.sampler_to_descriptor = stages[s].sampler_to_descriptor,
.embedded_sampler_to_binding = stages[s].embedded_sampler_to_binding,
};
}
/* When not link optimizing, import the executables (shader descriptions
@ -3551,8 +3557,8 @@ anv_pipeline_init_ray_tracing_stages(struct anv_ray_tracing_pipeline *pipeline,
},
};
stages[i].bind_map.embedded_sampler_to_binding =
stages[i].embedded_sampler_to_binding;
anv_stage_allocate_bind_map_tables(&pipeline->base, &stages[i],
tmp_pipeline_ctx);
pipeline->base.active_stages |= sinfo->stage;