gallium/radeon: subclass threaded_transfer
authorMarek Olšák <marek.olsak@amd.com>
Tue, 2 May 2017 23:51:42 +0000 (01:51 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 15 May 2017 11:01:33 +0000 (13:01 +0200)
v2: use assert on rtransfer->b.staging

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeon/r600_texture.c

index b57632e077246329ed426f906ef71ff6f9bcdb5f..8ded99e90ca0a4b9ad27368d8d3e9b1dd4f5df8c 100644 (file)
@@ -300,16 +300,17 @@ static void *r600_buffer_get_transfer(struct pipe_context *ctx,
        else
                transfer = slab_alloc(&rctx->pool_transfers);
 
-       transfer->transfer.resource = NULL;
-       pipe_resource_reference(&transfer->transfer.resource, resource);
-       transfer->transfer.level = 0;
-       transfer->transfer.usage = usage;
-       transfer->transfer.box = *box;
-       transfer->transfer.stride = 0;
-       transfer->transfer.layer_stride = 0;
+       transfer->b.b.resource = NULL;
+       pipe_resource_reference(&transfer->b.b.resource, resource);
+       transfer->b.b.level = 0;
+       transfer->b.b.usage = usage;
+       transfer->b.b.box = *box;
+       transfer->b.b.stride = 0;
+       transfer->b.b.layer_stride = 0;
+       transfer->b.staging = NULL;
        transfer->offset = offset;
        transfer->staging = staging;
-       *ptransfer = &transfer->transfer;
+       *ptransfer = &transfer->b.b;
        return data;
 }
 
@@ -512,9 +513,8 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
            !(transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT))
                r600_buffer_do_flush_region(ctx, transfer, &transfer->box);
 
-       if (rtransfer->staging)
-               r600_resource_reference(&rtransfer->staging, NULL);
-
+       r600_resource_reference(&rtransfer->staging, NULL);
+       assert(rtransfer->b.staging == NULL); /* for threaded context only */
        pipe_resource_reference(&transfer->resource, NULL);
 
        /* Don't use pool_transfers_unsync. We are always in the driver
index 34497863f89281f967410d1a4c01ea373556f2f2..a694b974adfb22be75604591653663836f45bd0e 100644 (file)
@@ -184,7 +184,7 @@ struct r600_resource {
 };
 
 struct r600_transfer {
-       struct pipe_transfer            transfer;
+       struct threaded_transfer        b;
        struct r600_resource            *staging;
        unsigned                        offset;
 };
index 3bcf9667fd0361d994166688410c66eac240178f..4d72b86f4e47fcad460d856771652d1b5a75c19a 100644 (file)
@@ -1648,10 +1648,10 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
        trans = CALLOC_STRUCT(r600_transfer);
        if (!trans)
                return NULL;
-       pipe_resource_reference(&trans->transfer.resource, texture);
-       trans->transfer.level = level;
-       trans->transfer.usage = usage;
-       trans->transfer.box = *box;
+       pipe_resource_reference(&trans->b.b.resource, texture);
+       trans->b.b.level = level;
+       trans->b.b.usage = usage;
+       trans->b.b.box = *box;
 
        if (rtex->is_depth) {
                struct r600_texture *staging_depth;
@@ -1693,8 +1693,8 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 
                        /* Just get the strides. */
                        r600_texture_get_offset(rctx->screen, staging_depth, level, NULL,
-                                               &trans->transfer.stride,
-                                               &trans->transfer.layer_stride);
+                                               &trans->b.b.stride,
+                                               &trans->b.b.layer_stride);
                } else {
                        /* XXX: only readback the rectangle which is being mapped? */
                        /* XXX: when discard is true, no need to read back from depth texture */
@@ -1711,8 +1711,8 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 
                        offset = r600_texture_get_offset(rctx->screen, staging_depth,
                                                         level, box,
-                                                        &trans->transfer.stride,
-                                                        &trans->transfer.layer_stride);
+                                                        &trans->b.b.stride,
+                                                        &trans->b.b.layer_stride);
                }
 
                trans->staging = (struct r600_resource*)staging_depth;
@@ -1737,8 +1737,8 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
 
                /* Just get the strides. */
                r600_texture_get_offset(rctx->screen, staging, 0, NULL,
-                                       &trans->transfer.stride,
-                                       &trans->transfer.layer_stride);
+                                       &trans->b.b.stride,
+                                       &trans->b.b.layer_stride);
 
                if (usage & PIPE_TRANSFER_READ)
                        r600_copy_to_staging_texture(ctx, trans);
@@ -1749,8 +1749,8 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
        } else {
                /* the resource is mapped directly */
                offset = r600_texture_get_offset(rctx->screen, rtex, level, box,
-                                                &trans->transfer.stride,
-                                                &trans->transfer.layer_stride);
+                                                &trans->b.b.stride,
+                                                &trans->b.b.layer_stride);
                buf = &rtex->resource;
        }
 
@@ -1760,7 +1760,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
                return NULL;
        }
 
-       *ptransfer = &trans->transfer;
+       *ptransfer = &trans->b.b;
        return map + offset;
 }