freedreno: Rename the UBWC layer size field and store it as bytes.
authorEric Anholt <eric@anholt.net>
Mon, 25 Nov 2019 19:49:05 +0000 (11:49 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 4 Feb 2020 23:18:00 +0000 (23:18 +0000)
This makes the field description match its usage in the code, matches tu's
usage of the field, and avoids storing values in surprising units.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3059>

src/freedreno/fdl/fd6_layout.c
src/freedreno/fdl/freedreno_layout.c
src/freedreno/fdl/freedreno_layout.h
src/freedreno/vulkan/tu_cmd_buffer.c
src/freedreno/vulkan/tu_image.c
src/freedreno/vulkan/tu_private.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 6f0a91afcb9d60087ecbefe731976c84d0ffe313..30f334968eeeb671e079152cd25590cf3f3cc14c 100644 (file)
@@ -198,8 +198,8 @@ fdl6_layout(struct fdl_layout *layout,
 
                        ubwc_slice->size0 = align(meta_pitch * meta_height, UBWC_PLANE_SIZE_ALIGNMENT);
                        ubwc_slice->pitch = meta_pitch;
-                       ubwc_slice->offset = layout->ubwc_size;
-                       layout->ubwc_size += ubwc_slice->size0;
+                       ubwc_slice->offset = layout->ubwc_layer_size;
+                       layout->ubwc_layer_size += ubwc_slice->size0;
                }
 
                depth = u_minify(depth, 1);
@@ -221,8 +221,8 @@ fdl6_layout(struct fdl_layout *layout,
         */
        if (ubwc) {
                for (uint32_t level = 0; level < mip_levels; level++)
-                       layout->slices[level].offset += layout->ubwc_size * array_size;
-               layout->size += layout->ubwc_size * array_size;
+                       layout->slices[level].offset += layout->ubwc_layer_size * array_size;
+               layout->size += layout->ubwc_layer_size * array_size;
        }
 }
 
index 7c0a7052a52d254412f0c01ad14f8c41317a4550..5336683ba18c10825432c2a1f26950c6e7034a2f 100644 (file)
@@ -47,7 +47,7 @@ fdl_dump_layout(struct fdl_layout *layout)
        for (uint32_t level = 0; level < layout->slices[level].size0; level++) {
                struct fdl_slice *slice = &layout->slices[level];
                struct fdl_slice *ubwc_slice = &layout->ubwc_slices[level];
-               uint32_t tile_mode = (layout->ubwc_size ?
+               uint32_t tile_mode = (layout->ubwc_layer_size ?
                                layout->tile_mode : fdl_tile_mode(layout, level));
 
                fprintf(stderr, "%s: %ux%ux%u@%ux%u:\t%2u: stride=%4u, size=%6u,%6u, aligned_height=%3u, offset=0x%x,0x%x, layersz %5u,%5u tiling=%d\n",
@@ -61,7 +61,7 @@ fdl_dump_layout(struct fdl_layout *layout)
                                slice->size0, ubwc_slice->size0,
                                slice->size0 / (slice->pitch * layout->cpp),
                                slice->offset, ubwc_slice->offset,
-                               layout->layer_size, layout->ubwc_size,
+                               layout->layer_size, layout->ubwc_layer_size,
                                tile_mode);
        }
 }
index e7dbc057df7daddfe9cb939d40e2f0805a9464e3..7230d337a484a741453f05e65d1b393f1e4180ea 100644 (file)
@@ -92,6 +92,7 @@ struct fdl_layout {
        struct fdl_slice slices[FDL_MAX_MIP_LEVELS];
        struct fdl_slice ubwc_slices[FDL_MAX_MIP_LEVELS];
        uint32_t layer_size;
+       uint32_t ubwc_layer_size; /* in bytes */
        bool layer_first : 1;    /* see above description */
 
        /* Note that for tiled textures, beyond a certain mipmap level (ie.
@@ -112,8 +113,6 @@ struct fdl_layout {
        enum pipe_format format;
 
        uint32_t size; /* Size of the whole image, in bytes. */
-
-       uint32_t ubwc_size;
 };
 
 static inline uint32_t
@@ -138,7 +137,7 @@ fdl_ubwc_offset(const struct fdl_layout *layout, unsigned level, unsigned layer)
        /* for now this doesn't do anything clever, but when UBWC is enabled
         * for multi layer/level images, it will.
         */
-       if (layout->ubwc_size) {
+       if (layout->ubwc_layer_size) {
                assert(level == 0);
                assert(layer == 0);
        }
@@ -166,7 +165,7 @@ fdl_tile_mode(const struct fdl_layout *layout, int level)
 static inline bool
 fdl_ubwc_enabled(const struct fdl_layout *layout, int level)
 {
-       return layout->ubwc_size && fdl_tile_mode(layout, level);
+       return layout->ubwc_layer_size && fdl_tile_mode(layout, level);
 }
 
 void
index 766279183a7c484ad30a81f4215bf793c4aebd4e..ff5f723aaf62beb88a0b160612851d6146b82d69 100644 (file)
@@ -597,12 +597,12 @@ tu6_emit_blit_info(struct tu_cmd_buffer *cmd,
                       .samples = tu_msaa_samples(iview->image->samples),
                       .color_format = format->rb,
                       .color_swap = format->swap,
-                      .flags = iview->image->layout.ubwc_size != 0),
+                      .flags = iview->image->layout.ubwc_layer_size != 0),
                    A6XX_RB_BLIT_DST(tu_image_view_base_ref(iview)),
                    A6XX_RB_BLIT_DST_PITCH(tu_image_stride(iview->image, iview->base_mip)),
                    A6XX_RB_BLIT_DST_ARRAY_PITCH(iview->image->layout.layer_size));
 
-   if (iview->image->layout.ubwc_size) {
+   if (iview->image->layout.ubwc_layer_size) {
       tu_cs_emit_regs(cs,
                       A6XX_RB_BLIT_FLAG_DST(tu_image_view_ubwc_base_ref(iview)),
                       A6XX_RB_BLIT_FLAG_DST_PITCH(tu_image_view_ubwc_pitches(iview)));
index c76c44870e9e134ab67ddd5f3615af7682f6074c..fee74a294c506b6d7e0a6e19544abd2072ec0ff6 100644 (file)
@@ -45,7 +45,7 @@ image_level_linear(struct tu_image *image, int level, bool ubwc)
 enum a6xx_tile_mode
 tu6_get_image_tile_mode(struct tu_image *image, int level)
 {
-   if (image_level_linear(image, level, !!image->layout.ubwc_size))
+   if (image_level_linear(image, level, !!image->layout.ubwc_layer_size))
       return TILE6_LINEAR;
    else
       return image->layout.tile_mode;
@@ -307,7 +307,7 @@ tu_image_view_init(struct tu_image_view *iview,
    iview->descriptor[4] = base_addr;
    iview->descriptor[5] = (base_addr >> 32) | A6XX_TEX_CONST_5_DEPTH(depth);
 
-   if (image->layout.ubwc_size) {
+   if (image->layout.ubwc_layer_size) {
       uint32_t block_width, block_height;
       fdl6_get_ubwc_blockwidth(&image->layout,
                                &block_width, &block_height);
@@ -344,7 +344,7 @@ tu_image_view_init(struct tu_image_view *iview,
       iview->storage_descriptor[4] = base_addr;
       iview->storage_descriptor[5] = (base_addr >> 32) | A6XX_IBO_5_DEPTH(depth);
 
-      if (image->layout.ubwc_size) {
+      if (image->layout.ubwc_layer_size) {
          iview->storage_descriptor[3] |= A6XX_IBO_3_FLAG | A6XX_IBO_3_UNK27;
          iview->storage_descriptor[7] |= ubwc_addr;
          iview->storage_descriptor[8] |= ubwc_addr >> 32;
@@ -441,7 +441,7 @@ tu_GetImageSubresourceLayout(VkDevice _device,
    pLayout->arrayPitch = image->layout.layer_size;
    pLayout->depthPitch = slice->size0;
 
-   if (image->layout.ubwc_size) {
+   if (image->layout.ubwc_layer_size) {
       /* UBWC starts at offset 0 */
       pLayout->offset = 0;
       /* UBWC scanout won't match what the kernel wants if we have levels/layers */
@@ -463,7 +463,7 @@ VkResult tu_GetImageDrmFormatModifierPropertiesEXT(
 
    if (!image->layout.tile_mode)
       pProperties->drmFormatModifier = DRM_FORMAT_MOD_LINEAR;
-   else if (image->layout.ubwc_size)
+   else if (image->layout.ubwc_layer_size)
       pProperties->drmFormatModifier = DRM_FORMAT_MOD_QCOM_COMPRESSED;
    else
       pProperties->drmFormatModifier = DRM_FORMAT_MOD_INVALID;
index a71e0fd138c5af06160d39e931437066e39b067f..3a1bb331b9d288286d725a1fe22d1466a0a61d6c 100644 (file)
@@ -1362,7 +1362,7 @@ tu_image_base(struct tu_image *image, int level, int layer)
 static inline VkDeviceSize
 tu_image_ubwc_size(struct tu_image *image, int level)
 {
-   return image->layout.ubwc_size;
+   return image->layout.ubwc_layer_size;
 }
 
 static inline uint32_t
index c28eff3c08223036dd2d7e2cb22214e8bd008856..a477d5429117d3abe4a5600d1d9835d246c15178 100644 (file)
@@ -60,7 +60,7 @@ fd6_emit_flag_reference(struct fd_ringbuffer *ring, struct fd_resource *rsc,
                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_slices[level].pitch) |
-                               A6XX_RB_MRT_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->layout.ubwc_size));
+                               A6XX_RB_MRT_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->layout.ubwc_layer_size >> 2));
        } else {
                OUT_RING(ring, 0x00000000);    /* RB_MRT_FLAG_BUFFER[i].ADDR_LO */
                OUT_RING(ring, 0x00000000);    /* RB_MRT_FLAG_BUFFER[i].ADDR_HI */
index 7a126ddf7b998437d8ac35827ad9583dffda7486..57503b5c14eb72dc3d87bd171b932106c8e29dc6 100644 (file)
@@ -198,7 +198,7 @@ static void emit_image_tex(struct fd_ringbuffer *ring, struct fd6_image *img)
        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_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_layer_size >> 2));
                OUT_RING(ring, A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(ubwc_slice->pitch));
        } else {
                OUT_RING(ring, 0x00000000);   /* texconst7 */
@@ -266,7 +266,7 @@ static void emit_image_ssbo(struct fd_ringbuffer *ring, struct fd6_image *img)
        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_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_layer_size >> 2));
                OUT_RING(ring, A6XX_IBO_10_FLAG_BUFFER_PITCH(ubwc_slice->pitch));
        } else {
                OUT_RING(ring, 0x00000000);
index b16a406c479b913745638f522cb1d39f36a1e7ae..04753f9e0dc958b78b87dd905bd4260e6d1b15c1 100644 (file)
@@ -136,7 +136,7 @@ fd6_fill_ubwc_buffer_sizes(struct fd_resource *rsc)
 
        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.ubwc_layer_size = meta_size;
        rsc->layout.tile_mode = TILE6_3;
 
        return meta_size;
@@ -151,7 +151,7 @@ void
 fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
                enum pipe_format format)
 {
-       if (!rsc->layout.ubwc_size)
+       if (!rsc->layout.ubwc_layer_size)
                return;
 
        if (ok_ubwc_format(format))
index a5185cd6708c90f394e91f8138b183b2a429d5ee..91b42bd3d7c1b5b556a6a407ff322fc2125bb2e5 100644 (file)
@@ -278,7 +278,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
                                cso->swizzle_b, cso->swizzle_a);
 
        if (so->ubwc_enabled) {
-               so->texconst9 |= A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size);
+               so->texconst9 |= A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_layer_size >> 2);
                so->texconst10 |= A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_slices[lvl].pitch);
        }
 
index 4eced1fb1fbe3738c6ca52d081e7cce27f8f97dd..77b6cb5b6ca039b495053260ab3053d91ea3886a 100644 (file)
@@ -227,7 +227,7 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc,
                swap(rsc->layout.slices[level], shadow->layout.slices[level]);
                swap(rsc->layout.ubwc_slices[level], shadow->layout.ubwc_slices[level]);
        }
-       swap(rsc->layout.ubwc_size, shadow->layout.ubwc_size);
+       swap(rsc->layout.ubwc_layer_size, shadow->layout.ubwc_layer_size);
        rsc->seqno = p_atomic_inc_return(&ctx->screen->rsc_seqno);
 
        /* at this point, the newly created shadow buffer is not referenced
@@ -728,7 +728,7 @@ fd_resource_modifier(struct fd_resource *rsc)
        if (!rsc->layout.tile_mode)
                return DRM_FORMAT_MOD_LINEAR;
 
-       if (rsc->layout.ubwc_size)
+       if (rsc->layout.ubwc_layer_size)
                return DRM_FORMAT_MOD_QCOM_COMPRESSED;
 
        /* TODO invent a modifier for tiled but not UBWC buffers: */