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

Samuel Pitoiset samuel.pitoiset at gmail.com
Mon Jun 12 12:37:22 UTC 2017


Please ignore this one.

On 06/12/2017 02:33 PM, Samuel Pitoiset 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()
> 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       | 14 +++++++++++
>   src/gallium/drivers/radeonsi/si_pipe.h          | 16 +++++++++++++
>   src/gallium/drivers/radeonsi/si_shader.h        | 12 ++++++++++
>   src/gallium/drivers/radeonsi/si_state_shaders.c | 31 +++++++++++++++++++++----
>   5 files changed, 70 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..3cf1538267 100644
> --- a/src/gallium/drivers/radeonsi/si_compute.h
> +++ b/src/gallium/drivers/radeonsi/si_compute.h
> @@ -49,6 +49,20 @@ 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;
>   };
>   
> +static inline bool
> +si_compute_uses_bindless_samplers(struct si_context *sctx)
> +{
> +	return sctx->cs_shader_state.program->uses_bindless_samplers;
> +}
> +
> +static inline bool
> +si_compute_uses_bindless_images(struct si_context *sctx)
> +{
> +	return sctx->cs_shader_state.program->uses_bindless_images;
> +}
> +
>   #endif /* SI_COMPUTE_H */
> diff --git a/src/gallium/drivers/radeonsi/si_pipe.h b/src/gallium/drivers/radeonsi/si_pipe.h
> index 252cec3b91..b87fa856cd 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 */
> @@ -548,6 +552,18 @@ static inline struct tgsi_shader_info *si_get_vs_info(struct si_context *sctx)
>   	return vs->cso ? &vs->cso->info : NULL;
>   }
>   
> +static inline bool
> +si_graphics_uses_bindless_samplers(struct si_context *sctx)
> +{
> +	return sctx->uses_bindless_samplers;
> +}
> +
> +static inline bool
> +si_graphics_uses_bindless_images(struct si_context *sctx)
> +{
> +	return sctx->uses_bindless_images;
> +}
> +
>   static inline struct si_shader* si_get_vs_state(struct si_context *sctx)
>   {
>   	if (sctx->gs_shader.cso)
> 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);
> 


More information about the mesa-dev mailing list