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: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3059>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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)));
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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 */
|
||||
|
@@ -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);
|
||||
|
@@ -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))
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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: */
|
||||
|
Reference in New Issue
Block a user