Mesa (7.10): r600g: bump domain selection up one layer.

Michel Dänzer daenzer at kemper.freedesktop.org
Mon Oct 3 08:11:18 PDT 2011


Module: Mesa
Branch: 7.10
Commit: 1e279de4b01b25df4f153c643f44f8b67dba50e9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e279de4b01b25df4f153c643f44f8b67dba50e9

Author: Dave Airlie <airlied at redhat.com>
Date:   Fri May 13 14:16:31 2011 +1000

r600g: bump domain selection up one layer.

this is taken from a patch from Mathias Froehlich, just going to
stage it in a few pieces.

Signed-off-by: Dave Airlie <airlied at redhat.com>
(cherry picked from commit ecc051d65b6e17115439fb3609cccfd59f6272bf, see
https://bugs.freedesktop.org/show_bug.cgi?id=40979)

---

 src/gallium/winsys/r600/drm/r600_bo.c   |   24 +++++++++++++++++++++---
 src/gallium/winsys/r600/drm/r600_priv.h |    2 +-
 src/gallium/winsys/r600/drm/radeon_bo.c |    4 ++--
 3 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/gallium/winsys/r600/drm/r600_bo.c b/src/gallium/winsys/r600/drm/r600_bo.c
index 6a3737f..15e4169 100644
--- a/src/gallium/winsys/r600/drm/r600_bo.c
+++ b/src/gallium/winsys/r600/drm/r600_bo.c
@@ -38,7 +38,8 @@ struct r600_bo *r600_bo(struct radeon *radeon,
 {
 	struct r600_bo *bo;
 	struct radeon_bo *rbo;
-
+	uint32_t initial_domain;
+	  
 	if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)) {
 		bo = r600_bomgr_bo_create(radeon->bomgr, size, alignment, *radeon->cfence);
 		if (bo) {
@@ -46,7 +47,24 @@ struct r600_bo *r600_bo(struct radeon *radeon,
 		}
 	}
 
-	rbo = radeon_bo(radeon, 0, size, alignment);
+	if (binding & (PIPE_BIND_CONSTANT_BUFFER | PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)) {
+		initial_domain = RADEON_GEM_DOMAIN_GTT;
+	} else {
+		switch(usage) {
+		case PIPE_USAGE_DYNAMIC:
+		case PIPE_USAGE_STREAM:
+		case PIPE_USAGE_STAGING:
+			initial_domain = RADEON_GEM_DOMAIN_GTT;
+			break;
+		case PIPE_USAGE_DEFAULT:
+		case PIPE_USAGE_STATIC:
+		case PIPE_USAGE_IMMUTABLE:
+		default:
+			initial_domain = RADEON_GEM_DOMAIN_VRAM;
+			break;
+		}
+	}
+	rbo = radeon_bo(radeon, 0, size, alignment, initial_domain);
 	if (rbo == NULL) {
 		return NULL;
 	}
@@ -80,7 +98,7 @@ struct r600_bo *r600_bo_handle(struct radeon *radeon,
 	struct r600_bo *bo = calloc(1, sizeof(struct r600_bo));
 	struct radeon_bo *rbo;
 
-	rbo = bo->bo = radeon_bo(radeon, handle, 0, 0);
+	rbo = bo->bo = radeon_bo(radeon, handle, 0, 0, 0);
 	if (rbo == NULL) {
 		free(bo);
 		return NULL;
diff --git a/src/gallium/winsys/r600/drm/r600_priv.h b/src/gallium/winsys/r600/drm/r600_priv.h
index a38a648..ceac609 100644
--- a/src/gallium/winsys/r600/drm/r600_priv.h
+++ b/src/gallium/winsys/r600/drm/r600_priv.h
@@ -116,7 +116,7 @@ unsigned radeon_family_from_device(unsigned device);
  * radeon_bo.c
  */
 struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
-			    unsigned size, unsigned alignment);
+			    unsigned size, unsigned alignment, unsigned initial_domain);
 void radeon_bo_reference(struct radeon *radeon, struct radeon_bo **dst,
 			 struct radeon_bo *src);
 int radeon_bo_wait(struct radeon *radeon, struct radeon_bo *bo);
diff --git a/src/gallium/winsys/r600/drm/radeon_bo.c b/src/gallium/winsys/r600/drm/radeon_bo.c
index 7e5f392..5520460 100644
--- a/src/gallium/winsys/r600/drm/radeon_bo.c
+++ b/src/gallium/winsys/r600/drm/radeon_bo.c
@@ -69,7 +69,7 @@ static void radeon_bo_fixed_unmap(struct radeon *radeon, struct radeon_bo *bo)
 }
 
 struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
-			unsigned size, unsigned alignment)
+			    unsigned size, unsigned alignment, unsigned initial_domain)
 {
 	struct radeon_bo *bo;
 	int r;
@@ -102,7 +102,7 @@ struct radeon_bo *radeon_bo(struct radeon *radeon, unsigned handle,
 
 		args.size = size;
 		args.alignment = alignment;
-		args.initial_domain = RADEON_GEM_DOMAIN_CPU;
+		args.initial_domain = initial_domain;
 		args.flags = 0;
 		args.handle = 0;
 		r = drmCommandWriteRead(radeon->fd, DRM_RADEON_GEM_CREATE,



More information about the mesa-commit mailing list