From 7af2a0b9bcd7a2213a9c873b9d453bf430f106f2 Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Tue, 12 May 2020 20:11:25 -0400 Subject: [PATCH] turnip: support multi-image layouts Signed-off-by: Jonathan Marek Part-of: --- src/freedreno/vulkan/tu_clear_blit.c | 150 ++++++++++++++----------- src/freedreno/vulkan/tu_device.c | 4 +- src/freedreno/vulkan/tu_image.c | 158 +++++++++++++++++++-------- src/freedreno/vulkan/tu_private.h | 3 +- 4 files changed, 200 insertions(+), 115 deletions(-) diff --git a/src/freedreno/vulkan/tu_clear_blit.c b/src/freedreno/vulkan/tu_clear_blit.c index ae88f043f33..260dfe5d56f 100644 --- a/src/freedreno/vulkan/tu_clear_blit.c +++ b/src/freedreno/vulkan/tu_clear_blit.c @@ -907,13 +907,46 @@ coords(const struct blit_ops *ops, ops->coords(cs, (const VkOffset2D*) dst, (const VkOffset2D*) src, (const VkExtent2D*) extent); } +static VkFormat +copy_format(VkFormat format, VkImageAspectFlags aspect_mask, bool copy_buffer) +{ + if (vk_format_is_compressed(format)) { + switch (vk_format_get_blocksize(format)) { + case 1: return VK_FORMAT_R8_UINT; + case 2: return VK_FORMAT_R16_UINT; + case 4: return VK_FORMAT_R32_UINT; + case 8: return VK_FORMAT_R32G32_UINT; + case 16:return VK_FORMAT_R32G32B32A32_UINT; + default: + unreachable("unhandled format size"); + } + } + + switch (format) { + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + if (aspect_mask == VK_IMAGE_ASPECT_PLANE_1_BIT) + return VK_FORMAT_R8G8_UNORM; + /* fallthrough */ + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + return VK_FORMAT_R8_UNORM; + case VK_FORMAT_D24_UNORM_S8_UINT: + if (aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT && copy_buffer) + return VK_FORMAT_R8_UNORM; + /* fallthrough */ + default: + return format; + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: + return VK_FORMAT_R32_UINT; + } +} + static void -tu_image_view_blit2(struct tu_image_view *iview, - struct tu_image *image, - VkFormat format, - const VkImageSubresourceLayers *subres, - uint32_t layer, - bool stencil_read) +tu_image_view_copy_blit(struct tu_image_view *iview, + struct tu_image *image, + VkFormat format, + const VkImageSubresourceLayers *subres, + uint32_t layer, + bool stencil_read) { VkImageAspectFlags aspect_mask = subres->aspectMask; @@ -939,13 +972,25 @@ tu_image_view_blit2(struct tu_image_view *iview, }); } +static void +tu_image_view_copy(struct tu_image_view *iview, + struct tu_image *image, + VkFormat format, + const VkImageSubresourceLayers *subres, + uint32_t layer, + bool stencil_read) +{ + format = copy_format(format, subres->aspectMask, false); + tu_image_view_copy_blit(iview, image, format, subres, layer, stencil_read); +} + static void tu_image_view_blit(struct tu_image_view *iview, struct tu_image *image, const VkImageSubresourceLayers *subres, uint32_t layer) { - tu_image_view_blit2(iview, image, image->vk_format, subres, layer, false); + tu_image_view_copy_blit(iview, image, image->vk_format, subres, layer, false); } static void @@ -1063,21 +1108,6 @@ tu_CmdBlitImage(VkCommandBuffer commandBuffer, tu6_blit_image(cmd, src_image, dst_image, pRegions + i, filter); } -static VkFormat -copy_format(VkFormat format) -{ - switch (vk_format_get_blocksize(format)) { - case 1: return VK_FORMAT_R8_UINT; - case 2: return VK_FORMAT_R16_UINT; - case 4: return VK_FORMAT_R32_UINT; - case 8: return VK_FORMAT_R32G32_UINT; - case 12:return VK_FORMAT_R32G32B32_UINT; - case 16:return VK_FORMAT_R32G32B32A32_UINT; - default: - unreachable("unhandled format size"); - } -} - static void copy_compressed(VkFormat format, VkOffset3D *offset, @@ -1112,14 +1142,13 @@ tu_copy_buffer_to_image(struct tu_cmd_buffer *cmd, { struct tu_cs *cs = &cmd->cs; uint32_t layers = MAX2(info->imageExtent.depth, info->imageSubresource.layerCount); - VkFormat dst_format = dst_image->vk_format; - VkFormat src_format = dst_image->vk_format; + VkFormat src_format = + copy_format(dst_image->vk_format, info->imageSubresource.aspectMask, true); const struct blit_ops *ops = &r2d_ops; /* special case for buffer to stencil */ - if (dst_format == VK_FORMAT_D24_UNORM_S8_UINT && + if (dst_image->vk_format == VK_FORMAT_D24_UNORM_S8_UINT && info->imageSubresource.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT) { - src_format = VK_FORMAT_R8_UNORM; ops = &r3d_ops; } @@ -1128,19 +1157,17 @@ tu_copy_buffer_to_image(struct tu_cmd_buffer *cmd, uint32_t src_width = info->bufferRowLength ?: extent.width; uint32_t src_height = info->bufferImageHeight ?: extent.height; - if (dst_format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 || vk_format_is_compressed(src_format)) { - assert(src_format == dst_format); - copy_compressed(dst_format, &offset, &extent, &src_width, &src_height); - src_format = dst_format = copy_format(dst_format); - } + copy_compressed(dst_image->vk_format, &offset, &extent, &src_width, &src_height); uint32_t pitch = src_width * vk_format_get_blocksize(src_format); uint32_t layer_size = src_height * pitch; - ops->setup(cmd, cs, dst_format, info->imageSubresource.aspectMask, ROTATE_0, false); + ops->setup(cmd, cs, + copy_format(dst_image->vk_format, info->imageSubresource.aspectMask, false), + info->imageSubresource.aspectMask, ROTATE_0, false); struct tu_image_view dst; - tu_image_view_blit2(&dst, dst_image, dst_format, &info->imageSubresource, offset.z, false); + tu_image_view_copy(&dst, dst_image, dst_image->vk_format, &info->imageSubresource, offset.z, false); for (uint32_t i = 0; i < layers; i++) { ops->dst(cs, &dst, i); @@ -1191,13 +1218,12 @@ tu_copy_image_to_buffer(struct tu_cmd_buffer *cmd, { struct tu_cs *cs = &cmd->cs; uint32_t layers = MAX2(info->imageExtent.depth, info->imageSubresource.layerCount); - VkFormat src_format = src_image->vk_format; - VkFormat dst_format = src_image->vk_format; + VkFormat dst_format = + copy_format(src_image->vk_format, info->imageSubresource.aspectMask, true); bool stencil_read = false; if (src_image->vk_format == VK_FORMAT_D24_UNORM_S8_UINT && info->imageSubresource.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT) { - dst_format = VK_FORMAT_R8_UNORM; stencil_read = true; } @@ -1207,11 +1233,7 @@ tu_copy_image_to_buffer(struct tu_cmd_buffer *cmd, uint32_t dst_width = info->bufferRowLength ?: extent.width; uint32_t dst_height = info->bufferImageHeight ?: extent.height; - if (dst_format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 || vk_format_is_compressed(dst_format)) { - assert(src_format == dst_format); - copy_compressed(dst_format, &offset, &extent, &dst_width, &dst_height); - src_format = dst_format = copy_format(dst_format); - } + copy_compressed(src_image->vk_format, &offset, &extent, &dst_width, &dst_height); uint32_t pitch = dst_width * vk_format_get_blocksize(dst_format); uint32_t layer_size = pitch * dst_height; @@ -1219,7 +1241,7 @@ tu_copy_image_to_buffer(struct tu_cmd_buffer *cmd, ops->setup(cmd, cs, dst_format, VK_IMAGE_ASPECT_COLOR_BIT, ROTATE_0, false); struct tu_image_view src; - tu_image_view_blit2(&src, src_image, src_format, &info->imageSubresource, offset.z, stencil_read); + tu_image_view_copy(&src, src_image, src_image->vk_format, &info->imageSubresource, offset.z, stencil_read); for (uint32_t i = 0; i < layers; i++) { ops->src(cmd, cs, &src, i, VK_FILTER_NEAREST); @@ -1286,7 +1308,7 @@ is_swapped_format(VkFormat format) static bool image_is_r8g8(struct tu_image *image) { - return image->layout.cpp == 2 && + return image->layout[0].cpp == 2 && vk_format_get_nr_components(image->vk_format) == 2; } @@ -1302,8 +1324,6 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, if (dst_image->samples > 1) ops = &r3d_ops; - assert(info->srcSubresource.aspectMask == info->dstSubresource.aspectMask); - VkFormat format = VK_FORMAT_UNDEFINED; VkOffset3D src_offset = info->srcOffset; VkOffset3D dst_offset = info->dstOffset; @@ -1328,10 +1348,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, copy_compressed(src_image->vk_format, &src_offset, &extent, NULL, NULL); copy_compressed(dst_image->vk_format, &dst_offset, NULL, NULL, NULL); - VkFormat dst_format = vk_format_is_compressed(dst_image->vk_format) ? - copy_format(dst_image->vk_format) : dst_image->vk_format; - VkFormat src_format = vk_format_is_compressed(src_image->vk_format) ? - copy_format(src_image->vk_format) : src_image->vk_format; + VkFormat dst_format = copy_format(dst_image->vk_format, info->dstSubresource.aspectMask, false); + VkFormat src_format = copy_format(src_image->vk_format, info->srcSubresource.aspectMask, false); bool use_staging_blit = false; @@ -1340,12 +1358,12 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, * the same as a blit. */ format = src_format; - } else if (!src_image->layout.tile_mode) { + } else if (!src_image->layout[0].tile_mode) { /* If an image is linear, we can always safely reinterpret it with the * other image's format and then do a regular blit. */ format = dst_format; - } else if (!dst_image->layout.tile_mode) { + } else if (!dst_image->layout[0].tile_mode) { format = src_format; } else if (image_is_r8g8(src_image) != image_is_r8g8(dst_image)) { /* We can't currently copy r8g8 images to/from other cpp=2 images, @@ -1358,9 +1376,9 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, * to/from it. */ use_staging_blit = true; - } else if (!src_image->layout.ubwc) { + } else if (!src_image->layout[0].ubwc) { format = dst_format; - } else if (!dst_image->layout.ubwc) { + } else if (!dst_image->layout[0].ubwc) { format = src_format; } else { /* Both formats use UBWC and so neither can be reinterpreted. @@ -1372,8 +1390,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, struct tu_image_view dst, src; if (use_staging_blit) { - tu_image_view_blit2(&dst, dst_image, dst_format, &info->dstSubresource, dst_offset.z, false); - tu_image_view_blit2(&src, src_image, src_format, &info->srcSubresource, src_offset.z, false); + tu_image_view_copy(&dst, dst_image, dst_format, &info->dstSubresource, dst_offset.z, false); + tu_image_view_copy(&src, src_image, src_format, &info->srcSubresource, src_offset.z, false); struct tu_image staging_image = { .vk_format = src_format, @@ -1395,10 +1413,10 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, VkOffset3D staging_offset = { 0 }; - staging_image.layout.tile_mode = TILE6_LINEAR; - staging_image.layout.ubwc = false; + staging_image.layout[0].tile_mode = TILE6_LINEAR; + staging_image.layout[0].ubwc = false; - fdl6_layout(&staging_image.layout, + fdl6_layout(&staging_image.layout[0], vk_format_to_pipe_format(staging_image.vk_format), staging_image.samples, staging_image.extent.width, @@ -1410,7 +1428,7 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, NULL); VkResult result = tu_get_scratch_bo(cmd->device, - staging_image.layout.size, + staging_image.layout[0].size, &staging_image.bo); if (result != VK_SUCCESS) { cmd->record_result = result; @@ -1421,8 +1439,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, MSM_SUBMIT_BO_READ | MSM_SUBMIT_BO_WRITE); struct tu_image_view staging; - tu_image_view_blit2(&staging, &staging_image, src_format, - &staging_subresource, 0, false); + tu_image_view_copy(&staging, &staging_image, src_format, + &staging_subresource, 0, false); ops->setup(cmd, cs, src_format, VK_IMAGE_ASPECT_COLOR_BIT, ROTATE_0, false); coords(ops, cs, &staging_offset, &src_offset, &extent); @@ -1439,8 +1457,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, tu6_emit_event_write(cmd, cs, PC_CCU_FLUSH_COLOR_TS); tu6_emit_event_write(cmd, cs, CACHE_INVALIDATE); - tu_image_view_blit2(&staging, &staging_image, dst_format, - &staging_subresource, 0, false); + tu_image_view_copy(&staging, &staging_image, dst_format, + &staging_subresource, 0, false); ops->setup(cmd, cs, dst_format, info->dstSubresource.aspectMask, ROTATE_0, false); coords(ops, cs, &dst_offset, &staging_offset, &extent); @@ -1451,8 +1469,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd, ops->run(cmd, cs); } } else { - tu_image_view_blit2(&dst, dst_image, format, &info->dstSubresource, dst_offset.z, false); - tu_image_view_blit2(&src, src_image, format, &info->srcSubresource, src_offset.z, false); + tu_image_view_copy(&dst, dst_image, format, &info->dstSubresource, dst_offset.z, false); + tu_image_view_copy(&src, src_image, format, &info->srcSubresource, src_offset.z, false); ops->setup(cmd, cs, format, info->dstSubresource.aspectMask, ROTATE_0, false); coords(ops, cs, &dst_offset, &src_offset, &extent); @@ -1695,7 +1713,7 @@ clear_image(struct tu_cmd_buffer *cmd, }); struct tu_image_view dst; - tu_image_view_blit2(&dst, image, format, &(VkImageSubresourceLayers) { + tu_image_view_copy_blit(&dst, image, format, &(VkImageSubresourceLayers) { .aspectMask = range->aspectMask, .mipLevel = range->baseMipLevel + j, .baseArrayLayer = range->baseArrayLayer, diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index c8f7f134a2c..760e3b71a94 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -1934,8 +1934,8 @@ tu_GetImageMemoryRequirements(VkDevice _device, TU_FROM_HANDLE(tu_image, image, _image); pMemoryRequirements->memoryTypeBits = 1; - pMemoryRequirements->size = image->layout.size; - pMemoryRequirements->alignment = image->layout.base_align; + pMemoryRequirements->size = image->total_size; + pMemoryRequirements->alignment = image->layout[0].base_align; } void diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index fb9a355d2c4..2b8273b28bf 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -36,6 +36,46 @@ #include "tu_cs.h" +static uint32_t +tu6_plane_count(VkFormat format) +{ + switch (format) { + default: + return 1; + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + return 2; + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + return 3; + } +} + +static VkFormat +tu6_plane_format(VkFormat format, uint32_t plane) +{ + switch (format) { + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + /* note: with UBWC, and Y plane UBWC is different from R8_UNORM */ + return plane ? VK_FORMAT_R8G8_UNORM : VK_FORMAT_R8_UNORM; + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + return VK_FORMAT_R8_UNORM; + default: + return format; + } +} + +static uint32_t +tu6_plane_index(VkImageAspectFlags aspect_mask) +{ + switch (aspect_mask) { + default: + return 0; + case VK_IMAGE_ASPECT_PLANE_1_BIT: + return 1; + case VK_IMAGE_ASPECT_PLANE_2_BIT: + return 2; + } +} + VkResult tu_image_create(VkDevice _device, const VkImageCreateInfo *pCreateInfo, @@ -86,7 +126,7 @@ tu_image_create(VkDevice _device, vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_MEMORY_IMAGE_CREATE_INFO) != NULL; - image->layout.tile_mode = TILE6_3; + enum a6xx_tile_mode tile_mode = TILE6_3; bool ubwc_enabled = !(device->physical_device->instance->debug_flags & TU_DEBUG_NOUBWC); @@ -105,7 +145,7 @@ tu_image_create(VkDevice _device, vk_format_description(image->vk_format)->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED || (pCreateInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT && !vk_format_is_depth_or_stencil(image->vk_format))) { - image->layout.tile_mode = TILE6_LINEAR; + tile_mode = TILE6_LINEAR; ubwc_enabled = false; } @@ -138,44 +178,70 @@ tu_image_create(VkDevice _device, if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) ubwc_enabled = false; - uint32_t ubwc_blockwidth, ubwc_blockheight; - fdl6_get_ubwc_blockwidth(&image->layout, - &ubwc_blockwidth, &ubwc_blockheight); - if (!ubwc_blockwidth) { - tu_finishme("UBWC for cpp=%d", image->layout.cpp); - ubwc_enabled = false; - } - /* expect UBWC enabled if we asked for it */ assert(modifier != DRM_FORMAT_MOD_QCOM_COMPRESSED || ubwc_enabled); - image->layout.ubwc = ubwc_enabled; + for (uint32_t i = 0; i < tu6_plane_count(image->vk_format); i++) { + struct fdl_layout *layout = &image->layout[i]; + VkFormat format = tu6_plane_format(image->vk_format, i); + uint32_t width0 = pCreateInfo->extent.width; + uint32_t height0 = pCreateInfo->extent.height; + + if (i > 0) { + switch (image->vk_format) { + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + /* half width/height on chroma planes */ + width0 = (width0 + 1) >> 1; + height0 = (height0 + 1) >> 1; + break; + default: + break; + } + } + + struct fdl_slice plane_layout; + + if (plane_layouts) { + /* only expect simple 2D images for now */ + if (pCreateInfo->mipLevels != 1 || + pCreateInfo->arrayLayers != 1 || + image->extent.depth != 1) + goto invalid_layout; - struct fdl_slice plane_layout; + plane_layout.offset = plane_layouts[i].offset; + plane_layout.pitch = plane_layouts[i].rowPitch; + /* note: use plane_layouts[0].arrayPitch to support array formats */ + } - if (plane_layouts) { - /* only expect simple 2D images for now */ - if (pCreateInfo->mipLevels != 1 || - pCreateInfo->arrayLayers != 1 || - image->extent.depth != 1) + layout->tile_mode = tile_mode; + layout->ubwc = ubwc_enabled; + + if (!fdl6_layout(layout, vk_format_to_pipe_format(format), + image->samples, + width0, height0, + pCreateInfo->extent.depth, + pCreateInfo->mipLevels, + pCreateInfo->arrayLayers, + pCreateInfo->imageType == VK_IMAGE_TYPE_3D, + plane_layouts ? &plane_layout : NULL)) { + assert(plane_layouts); /* can only fail with explicit layout */ goto invalid_layout; + } - plane_layout.offset = plane_layouts[0].offset; - plane_layout.pitch = plane_layouts[0].rowPitch; - /* note: use plane_layouts[0].arrayPitch to support array formats */ - } + /* fdl6_layout can't take explicit offset without explicit pitch + * add offset manually for extra layouts for planes + */ + if (!plane_layouts && i > 0) { + uint32_t offset = ALIGN_POT(image->total_size, 4096); + for (int i = 0; i < pCreateInfo->mipLevels; i++) { + layout->slices[i].offset += offset; + layout->ubwc_slices[i].offset += offset; + } + layout->size += offset; + } - if (!fdl6_layout(&image->layout, vk_format_to_pipe_format(image->vk_format), - image->samples, - pCreateInfo->extent.width, - pCreateInfo->extent.height, - pCreateInfo->extent.depth, - pCreateInfo->mipLevels, - pCreateInfo->arrayLayers, - pCreateInfo->imageType == VK_IMAGE_TYPE_3D, - plane_layouts ? &plane_layout : NULL)) { - assert(plane_layouts); /* can only fail with explicit layout */ - goto invalid_layout; + image->total_size = MAX2(image->total_size, layout->size); } *pImage = tu_image_to_handle(image); @@ -311,10 +377,10 @@ tu_image_view_init(struct tu_image_view *iview, memset(iview->descriptor, 0, sizeof(iview->descriptor)); - struct fdl_layout *layout = &image->layout; + struct fdl_layout *layout = &image->layout[tu6_plane_index(aspect_mask)]; - uint32_t width = u_minify(image->extent.width, range->baseMipLevel); - uint32_t height = u_minify(image->extent.height, range->baseMipLevel); + uint32_t width = u_minify(layout->width0, range->baseMipLevel); + uint32_t height = u_minify(layout->height0, range->baseMipLevel); uint32_t storage_depth = tu_get_layerCount(image, range); if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) { storage_depth = u_minify(image->extent.depth, range->baseMipLevel); @@ -374,8 +440,7 @@ tu_image_view_init(struct tu_image_view *iview, if (ubwc_enabled) { uint32_t block_width, block_height; - fdl6_get_ubwc_blockwidth(&image->layout, - &block_width, &block_height); + fdl6_get_ubwc_blockwidth(layout, &block_width, &block_height); iview->descriptor[3] |= A6XX_TEX_CONST_3_FLAG | A6XX_TEX_CONST_3_TILE_ALL; iview->descriptor[7] = ubwc_addr; @@ -389,7 +454,7 @@ tu_image_view_init(struct tu_image_view *iview, if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D) { iview->descriptor[3] |= - A6XX_TEX_CONST_3_MIN_LAYERSZ(image->layout.slices[image->level_count - 1].size0); + A6XX_TEX_CONST_3_MIN_LAYERSZ(layout->slices[image->level_count - 1].size0); } iview->SP_PS_2D_SRC_INFO = A6XX_SP_PS_2D_SRC_INFO( @@ -559,17 +624,18 @@ tu_GetImageSubresourceLayout(VkDevice _device, { TU_FROM_HANDLE(tu_image, image, _image); - const struct fdl_slice *slice = image->layout.slices + pSubresource->mipLevel; + struct fdl_layout *layout = + &image->layout[tu6_plane_index(pSubresource->aspectMask)]; + const struct fdl_slice *slice = layout->slices + pSubresource->mipLevel; - pLayout->offset = fdl_surface_offset(&image->layout, - pSubresource->mipLevel, - pSubresource->arrayLayer); + pLayout->offset = + fdl_surface_offset(layout, pSubresource->mipLevel, pSubresource->arrayLayer); pLayout->size = slice->size0; pLayout->rowPitch = slice->pitch; - pLayout->arrayPitch = image->layout.layer_size; + pLayout->arrayPitch = fdl_layer_stride(layout, pSubresource->mipLevel); pLayout->depthPitch = slice->size0; - if (image->layout.ubwc_layer_size) { + if (fdl_ubwc_enabled(layout, pSubresource->mipLevel)) { /* UBWC starts at offset 0 */ pLayout->offset = 0; /* UBWC scanout won't match what the kernel wants if we have levels/layers */ @@ -589,9 +655,9 @@ VkResult tu_GetImageDrmFormatModifierPropertiesEXT( /* TODO invent a modifier for tiled but not UBWC buffers */ - if (!image->layout.tile_mode) + if (!image->layout[0].tile_mode) pProperties->drmFormatModifier = DRM_FORMAT_MOD_LINEAR; - else if (image->layout.ubwc_layer_size) + else if (image->layout[0].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 c91c86c3949..6486e3293fb 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1221,7 +1221,8 @@ struct tu_image uint32_t layer_count; VkSampleCountFlagBits samples; - struct fdl_layout layout; + struct fdl_layout layout[3]; + uint32_t total_size; unsigned queue_family_mask; bool exclusive; -- 2.30.2