[Mesa-dev] [PATCH 4/7] gallium/radeon: reference pipe_resource in pipe_transfer
Marek Olšák
maraeo at gmail.com
Sun Mar 12 17:16:28 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
for threaded gallium
---
src/gallium/drivers/radeon/r600_buffer_common.c | 4 +++-
src/gallium/drivers/radeon/r600_texture.c | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c b/src/gallium/drivers/radeon/r600_buffer_common.c
index cc9d3be..5fde0d6 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -281,21 +281,22 @@ static void *r600_buffer_get_transfer(struct pipe_context *ctx,
struct pipe_resource *resource,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer,
void *data, struct r600_resource *staging,
unsigned offset)
{
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_transfer *transfer = slab_alloc(&rctx->pool_transfers);
- transfer->transfer.resource = resource;
+ 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->offset = offset;
transfer->staging = staging;
*ptransfer = &transfer->transfer;
return data;
}
@@ -468,20 +469,21 @@ static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
if (transfer->usage & PIPE_TRANSFER_WRITE &&
!(transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT))
r600_buffer_do_flush_region(ctx, transfer, &transfer->box);
if (rtransfer->staging)
r600_resource_reference(&rtransfer->staging, NULL);
+ pipe_resource_reference(&transfer->resource, NULL);
slab_free(&rctx->pool_transfers, transfer);
}
void r600_buffer_subdata(struct pipe_context *ctx,
struct pipe_resource *buffer,
unsigned usage, unsigned offset,
unsigned size, const void *data)
{
struct pipe_transfer *transfer = NULL;
struct pipe_box box;
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 7ca112c..ec7a325 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1483,21 +1483,21 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
usage, box))
r600_texture_invalidate_storage(rctx, rtex);
else
use_staging_texture = true;
}
}
trans = CALLOC_STRUCT(r600_transfer);
if (!trans)
return NULL;
- trans->transfer.resource = texture;
+ pipe_resource_reference(&trans->transfer.resource, texture);
trans->transfer.level = level;
trans->transfer.usage = usage;
trans->transfer.box = *box;
if (rtex->is_depth) {
struct r600_texture *staging_depth;
if (rtex->resource.b.b.nr_samples > 1) {
/* MSAA depth buffers need to be converted to single sample buffers.
*
@@ -1636,20 +1636,21 @@ static void r600_texture_transfer_unmap(struct pipe_context *ctx,
* usage will be slightly higher than given here because of the buffer
* cache in the winsys.
*
* The result is that the kernel memory manager is never a bottleneck.
*/
if (rctx->num_alloc_tex_transfer_bytes > rctx->screen->info.gart_size / 4) {
rctx->gfx.flush(rctx, RADEON_FLUSH_ASYNC, NULL);
rctx->num_alloc_tex_transfer_bytes = 0;
}
+ pipe_resource_reference(&transfer->resource, NULL);
FREE(transfer);
}
static const struct u_resource_vtbl r600_texture_vtbl =
{
NULL, /* get_handle */
r600_texture_destroy, /* resource_destroy */
r600_texture_transfer_map, /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
r600_texture_transfer_unmap, /* transfer_unmap */
--
2.7.4
More information about the mesa-dev
mailing list