mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 04:00:10 +01:00
vulkan,radv: Move vk_format_get_plane_format to common code
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16873>
This commit is contained in:
parent
1436fa55a6
commit
69e4d39d18
3 changed files with 35 additions and 32 deletions
|
|
@ -151,12 +151,6 @@ vk_to_non_srgb_format(VkFormat format)
|
|||
}
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
vk_format_get_plane_count(VkFormat format)
|
||||
{
|
||||
return util_format_get_num_planes(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
vk_format_get_plane_width(VkFormat format, unsigned plane, unsigned width)
|
||||
{
|
||||
|
|
@ -169,30 +163,4 @@ vk_format_get_plane_height(VkFormat format, unsigned plane, unsigned height)
|
|||
return util_format_get_plane_height(vk_format_to_pipe_format(format), plane, height);
|
||||
}
|
||||
|
||||
static inline VkFormat
|
||||
vk_format_get_plane_format(VkFormat format, unsigned plane_id)
|
||||
{
|
||||
assert(plane_id < vk_format_get_plane_count(format));
|
||||
|
||||
switch (format) {
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
|
||||
return VK_FORMAT_R8_UNORM;
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
|
||||
return plane_id ? VK_FORMAT_R8G8_UNORM : VK_FORMAT_R8_UNORM;
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
|
||||
return VK_FORMAT_R16_UNORM;
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
|
||||
return plane_id ? VK_FORMAT_R16G16_UNORM : VK_FORMAT_R16_UNORM;
|
||||
default:
|
||||
assert(vk_format_get_plane_count(format) == 1);
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* VK_FORMAT_H */
|
||||
|
|
|
|||
|
|
@ -340,6 +340,32 @@ vk_format_aspects(VkFormat format)
|
|||
}
|
||||
}
|
||||
|
||||
VkFormat
|
||||
vk_format_get_plane_format(VkFormat format, unsigned plane_id)
|
||||
{
|
||||
assert(plane_id < vk_format_get_plane_count(format));
|
||||
|
||||
switch (format) {
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
|
||||
return VK_FORMAT_R8_UNORM;
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
|
||||
return plane_id ? VK_FORMAT_R8G8_UNORM : VK_FORMAT_R8_UNORM;
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
|
||||
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
|
||||
return VK_FORMAT_R16_UNORM;
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
|
||||
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
|
||||
return plane_id ? VK_FORMAT_R16G16_UNORM : VK_FORMAT_R16_UNORM;
|
||||
default:
|
||||
assert(vk_format_get_plane_count(format) == 1);
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vk_component_mapping_to_pipe_swizzle(VkComponentMapping mapping,
|
||||
unsigned char out_swizzle[4])
|
||||
|
|
|
|||
|
|
@ -182,6 +182,15 @@ vk_format_get_blocksizebits(VkFormat format)
|
|||
return util_format_get_blocksizebits(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
vk_format_get_plane_count(VkFormat format)
|
||||
{
|
||||
return util_format_get_num_planes(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
VkFormat
|
||||
vk_format_get_plane_format(VkFormat format, unsigned plane_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue