freedreno: Move UBWC layout into a slices array like the non-UBWC slices.
authorEric Anholt <eric@anholt.net>
Mon, 25 Nov 2019 19:23:03 +0000 (11:23 -0800)
committerEric Anholt <eric@anholt.net>
Wed, 11 Dec 2019 04:24:18 +0000 (04:24 +0000)
This is a little refactor in preparation for UBWC mipmapping support.

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

index 40989c333711875730cf9b57095672b605d4df33..4704a5fc88d5f65cf57fee02db16ee3988098568 100644 (file)
@@ -81,6 +81,7 @@ struct fdl_slice {
  */
 struct fdl_layout {
        struct fdl_slice slices[MAX_MIP_LEVELS];
+       struct fdl_slice ubwc_slices[MAX_MIP_LEVELS];
        uint32_t layer_size;
        bool layer_first : 1;    /* see above description */
 
@@ -99,9 +100,6 @@ struct fdl_layout {
 
        uint32_t width0, height0, depth0;
 
-       /* UBWC specific fields: */
-       uint32_t ubwc_offset;    /* offset to UBWC meta data */
-       uint32_t ubwc_pitch;
        uint32_t ubwc_size;
 };
 
@@ -131,7 +129,7 @@ fdl_ubwc_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
                debug_assert(level == 0);
                debug_assert(layer == 0);
        }
-       return layout->ubwc_offset;
+       return layout->ubwc_slices[0].offset;
 }
 
 static inline bool
index 35199aea99a483579dcb5e73a9699139e46bab2c..fbc53b748eddedc2a3f08a743f9e8fe214e2ce1b 100644 (file)
@@ -61,7 +61,7 @@ fd6_emit_flag_reference(struct fd_ringbuffer *ring, struct fd_resource *rsc,
        if (fd_resource_ubwc_enabled(rsc, level)) {
                OUT_RELOCW(ring, rsc->bo, fd_resource_ubwc_offset(rsc, level, layer), 0, 0);
                OUT_RING(ring,
-                               A6XX_RB_MRT_FLAG_BUFFER_PITCH_PITCH(rsc->layout.ubwc_pitch) |
+                               A6XX_RB_MRT_FLAG_BUFFER_PITCH_PITCH(rsc->layout.ubwc_slices[level].pitch) |
                                A6XX_RB_MRT_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->layout.ubwc_size));
        } else {
                OUT_RING(ring, 0x00000000);    /* RB_MRT_FLAG_BUFFER[i].ADDR_LO */
index 62ce378653d1cd947e42a99cae18773a9e7c8416..8cc95b7cb5b000498babc470d3e5ec129a145f2b 100644 (file)
@@ -196,9 +196,10 @@ static void emit_image_tex(struct fd_ringbuffer *ring, struct fd6_image *img)
        OUT_RING(ring, 0x00000000);   /* texconst6 */
 
        if (ubwc_enabled) {
+               struct fdl_slice *ubwc_slice = &rsc->layout.ubwc_slices[img->level];
                OUT_RELOC(ring, rsc->bo, img->ubwc_offset, 0, 0);
                OUT_RING(ring, A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size));
-               OUT_RING(ring, A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_pitch));
+               OUT_RING(ring, A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(ubwc_slice->pitch));
        } else {
                OUT_RING(ring, 0x00000000);   /* texconst7 */
                OUT_RING(ring, 0x00000000);   /* texconst8 */
@@ -254,9 +255,10 @@ static void emit_image_ssbo(struct fd_ringbuffer *ring, struct fd6_image *img)
        OUT_RING(ring, 0x00000000);
 
        if (ubwc_enabled) {
+               struct fdl_slice *ubwc_slice = &rsc->layout.ubwc_slices[img->level];
                OUT_RELOCW(ring, rsc->bo, img->ubwc_offset, 0, 0);
                OUT_RING(ring, A6XX_IBO_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size));
-               OUT_RING(ring, A6XX_IBO_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_pitch));
+               OUT_RING(ring, A6XX_IBO_10_FLAG_BUFFER_PITCH(ubwc_slice->pitch));
        } else {
                OUT_RING(ring, 0x00000000);
                OUT_RING(ring, 0x00000000);
index 8b5e79c4ae8acc4e975972bbee639bac3d7965c9..4a35dd6db2fc649379263676f504fa5a76840ffc 100644 (file)
@@ -267,8 +267,8 @@ fd6_fill_ubwc_buffer_sizes(struct fd_resource *rsc)
                slice->offset += meta_size;
        }
 
-       rsc->layout.ubwc_offset = 0;
-       rsc->layout.ubwc_pitch = meta_stride;
+       rsc->layout.ubwc_slices[0].offset = 0;
+       rsc->layout.ubwc_slices[0].pitch = meta_stride;
        rsc->layout.ubwc_size = meta_size >> 2;   /* in dwords??? */
        rsc->layout.tile_mode = TILE6_3;
 
index 585d3eb81e863d874992ab9753aa663592e742bb..a5185cd6708c90f394e91f8138b183b2a429d5ee 100644 (file)
@@ -279,7 +279,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
 
        if (so->ubwc_enabled) {
                so->texconst9 |= A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size);
-               so->texconst10 |= A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_pitch);
+               so->texconst10 |= A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_slices[lvl].pitch);
        }
 
        so->texconst2 |= A6XX_TEX_CONST_2_TYPE(fd6_tex_type(cso->target));
index 3e74e0c5a00480d85f4d8565826f45f612be11d2..5826e16c1545dd377971ce48752759c373f1bf94 100644 (file)
@@ -223,10 +223,10 @@ 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);
-       for (int level = 0; level <= prsc->last_level; level++)
+       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_slices[level], shadow->layout.ubwc_slices[level]);
+       }
        swap(rsc->layout.ubwc_size, shadow->layout.ubwc_size);
        rsc->seqno = p_atomic_inc_return(&ctx->screen->rsc_seqno);