r600g,radeonsi: skip unnecessary buffer_is_busy call, add a comment
authorMarek Olšák <marek.olsak@amd.com>
Sat, 1 Feb 2014 14:06:39 +0000 (15:06 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 4 Feb 2014 19:19:16 +0000 (20:19 +0100)
src/gallium/drivers/radeon/r600_buffer_common.c

index 5b9282539e92777a39aa83127783014ee3b73b65..20772289e246c3a7cb81650970630cf837fb2c3b 100644 (file)
@@ -49,6 +49,7 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
                                       unsigned usage)
 {
        enum radeon_bo_usage rusage = RADEON_USAGE_READWRITE;
+       bool busy = false;
 
        if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) {
                return ctx->ws->buffer_map(resource->cs_buf, NULL, usage);
@@ -67,6 +68,7 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
                        return NULL;
                } else {
                        ctx->rings.gfx.flush(ctx, 0);
+                       busy = true;
                }
        }
        if (ctx->rings.dma.cs &&
@@ -78,10 +80,11 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
                        return NULL;
                } else {
                        ctx->rings.dma.flush(ctx, 0);
+                       busy = true;
                }
        }
 
-       if (ctx->ws->buffer_is_busy(resource->buf, rusage)) {
+       if (busy || ctx->ws->buffer_is_busy(resource->buf, rusage)) {
                if (usage & PIPE_TRANSFER_DONTBLOCK) {
                        return NULL;
                } else {
@@ -93,6 +96,7 @@ void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,
                }
        }
 
+       /* Setting the CS to NULL will prevent doing checks we have done already. */
        return ctx->ws->buffer_map(resource->cs_buf, NULL, usage);
 }