radeonsi: precompute si_*_descriptors_idx in si_shader_selector

It helps remove one use of sel->type.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6340>
This commit is contained in:
Marek Olšák 2020-08-15 00:56:39 -04:00
parent cbfc13b27c
commit 966307983b
4 changed files with 13 additions and 2 deletions

View file

@ -238,6 +238,10 @@ static void *si_create_compute_state(struct pipe_context *ctx, const struct pipe
sel->info.stage = MESA_SHADER_COMPUTE;
sel->type = PIPE_SHADER_COMPUTE;
sel->screen = sscreen;
sel->const_and_shader_buf_descriptors_index =
si_const_and_shader_buffer_descriptors_idx(sel->type);
sel->sampler_and_images_descriptors_index =
si_sampler_and_image_descriptors_idx(sel->type);
program->shader.selector = &program->sel;
program->ir_type = cso->ir_type;
program->local_size = cso->req_local_mem;

View file

@ -2916,8 +2916,8 @@ void si_set_active_descriptors_for_shader(struct si_context *sctx, struct si_sha
if (!sel)
return;
si_set_active_descriptors(sctx, si_const_and_shader_buffer_descriptors_idx(sel->type),
si_set_active_descriptors(sctx, sel->const_and_shader_buf_descriptors_index,
sel->active_const_and_shader_buffers);
si_set_active_descriptors(sctx, si_sampler_and_image_descriptors_idx(sel->type),
si_set_active_descriptors(sctx, sel->sampler_and_images_descriptors_index,
sel->active_samplers_and_images);
}

View file

@ -433,6 +433,8 @@ struct si_shader_selector {
/* PIPE_SHADER_[VERTEX|FRAGMENT|...] */
enum pipe_shader_type type;
ubyte const_and_shader_buf_descriptors_index;
ubyte sampler_and_images_descriptors_index;
bool vs_needs_prolog;
bool prim_discard_cs_allowed;
bool ngg_culling_allowed;

View file

@ -2604,6 +2604,11 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
si_nir_scan_shader(sel->nir, &sel->info);
sel->type = pipe_shader_type_from_mesa(sel->info.stage);
sel->const_and_shader_buf_descriptors_index =
si_const_and_shader_buffer_descriptors_idx(sel->type);
sel->sampler_and_images_descriptors_index =
si_sampler_and_image_descriptors_idx(sel->type);
p_atomic_inc(&sscreen->num_shaders_created);
si_get_active_slot_masks(&sel->info, &sel->active_const_and_shader_buffers,
&sel->active_samplers_and_images);