[Mesa-dev] [PATCH v2] radeonsi: Lazily re-set sampler views after disabling DCC

Nicolai Hähnle nhaehnle at gmail.com
Fri Mar 11 16:28:53 UTC 2016


On 10.03.2016 11:57, Bas Nieuwenhuizen wrote:
> Clear DCC flags if necessary when binding a new sampler view.
>
> v2: Do not reset DCC flags of bound sampler views.
>
> Signed-off-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
> ---
>   src/gallium/drivers/radeon/r600_texture.c     |  2 --
>   src/gallium/drivers/radeonsi/si_descriptors.c | 10 +++++++---
>   2 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index 1a8822c..07118fc 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -310,8 +310,6 @@ static void r600_texture_disable_dcc(struct r600_common_screen *rscreen,
>
>   	/* Notify all contexts about the change. */
>   	r600_dirty_all_framebuffer_states(rscreen);
> -
> -	/* TODO: re-set all sampler views and images, but how? */
>   }
>
>   static boolean r600_texture_get_handle(struct pipe_screen* screen,
> diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
> index 37b9d68..d996077 100644
> --- a/src/gallium/drivers/radeonsi/si_descriptors.c
> +++ b/src/gallium/drivers/radeonsi/si_descriptors.c
> @@ -185,12 +185,16 @@ static void si_set_sampler_view(struct si_context *sctx,
>   				struct si_sampler_views *views,
>   				unsigned slot, struct pipe_sampler_view *view)
>   {
> -	if (views->views[slot] == view)
> +	struct si_sampler_view *rview = (struct si_sampler_view*)view;
> +
> +	if (view && G_008F28_COMPRESSION_EN(rview->state[6]) &&
> +	    ((struct r600_texture*)rview->base.texture)->dcc_offset == 0) {

After just fixing a similar bug elsewhere, I realized: we need to guard 
this against PIPE_BUFFER textures. For buffer textures, state[6] is 
num_records, so it's possible that the COMPRESSION_EN check succeeds, 
and then the dcc_offset check goes out of bounds because the cast to 
r600_texture is not valid.

Nicolai

> +		rview->state[6] &= C_008F28_COMPRESSION_EN &
> +		                   C_008F28_ALPHA_IS_ON_MSB;
> +	} else if (views->views[slot] == view)
>   		return;
>
>   	if (view) {
> -		struct si_sampler_view *rview =
> -			(struct si_sampler_view*)view;
>   		struct r600_texture *rtex = (struct r600_texture *)view->texture;
>
>   		si_sampler_view_add_buffer(sctx, view->texture);
>


More information about the mesa-dev mailing list