[Mesa-dev] [PATCH 04/14] gallium/radeon: discard CMASK or DCC if overwriting a whole texture by DMA

Nicolai Hähnle nhaehnle at gmail.com
Sun May 8 16:12:03 UTC 2016


On 04.05.2016 18:43, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
>   src/gallium/drivers/radeon/r600_texture.c | 46 ++++++++++++++++++++++++++-----
>   1 file changed, 39 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index 0dba045..d6d95af 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -32,6 +32,23 @@
>   #include <errno.h>
>   #include <inttypes.h>
>
> +static void r600_texture_discard_dcc(struct r600_common_screen *rscreen,
> +				     struct r600_texture *rtex);
> +static void r600_texture_discard_cmask(struct r600_common_screen *rscreen,
> +				       struct r600_texture *rtex);
> +
> +
> +static bool range_covers_whole_texture(struct pipe_resource *tex,
> +				       unsigned level, unsigned x, unsigned y,
> +				       unsigned z, unsigned width,
> +				       unsigned height, unsigned depth)
> +{
> +	return x == 0 && y == 0 && z == 0 &&
> +	       width == u_minify(tex->width0, level) &&
> +	       height == u_minify(tex->height0, level) &&
> +	       depth == util_max_layer(tex, level) + 1;
> +}
> +
>   bool r600_prepare_for_dma_blit(struct r600_common_context *rctx,
>   			       struct r600_texture *rdst,
>   			       unsigned dst_level, unsigned dstx,
> @@ -61,21 +78,36 @@ bool r600_prepare_for_dma_blit(struct r600_common_context *rctx,
>
>   	/* DCC as:
>   	 *   src: Use the 3D path. DCC decompression is expensive.
> -	 *   dst: If overwriting the whole texture, disable DCC and use SDMA.
> +	 *   dst: If overwriting the whole texture, discard DCC and use SDMA.
>   	 *        Otherwise, use the 3D path.
> -	 * TODO: handle the case when the dst box covers the whole texture
>   	 */
> -	if (rsrc->dcc_offset || rdst->dcc_offset)
> +	if (rsrc->dcc_offset)
>   		return false;
>
> +	if (rdst->dcc_offset) {
> +		/* We can't discard DCC if the texture has been exported. */
> +		if (!rdst->resource.is_shared &&
> +		    range_covers_whole_texture(&rdst->resource.b.b, dst_level,
> +					       dstx, dsty, dstz, src_box->width,
> +					       src_box->height, src_box->depth))
> +			r600_texture_discard_dcc(rctx->screen, rdst);
> +		else
> +			return false;

It would feel more natural to me to invert the if-condition here and 
below, so that the true-case leads to the fallback (as in the other 
conditional checks). But I admit that's a bit of bike-shedding. Either 
way, patches 1, 2 & 4 are

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

> +	}
> +
>   	/* CMASK as:
>   	 *   src: Both texture and SDMA paths need decompression. Use SDMA.
> -	 *   dst: If overwriting the whole texture, deallocate CMASK and use
> +	 *   dst: If overwriting the whole texture, discard CMASK and use
>   	 *        SDMA. Otherwise, use the 3D path.
> -	 * TODO: handle the case when the dst box covers the whole texture
>   	 */
> -	if (rdst->cmask.size && rdst->dirty_level_mask & (1 << dst_level))
> -		return false;
> +	if (rdst->cmask.size && rdst->dirty_level_mask & (1 << dst_level)) {
> +		if (range_covers_whole_texture(&rdst->resource.b.b, dst_level,
> +					       dstx, dsty, dstz, src_box->width,
> +					       src_box->height, src_box->depth))
> +			r600_texture_discard_cmask(rctx->screen, rdst);
> +		else
> +			return false;
> +	}
>
>   	/* All requirements are met. Prepare textures for SDMA. */
>   	if (rsrc->cmask.size && rsrc->dirty_level_mask & (1 << src_level))
>


More information about the mesa-dev mailing list