turnip: don't always fallback to linear for mutable formats
Use VkImageFormatListCreateInfo, and enable VK_KHR_image_format_list to expose it. (and reorganize linear fallback code a bit) Signed-off-by: Jonathan Marek <jonathan@marek.ca> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6940>
This commit is contained in:
parent
8c4426f519
commit
f624692a57
|
@ -99,6 +99,7 @@ EXTENSIONS = [
|
||||||
Extension('VK_EXT_extended_dynamic_state', 1, True),
|
Extension('VK_EXT_extended_dynamic_state', 1, True),
|
||||||
Extension('VK_KHR_push_descriptor', 1, True),
|
Extension('VK_KHR_push_descriptor', 1, True),
|
||||||
Extension('VK_KHR_incremental_present', 1, 'TU_HAS_SURFACE'),
|
Extension('VK_KHR_incremental_present', 1, 'TU_HAS_SURFACE'),
|
||||||
|
Extension('VK_KHR_image_format_list', 1, True),
|
||||||
]
|
]
|
||||||
|
|
||||||
MAX_API_VERSION = VkVersion(MAX_API_VERSION)
|
MAX_API_VERSION = VkVersion(MAX_API_VERSION)
|
||||||
|
|
|
@ -510,37 +510,47 @@ tu_CreateImage(VkDevice _device,
|
||||||
bool ubwc_enabled =
|
bool ubwc_enabled =
|
||||||
!(device->physical_device->instance->debug_flags & TU_DEBUG_NOUBWC);
|
!(device->physical_device->instance->debug_flags & TU_DEBUG_NOUBWC);
|
||||||
|
|
||||||
/* disable tiling when linear is requested, for YUYV/UYVY, and for mutable
|
/* use linear tiling if requested and for special ycbcr formats
|
||||||
* images. Mutable images can be reinterpreted as any other compatible
|
* TODO: NV12 can be UBWC but has a special UBWC format for accessing the Y plane aspect
|
||||||
* format, including swapped formats which aren't supported with tiling.
|
* for 3plane, tiling/UBWC might be supported, but the blob doesn't use tiling
|
||||||
* This means that we have to fall back to linear almost always. However
|
|
||||||
* depth and stencil formats cannot be reintepreted as another format, and
|
|
||||||
* cannot be linear with sysmem rendering, so don't fall back for those.
|
|
||||||
*
|
|
||||||
* TODO: Be smarter and use usage bits and VK_KHR_image_format_list to
|
|
||||||
* enable tiling and/or UBWC when possible.
|
|
||||||
*/
|
*/
|
||||||
if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR ||
|
if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR ||
|
||||||
modifier == DRM_FORMAT_MOD_LINEAR ||
|
modifier == DRM_FORMAT_MOD_LINEAR ||
|
||||||
vk_format_description(image->vk_format)->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED ||
|
image->vk_format == VK_FORMAT_G8B8G8R8_422_UNORM ||
|
||||||
(pCreateInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT &&
|
image->vk_format == VK_FORMAT_B8G8R8G8_422_UNORM ||
|
||||||
!vk_format_is_depth_or_stencil(image->vk_format))) {
|
image->vk_format == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM ||
|
||||||
|
image->vk_format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM) {
|
||||||
tile_mode = TILE6_LINEAR;
|
tile_mode = TILE6_LINEAR;
|
||||||
ubwc_enabled = false;
|
ubwc_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* UBWC is supported for these formats, but NV12 has a special UBWC
|
/* Mutable images can be reinterpreted as any other compatible format.
|
||||||
* format for accessing the Y plane aspect, which isn't implemented
|
* This is a problem with UBWC (compression for different formats is different),
|
||||||
* For IYUV, the blob doesn't use UBWC, but it seems to work, but
|
* but also tiling ("swap" affects how tiled formats are stored in memory)
|
||||||
* disable it since we don't know if a special UBWC format is needed
|
* Depth and stencil formats cannot be reintepreted as another format, and
|
||||||
* like NV12
|
* cannot be linear with sysmem rendering, so don't fall back for those.
|
||||||
*
|
*
|
||||||
* Disable tiling completely, because we set the TILE_ALL bit to
|
* TODO:
|
||||||
* match the blob, however fdl expects the TILE_ALL bit to not be
|
* - if the fmt_list contains only formats which are swapped, but compatible
|
||||||
* set for non-UBWC tiled formats
|
* with each other (B8G8R8A8_UNORM and B8G8R8A8_UINT for example), then
|
||||||
|
* tiling is still possible
|
||||||
|
* - figure out which UBWC compressions are compatible to keep it enabled
|
||||||
*/
|
*/
|
||||||
if (image->vk_format == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM ||
|
if ((pCreateInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) &&
|
||||||
image->vk_format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM) {
|
!vk_format_is_depth_or_stencil(image->vk_format)) {
|
||||||
|
const VkImageFormatListCreateInfo *fmt_list =
|
||||||
|
vk_find_struct_const(pCreateInfo->pNext, IMAGE_FORMAT_LIST_CREATE_INFO);
|
||||||
|
bool may_be_swapped = true;
|
||||||
|
if (fmt_list) {
|
||||||
|
may_be_swapped = false;
|
||||||
|
for (uint32_t i = 0; i < fmt_list->viewFormatCount; i++) {
|
||||||
|
if (tu6_format_color(fmt_list->pViewFormats[i], TILE6_LINEAR).swap) {
|
||||||
|
may_be_swapped = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (may_be_swapped)
|
||||||
tile_mode = TILE6_LINEAR;
|
tile_mode = TILE6_LINEAR;
|
||||||
ubwc_enabled = false;
|
ubwc_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue