util/format: Add G8_B8R8_420_UNORM to match Vulkan.

turnip was playing fast and loose with the name, using the R8_G8B8 format
name but actually setting the descriptors up to read G8_B8R8 like Vulkan
(sensibly) wants.  This caused trouble when trying to make freedreno and
turnip share code.  By having both orderings as format names, we can share
the descriptor code and also confuse readers less.

Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13443>
This commit is contained in:
Emma Anholt 2021-10-20 15:52:23 -07:00 committed by Marge Bot
parent 271b6cb981
commit 2e6810a06a
7 changed files with 9 additions and 4 deletions

View File

@ -362,7 +362,8 @@ static const struct fd6_format formats[PIPE_FORMAT_COUNT] = {
_T_(R8G8_R8B8_UNORM, R8G8R8B8_422_UNORM, WZYX), /* YUYV */
_T_(G8R8_B8R8_UNORM, G8R8B8R8_422_UNORM, WZYX), /* UYVY */
_T_(R8_G8B8_420_UNORM, R8_G8B8_2PLANE_420_UNORM, WZYX),
_T_(R8_G8B8_420_UNORM, R8_G8B8_2PLANE_420_UNORM, WZYX), /* Gallium NV12 */
_T_(G8_B8R8_420_UNORM, R8_G8B8_2PLANE_420_UNORM, WZYX), /* Vulkan NV12 */
_T_(G8_B8_R8_420_UNORM, R8_G8_B8_3PLANE_420_UNORM, WZYX),
};
/* clang-format on */

View File

@ -61,7 +61,7 @@ fdl6_texswiz(const struct fdl_view_args *args, bool has_z24uint_s8uint)
switch (args->format) {
case PIPE_FORMAT_R8G8_R8B8_UNORM:
case PIPE_FORMAT_G8R8_B8R8_UNORM:
case PIPE_FORMAT_R8_G8B8_420_UNORM:
case PIPE_FORMAT_G8_B8R8_420_UNORM:
case PIPE_FORMAT_G8_B8_R8_420_UNORM:
format_swiz[0] = PIPE_SWIZZLE_Z;
format_swiz[1] = PIPE_SWIZZLE_X;
@ -208,6 +208,7 @@ fdl6_view_init(struct fdl6_view *view, const struct fdl_layout **layouts,
view->descriptor[3] |= A6XX_TEX_CONST_3_TILE_ALL;
if (args->format == PIPE_FORMAT_R8_G8B8_420_UNORM ||
args->format == PIPE_FORMAT_G8_B8R8_420_UNORM ||
args->format == PIPE_FORMAT_G8_B8_R8_420_UNORM) {
/* chroma offset re-uses MIPLVLS bits */
assert(args->level_count == 1);

View File

@ -1184,7 +1184,7 @@ copy_format(VkFormat vk_format, VkImageAspectFlags aspect_mask, bool copy_buffer
case PIPE_FORMAT_R9G9B9E5_FLOAT:
return PIPE_FORMAT_R32_UINT;
case PIPE_FORMAT_R8_G8B8_420_UNORM:
case PIPE_FORMAT_G8_B8R8_420_UNORM:
if (aspect_mask == VK_IMAGE_ASPECT_PLANE_1_BIT)
return PIPE_FORMAT_R8G8_UNORM;
else

View File

@ -69,7 +69,7 @@ tu_vk_format_to_pipe_format(VkFormat vk_format)
case VK_FORMAT_B8G8R8G8_422_UNORM: /* UYVY */
return PIPE_FORMAT_G8R8_B8R8_UNORM;
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
return PIPE_FORMAT_R8_G8B8_420_UNORM;
return PIPE_FORMAT_G8_B8R8_420_UNORM;
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
return PIPE_FORMAT_G8_B8_R8_420_UNORM;
default:

View File

@ -504,6 +504,7 @@ enum pipe_format {
PIPE_FORMAT_XYUV,
PIPE_FORMAT_R8_G8B8_420_UNORM,
PIPE_FORMAT_G8_B8R8_420_UNORM,
PIPE_FORMAT_G8_B8_R8_420_UNORM,
PIPE_FORMAT_Y8_UNORM,

View File

@ -400,6 +400,7 @@ PIPE_FORMAT_NV21 , planar2, 1, 1, 1, , , , , xy
# RGB version of NV12 and YV12 for hardware that supports sampling from
# multiplane textures but needs color-space conversion in the shader.
PIPE_FORMAT_R8_G8B8_420_UNORM , planar2, 1, 1, 1, un8, , , , xyzw, rgb
PIPE_FORMAT_G8_B8R8_420_UNORM , planar2, 1, 1, 1, un8, , , , xyzw, rgb
PIPE_FORMAT_G8_B8_R8_420_UNORM , planar3, 1, 1, 1, un8, , , , xyzw, rgb
# While most of Mesa uses R8 for Y, U, and V planes, freedreno requires distinguishing

Can't render this file because it contains an unexpected character in line 8 and column 3.

View File

@ -109,6 +109,7 @@ def has_access(format):
'y16_u16v16_422_unorm',
'y16_u16_v16_444_unorm',
'r8_g8b8_420_unorm',
'g8_b8r8_420_unorm',
'g8_b8_r8_420_unorm',
'y8_unorm',
]