[Mesa-dev] [PATCH 03/14] gallium/radeon: fix a possible crash for buffer exports

Andres Gomez agomez at igalia.com
Sat Jul 8 14:07:58 UTC 2017


Marek, do we want this into -stable?

On Thu, 2017-06-29 at 21:47 +0200, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> ---
>  src/gallium/drivers/radeon/r600_texture.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index d68587b..139ab13 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -582,30 +582,36 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
>  		 * 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 (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;
> +	if (res->b.b.target == PIPE_BUFFER) {
> +		offset = 0;
> +		stride = 0;
> +		slice_size = 0;
>  	} 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;
> +		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;
-- 
Br,

Andres


More information about the mesa-dev mailing list