[Mesa-dev] [PATCH 05/14] gallium/radeon: clean up r600_texture_get_handle

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Jun 29 21:18:46 UTC 2017


Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>

On 06/29/2017 09:47 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> ---
>   src/gallium/drivers/radeon/r600_texture.c | 47 +++++++++++++++----------------
>   1 file changed, 23 insertions(+), 24 deletions(-)
> 
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index c811d6a..e21dc37 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -530,28 +530,27 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
>   	struct r600_common_context *rctx;
>   	struct r600_resource *res = (struct r600_resource*)resource;
>   	struct r600_texture *rtex = (struct r600_texture*)resource;
>   	struct radeon_bo_metadata metadata;
>   	bool update_metadata = false;
>   	unsigned stride, offset, slice_size;
>   
>   	ctx = threaded_context_unwrap_sync(ctx);
>   	rctx = (struct r600_common_context*)(ctx ? ctx : rscreen->aux_context);
>   
> -	/* This is not supported now, but it might be required for OpenCL
> -	 * interop in the future.
> -	 */
> -	if (resource->target != PIPE_BUFFER &&
> -	    (resource->nr_samples > 1 || rtex->is_depth))
> -		return false;
> -
>   	if (resource->target != PIPE_BUFFER) {
> +		/* This is not supported now, but it might be required for OpenCL
> +		 * interop in the future.
> +		 */
> +		if (resource->nr_samples > 1 || rtex->is_depth)
> +			return false;
> +
>   		/* Since shader image stores don't support DCC on VI,
>   		 * disable it for external clients that want write
>   		 * access.
>   		 */
>   		if (usage & PIPE_HANDLE_USAGE_WRITE && rtex->dcc_offset) {
>   			if (r600_texture_disable_dcc(rctx, rtex))
>   				update_metadata = true;
>   		}
>   
>   		if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) &&
> @@ -568,51 +567,51 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
>   
>   		/* Set metadata. */
>   		if (!res->b.is_shared || update_metadata) {
>   			r600_texture_init_metadata(rscreen, rtex, &metadata);
>   			if (rscreen->query_opaque_metadata)
>   				rscreen->query_opaque_metadata(rscreen, rtex,
>   							       &metadata);
>   
>   			rscreen->ws->buffer_set_metadata(res->buf, &metadata);
>   		}
> +
> +		if (rscreen->chip_class >= GFX9) {
> +			offset = rtex->surface.u.gfx9.surf_offset;
> +			stride = rtex->surface.u.gfx9.surf_pitch *
> +				 rtex->surface.bpe;
> +			slice_size = rtex->surface.u.gfx9.surf_slice_size;
> +		} else {
> +			offset = rtex->surface.u.legacy.level[0].offset;
> +			stride = rtex->surface.u.legacy.level[0].nblk_x *
> +				 rtex->surface.bpe;
> +			slice_size = rtex->surface.u.legacy.level[0].slice_size;
> +		}
> +	} else {
> +		/* Buffers */
> +		offset = 0;
> +		stride = 0;
> +		slice_size = 0;
>   	}
>   
>   	if (res->b.is_shared) {
>   		/* USAGE_EXPLICIT_FLUSH must be cleared if at least one user
>   		 * doesn't set it.
>   		 */
>   		res->external_usage |= usage & ~PIPE_HANDLE_USAGE_EXPLICIT_FLUSH;
>   		if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH))
>   			res->external_usage &= ~PIPE_HANDLE_USAGE_EXPLICIT_FLUSH;
>   	} else {
>   		res->b.is_shared = true;
>   		res->external_usage = usage;
>   	}
>   
> -	if (res->b.b.target == PIPE_BUFFER) {
> -		offset = 0;
> -		stride = 0;
> -		slice_size = 0;
> -	} else {
> -		if (rscreen->chip_class >= GFX9) {
> -			offset = rtex->surface.u.gfx9.surf_offset;
> -			stride = rtex->surface.u.gfx9.surf_pitch *
> -				 rtex->surface.bpe;
> -			slice_size = rtex->surface.u.gfx9.surf_slice_size;
> -		} else {
> -			offset = rtex->surface.u.legacy.level[0].offset;
> -			stride = rtex->surface.u.legacy.level[0].nblk_x *
> -				 rtex->surface.bpe;
> -			slice_size = rtex->surface.u.legacy.level[0].slice_size;
> -		}
> -	}
>   	return rscreen->ws->buffer_get_handle(res->buf, stride, offset,
>   					      slice_size, whandle);
>   }
>   
>   static void r600_texture_destroy(struct pipe_screen *screen,
>   				 struct pipe_resource *ptex)
>   {
>   	struct r600_texture *rtex = (struct r600_texture*)ptex;
>   	struct r600_resource *resource = &rtex->resource;
>   
> 


More information about the mesa-dev mailing list