[Mesa-dev] [PATCH 6/6] radeonsi: always unmap texture CPU mappings on 32-bit CPU architectures

Marek Olšák maraeo at gmail.com
Fri Dec 14 21:24:00 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

Team Fortress 2 32-bit version runs out of the CPU address space.
---
 src/gallium/drivers/radeonsi/si_texture.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_texture.c b/src/gallium/drivers/radeonsi/si_texture.c
index 95f1e8c9693..39869445b0f 100644
--- a/src/gallium/drivers/radeonsi/si_texture.c
+++ b/src/gallium/drivers/radeonsi/si_texture.c
@@ -1791,20 +1791,26 @@ static void *si_texture_transfer_map(struct pipe_context *ctx,
 
 		buf = trans->staging;
 	} else {
 		/* the resource is mapped directly */
 		offset = si_texture_get_offset(sctx->screen, tex, level, box,
 						 &trans->b.b.stride,
 						 &trans->b.b.layer_stride);
 		buf = &tex->buffer;
 	}
 
+	/* Always unmap texture CPU mappings on 32-bit architectures, so that
+	 * we don't run out of the CPU address space.
+	 */
+	if (sizeof(void*) == 4)
+		usage |= RADEON_TRANSFER_TEMPORARY;
+
 	if (!(map = si_buffer_map_sync_with_rings(sctx, buf, usage)))
 		goto fail_trans;
 
 	*ptransfer = &trans->b.b;
 	return map + offset;
 
 fail_trans:
 	r600_resource_reference(&trans->staging, NULL);
 	pipe_resource_reference(&trans->b.b.resource, NULL);
 	FREE(trans);
@@ -1812,20 +1818,30 @@ fail_trans:
 }
 
 static void si_texture_transfer_unmap(struct pipe_context *ctx,
 				      struct pipe_transfer* transfer)
 {
 	struct si_context *sctx = (struct si_context*)ctx;
 	struct si_transfer *stransfer = (struct si_transfer*)transfer;
 	struct pipe_resource *texture = transfer->resource;
 	struct si_texture *tex = (struct si_texture*)texture;
 
+	/* Always unmap texture CPU mappings on 32-bit architectures, so that
+	 * we don't run out of the CPU address space.
+	 */
+	if (sizeof(void*) == 4) {
+		struct r600_resource *buf =
+			stransfer->staging ? stransfer->staging : &tex->buffer;
+
+		sctx->ws->buffer_unmap(buf->buf);
+	}
+
 	if ((transfer->usage & PIPE_TRANSFER_WRITE) && stransfer->staging) {
 		if (tex->is_depth && tex->buffer.b.b.nr_samples <= 1) {
 			ctx->resource_copy_region(ctx, texture, transfer->level,
 						  transfer->box.x, transfer->box.y, transfer->box.z,
 						  &stransfer->staging->b.b, transfer->level,
 						  &transfer->box);
 		} else {
 			si_copy_from_staging_texture(ctx, stransfer);
 		}
 	}
-- 
2.17.1



More information about the mesa-dev mailing list