[Mesa-dev] [PATCH 5/9] r600g/compute: avoid problems when promoting items mapped for reading

Tom Stellard tom at stellard.net
Mon Jun 16 07:59:33 PDT 2014


On Fri, Jun 13, 2014 at 10:35:34PM +0200, Bruno Jiménez wrote:
> Acording to the OpenCL spec, it is possible to have a buffer mapped
> for reading and at read from it using commands or buffers.
> 
> With this we can keep the mapping (that exists against the
> temporary item) and read with a kernel (from the item we have
> just added to the pool) without problems.

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

> ---
>  src/gallium/drivers/r600/compute_memory_pool.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c
> index 1da4609..e1f9c88 100644
> --- a/src/gallium/drivers/r600/compute_memory_pool.c
> +++ b/src/gallium/drivers/r600/compute_memory_pool.c
> @@ -369,10 +369,16 @@ int compute_memory_promote_item(struct compute_memory_pool *pool,
>  		0, &(struct pipe_box) {.width = item->size_in_dw * 4,
>  		.height = 1, .depth = 1});
>  
> -	pool->screen->b.b.resource_destroy(
> -			(struct pipe_screen *)pool->screen,
> -			(struct pipe_resource *)item->real_buffer);
> -	item->real_buffer = NULL;
> +	/* We check if the item is mapped for reading.
> +	 * In this case, we need to keep the temporary buffer 'alive'
> +	 * because it is possible to keep a map active for reading
> +	 * while a kernel (that reads from it) executes */
> +	if (!(item->status & ITEM_MAPPED_FOR_READING)) {
> +		pool->screen->b.b.resource_destroy(
> +				(struct pipe_screen *)pool->screen,
> +				(struct pipe_resource *)item->real_buffer);
> +		item->real_buffer = NULL;
> +	}
>  
>  	return 0;
>  }
> -- 
> 2.0.0
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list