Mesa (master): r600g: fix abysmal performance in Reaction Quake

Marek Olšák mareko at kemper.freedesktop.org
Thu Nov 1 02:18:52 UTC 2012


Module: Mesa
Branch: master
Commit: fa58644855e44830e0b91dc627703c236fa6712a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa58644855e44830e0b91dc627703c236fa6712a

Author: Marek Olšák <maraeo at gmail.com>
Date:   Thu Nov  1 00:52:19 2012 +0100

r600g: fix abysmal performance in Reaction Quake

The problem was we set VRAM|GTT for relocations of STATIC resources.
Setting just VRAM increases the framerate 4 times on my machine.

I rewrote the switch statement and adjusted the domains for window
framebuffers too.

NOTE: This is a candidate for the stable branches.

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Reviewed-by: Jerome Glisse <jglisse at redhat.com>

---

 src/gallium/drivers/r600/r600_buffer.c  |   42 ++++++++++++++++--------------
 src/gallium/drivers/r600/r600_texture.c |    3 +-
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_buffer.c b/src/gallium/drivers/r600/r600_buffer.c
index f4566ee..116ab51 100644
--- a/src/gallium/drivers/r600/r600_buffer.c
+++ b/src/gallium/drivers/r600/r600_buffer.c
@@ -206,29 +206,31 @@ bool r600_init_resource(struct r600_screen *rscreen,
 {
 	uint32_t initial_domain, domains;
 
-	/* Staging resources particpate in transfers and blits only
-	 * and are used for uploads and downloads from regular
-	 * resources.  We generate them internally for some transfers.
-	 */
-	if (usage == PIPE_USAGE_STAGING) {
+	switch(usage) {
+	case PIPE_USAGE_STAGING:
+		/* Staging resources participate in transfers, i.e. are used
+		 * for uploads and downloads from regular resources.
+		 * We generate them internally for some transfers.
+		 */
+		initial_domain = RADEON_DOMAIN_GTT;
 		domains = RADEON_DOMAIN_GTT;
+		break;
+	case PIPE_USAGE_DYNAMIC:
+	case PIPE_USAGE_STREAM:
+		/* Default to GTT, but allow the memory manager to move it to VRAM. */
 		initial_domain = RADEON_DOMAIN_GTT;
-	} else {
 		domains = RADEON_DOMAIN_GTT | RADEON_DOMAIN_VRAM;
-
-		switch(usage) {
-		case PIPE_USAGE_DYNAMIC:
-		case PIPE_USAGE_STREAM:
-		case PIPE_USAGE_STAGING:
-			initial_domain = RADEON_DOMAIN_GTT;
-			break;
-		case PIPE_USAGE_DEFAULT:
-		case PIPE_USAGE_STATIC:
-		case PIPE_USAGE_IMMUTABLE:
-		default:
-			initial_domain = RADEON_DOMAIN_VRAM;
-			break;
-		}
+		break;
+	case PIPE_USAGE_DEFAULT:
+	case PIPE_USAGE_STATIC:
+	case PIPE_USAGE_IMMUTABLE:
+	default:
+		/* Don't list GTT here, because the memory manager would put some
+		 * resources to GTT no matter what the initial domain is.
+		 * Not listing GTT in the domains improves performance a lot. */
+		initial_domain = RADEON_DOMAIN_VRAM;
+		domains = RADEON_DOMAIN_VRAM;
+		break;
 	}
 
 	res->buf = rscreen->ws->buffer_create(rscreen->ws, size, alignment, bind, initial_domain);
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 785eeff..2df390d 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -421,9 +421,10 @@ r600_texture_create_object(struct pipe_screen *screen,
 			return NULL;
 		}
 	} else if (buf) {
+		/* This is usually the window framebuffer. We want it in VRAM, always. */
 		resource->buf = buf;
 		resource->cs_buf = rscreen->ws->buffer_get_cs_handle(buf);
-		resource->domains = RADEON_DOMAIN_GTT | RADEON_DOMAIN_VRAM;
+		resource->domains = RADEON_DOMAIN_VRAM;
 	}
 
 	if (rtex->cmask_size) {




More information about the mesa-commit mailing list