panfrost: Map with size of first layer for 3D textures
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 2 Jan 2020 10:27:00 +0000 (11:27 +0100)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 2 Jan 2020 17:41:15 +0000 (12:41 -0500)
As that's what Gallium expects in transfer.layer_stride.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_resource.h

index df0fc9e5cac03944ac28ab843947874e9997b358..1de9d5acf2d0690f30c4997b8a0ccd2707d46576 100644 (file)
@@ -322,6 +322,8 @@ panfrost_setup_slices(struct panfrost_resource *pres, size_t *bo_size)
                 unsigned slice_one_size = slice->stride * effective_height;
                 unsigned slice_full_size = slice_one_size * effective_depth;
 
+                slice->size0 = slice_one_size;
+
                 /* Report 2D size for 3D texturing */
 
                 if (l == 0)
@@ -665,7 +667,10 @@ panfrost_transfer_map(struct pipe_context *pctx,
                 return transfer->map;
         } else {
                 transfer->base.stride = rsrc->slices[level].stride;
-                transfer->base.layer_stride = rsrc->cubemap_stride;
+                if (resource->target == PIPE_TEXTURE_3D)
+                        transfer->base.layer_stride = rsrc->slices[level].size0;
+                else
+                        transfer->base.layer_stride = rsrc->cubemap_stride;
 
                 /* By mapping direct-write, we're implicitly already
                  * initialized (maybe), so be conservative */
@@ -675,7 +680,7 @@ panfrost_transfer_map(struct pipe_context *pctx,
 
                 return bo->cpu
                        + rsrc->slices[level].offset
-                       + transfer->base.box.z * rsrc->cubemap_stride
+                       + transfer->base.box.z * transfer->base.layer_stride
                        + transfer->base.box.y * rsrc->slices[level].stride
                        + transfer->base.box.x * bytes_per_pixel;
         }
index a9c4d7cc539623339b6d57805305bfde32f513ac..0dcfbbd3a18ad3179d62e30322b70b5663285709 100644 (file)
@@ -43,6 +43,7 @@ enum panfrost_memory_layout {
 struct panfrost_slice {
         unsigned offset;
         unsigned stride;
+        unsigned size0;
 
         /* If there is a header preceding each slice, how big is
          * that header?  Used for AFBC */