From 17312b4a10718ee14a80e5c1b4e2e586d8a79920 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 25 Nov 2019 11:49:05 -0800 Subject: [PATCH] freedreno: Rename the UBWC layer size field and store it as bytes. 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: --- src/freedreno/fdl/fd6_layout.c | 8 ++++---- src/freedreno/fdl/freedreno_layout.c | 4 ++-- src/freedreno/fdl/freedreno_layout.h | 7 +++---- src/freedreno/vulkan/tu_cmd_buffer.c | 4 ++-- src/freedreno/vulkan/tu_image.c | 10 +++++----- src/freedreno/vulkan/tu_private.h | 2 +- src/gallium/drivers/freedreno/a6xx/fd6_gmem.c | 2 +- src/gallium/drivers/freedreno/a6xx/fd6_image.c | 4 ++-- src/gallium/drivers/freedreno/a6xx/fd6_resource.c | 4 ++-- src/gallium/drivers/freedreno/a6xx/fd6_texture.c | 2 +- src/gallium/drivers/freedreno/freedreno_resource.c | 4 ++-- 11 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/freedreno/fdl/fd6_layout.c b/src/freedreno/fdl/fd6_layout.c index 6f0a91afcb9..30f334968ee 100644 --- a/src/freedreno/fdl/fd6_layout.c +++ b/src/freedreno/fdl/fd6_layout.c @@ -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; } } diff --git a/src/freedreno/fdl/freedreno_layout.c b/src/freedreno/fdl/freedreno_layout.c index 7c0a7052a52..5336683ba18 100644 --- a/src/freedreno/fdl/freedreno_layout.c +++ b/src/freedreno/fdl/freedreno_layout.c @@ -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); } } diff --git a/src/freedreno/fdl/freedreno_layout.h b/src/freedreno/fdl/freedreno_layout.h index e7dbc057df7..7230d337a48 100644 --- a/src/freedreno/fdl/freedreno_layout.h +++ b/src/freedreno/fdl/freedreno_layout.h @@ -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 diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 766279183a7..ff5f723aaf6 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -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))); diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index c76c44870e9..fee74a294c5 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -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; diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index a71e0fd138c..3a1bb331b9d 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -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 diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c index c28eff3c082..a477d542911 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c @@ -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 */ diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index 7a126ddf7b9..57503b5c14e 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -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); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c index b16a406c479..04753f9e0dc 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_resource.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_resource.c @@ -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)) diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index a5185cd6708..91b42bd3d7c 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -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); } diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 4eced1fb1fb..77b6cb5b6ca 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -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: */ -- 2.30.2