[Mesa-dev] [PATCH] gallium/radeon: always unmap textures on 32-bit

Axel Davy axel.davy at ens.fr
Mon Feb 1 09:59:48 PST 2016


Hi,

This path is used for vertex buffers as well, right ?

Most d3d9 games are 32 bits, I guess your change would slow down a lot 
of d3d9 games.

I suggest rather to really unmap, except if the resource was already 
mapped/unmapped, ... say 5 times.

That way if the resource is frequently mapped, you get the optimization, 
else for most resources, which get mapped once or two times, you don't 
keep the additionnal memory storage.

Yours,

Axel Davy


On 01/02/2016 15:20, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> This might fix mmap errors with Natural Selection 2, which a 32-bit game.
>
> It would be nice if someone tested this patch with the game.
> ---
>   src/gallium/drivers/radeon/r600_pipe_common.h | 6 ++++++
>   src/gallium/drivers/radeon/r600_texture.c     | 9 +++++++++
>   2 files changed, 15 insertions(+)
>
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
> index 88e9cbc..01e0d8f 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -43,6 +43,12 @@
>   #include "util/u_suballoc.h"
>   #include "util/u_transfer.h"
>   
> +#ifdef PIPE_ARCH_X86
> +#define CPU_HAS_32BIT_ADDRESS_SPACE 1
> +#else
> +#define CPU_HAS_32BIT_ADDRESS_SPACE 0
> +#endif
> +
>   #define R600_RESOURCE_FLAG_TRANSFER		(PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
>   #define R600_RESOURCE_FLAG_FLUSHED_DEPTH	(PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
>   #define R600_RESOURCE_FLAG_FORCE_TILING		(PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
> diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
> index 7c4717d..d373a18 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -1153,10 +1153,19 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
>   static void r600_texture_transfer_unmap(struct pipe_context *ctx,
>   					struct pipe_transfer* transfer)
>   {
> +	struct r600_common_context *rctx = (struct r600_common_context*)ctx;
>   	struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
>   	struct pipe_resource *texture = transfer->resource;
>   	struct r600_texture *rtex = (struct r600_texture*)texture;
>   
> +	if (CPU_HAS_32BIT_ADDRESS_SPACE) {
> +		/* 32-bit address space can run out of space pretty quickly. */
> +		if (rtransfer->staging)
> +			rctx->ws->buffer_unmap(rtransfer->staging->buf);
> +		else
> +			rctx->ws->buffer_unmap(rtex->resource.buf);
> +	}
> +
>   	if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
>   		if (rtex->is_depth && rtex->resource.b.b.nr_samples <= 1) {
>   			ctx->resource_copy_region(ctx, texture, transfer->level,



More information about the mesa-dev mailing list