From b40d8026fa8753f71c7a67f8e39f245ddcb99eda Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 3 May 2017 01:51:42 +0200 Subject: [PATCH] gallium/radeon: subclass threaded_transfer MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit v2: use assert on rtransfer->b.staging Reviewed-by: Nicolai Hähnle Tested-by: Dieter Nützel --- .../drivers/radeon/r600_buffer_common.c | 22 ++++++++-------- src/gallium/drivers/radeon/r600_pipe_common.h | 2 +- src/gallium/drivers/radeon/r600_texture.c | 26 +++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c index b57632e0772..8ded99e90ca 100644 --- a/src/gallium/drivers/radeon/r600_buffer_common.c +++ b/src/gallium/drivers/radeon/r600_buffer_common.c @@ -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 diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index 34497863f89..a694b974adf 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -184,7 +184,7 @@ struct r600_resource { }; struct r600_transfer { - struct pipe_transfer transfer; + struct threaded_transfer b; struct r600_resource *staging; unsigned offset; }; diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c index 3bcf9667fd0..4d72b86f4e4 100644 --- a/src/gallium/drivers/radeon/r600_texture.c +++ b/src/gallium/drivers/radeon/r600_texture.c @@ -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; } -- 2.30.2