panfrost: Load from tiled images
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 18 Jun 2019 17:48:43 +0000 (10:48 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 20 Jun 2019 15:22:38 +0000 (08:22 -0700)
Now that we have lima tiling code available, use it to load from a tiled
source.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_resource.c

index 5b84daf3a3f073d55b5407dc5c08deff3a0a1db2..a99840e4a52c9c11a765e0350856628c3c0b6655 100644 (file)
@@ -506,9 +506,22 @@ panfrost_transfer_map(struct pipe_context *pctx,
 
                 transfer->base.stride = box->width * bytes_per_pixel;
                 transfer->base.layer_stride = transfer->base.stride * box->height;
-
-                /* TODO: Reads */
                 transfer->map = rzalloc_size(transfer, transfer->base.layer_stride * box->depth);
+                assert(box->depth == 1);
+
+                if (usage & PIPE_TRANSFER_READ) {
+                        if (bo->layout == PAN_AFBC) {
+                                DBG("Unimplemented: reads from AFBC");
+                        } else if (bo->layout == PAN_TILED) {
+                                panfrost_load_tiled_image(
+                                                transfer->map,
+                                                bo->cpu + bo->slices[level].offset,
+                                                box,
+                                                transfer->base.stride,
+                                                bo->slices[level].stride,
+                                                util_format_get_blocksize(resource->format));
+                        }
+                }
 
                 return transfer->map;
         } else {