turnip: enable 422_UNORM formats

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4590>
This commit is contained in:
Jonathan Marek 2020-04-09 21:01:35 -04:00 committed by Marge Bot
parent d070a7ba0c
commit 0d9996e223
3 changed files with 47 additions and 15 deletions

View file

@ -283,23 +283,39 @@ static const struct tu_native_format tu6_format_table[] = {
TU6_xTx(ASTC_12x12_SRGB_BLOCK, ASTC_12x12, WZYX), /* 184 */
};
#define FMT_EXT_BASE VK_FORMAT_G8B8G8R8_422_UNORM
#undef TU6_FMT
#define TU6_FMT(vkfmt, hwfmt, swapfmt, valid) \
[VK_FORMAT_##vkfmt - FMT_EXT_BASE] = { \
.fmt = FMT6_##hwfmt, \
.swap = swapfmt, \
.supported = valid, \
}
static const struct tu_native_format tu6_format_table_ext[] = {
TU6_xTx(G8B8G8R8_422_UNORM, R8G8R8B8_422_UNORM, WZYX), /* 0 */
TU6_xTx(B8G8R8G8_422_UNORM, G8R8B8R8_422_UNORM, WZYX), /* 1 */
};
static struct tu_native_format
tu6_get_native_format(VkFormat format)
{
struct tu_native_format fmt = {};
if (format >= ARRAY_SIZE(tu6_format_table))
return fmt;
if (!tu6_format_table[format].supported)
return fmt;
if (vk_format_to_pipe_format(format) == PIPE_FORMAT_NONE) {
tu_finishme("vk_format %d missing matching pipe format.\n", format);
return fmt;
if (format < ARRAY_SIZE(tu6_format_table)) {
fmt = tu6_format_table[format];
} else if (format >= FMT_EXT_BASE) {
unsigned idx = format - FMT_EXT_BASE;
if (idx < ARRAY_SIZE(tu6_format_table_ext))
fmt = tu6_format_table_ext[idx];
}
return tu6_format_table[format];
if (fmt.supported && vk_format_to_pipe_format(format) == PIPE_FORMAT_NONE) {
tu_finishme("vk_format %d missing matching pipe format.\n", format);
fmt.supported = false;
}
return fmt;
}
struct tu_native_format

View file

@ -89,9 +89,10 @@ tu_image_create(VkDevice _device,
bool ubwc_enabled =
!(device->physical_device->instance->debug_flags & TU_DEBUG_NOUBWC);
/* disable tiling when linear is requested and for compressed formats */
/* disable tiling when linear is requested and for YUYV/UYVY */
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->layout.tile_mode = TILE6_LINEAR;
ubwc_enabled = false;
}
@ -204,6 +205,12 @@ tu6_texswiz(const VkComponentMapping *comps,
};
switch (format) {
case VK_FORMAT_G8B8G8R8_422_UNORM:
case VK_FORMAT_B8G8R8G8_422_UNORM:
swiz[0] = A6XX_TEX_Z;
swiz[1] = A6XX_TEX_X;
swiz[2] = A6XX_TEX_Y;
break;
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
/* same hardware format is used for BC1_RGB / BC1_RGBA */
@ -556,8 +563,7 @@ tu_GetImageSubresourceLayout(VkDevice _device,
pSubresource->mipLevel,
pSubresource->arrayLayer);
pLayout->size = slice->size0;
pLayout->rowPitch =
slice->pitch * vk_format_get_blockheight(image->vk_format);
pLayout->rowPitch = slice->pitch;
pLayout->arrayPitch = image->layout.layer_size;
pLayout->depthPitch = slice->size0;

View file

@ -167,7 +167,8 @@ vk_format_compose_swizzles(const VkComponentMapping *mapping,
static inline bool
vk_format_is_compressed(VkFormat format)
{
return util_format_is_compressed(vk_format_to_pipe_format(format));
/* this includes 4:2:2 formats, which are compressed formats for vulkan */
return vk_format_get_blockwidth(format) > 1;
}
static inline bool
@ -312,6 +313,15 @@ vk_format_get_component_bits(VkFormat format,
enum util_format_colorspace colorspace,
unsigned component)
{
switch (format) {
case VK_FORMAT_G8B8G8R8_422_UNORM:
case VK_FORMAT_B8G8R8G8_422_UNORM:
/* util_format_get_component_bits doesn't return what we want */
return 8;
default:
break;
}
return util_format_get_component_bits(vk_format_to_pipe_format(format),
colorspace, component);
}