diff options
Diffstat (limited to 'src/egl')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 59 | ||||
-rw-r--r-- | src/egl/main/eglapi.c | 50 | ||||
-rw-r--r-- | src/egl/main/eglapi.h | 10 | ||||
-rw-r--r-- | src/egl/main/egldisplay.h | 2 | ||||
-rw-r--r-- | src/egl/main/eglfallbacks.c | 5 |
5 files changed, 125 insertions, 1 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index d5031961ce0..a428f284ae7 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -525,8 +525,14 @@ dri2_setup_screen(_EGLDisplay *disp) capabilities = dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen); disp->Extensions.MESA_drm_image = (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0; - } else + + if (dri2_dpy->image->base.version >= 11) + disp->Extensions.MESA_image_dma_buf_export = EGL_TRUE; + } else { disp->Extensions.MESA_drm_image = EGL_TRUE; + if (dri2_dpy->image->base.version >= 11) + disp->Extensions.MESA_image_dma_buf_export = EGL_TRUE; + } disp->Extensions.KHR_image_base = EGL_TRUE; disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE; @@ -1965,6 +1971,55 @@ dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, return EGL_TRUE; } + +static EGLBoolean +dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp, + _EGLImage *img, + EGLint *fourcc, EGLint *nplanes, + EGLuint64MESA *modifiers) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_image *dri2_img = dri2_egl_image(img); + + (void) drv; + + + if (nplanes) + dri2_dpy->image->queryImage(dri2_img->dri_image, + __DRI_IMAGE_ATTRIB_NUM_PLANES, nplanes); + if (fourcc) + dri2_dpy->image->queryImage(dri2_img->dri_image, + __DRI_IMAGE_ATTRIB_FOURCC, fourcc); + + if (modifiers) + *modifiers = 0; + + return EGL_TRUE; +} + +static EGLBoolean +dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, + int *fds, EGLint *strides, EGLint *offsets) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + struct dri2_egl_image *dri2_img = dri2_egl_image(img); + + (void) drv; + + /* rework later to provide multiple fds/strides/offsets */ + if (fds) + dri2_dpy->image->queryImage(dri2_img->dri_image, + __DRI_IMAGE_ATTRIB_FD, fds); + + if (strides) + dri2_dpy->image->queryImage(dri2_img->dri_image, + __DRI_IMAGE_ATTRIB_STRIDE, strides); + + if (offsets) + offsets[0] = 0; + + return EGL_TRUE; +} #endif #ifdef HAVE_WAYLAND_PLATFORM @@ -2219,6 +2274,8 @@ _eglBuiltInDriverDRI2(const char *args) #ifdef HAVE_LIBDRM dri2_drv->base.API.CreateDRMImageMESA = dri2_create_drm_image_mesa; dri2_drv->base.API.ExportDRMImageMESA = dri2_export_drm_image_mesa; + dri2_drv->base.API.ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa; + dri2_drv->base.API.ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa; #endif #ifdef HAVE_WAYLAND_PLATFORM dri2_drv->base.API.BindWaylandDisplayWL = dri2_bind_wayland_display_wl; diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 6031a7ad8dc..ea2ee734a21 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -423,6 +423,8 @@ _eglCreateExtensionsString(_EGLDisplay *dpy) _EGL_CHECK_EXTENSION(EXT_image_dma_buf_import); _EGL_CHECK_EXTENSION(NV_post_sub_buffer); + + _EGL_CHECK_EXTENSION(MESA_image_dma_buf_export); #undef _EGL_CHECK_EXTENSION } @@ -1239,6 +1241,10 @@ eglGetProcAddress(const char *procname) { "eglCreatePlatformWindowSurfaceEXT", (_EGLProc) eglCreatePlatformWindowSurfaceEXT }, { "eglCreatePlatformPixmapSurfaceEXT", (_EGLProc) eglCreatePlatformPixmapSurfaceEXT }, { "eglGetSyncValuesCHROMIUM", (_EGLProc) eglGetSyncValuesCHROMIUM }, +#ifdef EGL_MESA_drm_buf_image_export + { "eglExportDMABUFImageQueryMESA", (_EGLProc) eglExportDMABUFImageQueryMESA }, + { "eglExportDMABUFImageMESA", (_EGLProc) eglExportDMABUFImageMESA }, +#endif { NULL, NULL } }; EGLint i; @@ -1926,3 +1932,47 @@ eglGetSyncValuesCHROMIUM(EGLDisplay display, EGLSurface surface, RETURN_EGL_EVAL(disp, ret); } + +#ifdef EGL_MESA_image_dma_buf_export +EGLBoolean EGLAPIENTRY +eglExportDMABUFImageQueryMESA(EGLDisplay dpy, EGLImageKHR image, + EGLint *fourcc, EGLint *nplanes, + EGLuint64MESA *modifiers) +{ + _EGLDisplay *disp = _eglLockDisplay(dpy); + _EGLImage *img = _eglLookupImage(image, disp); + _EGLDriver *drv; + EGLBoolean ret; + + _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + assert(disp->Extensions.MESA_image_dma_buf_export); + + if (!img) + RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); + + ret = drv->API.ExportDMABUFImageQueryMESA(drv, disp, img, fourcc, nplanes, + modifiers); + + RETURN_EGL_EVAL(disp, ret); +} + +EGLBoolean EGLAPIENTRY +eglExportDMABUFImageMESA(EGLDisplay dpy, EGLImageKHR image, + int *fds, EGLint *strides, EGLint *offsets) +{ + _EGLDisplay *disp = _eglLockDisplay(dpy); + _EGLImage *img = _eglLookupImage(image, disp); + _EGLDriver *drv; + EGLBoolean ret; + + _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv); + assert(disp->Extensions.MESA_image_dma_buf_export); + + if (!img) + RETURN_EGL_ERROR(disp, EGL_BAD_PARAMETER, EGL_FALSE); + + ret = drv->API.ExportDMABUFImageMESA(drv, disp, img, fds, strides, offsets); + + RETURN_EGL_EVAL(disp, ret); +} +#endif diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 0626719ae70..eb5f58e6fa9 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -140,6 +140,11 @@ typedef EGLBoolean (*SwapBuffersWithDamageEXT_t) (_EGLDriver *drv, _EGLDisplay * typedef EGLBoolean (*GetSyncValuesCHROMIUM_t) (_EGLDisplay *dpy, _EGLSurface *surface, EGLuint64KHR *ust, EGLuint64KHR *msc, EGLuint64KHR *sbc); +#ifdef EGL_MESA_image_dma_buf_export +typedef EGLBoolean (*ExportDMABUFImageQueryMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fourcc, EGLint *stride, EGLuint64MESA *modifiers); +typedef EGLBoolean (*ExportDMABUFImageMESA_t)(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img, EGLint *fds, EGLint *strides, EGLint *offsets); +#endif + /** * The API dispatcher jumps through these functions */ @@ -226,6 +231,11 @@ struct _egl_api QueryBufferAge_t QueryBufferAge; GetSyncValuesCHROMIUM_t GetSyncValuesCHROMIUM; + +#ifdef EGL_MESA_image_dma_buf_export + ExportDMABUFImageQueryMESA_t ExportDMABUFImageQueryMESA; + ExportDMABUFImageMESA_t ExportDMABUFImageMESA; +#endif }; #endif /* EGLAPI_INCLUDED */ diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h index d7f5dbacde6..4a1fb4ab15c 100644 --- a/src/egl/main/egldisplay.h +++ b/src/egl/main/egldisplay.h @@ -123,6 +123,8 @@ struct _egl_extensions EGLBoolean EXT_buffer_age; EGLBoolean EXT_swap_buffers_with_damage; EGLBoolean EXT_image_dma_buf_import; + + EGLBoolean MESA_image_dma_buf_export; }; diff --git a/src/egl/main/eglfallbacks.c b/src/egl/main/eglfallbacks.c index be596430684..c108ca7687c 100644 --- a/src/egl/main/eglfallbacks.c +++ b/src/egl/main/eglfallbacks.c @@ -118,4 +118,9 @@ _eglInitDriverFallbacks(_EGLDriver *drv) #ifdef EGL_NOK_swap_region drv->API.SwapBuffersRegionNOK = NULL; #endif + +#ifdef EGL_MESA_dma_buf_image_export + drv->API.ExportDMABUFImageQueryMESA = NULL; + drv->API.ExportDMABUFImageMESA = NULL; +#endif } |