+/*
+ * Note: the first match is returned, which is important for formats like
+ * __DRI_IMAGE_FORMAT_R8 which maps to both MESA_FORMAT_{R,L}_UNORM8
+ */
+static const struct {
+ uint32_t image_format;
+ mesa_format mesa_format;
+} format_mapping[] = {
+ {
+ .image_format = __DRI_IMAGE_FORMAT_RGB565,
+ .mesa_format = MESA_FORMAT_B5G6R5_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_ARGB1555,
+ .mesa_format = MESA_FORMAT_B5G5R5A1_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_XRGB8888,
+ .mesa_format = MESA_FORMAT_B8G8R8X8_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_ABGR16161616F,
+ .mesa_format = MESA_FORMAT_RGBA_FLOAT16,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_XBGR16161616F,
+ .mesa_format = MESA_FORMAT_RGBX_FLOAT16,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_ARGB2101010,
+ .mesa_format = MESA_FORMAT_B10G10R10A2_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_XRGB2101010,
+ .mesa_format = MESA_FORMAT_B10G10R10X2_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_ABGR2101010,
+ .mesa_format = MESA_FORMAT_R10G10B10A2_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_XBGR2101010,
+ .mesa_format = MESA_FORMAT_R10G10B10X2_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_ARGB8888,
+ .mesa_format = MESA_FORMAT_B8G8R8A8_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_ABGR8888,
+ .mesa_format = MESA_FORMAT_R8G8B8A8_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_XBGR8888,
+ .mesa_format = MESA_FORMAT_R8G8B8X8_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_R8,
+ .mesa_format = MESA_FORMAT_R_UNORM8,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_R8,
+ .mesa_format = MESA_FORMAT_L_UNORM8,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_GR88,
+ .mesa_format = MESA_FORMAT_R8G8_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_GR88,
+ .mesa_format = MESA_FORMAT_L8A8_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_SABGR8,
+ .mesa_format = MESA_FORMAT_R8G8B8A8_SRGB,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_SARGB8,
+ .mesa_format = MESA_FORMAT_B8G8R8A8_SRGB,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_R16,
+ .mesa_format = MESA_FORMAT_R_UNORM16,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_R16,
+ .mesa_format = MESA_FORMAT_L_UNORM16,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_GR1616,
+ .mesa_format = MESA_FORMAT_R16G16_UNORM,
+ },
+ {
+ .image_format = __DRI_IMAGE_FORMAT_GR1616,
+ .mesa_format = MESA_FORMAT_L16A16_UNORM,
+ },
+};
+