radeonsi: track use of bindless samplers/images from tgsi_shader_info
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 16 May 2017 10:25:28 +0000 (12:25 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 14 Jun 2017 08:04:36 +0000 (10:04 +0200)
This adds some new helper functions to know if the current draw
call (or dispatch compute) is using bindless samplers/images,
based on TGSI analysis.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_compute.h
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index 0338b8a1234ca142de3a101b955955de5f2649de..79b107e96fc6f9dd5f5c75711971eb6e18b697f5 100644 (file)
@@ -108,6 +108,8 @@ static void si_create_compute_state_async(void *job, int thread_index)
        program->shader.is_monolithic = true;
        program->uses_grid_size = sel.info.uses_grid_size;
        program->uses_block_size = sel.info.uses_block_size;
+       program->uses_bindless_samplers = sel.info.uses_bindless_samplers;
+       program->uses_bindless_images = sel.info.uses_bindless_images;
 
        if (si_shader_create(program->screen, tm, &program->shader, debug)) {
                program->shader.compilation_failed = true;
index 764d708c4fb0a8f50895ca34de7d786af711e1ad..268817b23a6e6ed9e5a207d7710b3663b769e079 100644 (file)
@@ -49,6 +49,8 @@ struct si_compute {
        unsigned variable_group_size : 1;
        unsigned uses_grid_size:1;
        unsigned uses_block_size:1;
+       unsigned uses_bindless_samplers:1;
+       unsigned uses_bindless_images:1;
 };
 
 #endif /* SI_COMPUTE_H */
index 64be428943c2606082b1aa8909fccc50610077eb..9ebc92207424284c23aff0feffd3618e37569a43 100644 (file)
@@ -428,6 +428,10 @@ struct si_context {
        /* Resident bindless handles */
        struct util_dynarray    resident_tex_handles;
        struct util_dynarray    resident_img_handles;
+
+       /* Bindless state */
+       bool                    uses_bindless_samplers;
+       bool                    uses_bindless_images;
 };
 
 /* cik_sdma.c */
index ed1df2bfa7d582f9843c6cbf55bc23d67a4f0a84..063747a409699c13efbee19a64d9c29c4c92ab1c 100644 (file)
@@ -630,4 +630,16 @@ si_get_main_shader_part(struct si_shader_selector *sel,
        return &sel->main_shader_part;
 }
 
+static inline bool
+si_shader_uses_bindless_samplers(struct si_shader_selector *selector)
+{
+       return selector ? selector->info.uses_bindless_samplers : false;
+}
+
+static inline bool
+si_shader_uses_bindless_images(struct si_shader_selector *selector)
+{
+       return selector ? selector->info.uses_bindless_images : false;
+}
+
 #endif
index 848c5a75ee98b5f2b958fb5d7c2cf5ad2ec5389e..668c5d9447d0375fdcd5bed40696b6006faa2c0c 100644 (file)
@@ -2202,6 +2202,23 @@ static void si_update_clip_regs(struct si_context *sctx,
                si_mark_atom_dirty(sctx, &sctx->clip_regs);
 }
 
+static void si_update_common_shader_state(struct si_context *sctx)
+{
+       sctx->uses_bindless_samplers =
+               si_shader_uses_bindless_samplers(sctx->vs_shader.cso)  ||
+               si_shader_uses_bindless_samplers(sctx->gs_shader.cso)  ||
+               si_shader_uses_bindless_samplers(sctx->ps_shader.cso)  ||
+               si_shader_uses_bindless_samplers(sctx->tcs_shader.cso) ||
+               si_shader_uses_bindless_samplers(sctx->tes_shader.cso);
+       sctx->uses_bindless_images =
+               si_shader_uses_bindless_images(sctx->vs_shader.cso)  ||
+               si_shader_uses_bindless_images(sctx->gs_shader.cso)  ||
+               si_shader_uses_bindless_images(sctx->ps_shader.cso)  ||
+               si_shader_uses_bindless_images(sctx->tcs_shader.cso) ||
+               si_shader_uses_bindless_images(sctx->tes_shader.cso);
+       sctx->do_update_shaders = true;
+}
+
 static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
 {
        struct si_context *sctx = (struct si_context *)ctx;
@@ -2214,7 +2231,8 @@ static void si_bind_vs_shader(struct pipe_context *ctx, void *state)
 
        sctx->vs_shader.cso = sel;
        sctx->vs_shader.current = sel ? sel->first_variant : NULL;
-       sctx->do_update_shaders = true;
+
+       si_update_common_shader_state(sctx);
        r600_update_vs_writes_viewport_index(&sctx->b, si_get_vs_info(sctx));
        si_set_active_descriptors_for_shader(sctx, sel);
        si_update_streamout_state(sctx);
@@ -2249,7 +2267,8 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
        sctx->gs_shader.cso = sel;
        sctx->gs_shader.current = sel ? sel->first_variant : NULL;
        sctx->ia_multi_vgt_param_key.u.uses_gs = sel != NULL;
-       sctx->do_update_shaders = true;
+
+       si_update_common_shader_state(sctx);
        sctx->last_rast_prim = -1; /* reset this so that it gets updated */
 
        if (enable_changed) {
@@ -2276,7 +2295,8 @@ static void si_bind_tcs_shader(struct pipe_context *ctx, void *state)
        sctx->tcs_shader.cso = sel;
        sctx->tcs_shader.current = sel ? sel->first_variant : NULL;
        si_update_tess_uses_prim_id(sctx);
-       sctx->do_update_shaders = true;
+
+       si_update_common_shader_state(sctx);
 
        if (enable_changed)
                sctx->last_tcs = NULL; /* invalidate derived tess state */
@@ -2299,7 +2319,8 @@ static void si_bind_tes_shader(struct pipe_context *ctx, void *state)
        sctx->tes_shader.current = sel ? sel->first_variant : NULL;
        sctx->ia_multi_vgt_param_key.u.uses_tess = sel != NULL;
        si_update_tess_uses_prim_id(sctx);
-       sctx->do_update_shaders = true;
+
+       si_update_common_shader_state(sctx);
        sctx->last_rast_prim = -1; /* reset this so that it gets updated */
 
        if (enable_changed) {
@@ -2325,8 +2346,8 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 
        sctx->ps_shader.cso = sel;
        sctx->ps_shader.current = sel ? sel->first_variant : NULL;
-       sctx->do_update_shaders = true;
 
+       si_update_common_shader_state(sctx);
        if (sel) {
                if (sctx->ia_multi_vgt_param_key.u.uses_tess)
                        si_update_tess_uses_prim_id(sctx);