freedreno: Drop the extra offset field for mipmap slices.
authorEric Anholt <eric@anholt.net>
Thu, 21 Nov 2019 22:53:58 +0000 (14:53 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 11 Dec 2019 04:24:18 +0000 (04:24 +0000)
We can just bake the UBWC-goes-first delta into the slices at setup time.
I did have to fix up the resource shadowing swap path to swap the slice
fields, as it was missing and regressed the format reinterpets otherwise.

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
src/freedreno/fdl/freedreno_layout.h
src/gallium/drivers/freedreno/a6xx/fd6_resource.c
src/gallium/drivers/freedreno/freedreno_resource.c

index c17120a8ac686818d98eb8ce9d70c61e3d92cc9b..40989c333711875730cf9b57095672b605d4df33 100644 (file)
@@ -100,7 +100,6 @@ struct fdl_layout {
        uint32_t width0, height0, depth0;
 
        /* UBWC specific fields: */
-       uint32_t offset;         /* offset to start of pixel data */
        uint32_t ubwc_offset;    /* offset to UBWC meta data */
        uint32_t ubwc_pitch;
        uint32_t ubwc_size;
@@ -119,9 +118,7 @@ static inline uint32_t
 fdl_surface_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
 {
        const struct fdl_slice *slice = &layout->slices[level];
-       unsigned offset = slice->offset;
-       offset += fdl_layer_stride(layout, level) * layer;
-       return offset + layout->offset;
+       return slice->offset + fdl_layer_stride(layout, level) * layer;
 }
 
 static inline uint32_t
index 4acb80f1508c6b1636380d8d4c542c576a9a4e48..8b5e79c4ae8acc4e975972bbee639bac3d7965c9 100644 (file)
@@ -262,8 +262,12 @@ fd6_fill_ubwc_buffer_sizes(struct fd_resource *rsc)
         * because it is what the kernel expects for scanout.  For non-2D we
         * could just use a separate UBWC buffer..
         */
+       for (int level = 0; level <= prsc->last_level; level++) {
+               struct fdl_slice *slice = fd_resource_slice(rsc, level);
+               slice->offset += meta_size;
+       }
+
        rsc->layout.ubwc_offset = 0;
-       rsc->layout.offset = meta_size;
        rsc->layout.ubwc_pitch = meta_stride;
        rsc->layout.ubwc_size = meta_size >> 2;   /* in dwords??? */
        rsc->layout.tile_mode = TILE6_3;
index c17bd365f1a507f52fe68cd046f3930f728bc4dd..3e74e0c5a00480d85f4d8565826f45f612be11d2 100644 (file)
@@ -223,7 +223,8 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
        /* TODO valid_buffer_range?? */
        swap(rsc->bo,        shadow->bo);
        swap(rsc->write_batch,   shadow->write_batch);
-       swap(rsc->layout.offset, shadow->layout.offset);
+       for (int level = 0; level <= prsc->last_level; level++)
+               swap(rsc->layout.slices[level], shadow->layout.slices[level]);
        swap(rsc->layout.ubwc_offset, shadow->layout.ubwc_offset);
        swap(rsc->layout.ubwc_pitch, shadow->layout.ubwc_pitch);
        swap(rsc->layout.ubwc_size, shadow->layout.ubwc_size);