vk/image: Add vk_image_can_be_aliased_to_yuv_plane() helper
vk_image_can_be_aliased_to_yuv_plane() checks whether an image has a format that is compatible with a plane of a multiplane image and can be aliased to it. Signed-off-by: Rebecca Mckeever <rebecca.mckeever@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33460>
This commit is contained in:
committed by
Marge Bot
parent
24076eb3f9
commit
f419a0bc4e
@@ -379,6 +379,34 @@ vk_image_to_memory_copy_layout(const struct vk_image *image,
|
||||
return vk_image_buffer_copy_layout(image, &bic);
|
||||
}
|
||||
|
||||
bool
|
||||
vk_image_can_be_aliased_to_yuv_plane(const struct vk_image *image)
|
||||
{
|
||||
if (!(image->create_flags & VK_IMAGE_CREATE_ALIAS_BIT))
|
||||
return false;
|
||||
|
||||
VkFormat format = image->format;
|
||||
|
||||
/* Only the 8-bit, 16-bit, and 32-bit classes listed in
|
||||
* https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#formats-compatibility-classes
|
||||
* are compatible with yuv planes. We must exclude other classes with the
|
||||
* same block size as these.
|
||||
*/
|
||||
if (vk_format_is_depth_or_stencil(format) ||
|
||||
vk_format_is_alpha(format) ||
|
||||
vk_format_get_blockwidth(format) != 1 ||
|
||||
vk_format_get_blockheight(format) != 1)
|
||||
return false;
|
||||
|
||||
unsigned block_size = vk_format_get_blocksize(format);
|
||||
|
||||
/* The planes of all the multiplane formats have a block size of 1, 2, or 4.
|
||||
* See:
|
||||
* https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#formats-compatible-planes
|
||||
*/
|
||||
return block_size == 1 || block_size == 2 || block_size == 4;
|
||||
}
|
||||
|
||||
static VkComponentSwizzle
|
||||
remap_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component)
|
||||
{
|
||||
|
||||
@@ -255,6 +255,8 @@ struct vk_image_buffer_layout
|
||||
vk_image_to_memory_copy_layout(const struct vk_image *image,
|
||||
const VkImageToMemoryCopyEXT* region);
|
||||
|
||||
bool vk_image_can_be_aliased_to_yuv_plane(const struct vk_image *image);
|
||||
|
||||
struct vk_image_view {
|
||||
struct vk_object_base base;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user