diff --git a/src/backends/native/meta-drm-buffer-gbm.c b/src/backends/native/meta-drm-buffer-gbm.c index f87541964..2f20a9c6d 100644 --- a/src/backends/native/meta-drm-buffer-gbm.c +++ b/src/backends/native/meta-drm-buffer-gbm.c @@ -279,7 +279,9 @@ meta_drm_buffer_gbm_blit_to_framebuffer (CoglScanout *scanout, } drm_format = gbm_bo_get_format (buffer_gbm->bo); - result = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format); + result = meta_cogl_pixel_format_from_drm_format (drm_format, + &cogl_format, + NULL); g_assert (result); width = gbm_bo_get_width (buffer_gbm->bo); diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index eca6425cc..a3ba44711 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -746,7 +746,7 @@ copy_shared_framebuffer_primary_gpu (CoglOnscreen *onscre g_assert (cogl_framebuffer_get_width (framebuffer) == width); g_assert (cogl_framebuffer_get_height (framebuffer) == height); - ret = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format); + ret = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format, NULL); g_assert (ret); dmabuf_fd = meta_drm_buffer_dumb_ensure_dmabuf_fd (buffer_dumb, &error); @@ -848,7 +848,7 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen, g_assert (cogl_framebuffer_get_width (framebuffer) == width); g_assert (cogl_framebuffer_get_height (framebuffer) == height); - ret = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format); + ret = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format, NULL); g_assert (ret); dumb_bitmap = cogl_bitmap_new_for_data (cogl_context, @@ -2111,6 +2111,7 @@ pick_secondary_gpu_framebuffer_format_for_cpu (CoglOnscreen *onscreen) for (k = 0; k < G_N_ELEMENTS (preferred_formats); k++) { g_assert (meta_cogl_pixel_format_from_drm_format (preferred_formats[k], + NULL, NULL)); for (i = 0; i < formats->len; i++) @@ -2131,7 +2132,7 @@ pick_secondary_gpu_framebuffer_format_for_cpu (CoglOnscreen *onscreen) { drm_format = g_array_index (formats, uint32_t, i); - if (meta_cogl_pixel_format_from_drm_format (drm_format, NULL)) + if (meta_cogl_pixel_format_from_drm_format (drm_format, NULL, NULL)) return drm_format; } diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 76febc81f..6826fe925 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -615,7 +615,7 @@ meta_renderer_native_create_dma_buf_framebuffer (MetaRendererNative *renderer_n CoglOffscreen *cogl_fbo; int ret; - ret = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format); + ret = meta_cogl_pixel_format_from_drm_format (drm_format, &cogl_format, NULL); g_assert (ret); strides[0] = stride; diff --git a/src/common/meta-cogl-drm-formats.c b/src/common/meta-cogl-drm-formats.c index 9425f8b6d..24c4b833a 100644 --- a/src/common/meta-cogl-drm-formats.c +++ b/src/common/meta-cogl-drm-formats.c @@ -27,8 +27,9 @@ #include "common/meta-cogl-drm-formats.h" gboolean -meta_cogl_pixel_format_from_drm_format (uint32_t drm_format, - CoglPixelFormat *out_format) +meta_cogl_pixel_format_from_drm_format (uint32_t drm_format, + CoglPixelFormat *out_format, + MetaMultiTextureFormat *out_multi_texture_format) { const size_t n = G_N_ELEMENTS (meta_cogl_drm_format_map); size_t i; @@ -45,5 +46,8 @@ meta_cogl_pixel_format_from_drm_format (uint32_t drm_format, if (out_format) *out_format = meta_cogl_drm_format_map[i].cogl_format; + if (out_multi_texture_format) + *out_multi_texture_format = meta_cogl_drm_format_map[i].multi_texture_format; + return TRUE; } diff --git a/src/common/meta-cogl-drm-formats.h b/src/common/meta-cogl-drm-formats.h index 98661e638..c0574ef32 100644 --- a/src/common/meta-cogl-drm-formats.h +++ b/src/common/meta-cogl-drm-formats.h @@ -28,6 +28,7 @@ #include #include "cogl/cogl.h" +#include "meta/meta-multi-texture-format.h" G_BEGIN_DECLS @@ -35,44 +36,46 @@ typedef struct _CoglDrmFormatMap { uint32_t drm_format; CoglPixelFormat cogl_format; + MetaMultiTextureFormat multi_texture_format; } CoglDrmFormatMap; static const CoglDrmFormatMap meta_cogl_drm_format_map[] = { /* DRM formats are defined as little-endian, not machine endian. */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN - { DRM_FORMAT_RGB565, COGL_PIXEL_FORMAT_RGB_565 }, - { DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_XBGR_8888 }, - { DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE }, - { DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_XRGB_8888 }, - { DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE }, - { DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_BGRX_8888 }, - { DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE }, - { DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_RGBX_8888 }, - { DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE }, - { DRM_FORMAT_XRGB2101010, COGL_PIXEL_FORMAT_XRGB_2101010 }, - { DRM_FORMAT_ARGB2101010, COGL_PIXEL_FORMAT_ARGB_2101010_PRE }, - { DRM_FORMAT_XBGR2101010, COGL_PIXEL_FORMAT_XBGR_2101010 }, - { DRM_FORMAT_ABGR2101010, COGL_PIXEL_FORMAT_ABGR_2101010_PRE }, - { DRM_FORMAT_XRGB16161616F, COGL_PIXEL_FORMAT_BGRX_FP_16161616 }, - { DRM_FORMAT_ARGB16161616F, COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE }, - { DRM_FORMAT_XBGR16161616F, COGL_PIXEL_FORMAT_RGBX_FP_16161616 }, - { DRM_FORMAT_ABGR16161616F, COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE }, + { DRM_FORMAT_RGB565, COGL_PIXEL_FORMAT_RGB_565, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_XBGR_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_XRGB_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_BGRX_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_RGBX_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XRGB2101010, COGL_PIXEL_FORMAT_XRGB_2101010, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ARGB2101010, COGL_PIXEL_FORMAT_ARGB_2101010_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XBGR2101010, COGL_PIXEL_FORMAT_XBGR_2101010, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ABGR2101010, COGL_PIXEL_FORMAT_ABGR_2101010_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XRGB16161616F, COGL_PIXEL_FORMAT_BGRX_FP_16161616, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ARGB16161616F, COGL_PIXEL_FORMAT_BGRA_FP_16161616_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XBGR16161616F, COGL_PIXEL_FORMAT_RGBX_FP_16161616, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ABGR16161616F, COGL_PIXEL_FORMAT_RGBA_FP_16161616_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, #elif G_BYTE_ORDER == G_BIG_ENDIAN - { DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_RGBX_8888 }, - { DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE }, - { DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_BGRX_8888 }, - { DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE }, - { DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_XRGB_8888 }, - { DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE }, - { DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_XBGR_8888 }, - { DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE }, + { DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_RGBX_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_BGRX_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_XRGB_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_XBGR_8888, META_MULTI_TEXTURE_FORMAT_SIMPLE }, + { DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, META_MULTI_TEXTURE_FORMAT_SIMPLE }, #else #error "unexpected G_BYTE_ORDER" #endif }; -gboolean meta_cogl_pixel_format_from_drm_format (uint32_t drm_format, - CoglPixelFormat *out_format); +gboolean meta_cogl_pixel_format_from_drm_format (uint32_t drm_format, + CoglPixelFormat *out_format, + MetaMultiTextureFormat *out_multi_texture_format); G_END_DECLS diff --git a/src/wayland/meta-wayland-dma-buf.c b/src/wayland/meta-wayland-dma-buf.c index c205f1b64..535fae10a 100644 --- a/src/wayland/meta-wayland-dma-buf.c +++ b/src/wayland/meta-wayland-dma-buf.c @@ -357,7 +357,8 @@ meta_wayland_dma_buf_realize_texture (MetaWaylandBuffer *buffer, return TRUE; if (!meta_cogl_pixel_format_from_drm_format (dma_buf->drm_format, - &cogl_format)) + &cogl_format, + NULL)) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, @@ -1562,7 +1563,9 @@ init_formats (MetaWaylandDmaBufManager *dma_buf_manager, { for (j = 0; j < num_formats; j++) { - if (meta_cogl_drm_format_map[i].drm_format == driver_formats[j]) + if ((meta_cogl_drm_format_map[i].drm_format == driver_formats[j]) && + (meta_cogl_drm_format_map[i].multi_texture_format != + META_MULTI_TEXTURE_FORMAT_INVALID)) add_format (dma_buf_manager, egl_display, driver_formats[j]); } }