gallium/radeon: implement PIPE_CAP_INVALIDATE_BUFFER
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 14 Jan 2016 14:41:04 +0000 (09:41 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 14 Jan 2016 14:41:04 +0000 (09:41 -0500)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/si_pipe.c

index a8805f6905bef31f25ab55160880ee6a5b713c79..569f77c2b850fbed0af3623c4cc9c2843f103285 100644 (file)
@@ -278,6 +278,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_HALF_FLOAT_LINEAR:
        case PIPE_CAP_TGSI_TXQS:
        case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
+       case PIPE_CAP_INVALIDATE_BUFFER:
                return 1;
 
        case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
@@ -355,7 +356,6 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
        case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
-       case PIPE_CAP_INVALIDATE_BUFFER:
                return 0;
 
        case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
index aeb9a20e2971d8bfdf1d73fa1a4f9e6e6b1fa144..09755e04b5849d6171c4476b3a2b556a21bdec7f 100644 (file)
@@ -209,6 +209,21 @@ static void r600_buffer_destroy(struct pipe_screen *screen,
        FREE(rbuffer);
 }
 
+void r600_invalidate_resource(struct pipe_context *ctx,
+                             struct pipe_resource *resource)
+{
+       struct r600_common_context *rctx = (struct r600_common_context*)ctx;
+        struct r600_resource *rbuffer = r600_resource(resource);
+
+       /* Check if mapping this buffer would cause waiting for the GPU. */
+       if (r600_rings_is_buffer_referenced(rctx, rbuffer->buf, RADEON_USAGE_READWRITE) ||
+           !rctx->ws->buffer_wait(rbuffer->buf, 0, RADEON_USAGE_READWRITE)) {
+               rctx->invalidate_buffer(&rctx->b, &rbuffer->b.b);
+       } else {
+               util_range_set_empty(&rbuffer->valid_buffer_range);
+       }
+}
+
 static void *r600_buffer_get_transfer(struct pipe_context *ctx,
                                      struct pipe_resource *resource,
                                       unsigned level,
@@ -276,13 +291,7 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx,
            !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
                assert(usage & PIPE_TRANSFER_WRITE);
 
-               /* Check if mapping this buffer would cause waiting for the GPU. */
-               if (r600_rings_is_buffer_referenced(rctx, rbuffer->buf, RADEON_USAGE_READWRITE) ||
-                   !rctx->ws->buffer_wait(rbuffer->buf, 0, RADEON_USAGE_READWRITE)) {
-                       rctx->invalidate_buffer(&rctx->b, &rbuffer->b.b);
-               } else {
-                       util_range_set_empty(&rbuffer->valid_buffer_range);
-               }
+               r600_invalidate_resource(ctx, resource);
 
                /* At this point, the buffer is always idle. */
                usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
index 52c365e81d0a3bae3394655892a8d3dab4c04e57..e926f56023fdcfb5b7352ee2dc280934555670c4 100644 (file)
@@ -257,6 +257,7 @@ bool r600_common_context_init(struct r600_common_context *rctx,
        else
                rctx->max_db = 4;
 
+       rctx->b.invalidate_resource = r600_invalidate_resource;
        rctx->b.transfer_map = u_transfer_map_vtbl;
        rctx->b.transfer_flush_region = u_transfer_flush_region_vtbl;
        rctx->b.transfer_unmap = u_transfer_unmap_vtbl;
index 68b50a9fb0fe8368e8c01ad4a62224894ff26fca..27f6e983eeae541865bdf093ccf96b9e9f5d15a1 100644 (file)
@@ -500,6 +500,9 @@ struct pipe_resource *
 r600_buffer_from_user_memory(struct pipe_screen *screen,
                             const struct pipe_resource *templ,
                             void *user_memory);
+void
+r600_invalidate_resource(struct pipe_context *ctx,
+                        struct pipe_resource *resource);
 
 /* r600_common_pipe.c */
 void r600_draw_rectangle(struct blitter_context *blitter,
index d8deac3d2f256da3494cea97148d65fcb5920bde..cb80a72f94b5c6e649662e1bacc82f8fef719122 100644 (file)
@@ -303,6 +303,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
        case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
        case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
+       case PIPE_CAP_INVALIDATE_BUFFER:
                return 1;
 
        case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
@@ -347,7 +348,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_MULTI_DRAW_INDIRECT:
        case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
        case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
-       case PIPE_CAP_INVALIDATE_BUFFER:
                return 0;
 
        case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS: