gallium/radeon: handle PIPE_TRANSFER_FLUSH_EXPLICIT
Basically, do the same thing as for buffer_unmap, but use the explicit range instead. It's for apps which want to map a whole buffer and mark touched ranges explicitly. Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
This commit is contained in:
parent
60ec8fb448
commit
b409524fef
|
@ -346,37 +346,59 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx,
|
|||
ptransfer, data, NULL, 0);
|
||||
}
|
||||
|
||||
static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
|
||||
struct pipe_transfer *transfer)
|
||||
static void r600_buffer_do_flush_region(struct pipe_context *ctx,
|
||||
struct pipe_transfer *transfer,
|
||||
const struct pipe_box *box)
|
||||
{
|
||||
struct r600_common_context *rctx = (struct r600_common_context*)ctx;
|
||||
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
|
||||
struct r600_resource *rbuffer = r600_resource(transfer->resource);
|
||||
|
||||
if (rtransfer->staging) {
|
||||
if (rtransfer->transfer.usage & PIPE_TRANSFER_WRITE) {
|
||||
struct pipe_resource *dst, *src;
|
||||
unsigned soffset, doffset, size;
|
||||
struct pipe_box box;
|
||||
struct pipe_resource *dst, *src;
|
||||
unsigned soffset;
|
||||
struct pipe_box dma_box;
|
||||
|
||||
dst = transfer->resource;
|
||||
src = &rtransfer->staging->b.b;
|
||||
size = transfer->box.width;
|
||||
doffset = transfer->box.x;
|
||||
soffset = rtransfer->offset + transfer->box.x % R600_MAP_BUFFER_ALIGNMENT;
|
||||
dst = transfer->resource;
|
||||
src = &rtransfer->staging->b.b;
|
||||
soffset = rtransfer->offset + box->x % R600_MAP_BUFFER_ALIGNMENT;
|
||||
|
||||
u_box_1d(soffset, size, &box);
|
||||
u_box_1d(soffset, box->width, &dma_box);
|
||||
|
||||
/* Copy the staging buffer into the original one. */
|
||||
rctx->dma_copy(ctx, dst, 0, doffset, 0, 0, src, 0, &box);
|
||||
}
|
||||
/* Copy the staging buffer into the original one. */
|
||||
rctx->dma_copy(ctx, dst, 0, box->x, 0, 0, src, 0, &dma_box);
|
||||
}
|
||||
|
||||
util_range_add(&rbuffer->valid_buffer_range, box->x,
|
||||
box->x + box->width);
|
||||
}
|
||||
|
||||
static void r600_buffer_flush_region(struct pipe_context *ctx,
|
||||
struct pipe_transfer *transfer,
|
||||
const struct pipe_box *rel_box)
|
||||
{
|
||||
if (transfer->usage & (PIPE_TRANSFER_WRITE |
|
||||
PIPE_TRANSFER_FLUSH_EXPLICIT)) {
|
||||
struct pipe_box box;
|
||||
|
||||
u_box_1d(transfer->box.x + rel_box->x, rel_box->width, &box);
|
||||
r600_buffer_do_flush_region(ctx, transfer, &box);
|
||||
}
|
||||
}
|
||||
|
||||
static void r600_buffer_transfer_unmap(struct pipe_context *ctx,
|
||||
struct pipe_transfer *transfer)
|
||||
{
|
||||
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)
|
||||
pipe_resource_reference((struct pipe_resource**)&rtransfer->staging, NULL);
|
||||
}
|
||||
|
||||
if (transfer->usage & PIPE_TRANSFER_WRITE) {
|
||||
util_range_add(&rbuffer->valid_buffer_range, transfer->box.x,
|
||||
transfer->box.x + transfer->box.width);
|
||||
}
|
||||
util_slab_free(&rctx->pool_transfers, transfer);
|
||||
}
|
||||
|
||||
|
@ -385,7 +407,7 @@ static const struct u_resource_vtbl r600_buffer_vtbl =
|
|||
NULL, /* get_handle */
|
||||
r600_buffer_destroy, /* resource_destroy */
|
||||
r600_buffer_transfer_map, /* transfer_map */
|
||||
NULL, /* transfer_flush_region */
|
||||
r600_buffer_flush_region, /* transfer_flush_region */
|
||||
r600_buffer_transfer_unmap, /* transfer_unmap */
|
||||
NULL /* transfer_inline_write */
|
||||
};
|
||||
|
|
|
@ -231,7 +231,7 @@ bool r600_common_context_init(struct r600_common_context *rctx,
|
|||
rctx->max_db = 4;
|
||||
|
||||
rctx->b.transfer_map = u_transfer_map_vtbl;
|
||||
rctx->b.transfer_flush_region = u_default_transfer_flush_region;
|
||||
rctx->b.transfer_flush_region = u_transfer_flush_region_vtbl;
|
||||
rctx->b.transfer_unmap = u_transfer_unmap_vtbl;
|
||||
rctx->b.transfer_inline_write = u_default_transfer_inline_write;
|
||||
rctx->b.memory_barrier = r600_memory_barrier;
|
||||
|
|
|
@ -1092,7 +1092,7 @@ static const struct u_resource_vtbl r600_texture_vtbl =
|
|||
NULL, /* get_handle */
|
||||
r600_texture_destroy, /* resource_destroy */
|
||||
r600_texture_transfer_map, /* transfer_map */
|
||||
NULL, /* transfer_flush_region */
|
||||
u_default_transfer_flush_region, /* transfer_flush_region */
|
||||
r600_texture_transfer_unmap, /* transfer_unmap */
|
||||
NULL /* transfer_inline_write */
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue