llvmpipe: Cleanup/improve llvmpipe_flush_resource usage.

Recognize PIPE_TRANSFER_UNSYNCHRONIZED and PIPE_TRANSFER_DONTBLOCK.
This commit is contained in:
José Fonseca
2010-04-25 16:59:09 +01:00
parent 8352983e2a
commit 43b85af56e
4 changed files with 48 additions and 36 deletions

View File

@@ -492,6 +492,27 @@ llvmpipe_get_transfer(struct pipe_context *pipe,
assert(resource);
assert(sr.level <= resource->last_level);
/*
* Transfers, like other pipe operations, must happen in order, so flush the
* context if necessary.
*/
if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
boolean read_only = !(usage & PIPE_TRANSFER_WRITE);
boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK);
if (!llvmpipe_flush_resource(pipe, resource,
sr.face, sr.level,
0, /* flush_flags */
read_only,
TRUE, /* cpu_access */
do_not_block)) {
/*
* It would have blocked, but state tracker requested no to.
*/
assert(do_not_block);
return NULL;
}
}
lpr = CALLOC_STRUCT(llvmpipe_transfer);
if (lpr) {
struct pipe_transfer *pt = &lpr->base;
@@ -562,19 +583,6 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
lpr = llvmpipe_resource(transfer->resource);
format = lpr->base.format;
/*
* Transfers, like other pipe operations, must happen in order, so flush the
* context if necessary.
*/
llvmpipe_flush_resource(pipe,
transfer->resource,
transfer->sr.face,
transfer->sr.level,
0, /* flush_flags */
!(transfer->usage & PIPE_TRANSFER_WRITE), /* read_only */
TRUE, /* cpu_access */
FALSE); /* do_not_flush */
map = llvmpipe_resource_map(transfer->resource,
transfer->sr.face,
transfer->sr.level,