From: Marek Olšák Date: Sat, 15 Aug 2020 04:56:39 +0000 (-0400) Subject: radeonsi: precompute si_*_descriptors_idx in si_shader_selector X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=966307983bda3fc6141a33bb5300a91fd15d5551;p=mesa.git radeonsi: precompute si_*_descriptors_idx in si_shader_selector It helps remove one use of sel->type. Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c index e2320e7e1df..24e43410164 100644 --- a/src/gallium/drivers/radeonsi/si_compute.c +++ b/src/gallium/drivers/radeonsi/si_compute.c @@ -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; diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index c2219bf09b4..27f2258d1f6 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -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); } diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index fab54883ffd..9da7363d99e 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -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; diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 16a6f1fcc90..b754b03ca95 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -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);