[Mesa-dev] [PATCH 2/7] r600g, radeonsi: use current domain for deciding when to do blit-based transfer

Marek Olšák maraeo at gmail.com
Mon Feb 24 15:48:29 PST 2014


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

---
 src/gallium/drivers/radeon/r600_texture.c     |  3 ++-
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 24 ++++++++++++++++++++++++
 src/gallium/winsys/radeon/drm/radeon_winsys.h |  8 +++++++-
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 35ad97b..1966251 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -910,7 +910,8 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 
 	/* Untiled buffers in VRAM, which is slow for CPU reads and writes */
 	if (!(usage & PIPE_TRANSFER_MAP_DIRECTLY) &&
-	    (rtex->resource.domains == RADEON_DOMAIN_VRAM)) {
+	    (rctx->ws->buffer_get_current_domain(rtex->resource.cs_buf) ==
+	     RADEON_DOMAIN_VRAM)) {
 		use_staging_texture = TRUE;
 	}
 
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 2ac060b..9665613 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -201,6 +201,29 @@ static boolean radeon_bo_is_busy(struct pb_buffer *_buf,
     }
 }
 
+static enum radeon_bo_domain radeon_bo_get_current_domain(
+		struct radeon_winsys_cs_handle *buf)
+{
+    struct radeon_bo *bo = (struct radeon_bo*)buf;
+    struct drm_radeon_gem_busy args;
+
+    memset(&args, 0, sizeof(args));
+    args.handle = bo->handle;
+
+    drmCommandWriteRead(bo->rws->fd, DRM_RADEON_GEM_BUSY,
+                        &args, sizeof(args));
+
+    /* GEM domains and winsys domains are defined the same. */
+    /* Zero domains the driver doesn't understand. */
+    args.domain &= RADEON_DOMAIN_VRAM_GTT;
+
+    /* If no domain is set, we must set something... */
+    if (!args.domain)
+        args.domain = RADEON_DOMAIN_VRAM_GTT;
+
+    return args.domain;
+}
+
 static uint64_t radeon_bomgr_find_va(struct radeon_bomgr *mgr, uint64_t size, uint64_t alignment)
 {
     struct radeon_bo_va_hole *hole, *n;
@@ -1089,4 +1112,5 @@ void radeon_bomgr_init_functions(struct radeon_drm_winsys *ws)
     ws->base.buffer_from_handle = radeon_winsys_bo_from_handle;
     ws->base.buffer_get_handle = radeon_winsys_bo_get_handle;
     ws->base.buffer_get_virtual_address = radeon_winsys_bo_va;
+    ws->base.buffer_get_current_domain = radeon_bo_get_current_domain;
 }
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index 37affc3..dc34f95 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -61,7 +61,8 @@ enum radeon_bo_layout {
 
 enum radeon_bo_domain { /* bitfield */
     RADEON_DOMAIN_GTT  = 2,
-    RADEON_DOMAIN_VRAM = 4
+    RADEON_DOMAIN_VRAM = 4,
+    RADEON_DOMAIN_VRAM_GTT = RADEON_DOMAIN_VRAM | RADEON_DOMAIN_GTT
 };
 
 enum radeon_bo_usage { /* bitfield */
@@ -378,6 +379,11 @@ struct radeon_winsys {
      */
     uint64_t (*buffer_get_virtual_address)(struct radeon_winsys_cs_handle *buf);
 
+    /**
+     * Query the current placement of the buffer from the memory manager.
+     */
+    enum radeon_bo_domain (*buffer_get_current_domain)(struct radeon_winsys_cs_handle *buf);
+
     /**************************************************************************
      * Command submission.
      *
-- 
1.8.3.2



More information about the mesa-dev mailing list