#include "egl_dri2.h"
#include "GL/mesa_glinterop.h"
#include "loader/loader.h"
+#include "util/libsync.h"
#include "util/os_file.h"
#include "util/u_atomic.h"
+#include "util/u_call_once.h"
#include "util/u_vector.h"
#include "mapi/glapi/glapi.h"
#include "util/bitscan.h"
+#include "util/driconf.h"
#include "util/u_math.h"
-/* Additional definitions not yet in the drm_fourcc.h.
- */
-#ifndef DRM_FORMAT_P010
-#define DRM_FORMAT_P010 fourcc_code('P', '0', '1', '0') /* 2x2 subsampled Cb:Cr plane 10 bits per channel */
-#endif
-
-#ifndef DRM_FORMAT_P012
-#define DRM_FORMAT_P012 fourcc_code('P', '0', '1', '2') /* 2x2 subsampled Cb:Cr plane 12 bits per channel */
-#endif
-
-#ifndef DRM_FORMAT_P016
-#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cb:Cr plane 16 bits per channel */
-#endif
-
#define NUM_ATTRIBS 12
static const struct dri2_pbuffer_visual {
}
static void
+dri2_gl_flush_get(_glapi_proc *glFlush)
+{
+ *glFlush = _glapi_get_proc_address("glFlush");
+}
+
+static void
dri2_gl_flush()
{
static void (*glFlush)(void);
- static mtx_t glFlushMutex = _MTX_INITIALIZER_NP;
+ static util_once_flag once = UTIL_ONCE_FLAG_INIT;
- mtx_lock(&glFlushMutex);
- if (!glFlush)
- glFlush = _glapi_get_proc_address("glFlush");
- mtx_unlock(&glFlushMutex);
+ util_call_once_data(&once,
+ (util_call_once_data_func)dri2_gl_flush_get, &glFlush);
/* if glFlush is not available things are horribly broken */
if (!glFlush) {
}
static GLboolean
-dri_is_thread_safe(void *loaderPrivate)
+dri_is_thread_safe(UNUSED void *loaderPrivate)
{
+#ifdef HAVE_X11_PLATFORM
struct dri2_egl_surface *dri2_surf = loaderPrivate;
- UNUSED _EGLDisplay *display = dri2_surf->base.Resource.Display;
-#ifdef HAVE_X11_PLATFORM
+ /* loader_dri3_blit_context_get creates a context with
+ * loaderPrivate being NULL. Enabling glthread for a blitting
+ * context isn't useful so return false.
+ */
+ if (!loaderPrivate)
+ return false;
+
+ _EGLDisplay *display = dri2_surf->base.Resource.Display;
+
Display *xdpy = (Display*)display->PlatformDisplay;
/* Check Xlib is running in thread safe mode when running on EGL/X11-xlib
return false;
#endif
-#ifdef HAVE_WAYLAND_PLATFORM
- if (display->Platform == _EGL_PLATFORM_WAYLAND)
- return true;
-#endif
-
return true;
}
surface_type &= ~EGL_PIXMAP_BIT;
}
- /* No support for pbuffer + MSAA for now.
- *
- * XXX TODO: pbuffer + MSAA does not work and causes crashes.
- * See QT bugreport: https://bugreports.qt.io/browse/QTBUG-47509
- */
- if (base.Samples) {
- surface_type &= ~EGL_PBUFFER_BIT;
- }
-
if (!surface_type)
return NULL;
}
EGLBoolean
-dri2_add_pbuffer_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
+dri2_add_pbuffer_configs_for_visuals(_EGLDisplay *disp)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
unsigned int format_count[ARRAY_SIZE(dri2_pbuffer_visuals)] = { 0 };
return (config_count != 0);
}
-__DRIimage *
-dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
+GLboolean
+dri2_validate_egl_image(void *image, void *data)
{
- _EGLDisplay *disp = data;
- struct dri2_egl_image *dri2_img;
- _EGLImage *img;
+ _EGLDisplay *disp = _eglLockDisplay(data);
+ _EGLImage *img = _eglLookupImage(image, disp);
+ _eglUnlockDisplay(disp);
- (void) screen;
-
- img = _eglLookupImage(image, disp);
if (img == NULL) {
- _eglError(EGL_BAD_PARAMETER, "dri2_lookup_egl_image");
- return NULL;
+ _eglError(EGL_BAD_PARAMETER, "dri2_validate_egl_image");
+ return false;
}
+ return true;
+}
+
+__DRIimage *
+dri2_lookup_egl_image_validated(void *image, void *data)
+{
+ struct dri2_egl_image *dri2_img;
+
+ (void)data;
+
dri2_img = dri2_egl_image(image);
return dri2_img->dri_image;
}
+__DRIimage *
+dri2_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
+{
+ (void) screen;
+
+ if (!dri2_validate_egl_image(image, data))
+ return NULL;
+
+ return dri2_lookup_egl_image_validated(image, data);
+}
+
const __DRIimageLookupExtension image_lookup_extension = {
- .base = { __DRI_IMAGE_LOOKUP, 1 },
+ .base = { __DRI_IMAGE_LOOKUP, 2 },
- .lookupEGLImage = dri2_lookup_egl_image
+ .lookupEGLImage = dri2_lookup_egl_image,
+ .validateEGLImage = dri2_validate_egl_image,
+ .lookupEGLImageValidated = dri2_lookup_egl_image_validated,
};
struct dri2_extension_match {
static const struct dri2_extension_match optional_core_extensions[] = {
{ __DRI2_ROBUSTNESS, 1, offsetof(struct dri2_egl_display, robustness) },
- { __DRI2_NO_ERROR, 1, offsetof(struct dri2_egl_display, no_error) },
{ __DRI2_CONFIG_QUERY, 1, offsetof(struct dri2_egl_display, config) },
{ __DRI2_FENCE, 1, offsetof(struct dri2_egl_display, fence) },
{ __DRI2_BUFFER_DAMAGE, 1, offsetof(struct dri2_egl_display, buffer_damage) },
{ __DRI2_FLUSH_CONTROL, 1, offsetof(struct dri2_egl_display, flush_control) },
{ __DRI2_BLOB, 1, offsetof(struct dri2_egl_display, blob) },
{ __DRI_MUTABLE_RENDER_BUFFER_DRIVER, 1, offsetof(struct dri2_egl_display, mutable_render_buffer) },
+ { __DRI_KOPPER, 1, offsetof(struct dri2_egl_display, kopper) },
{ NULL, 0, 0 }
};
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
const __DRIextension **extensions;
+ /*This exception only happen in multithread case, when _eglAtExit is *
+ *called and disp is freed in main thread. */
+ if (dri2_dpy == NULL) {
+ _eglLog(_EGL_FATAL, "DRI2: disp is freed");
+ return EGL_FALSE;
+ }
+
extensions = dri2_open_driver(disp);
if (!extensions)
return EGL_FALSE;
static char *
dri2_query_driver_config(_EGLDisplay *disp)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
const __DRIconfigOptionsExtension *ext = dri2_dpy->configOptions;
+ char *ret;
+
+ if (ext->base.version >= 2) {
+ ret = ext->getXml(dri2_dpy->driver_name);
+ } else {
+ ret = strdup(ext->xml);
+ }
- if (ext->base.version >= 2)
- return ext->getXml(dri2_dpy->driver_name);
+ mtx_unlock(&dri2_dpy->lock);
- return strdup(ext->xml);
+ return ret;
}
disp->Extensions.EXT_create_context_robustness = EGL_TRUE;
}
- if (dri2_dpy->no_error)
+ if (dri2_renderer_query_integer(dri2_dpy,
+ __DRI2_RENDERER_HAS_NO_ERROR_CONTEXT))
disp->Extensions.KHR_create_context_no_error = EGL_TRUE;
if (dri2_dpy->fence) {
if (dri2_dpy->buffer_damage && dri2_dpy->buffer_damage->set_damage_region)
disp->Extensions.KHR_partial_update = EGL_TRUE;
+
+ disp->Extensions.EXT_protected_surface =
+ dri2_renderer_query_integer(dri2_dpy,
+ __DRI2_RENDERER_HAS_PROTECTED_SURFACE);
+ disp->Extensions.EXT_protected_content =
+ dri2_renderer_query_integer(dri2_dpy,
+ __DRI2_RENDERER_HAS_PROTECTED_CONTEXT);
}
void
}
if (dri2_dpy->dri_screen == NULL) {
- _eglLog(_EGL_WARNING, "DRI2: failed to create dri screen");
+ _eglLog(_EGL_WARNING, "egl: failed to create dri2 screen");
return EGL_FALSE;
}
* called many times (without a eglTerminate in between).
*/
static EGLBoolean
-dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp)
+dri2_initialize(_EGLDisplay *disp)
{
EGLBoolean ret = EGL_FALSE;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
* to free it up correctly.
*/
if (dri2_dpy) {
- dri2_dpy->ref_count++;
+ p_atomic_inc(&dri2_dpy->ref_count);
return EGL_TRUE;
}
switch (disp->Platform) {
case _EGL_PLATFORM_SURFACELESS:
- ret = dri2_initialize_surfaceless(drv, disp);
+ ret = dri2_initialize_surfaceless(disp);
break;
case _EGL_PLATFORM_DEVICE:
- ret = dri2_initialize_device(drv, disp);
+ ret = dri2_initialize_device(disp);
break;
case _EGL_PLATFORM_X11:
- ret = dri2_initialize_x11(drv, disp);
+ case _EGL_PLATFORM_XCB:
+ ret = dri2_initialize_x11(disp);
break;
case _EGL_PLATFORM_DRM:
- ret = dri2_initialize_drm(drv, disp);
+ ret = dri2_initialize_drm(disp);
break;
case _EGL_PLATFORM_WAYLAND:
- ret = dri2_initialize_wayland(drv, disp);
+ ret = dri2_initialize_wayland(disp);
break;
case _EGL_PLATFORM_ANDROID:
- ret = dri2_initialize_android(drv, disp);
+ ret = dri2_initialize_android(disp);
+ break;
+
+#ifdef HAVE_TIZEN_PLATFORM
+ case _EGL_PLATFORM_TIZEN:
+ ret = dri2_initialize_tizen(disp);
break;
+#endif
default:
unreachable("Callers ensure we cannot get here.");
return EGL_FALSE;
return EGL_FALSE;
dri2_dpy = dri2_egl_display(disp);
- dri2_dpy->ref_count++;
+ p_atomic_inc(&dri2_dpy->ref_count);
+
+ mtx_init(&dri2_dpy->lock, mtx_plain);
return EGL_TRUE;
}
dri2_dpy = dri2_egl_display(disp);
assert(dri2_dpy->ref_count > 0);
- dri2_dpy->ref_count--;
- if (dri2_dpy->ref_count > 0)
+ if (!p_atomic_dec_zero(&dri2_dpy->ref_count))
return;
_eglCleanupDisplay(disp);
}
if (dri2_dpy->fd >= 0)
close(dri2_dpy->fd);
+
+ /* Don't dlclose the driver when building with the address sanitizer, so you
+ * get good symbols from the leak reports.
+ */
+#if !BUILT_WITH_ASAN || defined(NDEBUG)
if (dri2_dpy->driver)
dlclose(dri2_dpy->driver);
+#endif
+
free(dri2_dpy->driver_name);
#ifdef HAVE_WAYLAND_PLATFORM
case _EGL_PLATFORM_WAYLAND:
dri2_teardown_wayland(dri2_dpy);
break;
+
+#ifdef HAVE_TIZEN_PLATFORM
+ case _EGL_PLATFORM_TIZEN:
+ dri2_teardown_tizen(disp);
+ break;
+#endif
default:
/* TODO: add teardown for other platforms */
break;
* called many times (without a eglInitialize in between).
*/
static EGLBoolean
-dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
+dri2_terminate(_EGLDisplay *disp)
{
/* Release all non-current Context/Surfaces. */
- _eglReleaseDisplayResources(drv, disp);
+ _eglReleaseDisplayResources(disp);
dri2_display_release(disp);
ctx_attribs[pos++] = __DRI_CTX_ATTRIB_MINOR_VERSION;
ctx_attribs[pos++] = dri2_ctx->base.ClientMinorVersion;
- if (dri2_ctx->base.Flags != 0 || dri2_ctx->base.NoError) {
+ if (dri2_ctx->base.Flags != 0) {
/* If the implementation doesn't support the __DRI2_ROBUSTNESS
* extension, don't even try to send it the robust-access flag.
* It may explode. Instead, generate the required EGL error here.
}
ctx_attribs[pos++] = __DRI_CTX_ATTRIB_FLAGS;
- ctx_attribs[pos++] = dri2_ctx->base.Flags |
- (dri2_ctx->base.NoError ? __DRI_CTX_FLAG_NO_ERROR : 0);
+ ctx_attribs[pos++] = dri2_ctx->base.Flags;
}
if (dri2_ctx->base.ResetNotificationStrategy != EGL_NO_RESET_NOTIFICATION_KHR) {
ctx_attribs[pos++] = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
}
+ if (dri2_ctx->base.NoError) {
+ ctx_attribs[pos++] = __DRI_CTX_ATTRIB_NO_ERROR;
+ ctx_attribs[pos++] = true;
+ }
+
+ if (dri2_ctx->base.Protected) {
+ ctx_attribs[pos++] = __DRI_CTX_ATTRIB_PROTECTED;
+ ctx_attribs[pos++] = true;
+ }
+
*num_attribs = pos;
return true;
* Called via eglCreateContext(), drv->CreateContext().
*/
static _EGLContext *
-dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
+dri2_create_context(_EGLDisplay *disp, _EGLConfig *conf,
_EGLContext *share_list, const EGLint *attrib_list)
{
struct dri2_egl_context *dri2_ctx;
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_context *dri2_ctx_shared = dri2_egl_context(share_list);
__DRIcontext *shared =
dri2_ctx_shared ? dri2_ctx_shared->dri_context : NULL;
unsigned num_attribs = NUM_ATTRIBS;
uint32_t ctx_attribs[NUM_ATTRIBS];
- (void) drv;
-
dri2_ctx = malloc(sizeof *dri2_ctx);
if (!dri2_ctx) {
- _eglError(EGL_BAD_ALLOC, "eglCreateContext");
+ dri2_egl_error_unlock(dri2_dpy, EGL_BAD_ALLOC, "eglCreateContext");
return NULL;
}
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglCreateContext");
- free(dri2_ctx);
- return NULL;
+ goto cleanup;
}
break;
case EGL_OPENGL_API:
break;
default:
_eglError(EGL_BAD_PARAMETER, "eglCreateContext");
- free(dri2_ctx);
- return NULL;
+ goto cleanup;
}
if (conf != NULL) {
if (!dri2_ctx->dri_context)
goto cleanup;
+ mtx_unlock(&dri2_dpy->lock);
+
return &dri2_ctx->base;
cleanup:
+ mtx_unlock(&dri2_dpy->lock);
free(dri2_ctx);
return NULL;
}
* Called via eglDestroyContext(), drv->DestroyContext().
*/
static EGLBoolean
-dri2_destroy_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
+dri2_destroy_context(_EGLDisplay *disp, _EGLContext *ctx)
{
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
}
static EGLBoolean
-dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+dri2_destroy_surface(_EGLDisplay *disp, _EGLSurface *surf)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ EGLBoolean ret = EGL_TRUE;
- if (!_eglPutSurface(surf))
- return EGL_TRUE;
+ if (_eglPutSurface(surf))
+ ret = dri2_dpy->vtbl->destroy_surface(disp, surf);
- return dri2_dpy->vtbl->destroy_surface(drv, disp, surf);
+ return ret;
}
static void
struct dri2_egl_surface *dri2_surf,
void *loaderPrivate)
{
- __DRIcreateNewDrawableFunc createNewDrawable;
-
- if (dri2_dpy->image_driver)
- createNewDrawable = dri2_dpy->image_driver->createNewDrawable;
- else if (dri2_dpy->dri2)
- createNewDrawable = dri2_dpy->dri2->createNewDrawable;
- else if (dri2_dpy->swrast)
- createNewDrawable = dri2_dpy->swrast->createNewDrawable;
- else
- return _eglError(EGL_BAD_ALLOC, "no createNewDrawable");
+ if (dri2_dpy->kopper) {
+ dri2_surf->dri_drawable =
+ dri2_dpy->kopper->createNewDrawable(dri2_dpy->dri_screen, config, loaderPrivate,
+ dri2_surf->base.Type == EGL_PBUFFER_BIT ||
+ dri2_surf->base.Type == EGL_PIXMAP_BIT);
+ } else {
+ __DRIcreateNewDrawableFunc createNewDrawable;
+ if (dri2_dpy->image_driver)
+ createNewDrawable = dri2_dpy->image_driver->createNewDrawable;
+ else if (dri2_dpy->dri2)
+ createNewDrawable = dri2_dpy->dri2->createNewDrawable;
+ else if (dri2_dpy->swrast)
+ createNewDrawable = dri2_dpy->swrast->createNewDrawable;
+ else
+ return _eglError(EGL_BAD_ALLOC, "no createNewDrawable");
- dri2_surf->dri_drawable = createNewDrawable(dri2_dpy->dri_screen,
- config, loaderPrivate);
+ dri2_surf->dri_drawable = createNewDrawable(dri2_dpy->dri_screen,
+ config, loaderPrivate);
+ }
if (dri2_surf->dri_drawable == NULL)
return _eglError(EGL_BAD_ALLOC, "createNewDrawable");
* Called via eglMakeCurrent(), drv->MakeCurrent().
*/
static EGLBoolean
-dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
+dri2_make_current(_EGLDisplay *disp, _EGLSurface *dsurf,
_EGLSurface *rsurf, _EGLContext *ctx)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
_EGLSurface *tmp_dsurf, *tmp_rsurf;
__DRIdrawable *ddraw, *rdraw;
__DRIcontext *cctx;
- EGLBoolean unbind;
+ EGLint egl_error = EGL_SUCCESS;
if (!dri2_dpy)
return _eglError(EGL_NOT_INITIALIZED, "eglMakeCurrent");
- /* make new bindings */
- if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf)) {
- /* _eglBindContext already sets the EGL error (in _eglCheckMakeCurrent) */
+ /* make new bindings, set the EGL error otherwise */
+ if (!_eglBindContext(ctx, dsurf, rsurf, &old_ctx, &old_dsurf, &old_rsurf))
return EGL_FALSE;
- }
- if (old_ctx) {
- old_disp = old_ctx->Resource.Display;
- old_dri2_dpy = dri2_egl_display(old_disp);
+ if (old_ctx == ctx && old_dsurf == dsurf && old_rsurf == rsurf) {
+ _eglPutSurface(old_dsurf);
+ _eglPutSurface(old_rsurf);
+ _eglPutContext(old_ctx);
+ return EGL_TRUE;
}
- /* flush before context switch */
- if (old_ctx)
- dri2_gl_flush();
-
- ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
- rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
- cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
-
if (old_ctx) {
__DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
-
- if (old_dsurf)
- dri2_surf_update_fence_fd(old_ctx, disp, old_dsurf);
+ old_disp = old_ctx->Resource.Display;
+ old_dri2_dpy = dri2_egl_display(old_disp);
/* Disable shared buffer mode */
if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) &&
old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, false);
}
- dri2_dpy->core->unbindContext(old_cctx);
+ old_dri2_dpy->core->unbindContext(old_cctx);
+
+ if (old_dsurf)
+ dri2_surf_update_fence_fd(old_ctx, old_disp, old_dsurf);
}
- unbind = (cctx == NULL && ddraw == NULL && rdraw == NULL);
+ ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
+ rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
+ cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
- if (!unbind && !dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
- /* undo the previous _eglBindContext */
- _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf);
- assert(&dri2_ctx->base == ctx &&
- tmp_dsurf == dsurf &&
- tmp_rsurf == rsurf);
+ if (cctx) {
+ if (!dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
+ _EGLContext *tmp_ctx;
- if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) &&
- old_dri2_dpy->vtbl->set_shared_buffer_mode) {
- old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, true);
- }
+ /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but
+ * setting the error to EGL_BAD_MATCH is surely better than leaving it
+ * as EGL_SUCCESS.
+ */
+ egl_error = EGL_BAD_MATCH;
+
+ /* undo the previous _eglBindContext */
+ _eglBindContext(old_ctx, old_dsurf, old_rsurf, &ctx, &tmp_dsurf, &tmp_rsurf);
+ assert(&dri2_ctx->base == ctx &&
+ tmp_dsurf == dsurf &&
+ tmp_rsurf == rsurf);
+
+ _eglPutSurface(dsurf);
+ _eglPutSurface(rsurf);
+ _eglPutContext(ctx);
+
+ _eglPutSurface(old_dsurf);
+ _eglPutSurface(old_rsurf);
+ _eglPutContext(old_ctx);
+
+ ddraw = (old_dsurf) ? dri2_dpy->vtbl->get_dri_drawable(old_dsurf) : NULL;
+ rdraw = (old_rsurf) ? dri2_dpy->vtbl->get_dri_drawable(old_rsurf) : NULL;
+ cctx = (old_ctx) ? dri2_egl_context(old_ctx)->dri_context : NULL;
+
+ /* undo the previous dri2_dpy->core->unbindContext */
+ if (dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
+ if (old_dsurf && _eglSurfaceInSharedBufferMode(old_dsurf) &&
+ old_dri2_dpy->vtbl->set_shared_buffer_mode) {
+ old_dri2_dpy->vtbl->set_shared_buffer_mode(old_disp, old_dsurf, true);
+ }
- _eglPutSurface(dsurf);
- _eglPutSurface(rsurf);
- _eglPutContext(ctx);
+ return _eglError(egl_error, "eglMakeCurrent");
+ }
- _eglPutSurface(old_dsurf);
- _eglPutSurface(old_rsurf);
- _eglPutContext(old_ctx);
+ /* We cannot restore the same state as it was before calling
+ * eglMakeCurrent() and the spec isn't clear about what to do. We
+ * can prevent EGL from calling into the DRI driver with no DRI
+ * context bound.
+ */
+ dsurf = rsurf = NULL;
+ ctx = NULL;
- /* dri2_dpy->core->bindContext failed. We cannot tell for sure why, but
- * setting the error to EGL_BAD_MATCH is surely better than leaving it
- * as EGL_SUCCESS.
- */
- return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
- }
+ _eglBindContext(ctx, dsurf, rsurf, &tmp_ctx, &tmp_dsurf, &tmp_rsurf);
+ assert(tmp_ctx == old_ctx && tmp_dsurf == old_dsurf &&
+ tmp_rsurf == old_rsurf);
- dri2_destroy_surface(drv, disp, old_dsurf);
- dri2_destroy_surface(drv, disp, old_rsurf);
+ _eglLog(_EGL_WARNING, "DRI2: failed to rebind the previous context");
+ } else {
+ /* dri2_dpy->core->bindContext succeeded, so take a reference on the
+ * dri2_dpy. This prevents dri2_dpy from being reinitialized when a
+ * EGLDisplay is terminated and then initialized again while a
+ * context is still bound. See dri2_initialize() for a more in depth
+ * explanation. */
+ p_atomic_inc(&dri2_dpy->ref_count);
+ }
+ }
- if (!unbind)
- dri2_dpy->ref_count++;
+ dri2_destroy_surface(disp, old_dsurf);
+ dri2_destroy_surface(disp, old_rsurf);
if (old_ctx) {
- dri2_destroy_context(drv, disp, old_ctx);
+ dri2_destroy_context(disp, old_ctx);
dri2_display_release(old_disp);
}
+ if (egl_error != EGL_SUCCESS)
+ return _eglError(egl_error, "eglMakeCurrent");
+
if (dsurf && _eglSurfaceHasMutableRenderBuffer(dsurf) &&
dri2_dpy->vtbl->set_shared_buffer_mode) {
/* Always update the shared buffer mode. This is obviously needed when
* Called from eglGetProcAddress() via drv->GetProcAddress().
*/
static _EGLProc
-dri2_get_proc_address(_EGLDriver *drv, const char *procname)
+dri2_get_proc_address(const char *procname)
{
return _glapi_get_proc_address(procname);
}
static _EGLSurface*
-dri2_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLConfig *conf, void *native_window,
- const EGLint *attrib_list)
-{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- return dri2_dpy->vtbl->create_window_surface(drv, disp, conf, native_window,
- attrib_list);
+dri2_create_window_surface(_EGLDisplay *disp, _EGLConfig *conf,
+ void *native_window, const EGLint *attrib_list)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ _EGLSurface *ret =
+ dri2_dpy->vtbl->create_window_surface(disp, conf, native_window,
+ attrib_list);
+ mtx_unlock(&dri2_dpy->lock);
+ return ret;
}
static _EGLSurface*
-dri2_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLConfig *conf, void *native_pixmap,
- const EGLint *attrib_list)
+dri2_create_pixmap_surface(_EGLDisplay *disp, _EGLConfig *conf,
+ void *native_pixmap, const EGLint *attrib_list)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->create_pixmap_surface)
- return NULL;
- return dri2_dpy->vtbl->create_pixmap_surface(drv, disp, conf, native_pixmap,
- attrib_list);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ _EGLSurface *ret = NULL;
+
+ if (dri2_dpy->vtbl->create_pixmap_surface)
+ ret = dri2_dpy->vtbl->create_pixmap_surface(disp, conf, native_pixmap,
+ attrib_list);
+
+ mtx_unlock(&dri2_dpy->lock);
+
+ return ret;
}
static _EGLSurface*
-dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLConfig *conf, const EGLint *attrib_list)
+dri2_create_pbuffer_surface(_EGLDisplay *disp, _EGLConfig *conf,
+ const EGLint *attrib_list)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->create_pbuffer_surface)
- return NULL;
- return dri2_dpy->vtbl->create_pbuffer_surface(drv, disp, conf, attrib_list);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ _EGLSurface *ret = NULL;
+
+ if (dri2_dpy->vtbl->create_pbuffer_surface)
+ ret = dri2_dpy->vtbl->create_pbuffer_surface(disp, conf, attrib_list);
+
+ mtx_unlock(&dri2_dpy->lock);
+
+ return ret;
}
static EGLBoolean
-dri2_swap_interval(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
- EGLint interval)
+dri2_swap_interval(_EGLDisplay *disp, _EGLSurface *surf, EGLint interval)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->swap_interval)
- return EGL_TRUE;
- return dri2_dpy->vtbl->swap_interval(drv, disp, surf, interval);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ EGLBoolean ret = EGL_TRUE;
+
+ if (dri2_dpy->vtbl->swap_interval)
+ ret = dri2_dpy->vtbl->swap_interval(disp, surf, interval);
+
+ mtx_unlock(&dri2_dpy->lock);
+
+ return ret;
}
/**
}
static EGLBoolean
-dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+dri2_swap_buffers(_EGLDisplay *disp, _EGLSurface *surf)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
__DRIdrawable *dri_drawable = dri2_dpy->vtbl->get_dri_drawable(surf);
if (ctx && surf)
dri2_surf_update_fence_fd(ctx, disp, surf);
- ret = dri2_dpy->vtbl->swap_buffers(drv, disp, surf);
+ ret = dri2_dpy->vtbl->swap_buffers(disp, surf);
/* SwapBuffers marks the end of the frame; reset the damage region for
* use again next time.
}
static EGLBoolean
-dri2_swap_buffers_with_damage(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLSurface *surf,
+dri2_swap_buffers_with_damage(_EGLDisplay *disp, _EGLSurface *surf,
const EGLint *rects, EGLint n_rects)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
if (ctx && surf)
dri2_surf_update_fence_fd(ctx, disp, surf);
if (dri2_dpy->vtbl->swap_buffers_with_damage)
- ret = dri2_dpy->vtbl->swap_buffers_with_damage(drv, disp, surf,
+ ret = dri2_dpy->vtbl->swap_buffers_with_damage(disp, surf,
rects, n_rects);
else
- ret = dri2_dpy->vtbl->swap_buffers(drv, disp, surf);
+ ret = dri2_dpy->vtbl->swap_buffers(disp, surf);
/* SwapBuffers marks the end of the frame; reset the damage region for
* use again next time.
}
static EGLBoolean
-dri2_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+dri2_swap_buffers_region(_EGLDisplay *disp, _EGLSurface *surf,
EGLint numRects, const EGLint *rects)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
if (!dri2_dpy->vtbl->swap_buffers_region)
return EGL_FALSE;
- ret = dri2_dpy->vtbl->swap_buffers_region(drv, disp, surf, numRects, rects);
+ ret = dri2_dpy->vtbl->swap_buffers_region(disp, surf, numRects, rects);
/* SwapBuffers marks the end of the frame; reset the damage region for
* use again next time.
}
static EGLBoolean
-dri2_set_damage_region(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+dri2_set_damage_region(_EGLDisplay *disp, _EGLSurface *surf,
EGLint *rects, EGLint n_rects)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
__DRIdrawable *drawable = dri2_dpy->vtbl->get_dri_drawable(surf);
- if (!dri2_dpy->buffer_damage || !dri2_dpy->buffer_damage->set_damage_region)
+ if (!dri2_dpy->buffer_damage || !dri2_dpy->buffer_damage->set_damage_region) {
+ mtx_unlock(&dri2_dpy->lock);
return EGL_FALSE;
+ }
dri2_dpy->buffer_damage->set_damage_region(drawable, n_rects, rects);
+ mtx_unlock(&dri2_dpy->lock);
return EGL_TRUE;
}
static EGLBoolean
-dri2_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+dri2_post_sub_buffer(_EGLDisplay *disp, _EGLSurface *surf,
EGLint x, EGLint y, EGLint width, EGLint height)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->post_sub_buffer)
- return EGL_FALSE;
- return dri2_dpy->vtbl->post_sub_buffer(drv, disp, surf, x, y, width, height);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ EGLBoolean ret = EGL_FALSE;
+
+ if (dri2_dpy->vtbl->post_sub_buffer)
+ ret = dri2_dpy->vtbl->post_sub_buffer(disp, surf, x, y, width, height);
+
+ mtx_unlock(&dri2_dpy->lock);
+
+ return ret;
}
static EGLBoolean
-dri2_copy_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
- void *native_pixmap_target)
+dri2_copy_buffers(_EGLDisplay *disp, _EGLSurface *surf, void *native_pixmap_target)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
if (!dri2_dpy->vtbl->copy_buffers)
- return _eglError(EGL_BAD_NATIVE_PIXMAP, "no support for native pixmaps");
- return dri2_dpy->vtbl->copy_buffers(drv, disp, surf, native_pixmap_target);
+ return dri2_egl_error_unlock(dri2_dpy, EGL_BAD_NATIVE_PIXMAP, "no support for native pixmaps");
+ EGLBoolean ret = dri2_dpy->vtbl->copy_buffers(disp, surf, native_pixmap_target);
+ mtx_unlock(&dri2_dpy->lock);
+ return ret;
}
static EGLint
-dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
+dri2_query_buffer_age(_EGLDisplay *disp, _EGLSurface *surf)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
if (!dri2_dpy->vtbl->query_buffer_age)
return 0;
- return dri2_dpy->vtbl->query_buffer_age(drv, disp, surf);
+ return dri2_dpy->vtbl->query_buffer_age(disp, surf);
}
static EGLBoolean
-dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx)
+dri2_wait_client(_EGLDisplay *disp, _EGLContext *ctx)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
_EGLSurface *surf = ctx->DrawSurface;
__DRIdrawable *dri_drawable = dri2_dpy->vtbl->get_dri_drawable(surf);
- (void) drv;
-
/* FIXME: If EGL allows frontbuffer rendering for window surfaces,
* we need to copy fake to real here.*/
}
static EGLBoolean
-dri2_wait_native(_EGLDriver *drv, _EGLDisplay *disp, EGLint engine)
+dri2_wait_native(EGLint engine)
{
- (void) drv;
- (void) disp;
-
if (engine != EGL_CORE_NATIVE_ENGINE)
return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
/* glXWaitX(); */
}
static EGLBoolean
-dri2_bind_tex_image(_EGLDriver *drv,
- _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
+dri2_bind_tex_image(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_context *dri2_ctx;
_EGLContext *ctx;
GLint format, target;
ctx = _eglGetCurrentContext();
dri2_ctx = dri2_egl_context(ctx);
- if (!_eglBindTexImage(drv, disp, surf, buffer))
+ if (!_eglBindTexImage(disp, surf, buffer)) {
+ mtx_unlock(&dri2_dpy->lock);
return EGL_FALSE;
+ }
switch (surf->TextureFormat) {
case EGL_TEXTURE_RGB:
target, format,
dri_drawable);
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
}
static EGLBoolean
-dri2_release_tex_image(_EGLDriver *drv,
- _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
+dri2_release_tex_image(_EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_context *dri2_ctx;
_EGLContext *ctx;
GLint target;
ctx = _eglGetCurrentContext();
dri2_ctx = dri2_egl_context(ctx);
- if (!_eglReleaseTexImage(drv, disp, surf, buffer))
+ if (!_eglReleaseTexImage(disp, surf, buffer)) {
+ mtx_unlock(&dri2_dpy->lock);
return EGL_FALSE;
+ }
switch (surf->TextureTarget) {
case EGL_TEXTURE_2D:
target, dri_drawable);
}
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
}
static _EGLImage*
-dri2_create_image(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx,
- EGLenum target, EGLClientBuffer buffer,
- const EGLint *attr_list)
+dri2_create_image(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target,
+ EGLClientBuffer buffer, const EGLint *attr_list)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- return dri2_dpy->vtbl->create_image(drv, disp, ctx, target, buffer,
- attr_list);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ _EGLImage *ret = dri2_dpy->vtbl->create_image(disp, ctx, target, buffer,
+ attr_list);
+ mtx_unlock(&dri2_dpy->lock);
+ return ret;
}
-static _EGLImage *
+_EGLImage *
dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image)
{
struct dri2_egl_image *dri2_img;
EGLuint64KHR *sbc)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->get_sync_values)
+ EGLBoolean ret = EGL_FALSE;
+
+ if (dri2_dpy->vtbl->get_sync_values)
+ ret = dri2_dpy->vtbl->get_sync_values(disp, surf, ust, msc, sbc);
+
+ return ret;
+}
+
+static EGLBoolean
+dri2_get_msc_rate_angle(_EGLDisplay *disp, _EGLSurface *surf,
+ EGLint *numerator, EGLint *denominator)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ if (!dri2_dpy->vtbl->get_msc_rate)
return EGL_FALSE;
- return dri2_dpy->vtbl->get_sync_values(disp, surf, ust, msc, sbc);
+ return dri2_dpy->vtbl->get_msc_rate(disp, surf, numerator, denominator);
}
/**
depth,
attrs.GLTextureLevel,
&error,
- dri2_img);
+ NULL);
dri2_create_image_khr_texture_error(error);
if (!dri2_img->dri_image) {
}
static EGLBoolean
-dri2_query_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+dri2_query_surface(_EGLDisplay *disp, _EGLSurface *surf,
EGLint attribute, EGLint *value)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->query_surface)
- return _eglQuerySurface(drv, disp, surf, attribute, value);
- return dri2_dpy->vtbl->query_surface(drv, disp, surf, attribute, value);
+ EGLBoolean ret;
+
+ if (!dri2_dpy->vtbl->query_surface) {
+ ret = _eglQuerySurface(disp, surf, attribute, value);
+ } else {
+ ret = dri2_dpy->vtbl->query_surface(disp, surf, attribute, value);
+ }
+
+ return ret;
}
static struct wl_buffer*
-dri2_create_wayland_buffer_from_image(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLImage *img)
+dri2_create_wayland_buffer_from_image(_EGLDisplay *disp, _EGLImage *img)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (!dri2_dpy->vtbl->create_wayland_buffer_from_image)
- return NULL;
- return dri2_dpy->vtbl->create_wayland_buffer_from_image(drv, disp, img);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ struct wl_buffer *ret = NULL;
+
+ if (dri2_dpy->vtbl->create_wayland_buffer_from_image)
+ ret = dri2_dpy->vtbl->create_wayland_buffer_from_image(disp, img);
+
+ mtx_unlock(&dri2_dpy->lock);
+
+ return ret;
}
#ifdef HAVE_LIBDRM
case DRM_FORMAT_ABGR2101010:
case DRM_FORMAT_RGBA1010102:
case DRM_FORMAT_BGRA1010102:
+ case DRM_FORMAT_ABGR16161616:
+ case DRM_FORMAT_XBGR16161616:
case DRM_FORMAT_XBGR16161616F:
case DRM_FORMAT_ABGR16161616F:
case DRM_FORMAT_YUYV:
case DRM_FORMAT_VYUY:
case DRM_FORMAT_AYUV:
case DRM_FORMAT_XYUV8888:
+ case DRM_FORMAT_Y210:
+ case DRM_FORMAT_Y212:
+ case DRM_FORMAT_Y216:
+ case DRM_FORMAT_Y410:
+ case DRM_FORMAT_Y412:
+ case DRM_FORMAT_Y416:
return 1;
case DRM_FORMAT_NV12:
}
static EGLBoolean
-dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp,
- EGLint max, EGLint *formats, EGLint *count)
+dri2_query_dma_buf_formats(_EGLDisplay *disp, EGLint max,
+ EGLint *formats, EGLint *count)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- if (max < 0 || (max > 0 && formats == NULL))
- return _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ if (max < 0 || (max > 0 && formats == NULL)) {
+ _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
+ goto fail;
+ }
if (dri2_dpy->image->base.version < 15 ||
dri2_dpy->image->queryDmaBufFormats == NULL)
- return EGL_FALSE;
+ goto fail;
if (!dri2_dpy->image->queryDmaBufFormats(dri2_dpy->dri_screen, max,
formats, count))
- return EGL_FALSE;
+ goto fail;
if (max > 0) {
/* Assert that all of the formats returned are actually fourcc formats.
}
}
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
+
+fail:
+ mtx_unlock(&dri2_dpy->lock);
+ return EGL_FALSE;
}
static EGLBoolean
-dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint format,
+dri2_query_dma_buf_modifiers(_EGLDisplay *disp, EGLint format,
EGLint max, EGLuint64KHR *modifiers,
EGLBoolean *external_only, EGLint *count)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
if (dri2_num_fourcc_format_planes(format) == 0)
- return _eglError(EGL_BAD_PARAMETER, "invalid fourcc format");
+ return dri2_egl_error_unlock(dri2_dpy, EGL_BAD_PARAMETER, "invalid fourcc format");
if (max < 0)
- return _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");
+ return dri2_egl_error_unlock(dri2_dpy, EGL_BAD_PARAMETER, "invalid value for max count of formats");
if (max > 0 && modifiers == NULL)
- return _eglError(EGL_BAD_PARAMETER, "invalid modifiers array");
+ return dri2_egl_error_unlock(dri2_dpy, EGL_BAD_PARAMETER, "invalid modifiers array");
if (dri2_dpy->image->base.version < 15 ||
- dri2_dpy->image->queryDmaBufModifiers == NULL)
+ dri2_dpy->image->queryDmaBufModifiers == NULL) {
+ mtx_unlock(&dri2_dpy->lock);
return EGL_FALSE;
+ }
if (dri2_dpy->image->queryDmaBufModifiers(dri2_dpy->dri_screen, format,
max, modifiers,
(unsigned int *) external_only,
count) == false)
- return _eglError(EGL_BAD_PARAMETER, "invalid format");
+ return dri2_egl_error_unlock(dri2_dpy, EGL_BAD_PARAMETER, "invalid format");
+
+ mtx_unlock(&dri2_dpy->lock);
return EGL_TRUE;
}
uint64_t modifier;
bool has_modifier = false;
unsigned error;
+ EGLint egl_error;
/**
* The spec says:
has_modifier = true;
}
- if (has_modifier) {
+ if (attrs.ProtectedContent) {
+ if (dri2_dpy->image->base.version < 18 ||
+ dri2_dpy->image->createImageFromDmaBufs3 == NULL) {
+ _eglError(EGL_BAD_MATCH, "unsupported protected_content attribute");
+ return EGL_NO_IMAGE_KHR;
+ }
+ if (!has_modifier)
+ modifier = DRM_FORMAT_MOD_INVALID;
+
+ dri_image =
+ dri2_dpy->image->createImageFromDmaBufs3(dri2_dpy->dri_screen,
+ attrs.Width, attrs.Height, attrs.DMABufFourCC.Value,
+ modifier, fds, num_fds, pitches, offsets,
+ attrs.DMABufYuvColorSpaceHint.Value,
+ attrs.DMABufSampleRangeHint.Value,
+ attrs.DMABufChromaHorizontalSiting.Value,
+ attrs.DMABufChromaVerticalSiting.Value,
+ attrs.ProtectedContent ? __DRI_IMAGE_PROTECTED_CONTENT_FLAG : 0,
+ &error,
+ NULL);
+ }
+ else if (has_modifier) {
if (dri2_dpy->image->base.version < 15 ||
dri2_dpy->image->createImageFromDmaBufs2 == NULL) {
_eglError(EGL_BAD_MATCH, "unsupported dma_buf format modifier");
&error,
NULL);
}
- dri2_create_image_khr_texture_error(error);
+
+ egl_error = egl_error_from_dri_image_error(error);
+ if (egl_error != EGL_SUCCESS)
+ _eglError(egl_error, "createImageFromDmaBufs failed");
if (!dri_image)
return EGL_NO_IMAGE_KHR;
return res;
}
static _EGLImage *
-dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp,
- const EGLint *attr_list)
+dri2_create_drm_image_mesa(_EGLDisplay *disp, const EGLint *attr_list)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_image *dri2_img;
_EGLImageAttribs attrs;
unsigned int dri_use, valid_mask;
int format;
- (void) drv;
-
if (!attr_list) {
_eglError(EGL_BAD_PARAMETER, __func__);
- return EGL_NO_IMAGE_KHR;
+ goto fail;
}
if (!_eglParseImageAttribList(&attrs, disp, attr_list))
- return EGL_NO_IMAGE_KHR;
+ goto fail;
if (attrs.Width <= 0 || attrs.Height <= 0) {
_eglError(EGL_BAD_PARAMETER, __func__);
- return EGL_NO_IMAGE_KHR;
+ goto fail;
}
switch (attrs.DRMBufferFormatMESA) {
break;
default:
_eglError(EGL_BAD_PARAMETER, __func__);
- return EGL_NO_IMAGE_KHR;
+ goto fail;
}
valid_mask =
EGL_DRM_BUFFER_USE_CURSOR_MESA;
if (attrs.DRMBufferUseMESA & ~valid_mask) {
_eglError(EGL_BAD_PARAMETER, __func__);
- return EGL_NO_IMAGE_KHR;
+ goto fail;
}
dri_use = 0;
dri2_img = malloc(sizeof *dri2_img);
if (!dri2_img) {
_eglError(EGL_BAD_ALLOC, "dri2_create_image_khr");
- return EGL_NO_IMAGE_KHR;
+ goto fail;
}
_eglInitImage(&dri2_img->base, disp);
format, dri_use, dri2_img);
if (dri2_img->dri_image == NULL) {
free(dri2_img);
- _eglError(EGL_BAD_ALLOC, "dri2_create_drm_image_mesa");
- return EGL_NO_IMAGE_KHR;
+ _eglError(EGL_BAD_ALLOC, "dri2_create_drm_image_mesa");
+ goto fail;
}
+ mtx_unlock(&dri2_dpy->lock);
+
return &dri2_img->base;
+
+fail:
+ mtx_unlock(&dri2_dpy->lock);
+ return EGL_NO_IMAGE_KHR;
}
static EGLBoolean
-dri2_export_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img,
+dri2_export_drm_image_mesa(_EGLDisplay *disp, _EGLImage *img,
EGLint *name, EGLint *handle, EGLint *stride)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(img);
- (void) drv;
-
if (name && !dri2_dpy->image->queryImage(dri2_img->dri_image,
__DRI_IMAGE_ATTRIB_NAME, name))
return _eglError(EGL_BAD_ALLOC, "dri2_export_drm_image_mesa");
dri2_dpy->image->queryImage(dri2_img->dri_image,
__DRI_IMAGE_ATTRIB_STRIDE, stride);
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
}
}
static EGLBoolean
-dri2_export_dma_buf_image_query_mesa(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLImage *img,
+dri2_export_dma_buf_image_query_mesa(_EGLDisplay *disp, _EGLImage *img,
EGLint *fourcc, EGLint *nplanes,
EGLuint64KHR *modifiers)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(img);
int num_planes;
- (void) drv;
-
- if (!dri2_can_export_dma_buf_image(disp, img))
+ if (!dri2_can_export_dma_buf_image(disp, img)) {
+ mtx_unlock(&dri2_dpy->lock);
return EGL_FALSE;
+ }
dri2_dpy->image->queryImage(dri2_img->dri_image,
__DRI_IMAGE_ATTRIB_NUM_PLANES, &num_planes);
modifiers[i] = modifier;
}
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
}
static EGLBoolean
-dri2_export_dma_buf_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *img,
+dri2_export_dma_buf_image_mesa(_EGLDisplay *disp, _EGLImage *img,
int *fds, EGLint *strides, EGLint *offsets)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(img);
EGLint nplanes;
- (void) drv;
-
if (!dri2_can_export_dma_buf_image(disp, img))
return EGL_FALSE;
offsets[0] = 0;
}
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
}
#endif
_EGLImage *
-dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp,
- _EGLContext *ctx, EGLenum target,
+dri2_create_image_khr(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target,
EGLClientBuffer buffer, const EGLint *attr_list)
{
- (void) drv;
-
switch (target) {
case EGL_GL_TEXTURE_2D_KHR:
case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR:
}
static EGLBoolean
-dri2_destroy_image_khr(_EGLDriver *drv, _EGLDisplay *disp, _EGLImage *image)
+dri2_destroy_image_khr(_EGLDisplay *disp, _EGLImage *image)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_image *dri2_img = dri2_egl_image(image);
- (void) drv;
-
dri2_dpy->image->destroyImage(dri2_img->dri_image);
free(dri2_img);
+ mtx_unlock(&dri2_dpy->lock);
+
return EGL_TRUE;
}
}
static EGLBoolean
-dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
- struct wl_display *wl_dpy)
+dri2_bind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
const struct wayland_drm_callbacks wl_drm_callbacks = {
.authenticate = (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate,
.reference_buffer = dri2_wl_reference_buffer,
.is_format_supported = dri2_wl_is_format_supported
};
int flags = 0;
+ char *device_name;
uint64_t cap;
- (void) drv;
-
if (dri2_dpy->wl_server_drm)
- return EGL_FALSE;
+ goto fail;
+
+ device_name = drmGetRenderDeviceNameFromFd(dri2_dpy->fd);
+ if (!device_name)
+ device_name = strdup(dri2_dpy->device_name);
+ if (!device_name)
+ goto fail;
if (drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap) == 0 &&
cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
flags |= WAYLAND_DRM_PRIME;
dri2_dpy->wl_server_drm =
- wayland_drm_init(wl_dpy, dri2_dpy->device_name,
+ wayland_drm_init(wl_dpy, device_name,
&wl_drm_callbacks, disp, flags);
+ free(device_name);
+
if (!dri2_dpy->wl_server_drm)
- return EGL_FALSE;
+ goto fail;
#ifdef HAVE_DRM_PLATFORM
/* We have to share the wl_drm instance with gbm, so gbm can convert
dri2_dpy->gbm_dri->wl_drm = dri2_dpy->wl_server_drm;
#endif
+ mtx_unlock(&dri2_dpy->lock);
return EGL_TRUE;
+
+fail:
+ mtx_unlock(&dri2_dpy->lock);
+ return EGL_FALSE;
}
static EGLBoolean
-dri2_unbind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
- struct wl_display *wl_dpy)
+dri2_unbind_wayland_display_wl(_EGLDisplay *disp, struct wl_display *wl_dpy)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- (void) drv;
-
if (!dri2_dpy->wl_server_drm)
return EGL_FALSE;
}
static EGLBoolean
-dri2_query_wayland_buffer_wl(_EGLDriver *drv, _EGLDisplay *disp,
- struct wl_resource *buffer_resource,
+dri2_query_wayland_buffer_wl(_EGLDisplay *disp, struct wl_resource *buffer_resource,
EGLint attribute, EGLint *value)
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
}
#endif
+#ifdef HAVE_TIZEN_PLATFORM
+static EGLBoolean
+tizen_bind_wayland_display_wl(_EGLDisplay *disp,
+ struct wl_display *wl_dpy)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
+ (void) wl_dpy;
+
+ if (!dri2_dpy->tpl_display)
+ return EGL_FALSE;
+
+ if (!tpl_display_get_native_handle(dri2_dpy->tpl_display))
+ return EGL_FALSE;
+
+ return EGL_TRUE;
+}
+
+static EGLBoolean
+tizen_unbind_wayland_display_wl(_EGLDisplay *disp,
+ struct wl_display *wl_dpy)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+
+ (void) wl_dpy;
+
+ if (!dri2_dpy->tpl_display)
+ return EGL_FALSE;
+
+ if (!tpl_display_get_native_handle(dri2_dpy->tpl_display))
+ return EGL_FALSE;
+
+ return EGL_TRUE;
+}
+
+static EGLBoolean
+tizen_query_wayland_buffer_wl(_EGLDisplay *disp,
+ struct wl_resource *buffer_resource,
+ EGLint attribute, EGLint *value)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ tbm_format tbm_format = 0;
+ int width = 0, height = 0;
+ tpl_result_t res;
+
+ if (!dri2_dpy->tpl_display)
+ return EGL_FALSE;
+
+ if (!tpl_display_get_native_handle(dri2_dpy->tpl_display))
+ return EGL_FALSE;
+
+ res = tpl_display_get_native_pixmap_info(dri2_dpy->tpl_display,
+ (tpl_handle_t)buffer_resource,
+ &width, &height, &tbm_format);
+ if (res != TPL_ERROR_NONE)
+ return EGL_FALSE;
+
+ switch (attribute) {
+ case EGL_TEXTURE_FORMAT:
+ switch (tbm_format) {
+ case TBM_FORMAT_ARGB8888:
+ *value = EGL_TEXTURE_RGBA;
+ return EGL_TRUE;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+ case TBM_FORMAT_XRGB8888:
+ case TBM_FORMAT_RGB565:
+#pragma GCC diagnostic pop
+ *value = EGL_TEXTURE_RGB;
+ return EGL_TRUE;
+ default:
+ break;
+ }
+ break;
+ case EGL_WIDTH:
+ *value = width;
+ return EGL_TRUE;
+ case EGL_HEIGHT:
+ *value = height;
+ return EGL_TRUE;
+ default:
+ break;
+ }
+
+ return EGL_FALSE;
+}
+#endif
+
static void
dri2_egl_ref_sync(struct dri2_egl_sync *sync)
{
case EGL_SYNC_REUSABLE_KHR:
cnd_destroy(&dri2_sync->cond);
break;
+#ifdef HAVE_TIZEN_PLATFORM
+ case EGL_SYNC_NATIVE_FENCE_TIZEN:
+ if (dri2_sync->base.SyncFd != EGL_NO_NATIVE_FENCE_FD_TIZEN)
+ close(dri2_sync->base.SyncFd);
+ break;
+#else
case EGL_SYNC_NATIVE_FENCE_ANDROID:
if (dri2_sync->base.SyncFd != EGL_NO_NATIVE_FENCE_FD_ANDROID)
close(dri2_sync->base.SyncFd);
break;
+#endif
default:
break;
}
}
static _EGLSync *
-dri2_create_sync(_EGLDriver *drv, _EGLDisplay *disp,
- EGLenum type, const EGLAttrib *attrib_list)
+dri2_create_sync(_EGLDisplay *disp, EGLenum type, const EGLAttrib *attrib_list)
{
_EGLContext *ctx = _eglGetCurrentContext();
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
struct dri2_egl_sync *dri2_sync;
EGLint ret;
dri2_sync = calloc(1, sizeof(struct dri2_egl_sync));
if (!dri2_sync) {
_eglError(EGL_BAD_ALLOC, "eglCreateSyncKHR");
- return NULL;
+ goto fail;
}
if (!_eglInitSync(&dri2_sync->base, disp, type, attrib_list)) {
- free(dri2_sync);
- return NULL;
+ goto fail;
}
switch (type) {
* a generic EGL error that doesn't communicate user error.
*/
_eglError(EGL_BAD_ALLOC, "eglCreateSyncKHR");
- free(dri2_sync);
- return NULL;
+ goto fail;
}
break;
/* this can only happen if the cl_event passed in is invalid. */
if (!dri2_sync->fence) {
_eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR");
- free(dri2_sync);
- return NULL;
+ goto fail;
}
/* the initial status must be "signaled" if the cl_event is signaled */
if (ret) {
_eglError(EGL_BAD_ACCESS, "eglCreateSyncKHR");
- free(dri2_sync);
- return NULL;
+ goto fail;
}
/* change clock attribute to CLOCK_MONOTONIC */
if (ret) {
_eglError(EGL_BAD_ACCESS, "eglCreateSyncKHR");
- free(dri2_sync);
- return NULL;
+ goto fail;
}
ret = pthread_cond_init(&dri2_sync->cond, &attr);
if (ret) {
_eglError(EGL_BAD_ACCESS, "eglCreateSyncKHR");
- free(dri2_sync);
- return NULL;
+ goto fail;
}
/* initial status of reusable sync must be "unsignaled" */
dri2_sync->base.SyncStatus = EGL_UNSIGNALED_KHR;
break;
+#ifdef HAVE_TIZEN_PLATFORM
+ case EGL_SYNC_NATIVE_FENCE_TIZEN:
+ if (dri2_dpy->fence->create_fence_fd) {
+ dri2_sync->fence = dri2_dpy->fence->create_fence_fd(
+ dri2_ctx->dri_context,
+ dri2_sync->base.SyncFd);
+ }
+ if (!dri2_sync->fence) {
+ _eglError(EGL_BAD_ATTRIBUTE, "eglCreateSyncKHR");
+ goto fail;
+ }
+ break;
+ }
+#else
case EGL_SYNC_NATIVE_FENCE_ANDROID:
if (dri2_dpy->fence->create_fence_fd) {
dri2_sync->fence = dri2_dpy->fence->create_fence_fd(
return NULL;
}
break;
- }
+#endif
p_atomic_set(&dri2_sync->refcount, 1);
+ mtx_unlock(&dri2_dpy->lock);
+
return &dri2_sync->base;
+
+fail:
+ free(dri2_sync);
+ mtx_unlock(&dri2_dpy->lock);
+ return NULL;
}
static EGLBoolean
-dri2_destroy_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync)
+dri2_destroy_sync(_EGLDisplay *disp, _EGLSync *sync)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
EGLint ret = EGL_TRUE;
EGLint err;
dri2_egl_unref_sync(dri2_dpy, dri2_sync);
+ mtx_unlock(&dri2_dpy->lock);
+
return ret;
}
static EGLint
-dri2_dup_native_fence_fd(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync)
+dri2_dup_native_fence_fd(_EGLDisplay *disp, _EGLSync *sync)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
assert(sync->Type == EGL_SYNC_NATIVE_FENCE_ANDROID);
dri2_sync->fence);
}
+ mtx_unlock(&dri2_dpy->lock);
+
if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
/* if native fence fd still not created, return an error: */
_eglError(EGL_BAD_PARAMETER, "eglDupNativeFenceFDANDROID");
return EGL_NO_NATIVE_FENCE_FD_ANDROID;
}
+ assert(sync_valid_fd(sync->SyncFd));
+
return os_dupfd_cloexec(sync->SyncFd);
}
+static EGLint
+dri2_dup_native_fence_fd_tizen(_EGLDisplay *dpy, _EGLSync *sync)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
+ struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
+
+ assert(sync->Type == EGL_SYNC_NATIVE_FENCE_TIZEN);
+
+ if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_TIZEN) {
+ /* try to retrieve the actual native fence fd.. if rendering is
+ * not flushed this will just return -1, aka NO_NATIVE_FENCE_FD:
+ */
+ sync->SyncFd = dri2_dpy->fence->get_fence_fd(dri2_dpy->dri_screen,
+ dri2_sync->fence);
+ }
+
+ if (sync->SyncFd == EGL_NO_NATIVE_FENCE_FD_TIZEN) {
+ /* if native fence fd still not created, return an error: */
+ _eglError(EGL_BAD_PARAMETER, "eglDupNativeFenceFDTIZEN");
+ return EGL_NO_NATIVE_FENCE_FD_TIZEN;
+ }
+
+ return dup(sync->SyncFd);
+}
+
static void
-dri2_set_blob_cache_funcs(_EGLDriver *drv, _EGLDisplay *disp,
+dri2_set_blob_cache_funcs(_EGLDisplay *disp,
EGLSetBlobFuncANDROID set,
EGLGetBlobFuncANDROID get)
{
- struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- dri2_dpy->blob->set_cache_funcs(dri2_dpy->dri_screen,
- disp->BlobCacheSet,
- disp->BlobCacheGet);
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display_lock(disp);
+ dri2_dpy->blob->set_cache_funcs(dri2_dpy->dri_screen, set, get);
+ mtx_unlock(&dri2_dpy->lock);
}
static EGLint
-dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync,
+dri2_client_wait_sync(_EGLDisplay *disp, _EGLSync *sync,
EGLint flags, EGLTime timeout)
{
_EGLContext *ctx = _eglGetCurrentContext();
switch (sync->Type) {
case EGL_SYNC_FENCE_KHR:
+#ifdef HAVE_TIZEN_PLATFORM
+ case EGL_SYNC_NATIVE_FENCE_TIZEN:
+#else
case EGL_SYNC_NATIVE_FENCE_ANDROID:
+#endif
case EGL_SYNC_CL_EVENT_KHR:
if (dri2_dpy->fence->client_wait_sync(dri2_ctx ? dri2_ctx->dri_context : NULL,
dri2_sync->fence, wait_flags,
ret = cnd_timedwait(&dri2_sync->cond, &dri2_sync->mutex, &expire);
mtx_unlock(&dri2_sync->mutex);
- if (ret == thrd_busy) {
+ if (ret == thrd_timedout) {
if (dri2_sync->base.SyncStatus == EGL_UNSIGNALED_KHR) {
ret = EGL_TIMEOUT_EXPIRED_KHR;
} else {
}
}
break;
- }
- dri2_egl_unref_sync(dri2_dpy, dri2_sync);
+ }
+
+ dri2_egl_unref_sync(dri2_dpy, dri2_sync);
- return ret;
+ return ret;
}
static EGLBoolean
-dri2_signal_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync,
- EGLenum mode)
+dri2_signal_sync(_EGLDisplay *disp, _EGLSync *sync, EGLenum mode)
{
struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
EGLint ret;
}
static EGLint
-dri2_server_wait_sync(_EGLDriver *drv, _EGLDisplay *disp, _EGLSync *sync)
+dri2_server_wait_sync(_EGLDisplay *disp, _EGLSync *sync)
{
_EGLContext *ctx = _eglGetCurrentContext();
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out);
}
-/**
- * This is the main entrypoint into the driver, called by libEGL.
- * Gets an _EGLDriver object and init its dispatch table.
- */
-void
-_eglInitDriver(_EGLDriver *dri2_drv)
-{
- dri2_drv->Initialize = dri2_initialize;
- dri2_drv->Terminate = dri2_terminate;
- dri2_drv->CreateContext = dri2_create_context;
- dri2_drv->DestroyContext = dri2_destroy_context;
- dri2_drv->MakeCurrent = dri2_make_current;
- dri2_drv->CreateWindowSurface = dri2_create_window_surface;
- dri2_drv->CreatePixmapSurface = dri2_create_pixmap_surface;
- dri2_drv->CreatePbufferSurface = dri2_create_pbuffer_surface;
- dri2_drv->DestroySurface = dri2_destroy_surface;
- dri2_drv->GetProcAddress = dri2_get_proc_address;
- dri2_drv->WaitClient = dri2_wait_client;
- dri2_drv->WaitNative = dri2_wait_native;
- dri2_drv->BindTexImage = dri2_bind_tex_image;
- dri2_drv->ReleaseTexImage = dri2_release_tex_image;
- dri2_drv->SwapInterval = dri2_swap_interval;
- dri2_drv->SwapBuffers = dri2_swap_buffers;
- dri2_drv->SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage;
- dri2_drv->SwapBuffersRegionNOK = dri2_swap_buffers_region;
- dri2_drv->SetDamageRegion = dri2_set_damage_region;
- dri2_drv->PostSubBufferNV = dri2_post_sub_buffer;
- dri2_drv->CopyBuffers = dri2_copy_buffers,
- dri2_drv->QueryBufferAge = dri2_query_buffer_age;
- dri2_drv->CreateImageKHR = dri2_create_image;
- dri2_drv->DestroyImageKHR = dri2_destroy_image_khr;
- dri2_drv->CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
- dri2_drv->QuerySurface = dri2_query_surface;
- dri2_drv->QueryDriverName = dri2_query_driver_name;
- dri2_drv->QueryDriverConfig = dri2_query_driver_config;
+static int
+dri2_interop_flush_objects(_EGLDisplay *disp, _EGLContext *ctx,
+ unsigned count, struct mesa_glinterop_export_in *objects,
+ GLsync *sync)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
+
+ if (!dri2_dpy->interop || dri2_dpy->interop->base.version < 2)
+ return MESA_GLINTEROP_UNSUPPORTED;
+
+ return dri2_dpy->interop->flush_objects(dri2_ctx->dri_context, count, objects, sync);
+}
+
+const _EGLDriver _eglDriver = {
+ .Initialize = dri2_initialize,
+ .Terminate = dri2_terminate,
+ .CreateContext = dri2_create_context,
+ .DestroyContext = dri2_destroy_context,
+ .MakeCurrent = dri2_make_current,
+ .CreateWindowSurface = dri2_create_window_surface,
+ .CreatePixmapSurface = dri2_create_pixmap_surface,
+ .CreatePbufferSurface = dri2_create_pbuffer_surface,
+ .DestroySurface = dri2_destroy_surface,
+ .GetProcAddress = dri2_get_proc_address,
+ .WaitClient = dri2_wait_client,
+ .WaitNative = dri2_wait_native,
+ .BindTexImage = dri2_bind_tex_image,
+ .ReleaseTexImage = dri2_release_tex_image,
+ .SwapInterval = dri2_swap_interval,
+ .SwapBuffers = dri2_swap_buffers,
+ .SwapBuffersWithDamageEXT = dri2_swap_buffers_with_damage,
+ .SwapBuffersRegionNOK = dri2_swap_buffers_region,
+ .SetDamageRegion = dri2_set_damage_region,
+ .PostSubBufferNV = dri2_post_sub_buffer,
+ .CopyBuffers = dri2_copy_buffers,
+ .QueryBufferAge = dri2_query_buffer_age,
+ .CreateImageKHR = dri2_create_image,
+ .DestroyImageKHR = dri2_destroy_image_khr,
+ .CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image,
+ .QuerySurface = dri2_query_surface,
+ .QueryDriverName = dri2_query_driver_name,
+ .QueryDriverConfig = dri2_query_driver_config,
#ifdef HAVE_LIBDRM
- dri2_drv->CreateDRMImageMESA = dri2_create_drm_image_mesa;
- dri2_drv->ExportDRMImageMESA = dri2_export_drm_image_mesa;
- dri2_drv->ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa;
- dri2_drv->ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa;
- dri2_drv->QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats;
- dri2_drv->QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers;
+ .CreateDRMImageMESA = dri2_create_drm_image_mesa,
+ .ExportDRMImageMESA = dri2_export_drm_image_mesa,
+ .ExportDMABUFImageQueryMESA = dri2_export_dma_buf_image_query_mesa,
+ .ExportDMABUFImageMESA = dri2_export_dma_buf_image_mesa,
+ .QueryDmaBufFormatsEXT = dri2_query_dma_buf_formats,
+ .QueryDmaBufModifiersEXT = dri2_query_dma_buf_modifiers,
#endif
#ifdef HAVE_WAYLAND_PLATFORM
- dri2_drv->BindWaylandDisplayWL = dri2_bind_wayland_display_wl;
- dri2_drv->UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl;
- dri2_drv->QueryWaylandBufferWL = dri2_query_wayland_buffer_wl;
+ .BindWaylandDisplayWL = dri2_bind_wayland_display_wl,
+ .UnbindWaylandDisplayWL = dri2_unbind_wayland_display_wl,
+ .QueryWaylandBufferWL = dri2_query_wayland_buffer_wl,
#endif
- dri2_drv->GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium;
- dri2_drv->CreateSyncKHR = dri2_create_sync;
- dri2_drv->ClientWaitSyncKHR = dri2_client_wait_sync;
- dri2_drv->SignalSyncKHR = dri2_signal_sync;
- dri2_drv->WaitSyncKHR = dri2_server_wait_sync;
- dri2_drv->DestroySyncKHR = dri2_destroy_sync;
- dri2_drv->GLInteropQueryDeviceInfo = dri2_interop_query_device_info;
- dri2_drv->GLInteropExportObject = dri2_interop_export_object;
- dri2_drv->DupNativeFenceFDANDROID = dri2_dup_native_fence_fd;
- dri2_drv->SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs;
-}
+#ifdef HAVE_TIZEN_PLATFORM
+ .BindWaylandDisplayWL = tizen_bind_wayland_display_wl,
+ .UnbindWaylandDisplayWL = tizen_unbind_wayland_display_wl,
+ .QueryWaylandBufferWL = tizen_query_wayland_buffer_wl,
+ #endif
+ .GetSyncValuesCHROMIUM = dri2_get_sync_values_chromium,
+ .GetMscRateANGLE = dri2_get_msc_rate_angle,
+ .CreateSyncKHR = dri2_create_sync,
+ .ClientWaitSyncKHR = dri2_client_wait_sync,
+ .SignalSyncKHR = dri2_signal_sync,
+ .WaitSyncKHR = dri2_server_wait_sync,
+ .DestroySyncKHR = dri2_destroy_sync,
+ .GLInteropQueryDeviceInfo = dri2_interop_query_device_info,
+ .GLInteropExportObject = dri2_interop_export_object,
+ .GLInteropFlushObjects = dri2_interop_flush_objects,
+ .DupNativeFenceFDANDROID = dri2_dup_native_fence_fd,
+ .DupNativeFenceFDTIZEN = dri2_dup_native_fence_fd_tizen,
+ .SetBlobCacheFuncsANDROID = dri2_set_blob_cache_funcs,
+};