/**
* Everything else that doesn't fit in any of the above layouts.
*/
- VK_FORMAT_LAYOUT_OTHER = 9
+ VK_FORMAT_LAYOUT_OTHER = 9,
+
+ /**
+ * Formats that contain multiple planes.
+ */
+ VK_FORMAT_LAYOUT_MULTIPLANE = 10,
};
struct vk_format_block
unsigned char swizzle[4];
enum vk_format_colorspace colorspace;
+
+ unsigned plane_count:2;
+ unsigned width_divisor:2;
+ unsigned height_divisor:2;
+ VkFormat plane_formats[3];
};
extern const struct vk_format_description vk_format_description_table[];
case VK_COMPONENT_SWIZZLE_R:
for (x = 0; x < 4; x++)
if (chan[x] == 0)
- return x;
+ return (enum vk_swizzle)x;
return VK_SWIZZLE_0;
case VK_COMPONENT_SWIZZLE_G:
for (x = 0; x < 4; x++)
if (chan[x] == 1)
- return x;
+ return (enum vk_swizzle)x;
return VK_SWIZZLE_0;
case VK_COMPONENT_SWIZZLE_B:
for (x = 0; x < 4; x++)
if (chan[x] == 2)
- return x;
+ return (enum vk_swizzle)x;
return VK_SWIZZLE_0;
case VK_COMPONENT_SWIZZLE_A:
for (x = 0; x < 4; x++)
if (chan[x] == 3)
- return x;
+ return (enum vk_swizzle)x;
return VK_SWIZZLE_1;
default:
unreachable("Illegal swizzle");
return desc->nr_channels;
}
+static inline unsigned
+vk_format_get_plane_count(VkFormat format)
+{
+ const struct vk_format_description *desc = vk_format_description(format);
+
+ return desc->plane_count;
+}
+
+static inline VkFormat
+vk_format_get_plane_format(VkFormat format, unsigned plane_id)
+{
+ const struct vk_format_description *desc = vk_format_description(format);
+
+ if (desc->layout != VK_FORMAT_LAYOUT_MULTIPLANE) {
+ assert(plane_id == 0);
+ return format;
+ }
+
+ assert(plane_id < desc->plane_count);
+
+ return desc->plane_formats[plane_id];
+}
+
+
#endif /* VK_FORMAT_H */