radeonsi: precompute si_*_descriptors_idx in si_shader_selector
authorMarek Olšák <marek.olsak@amd.com>
Sat, 15 Aug 2020 04:56:39 +0000 (00:56 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 3 Sep 2020 03:03:00 +0000 (23:03 -0400)
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>

src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_descriptors.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index e2320e7e1df71fd5d9681eeb39c810e72304b557..24e43410164b855817f71279d85006251e8c7160 100644 (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;
index c2219bf09b42e56483ff38792cfc11b96d3c62d6..27f2258d1f6894f208a5814ccc43b56d03d2e841 100644 (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);
 }
index fab54883ffdf8c8a97e4daf9475535ac8c4e72f1..9da7363d99e4f875756dcbc6384c333a12cdfaf7 100644 (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;
index 16a6f1fcc90ac35b28fb6a51dc2aaa3037dd88c6..b754b03ca95682e24833f9a2ab233408d49be1fd 100644 (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);