r300g: do not tell st that a buffer is referenced by hw
authorMarek Olšák <maraeo@gmail.com>
Sun, 18 Apr 2010 04:32:10 +0000 (06:32 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 18 Apr 2010 14:09:21 +0000 (16:09 +0200)
It saves a few libdrm calls and unnecessary flushes.

src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/r300/r300_screen_buffer.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_winsys.h
src/gallium/winsys/radeon/drm/radeon_buffer.h
src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
src/gallium/winsys/radeon/drm/radeon_r300.c

index f6bc68c43ad968b0614a6e1322d14f73ab4194ab..26ff71c84614bec1e1b87b2694d71cdbbd3d30c4 100644 (file)
@@ -152,9 +152,9 @@ static boolean immd_is_good_idea(struct r300_context *r300,
         if (!checked[vbi]) {
             vbuf = &r300->vertex_buffer[vbi];
 
-            if (r300->context.is_resource_referenced(&r300->context,
-                                                    vbuf->buffer,
-                                                    0, 0)) {
+            if (r300->rws->is_buffer_referenced(r300->rws,
+                                                r300_buffer(vbuf->buffer)->buf,
+                                                R300_REF_CS | R300_REF_HW)) {
                 /* It's a very bad idea to map it... */
                 return FALSE;
             }
index 739f723f163ebe63bb1f595a93c5610820eeb43c..c5c10af2a4c0589af6996d6c5f090292167cb0ab 100644 (file)
@@ -44,7 +44,7 @@ static unsigned r300_buffer_is_referenced(struct pipe_context *context,
     if (r300_buffer_is_user_buffer(buf))
        return PIPE_UNREFERENCED;
 
-    if (r300->rws->is_buffer_referenced(r300->rws, rbuf->buf))
+    if (r300->rws->is_buffer_referenced(r300->rws, rbuf->buf, R300_REF_CS))
         return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
 
     return PIPE_UNREFERENCED;
index a4a3f2166f87ced7efbeda537c43b490c5971cac..e795c8df0bbd34f93e8b3827338d8860adc92dcf 100644 (file)
@@ -880,7 +880,7 @@ static unsigned r300_texture_is_referenced(struct pipe_context *context,
     struct r300_context *r300 = r300_context(context);
     struct r300_texture *rtex = (struct r300_texture *)texture;
 
-    if (r300->rws->is_buffer_referenced(r300->rws, rtex->buffer))
+    if (r300->rws->is_buffer_referenced(r300->rws, rtex->buffer, R300_REF_CS))
         return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
 
     return PIPE_UNREFERENCED;
index 9c348d911581d05a9dadb1067e0609c10fe01129..2bd40176d10dbadab4ac7fb0f2317546a4e58c9d 100644 (file)
@@ -42,6 +42,11 @@ enum r300_value_id {
     R300_VID_TEX3D_MIP_BUG,
 };
 
+enum r300_reference_domain { /* bitfield */
+    R300_REF_CS = 1,
+    R300_REF_HW = 2
+};
+
 struct r300_winsys_screen {
     void (*destroy)(struct r300_winsys_screen *ws);
     
@@ -160,9 +165,8 @@ struct r300_winsys_screen {
                                 struct winsys_handle *whandle);
 
     boolean (*is_buffer_referenced)(struct r300_winsys_screen *winsys,
-                                    struct r300_winsys_buffer *buffer);
-
-  
+                                    struct r300_winsys_buffer *buffer,
+                                    enum r300_reference_domain domain);
 };
 
 struct r300_winsys_screen *
index 8782d675df24961422b2d9382ad4dc4ee75cbf20..b48b6358e01a4dec2000805ba5d1155dcf3bf84f 100644 (file)
@@ -86,5 +86,6 @@ void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr);
 boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
                                     struct winsys_handle *whandle);
 
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf);
+boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf,
+                                               enum r300_reference_domain domain);
 #endif
index c9179a3620aa62c8a46e33888c3bf34c817844d0..9824ada5b33135cbd3b02959bff91b32de60c1dc 100644 (file)
@@ -381,13 +381,25 @@ void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
     }
 }
 
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf)
+boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf,
+                                               enum r300_reference_domain domain)
 {
     struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
-    uint32_t domain;
+    uint32_t tmp;
+
+    if (domain & R300_REF_CS) {
+        if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
+            return TRUE;
+        }
+    }
+
+    if (domain & R300_REF_HW) {
+        if (radeon_bo_is_busy(buf->bo, &tmp)) {
+            return TRUE;
+        }
+    }
 
-    return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) ||
-           radeon_bo_is_busy(buf->bo, &domain));
+    return FALSE;
 }
 
 
index d1e65f87c36ceb960614fdd46cbff2ce326f4829..2fcf7cf98216acb14ef7e20a73121ebcb2f7aef4 100644 (file)
@@ -111,11 +111,12 @@ static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws,
 }
 
 static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws,
-                                                      struct r300_winsys_buffer *buf)
+                                                      struct r300_winsys_buffer *buf,
+                                                       enum r300_reference_domain domain)
 {
     struct pb_buffer *_buf = radeon_pb_buffer(buf);
 
-    return radeon_drm_bufmgr_is_buffer_referenced(_buf);
+    return radeon_drm_bufmgr_is_buffer_referenced(_buf, domain);
 }
 
 static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,