mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 17:30:12 +01:00
vulkan/format: Add a vk_format_get_aspect_format helper
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
69e4d39d18
commit
ed0cd6f654
2 changed files with 28 additions and 0 deletions
|
|
@ -366,6 +366,30 @@ vk_format_get_plane_format(VkFormat format, unsigned plane_id)
|
|||
}
|
||||
}
|
||||
|
||||
VkFormat
|
||||
vk_format_get_aspect_format(VkFormat format, const VkImageAspectFlags aspect)
|
||||
{
|
||||
assert(util_bitcount(aspect) == 1);
|
||||
assert(aspect & vk_format_aspects(format));
|
||||
|
||||
switch (aspect) {
|
||||
case VK_IMAGE_ASPECT_COLOR_BIT:
|
||||
return format;
|
||||
case VK_IMAGE_ASPECT_DEPTH_BIT:
|
||||
return vk_format_depth_only(format);
|
||||
case VK_IMAGE_ASPECT_STENCIL_BIT:
|
||||
return vk_format_stencil_only(format);
|
||||
case VK_IMAGE_ASPECT_PLANE_0_BIT:
|
||||
return vk_format_get_plane_format(format, 0);
|
||||
case VK_IMAGE_ASPECT_PLANE_1_BIT:
|
||||
return vk_format_get_plane_format(format, 1);
|
||||
case VK_IMAGE_ASPECT_PLANE_2_BIT:
|
||||
return vk_format_get_plane_format(format, 2);
|
||||
default:
|
||||
unreachable("Cannot translate format aspect");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vk_component_mapping_to_pipe_swizzle(VkComponentMapping mapping,
|
||||
unsigned char out_swizzle[4])
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -191,6 +192,9 @@ vk_format_get_plane_count(VkFormat format)
|
|||
VkFormat
|
||||
vk_format_get_plane_format(VkFormat format, unsigned plane_id);
|
||||
|
||||
VkFormat
|
||||
vk_format_get_aspect_format(VkFormat format, const VkImageAspectFlags aspect);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue