iris: maps
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 19 Jan 2018 23:30:55 +0000 (15:30 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:05 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_bufmgr.h
src/gallium/drivers/iris/iris_pipe.c

index 13b877669a0beb2bc1af69166b4320270fd1ad60..035c908f3d9e8f394b43d29896060635a1d225af 100644 (file)
@@ -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)
index a088da839848c1d037183d6f7bef8dba7963fb84..ec7ff5244eb7ed368f63d649e0ebd7c9e5458279 100644 (file)
@@ -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