diff --git a/client/renderers/EGL/texture_dmabuf.c b/client/renderers/EGL/texture_dmabuf.c index c701f822..00867100 100644 --- a/client/renderers/EGL/texture_dmabuf.c +++ b/client/renderers/EGL/texture_dmabuf.c @@ -20,6 +20,7 @@ #include "texture.h" #include "texture_buffer.h" +#include "util.h" #include "common/vector.h" #include "egl_dynprocs.h" @@ -36,6 +37,7 @@ typedef struct TexDMABUF TextureBuffer base; EGLDisplay display; + bool hasImportModifiers; Vector images; } TexDMABUF; @@ -77,6 +79,11 @@ static bool egl_texDMABUFInit(EGL_Texture ** texture, EGL_TexType type, } this->display = display; + + const char * client_exts = eglQueryString(this->display, EGL_EXTENSIONS); + this->hasImportModifiers = + util_hasGLExt(client_exts, "EGL_EXT_image_dma_buf_import_modifiers"); + return true; } @@ -122,17 +129,24 @@ static bool egl_texDMABUFUpdate(EGL_Texture * texture, if (image == EGL_NO_IMAGE) { - EGLAttrib const attribs[] = + const uint64_t modifier = DRM_FORMAT_MOD_LINEAR; + EGLAttrib attribs[] = { - EGL_WIDTH , texture->format.width, - EGL_HEIGHT , texture->format.height, - EGL_LINUX_DRM_FOURCC_EXT , texture->format.fourcc, - EGL_DMA_BUF_PLANE0_FD_EXT , update->dmaFD, - EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, - EGL_DMA_BUF_PLANE0_PITCH_EXT , texture->format.stride, - EGL_NONE , EGL_NONE + EGL_WIDTH , texture->format.width, + EGL_HEIGHT , texture->format.height, + EGL_LINUX_DRM_FOURCC_EXT , texture->format.fourcc, + EGL_DMA_BUF_PLANE0_FD_EXT , update->dmaFD, + EGL_DMA_BUF_PLANE0_OFFSET_EXT , 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT , texture->format.stride, + EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, (modifier & 0xffffff), + EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, (modifier >> 32), + EGL_NONE , EGL_NONE }; + if (!this->hasImportModifiers) + attribs[12] = attribs[13] = + attribs[14] = attribs[15] = EGL_NONE; + image = g_egl_dynProcs.eglCreateImage( this->display, EGL_NO_CONTEXT, diff --git a/client/renderers/EGL/texture_util.c b/client/renderers/EGL/texture_util.c index e98f9d31..7146d5af 100644 --- a/client/renderers/EGL/texture_util.c +++ b/client/renderers/EGL/texture_util.c @@ -28,17 +28,6 @@ #include "egldebug.h" #include "egl_dynprocs.h" -/** - * the following comes from drm_fourcc.h and is included here to avoid the - * external dependency for the few simple defines we need - */ -#define fourcc_code(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ - ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) -#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') -#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') -#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') -#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') - bool egl_texUtilGetFormat(const EGL_TexSetup * setup, EGL_TexFormat * fmt) { switch(setup->pixFmt) diff --git a/client/renderers/EGL/texture_util.h b/client/renderers/EGL/texture_util.h index a0d7c1c0..ae8e11b1 100644 --- a/client/renderers/EGL/texture_util.h +++ b/client/renderers/EGL/texture_util.h @@ -55,3 +55,20 @@ bool egl_texUtilGenBuffers(const EGL_TexFormat * fmt, EGL_TexBuffer * buffers, void egl_texUtilFreeBuffers(EGL_TexBuffer * buffers, int count); bool egl_texUtilMapBuffer(EGL_TexBuffer * buffer); void egl_texUtilUnmapBuffer(EGL_TexBuffer * buffer); + +/** + * the following comes from drm_fourcc.h and is included here to avoid the + * external dependency for the few simple defines we need + */ +#define fourcc_code(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ + ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) +#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') +#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') +#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') +#define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') + +#define DRM_FORMAT_MOD_VENDOR_NONE 0 +#define fourcc_mod_code(vendor, val) \ + ((((uint64_t)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | \ + ((val) & 0x00ffffffffffffffULL)) +#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0)