winsys/radeon: add usage parameter to cs_is_buffer_referenced
authorMarek Olšák <maraeo@gmail.com>
Sun, 26 Feb 2012 17:04:36 +0000 (18:04 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 5 Mar 2012 13:22:25 +0000 (14:22 +0100)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
src/gallium/drivers/r300/r300_transfer.c
src/gallium/drivers/r600/r600_query.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/winsys/radeon/drm/radeon_drm_cs.c
src/gallium/winsys/radeon/drm/radeon_winsys.h

index 5e99cc467a861ac89d9e18a1a884c1e9908951f5..d440db8e305d3b955d3f6976b97ab69aa38430f9 100644 (file)
@@ -90,7 +90,7 @@ r300_texture_get_transfer(struct pipe_context *ctx,
     boolean referenced_cs, referenced_hw;
 
     referenced_cs =
-        r300->rws->cs_is_buffer_referenced(r300->cs, tex->cs_buf);
+        r300->rws->cs_is_buffer_referenced(r300->cs, tex->cs_buf, RADEON_USAGE_READWRITE);
     if (referenced_cs) {
         referenced_hw = TRUE;
     } else {
index def0a9700f7e85df7068ec67dc17a16809d804ef..df5764aec689677d6cbe9e5b6d40903827781f89 100644 (file)
@@ -346,7 +346,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
        }
 
        /* Obtain a new buffer if the current one can't be mapped without a stall. */
-       if (rctx->ws->cs_is_buffer_referenced(rctx->cs, rquery->buffer.buf->cs_buf) ||
+       if (rctx->ws->cs_is_buffer_referenced(rctx->cs, rquery->buffer.buf->cs_buf, RADEON_USAGE_READWRITE) ||
            rctx->ws->buffer_is_busy(rquery->buffer.buf->buf, RADEON_USAGE_READWRITE)) {
                pipe_resource_reference((struct pipe_resource**)&rquery->buffer.buf, NULL);
                rquery->buffer.buf = r600_new_query_buffer(rctx, rquery->type);
index 6e275ebc109ad89ac9b0490be8d2f8ca53a5f4a1..6222410f6c31feed5bef2ddc0129698508db8be1 100644 (file)
@@ -796,7 +796,7 @@ struct pipe_transfer* r600_texture_get_transfer(struct pipe_context *ctx,
 
        /* Use a staging texture for uploads if the underlying BO is busy. */
        if (!(usage & PIPE_TRANSFER_READ) &&
-           (rctx->ws->cs_is_buffer_referenced(rctx->cs, rtex->resource.cs_buf) ||
+           (rctx->ws->cs_is_buffer_referenced(rctx->cs, rtex->resource.cs_buf, RADEON_USAGE_READWRITE) ||
             rctx->ws->buffer_is_busy(rtex->resource.buf, RADEON_USAGE_READWRITE)))
                use_staging_texture = TRUE;
 
index cf8f25bc5b44f3b499bac1a0027293b7e385ab45..10f933884631d9dc71ca6a41c18541cc0c9c70d8 100644 (file)
@@ -512,12 +512,26 @@ static void radeon_drm_cs_set_flush(struct radeon_winsys_cs *rcs,
 }
 
 static boolean radeon_bo_is_referenced(struct radeon_winsys_cs *rcs,
-                                       struct radeon_winsys_cs_handle *_buf)
+                                       struct radeon_winsys_cs_handle *_buf,
+                                       enum radeon_bo_usage usage)
 {
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
     struct radeon_bo *bo = (struct radeon_bo*)_buf;
+    int index;
 
-    return radeon_bo_is_referenced_by_cs(cs, bo);
+    if (!bo->num_cs_references)
+        return FALSE;
+
+    index = radeon_get_reloc(cs->csc, bo);
+    if (index == -1)
+        return FALSE;
+
+    if ((usage & RADEON_USAGE_WRITE) && cs->csc->relocs[index].write_domain)
+        return TRUE;
+    if ((usage & RADEON_USAGE_READ) && cs->csc->relocs[index].read_domains)
+        return TRUE;
+
+    return FALSE;
 }
 
 void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws)
index ef07d37bc9ac568c98e6523019d094a3441f2d5f..9c61dcb4ebeb05b76f7379d001e34764b2b1ff24 100644 (file)
@@ -341,7 +341,8 @@ struct radeon_winsys {
      * \param buf       A winsys buffer.
      */
     boolean (*cs_is_buffer_referenced)(struct radeon_winsys_cs *cs,
-                                       struct radeon_winsys_cs_handle *buf);
+                                       struct radeon_winsys_cs_handle *buf,
+                                       enum radeon_bo_usage usage);
 
     /**
      * Request access to a feature for a command stream.