From: Kenneth Graunke Date: Fri, 19 Jan 2018 23:30:55 +0000 (-0800) Subject: iris: maps X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6c7a27647079402494589b9ba99a9629618379c0;p=mesa.git iris: maps --- diff --git a/src/gallium/drivers/iris/iris_bufmgr.h b/src/gallium/drivers/iris/iris_bufmgr.h index 13b877669a0..035c908f3d9 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.h +++ b/src/gallium/drivers/iris/iris_bufmgr.h @@ -196,11 +196,11 @@ iris_bo_reference(struct iris_bo *bo) */ void iris_bo_unreference(struct iris_bo *bo); -#define MAP_READ 0x01 -#define MAP_WRITE 0x02 -#define MAP_ASYNC 0x20 -#define MAP_PERSISTENT 0x40 -#define MAP_COHERENT 0x80 +#define MAP_READ PIPE_TRANSFER_READ +#define MAP_WRITE PIPE_TRANSFER_WRITE +#define MAP_ASYNC PIPE_TRANSFER_UNSYNCHRONIZED +#define MAP_PERSISTENT PIPE_TRANSFER_PERSISTENT +#define MAP_COHERENT PIPE_TRANSFER_COHERENT /* internal */ #define MAP_INTERNAL_MASK (0xff << 24) #define MAP_RAW (0x01 << 24) diff --git a/src/gallium/drivers/iris/iris_pipe.c b/src/gallium/drivers/iris/iris_pipe.c index a088da83984..ec7ff5244eb 100644 --- a/src/gallium/drivers/iris/iris_pipe.c +++ b/src/gallium/drivers/iris/iris_pipe.c @@ -102,19 +102,25 @@ iris_set_active_query_state(struct pipe_context *pipe, boolean enable) * transfer */ static void * -iris_transfer_map(struct pipe_context *pipe, +iris_transfer_map(struct pipe_context *ctx, struct pipe_resource *resource, unsigned level, enum pipe_transfer_usage usage, const struct pipe_box *box, struct pipe_transfer **ptransfer) { - struct pipe_transfer *transfer; + struct iris_context *ice = (struct iris_context *)ctx; struct iris_resource *res = (struct iris_resource *)resource; + struct pipe_transfer *transfer; + + // PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE + // PIPE_TRANSFER_DISCARD_RANGE + // PIPE_TRANSFER_MAP_DIRECTLY transfer = calloc(1, sizeof(struct pipe_transfer)); if (!transfer) return NULL; + pipe_resource_reference(&transfer->resource, resource); transfer->level = level; transfer->usage = usage; @@ -123,7 +129,23 @@ iris_transfer_map(struct pipe_context *pipe, transfer->layer_stride = 1; *ptransfer = transfer; - return NULL; +#if 0 + if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED) && + iris_batch_references(&ice->batch, res->bo)) { + iris_batch_flush(&ice->batch); + } +#endif + + if ((usage & PIPE_TRANSFER_DONTBLOCK) && iris_bo_busy(res->bo)) + return NULL; + + usage &= (PIPE_TRANSFER_READ | + PIPE_TRANSFER_WRITE | + PIPE_TRANSFER_UNSYNCHRONIZED | + PIPE_TRANSFER_PERSISTENT | + PIPE_TRANSFER_COHERENT); + + return iris_bo_map(&ice->dbg, res->bo, usage); } static void