[Mesa-dev] [PATCH v4 57/63] radeonsi: track use of bindless samplers/images from tgsi_shader_info

Marek Olšák maraeo at gmail.com
Tue Jun 13 21:07:26 UTC 2017


Ignore my previous question.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Mon, Jun 12, 2017 at 2:35 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> 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.
>
> v4: - rename si_bind_shader_common() to si_update_common_shader_state()
>     - remove si_*_uses_bindless_*()
> v3: - add si_context::uses_bindless_{samplers,images}
>     - add si_bind_shader_common() to limit code duplication
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
>  src/gallium/drivers/radeonsi/si_compute.c       |  2 ++
>  src/gallium/drivers/radeonsi/si_compute.h       |  2 ++
>  src/gallium/drivers/radeonsi/si_pipe.h          |  4 ++++
>  src/gallium/drivers/radeonsi/si_shader.h        | 12 ++++++++++
>  src/gallium/drivers/radeonsi/si_state_shaders.c | 31 +++++++++++++++++++++----
>  5 files changed, 46 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_compute.c b/src/gallium/drivers/radeonsi/si_compute.c
> index 0338b8a123..79b107e96f 100644
> --- a/src/gallium/drivers/radeonsi/si_compute.c
> +++ b/src/gallium/drivers/radeonsi/si_compute.c
> @@ -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;
> diff --git a/src/gallium/drivers/radeonsi/si_compute.h b/src/gallium/drivers/radeonsi/si_compute.h
> index 764d708c4f..268817b23a 100644
> --- a/src/gallium/drivers/radeonsi/si_compute.h
> +++ b/src/gallium/drivers/radeonsi/si_compute.h
> @@ -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 */
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
> index 252cec3b91..78b0de4101 100644
> --- a/src/gallium/drivers/radeonsi/si_pipe.h
> +++ b/src/gallium/drivers/radeonsi/si_pipe.h
> @@ -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 */
> diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h
> index 7c04b7e253..4ebb745cb6 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.h
> +++ b/src/gallium/drivers/radeonsi/si_shader.h
> @@ -629,4 +629,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
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index 677a6de88c..2c917279d1 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -2200,6 +2200,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;
> @@ -2212,7 +2229,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);
> @@ -2247,7 +2265,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) {
> @@ -2274,7 +2293,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 */
> @@ -2297,7 +2317,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) {
> @@ -2323,8 +2344,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);
> --
> 2.13.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list