[Mesa-dev] [PATCH 5/7] EGL: Record the debug object label in _EGLThreadInfo

Adam Jackson ajax at redhat.com
Thu Sep 8 17:47:00 UTC 2016


From: Kyle Brenneman <kbrenneman at nvidia.com>

Added a field to _EGLThreadInfo to hold the object label for the current
EGL function call.

Changed the _EGL_FUNC_START macro and _eglSetFuncName function to take
an object type enum and an _EGLResource pointer, which it uses to fill
in the object label.

Removed the command name and object label parameters from
_eglDebugReport, and made it look them up from the current
_EGLThreadInfo.

Added a separate _eglDebugReportFull function to allow the caller to
specify the command and label.

Reviewed-by: Adam Jackson <ajax at redhat.com>
---
 src/egl/main/eglapi.c     | 183 ++++++++++++++++++++++++++--------------------
 src/egl/main/eglcurrent.c |  47 ++++++++----
 src/egl/main/eglcurrent.h |  23 +++---
 3 files changed, 149 insertions(+), 104 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 087077d..a684b43 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -250,9 +250,9 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
    mtx_unlock(&dpy->Mutex);
 }
 
-#define _EGL_FUNC_START(disp, ret) \
+#define _EGL_FUNC_START(disp, objectType, object, ret) \
    do { \
-      if (!_eglSetFuncName(__func__)) { \
+      if (!_eglSetFuncName(__func__, disp, objectType, (_EGLResource *) object)) { \
          if (disp)                                 \
             _eglUnlockDisplay(disp);               \
          return ret; \
@@ -260,14 +260,32 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
    } while(0)
 
 static EGLBoolean
-_eglSetFuncName(const char *funcName)
+_eglSetFuncName(const char *funcName, _EGLDisplay *disp, EGLenum objectType, _EGLResource *object)
 {
    _EGLThreadInfo *thr = _eglGetCurrentThread();
    if (!_eglIsCurrentThreadDummy()) {
       thr->CurrentFuncName = funcName;
+      thr->CurrentObjectLabel = NULL;
+
+      if (objectType == EGL_OBJECT_THREAD_KHR) {
+         thr->CurrentObjectLabel = thr->Label;
+      } else if (objectType == EGL_OBJECT_DISPLAY_KHR) {
+         if (disp != NULL) {
+            thr->CurrentObjectLabel = disp->Label;
+         }
+      } else {
+         /*
+          * Everything else will either be NULL or a valid _EGLResource
+          * pointer.
+          */
+         if (object != NULL) {
+            thr->CurrentObjectLabel = object->Label;
+         }
+      }
+
       return EGL_TRUE;
    } else {
-      _eglDebugReport(EGL_BAD_ALLOC, funcName, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, NULL, NULL);
+      _eglDebugReportFull(EGL_BAD_ALLOC, funcName, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, NULL, NULL);
       return EGL_FALSE;
    }
 }
@@ -308,7 +326,7 @@ eglGetDisplay(EGLNativeDisplayType nativeDisplay)
    _EGLDisplay *dpy;
    void *native_display_ptr;
 
-   _EGL_FUNC_START(NULL, EGL_NO_DISPLAY);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_DISPLAY);
 
    STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay));
    native_display_ptr = (void*) nativeDisplay;
@@ -324,7 +342,7 @@ eglGetPlatformDisplayEXT(EGLenum platform, void *native_display,
 {
    _EGLDisplay *dpy;
 
-   _EGL_FUNC_START(NULL, EGL_NO_DISPLAY);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_DISPLAY);
 
    switch (platform) {
 #ifdef HAVE_X11_PLATFORM
@@ -358,7 +376,7 @@ eglGetPlatformDisplay(EGLenum platform, void *native_display,
    EGLDisplay display;
    EGLint *int_attribs;
 
-   _EGL_FUNC_START(NULL, EGL_NO_DISPLAY);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_DISPLAY);
 
    int_attribs = _eglConvertAttribsToInt(attrib_list);
    if (attrib_list && !int_attribs)
@@ -501,7 +519,7 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
 {
    _EGLDisplay *disp = _eglLockDisplay(dpy);
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    if (!disp)
       RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
@@ -553,7 +571,7 @@ eglTerminate(EGLDisplay dpy)
 {
    _EGLDisplay *disp = _eglLockDisplay(dpy);
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    if (!disp)
       RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
@@ -577,13 +595,13 @@ eglQueryString(EGLDisplay dpy, EGLint name)
    _EGLDisplay *disp;
    _EGLDriver *drv;
 
-   _EGL_FUNC_START(NULL, NULL);
-
    if (dpy == EGL_NO_DISPLAY && name == EGL_EXTENSIONS) {
       RETURN_EGL_SUCCESS(NULL, _eglGlobal.ClientExtensionString);
    }
 
    disp = _eglLockDisplay(dpy);
+
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, NULL);
    _EGL_CHECK_DISPLAY(disp, NULL, drv);
 
    switch (name) {
@@ -609,7 +627,7 @@ eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    ret = drv->API.GetConfigs(drv, disp, configs, config_size, num_config);
@@ -626,7 +644,7 @@ eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    ret = drv->API.ChooseConfig(drv, disp, attrib_list, configs,
@@ -645,7 +663,7 @@ eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_CONFIG(disp, conf, EGL_FALSE, drv);
    ret = drv->API.GetConfigAttrib(drv, disp, conf, attribute, value);
@@ -665,7 +683,7 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_list,
    _EGLContext *context;
    EGLContext ret;
 
-   _EGL_FUNC_START(disp, EGL_NO_CONTEXT);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_CONTEXT);
 
    _EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv);
 
@@ -690,7 +708,7 @@ eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, context, EGL_FALSE);
 
    _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv);
    _eglUnlinkContext(context);
@@ -711,7 +729,7 @@ eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, context, EGL_FALSE);
 
    if (!disp)
       RETURN_EGL_ERROR(disp, EGL_BAD_DISPLAY, EGL_FALSE);
@@ -759,7 +777,7 @@ eglQueryContext(EGLDisplay dpy, EGLContext ctx,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, context, EGL_FALSE);
 
    _EGL_CHECK_CONTEXT(disp, context, EGL_FALSE, drv);
    ret = drv->API.QueryContext(drv, disp, context, attribute, value);
@@ -795,7 +813,7 @@ eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config,
                        EGLNativeWindowType window, const EGLint *attrib_list)
 {
    _EGLDisplay *disp = _eglLockDisplay(dpy);
-   _EGL_FUNC_START(disp, EGL_NO_SURFACE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
    STATIC_ASSERT(sizeof(void*) == sizeof(window));
    return _eglCreateWindowSurfaceCommon(disp, config, (void*) window,
                                         attrib_list);
@@ -808,7 +826,7 @@ eglCreatePlatformWindowSurfaceEXT(EGLDisplay dpy, EGLConfig config,
                                   const EGLint *attrib_list)
 {
    _EGLDisplay *disp = _eglLockDisplay(dpy);
-   _EGL_FUNC_START(disp, EGL_NO_SURFACE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
 
 #ifdef HAVE_X11_PLATFORM
    if (disp->Platform == _EGL_PLATFORM_X11 && native_window != NULL) {
@@ -836,7 +854,7 @@ eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config,
    EGLSurface surface;
    EGLint *int_attribs;
 
-   _EGL_FUNC_START(NULL, EGL_NO_SURFACE);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_SURFACE);
 
    int_attribs = _eglConvertAttribsToInt(attrib_list);
    if (attrib_list && !int_attribs)
@@ -872,7 +890,7 @@ eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config,
                        EGLNativePixmapType pixmap, const EGLint *attrib_list)
 {
    _EGLDisplay *disp = _eglLockDisplay(dpy);
-   _EGL_FUNC_START(disp, EGL_NO_SURFACE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
    STATIC_ASSERT(sizeof(void*) == sizeof(pixmap));
    return _eglCreatePixmapSurfaceCommon(disp, config, (void*) pixmap,
                                          attrib_list);
@@ -884,7 +902,7 @@ eglCreatePlatformPixmapSurfaceEXT(EGLDisplay dpy, EGLConfig config,
                                    const EGLint *attrib_list)
 {
    _EGLDisplay *disp = _eglLockDisplay(dpy);
-   _EGL_FUNC_START(disp, EGL_NO_SURFACE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
 
 #ifdef HAVE_X11_PLATFORM
       /* The `native_pixmap` parameter for the X11 platform differs between
@@ -912,7 +930,7 @@ eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config,
    EGLSurface surface;
    EGLint *int_attribs;
 
-   _EGL_FUNC_START(NULL, EGL_NO_SURFACE);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_SURFACE);
 
    int_attribs = _eglConvertAttribsToInt(attrib_list);
    if (attrib_list && !int_attribs)
@@ -935,7 +953,7 @@ eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config,
    _EGLSurface *surf;
    EGLSurface ret;
 
-   _EGL_FUNC_START(disp, EGL_NO_SURFACE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
    _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
 
    surf = drv->API.CreatePbufferSurface(drv, disp, conf, attrib_list);
@@ -953,7 +971,7 @@ eglDestroySurface(EGLDisplay dpy, EGLSurface surface)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
    _eglUnlinkSurface(surf);
    ret = drv->API.DestroySurface(drv, disp, surf);
@@ -970,7 +988,7 @@ eglQuerySurface(EGLDisplay dpy, EGLSurface surface,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
    ret = drv->API.QuerySurface(drv, disp, surf, attribute, value);
 
@@ -986,7 +1004,7 @@ eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
    ret = drv->API.SurfaceAttrib(drv, disp, surf, attribute, value);
 
@@ -1002,7 +1020,7 @@ eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
    ret = drv->API.BindTexImage(drv, disp, surf, buffer);
 
@@ -1018,7 +1036,7 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
    ret = drv->API.ReleaseTexImage(drv, disp, surf, buffer);
 
@@ -1035,7 +1053,7 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_NONE, NULL, EGL_FALSE);
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
 
    if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
@@ -1061,7 +1079,7 @@ eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
 
    /* surface must be bound to current context in EGL 1.4 */
@@ -1087,7 +1105,7 @@ eglSwapBuffersWithDamageEXT(EGLDisplay dpy, EGLSurface surface,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
 
    /* surface must be bound to current context in EGL 1.4 */
@@ -1112,7 +1130,7 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target)
    EGLBoolean ret;
    void *native_pixmap_ptr;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
    STATIC_ASSERT(sizeof(void*) == sizeof(target));
    native_pixmap_ptr = (void*) target;
 
@@ -1136,11 +1154,11 @@ eglWaitClient(void)
    if (!ctx)
       RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
 
-   _EGL_FUNC_START(NULL, EGL_FALSE);
-
    disp = ctx->Resource.Display;
    mtx_lock(&disp->Mutex);
 
+   _EGL_FUNC_START(disp, EGL_OBJECT_CONTEXT_KHR, ctx, EGL_FALSE);
+
    /* let bad current context imply bad current surface */
    if (_eglGetContextHandle(ctx) == EGL_NO_CONTEXT ||
        _eglGetSurfaceHandle(ctx->DrawSurface) == EGL_NO_SURFACE)
@@ -1174,7 +1192,7 @@ eglWaitNative(EGLint engine)
    if (!ctx)
       RETURN_EGL_SUCCESS(NULL, EGL_TRUE);
 
-   _EGL_FUNC_START(NULL, EGL_FALSE);
+   _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL, EGL_FALSE);
 
    disp = ctx->Resource.Display;
    mtx_lock(&disp->Mutex);
@@ -1225,7 +1243,7 @@ eglGetCurrentSurface(EGLint readdraw)
    _EGLSurface *surf;
    EGLSurface ret;
 
-   _EGL_FUNC_START(NULL, EGL_NO_SURFACE);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_SURFACE);
 
    if (!ctx)
       RETURN_EGL_SUCCESS(NULL, EGL_NO_SURFACE);
@@ -1278,10 +1296,11 @@ eglGetError(void)
 EGLBoolean EGLAPIENTRY
 eglBindAPI(EGLenum api)
 {
-   _EGLThreadInfo *t = _eglGetCurrentThread();
+   _EGLThreadInfo *t;
 
-   _EGL_FUNC_START(NULL, EGL_FALSE);
+   _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL, EGL_FALSE);
 
+   t = _eglGetCurrentThread();
    if (_eglIsCurrentThreadDummy())
       RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
 
@@ -1321,7 +1340,7 @@ eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
    _EGLSurface *surf;
    EGLSurface ret;
 
-   _EGL_FUNC_START(disp, EGL_NO_SURFACE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_SURFACE);
 
    _EGL_CHECK_CONFIG(disp, conf, EGL_NO_SURFACE, drv);
 
@@ -1341,7 +1360,7 @@ eglReleaseThread(void)
       _EGLThreadInfo *t = _eglGetCurrentThread();
       _EGLContext *ctx = t->CurrentContext;
 
-      _eglSetFuncName(__func__);
+      _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL, EGL_FALSE);
 
       if (ctx) {
          _EGLDisplay *disp = ctx->Resource.Display;
@@ -1370,7 +1389,7 @@ eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
    _EGLImage *img;
    EGLImage ret;
 
-   _EGL_FUNC_START(disp, EGL_NO_IMAGE_KHR);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_NO_IMAGE_KHR);
 
    _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
    if (!disp->Extensions.KHR_image_base)
@@ -1398,7 +1417,7 @@ eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target,
    EGLImage image;
    EGLint *int_attribs;
 
-   _EGL_FUNC_START(NULL, EGL_NO_IMAGE_KHR);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_NO_IMAGE_KHR);
 
    int_attribs = _eglConvertAttribsToInt(attr_list);
    if (attr_list && !int_attribs)
@@ -1418,7 +1437,7 @@ eglDestroyImage(EGLDisplay dpy, EGLImage image)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    if (!disp->Extensions.KHR_image_base)
@@ -1434,11 +1453,10 @@ eglDestroyImage(EGLDisplay dpy, EGLImage image)
 
 
 static EGLSync
-_eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list,
+_eglCreateSync(_EGLDisplay *disp, EGLenum type, const EGLint *attrib_list,
                const EGLAttrib *attrib_list64, EGLBoolean is64,
                EGLenum invalid_type_error)
 {
-   _EGLDisplay *disp = _eglLockDisplay(dpy);
    _EGLContext *ctx = _eglGetCurrentContext();
    _EGLDriver *drv;
    _EGLSync *sync;
@@ -1450,7 +1468,7 @@ _eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list,
       RETURN_EGL_EVAL(disp, EGL_NO_SYNC_KHR);
 
    /* return an error if the client API doesn't support GL_OES_EGL_sync */
-   if (!ctx || ctx->Resource.Display != dpy ||
+   if (!ctx || ctx->Resource.Display != disp ||
        ctx->ClientAPI != EGL_OPENGL_ES_API)
       RETURN_EGL_ERROR(disp, EGL_BAD_MATCH, EGL_NO_SYNC_KHR);
 
@@ -1481,8 +1499,9 @@ _eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list,
 static EGLSync EGLAPIENTRY
 eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
 {
-   _EGL_FUNC_START(NULL, EGL_NO_SYNC_KHR);
-   return _eglCreateSync(dpy, type, attrib_list, NULL, EGL_FALSE,
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
+   return _eglCreateSync(disp, type, attrib_list, NULL, EGL_FALSE,
                          EGL_BAD_ATTRIBUTE);
 }
 
@@ -1490,8 +1509,9 @@ eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
 static EGLSync EGLAPIENTRY
 eglCreateSync64KHR(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list)
 {
-   _EGL_FUNC_START(NULL, EGL_NO_SYNC_KHR);
-   return _eglCreateSync(dpy, type, NULL, attrib_list, EGL_TRUE,
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
+   return _eglCreateSync(disp, type, NULL, attrib_list, EGL_TRUE,
                          EGL_BAD_ATTRIBUTE);
 }
 
@@ -1499,8 +1519,9 @@ eglCreateSync64KHR(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list)
 EGLSync EGLAPIENTRY
 eglCreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list)
 {
-   _EGL_FUNC_START(NULL, EGL_NO_SYNC_KHR);
-   return _eglCreateSync(dpy, type, NULL, attrib_list, EGL_TRUE,
+   _EGLDisplay *disp = _eglLockDisplay(dpy);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
+   return _eglCreateSync(disp, type, NULL, attrib_list, EGL_TRUE,
                          EGL_BAD_PARAMETER);
 }
 
@@ -1513,7 +1534,7 @@ eglDestroySync(EGLDisplay dpy, EGLSync sync)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE);
 
    _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
    assert(disp->Extensions.KHR_reusable_sync ||
@@ -1534,7 +1555,7 @@ eglClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout)
    _EGLDriver *drv;
    EGLint ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE);
 
    _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
    assert(disp->Extensions.KHR_reusable_sync ||
@@ -1573,7 +1594,7 @@ eglWaitSyncKHR(EGLDisplay dpy, EGLSync sync, EGLint flags)
    _EGLDriver *drv;
    EGLint ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE);
 
    _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
    assert(disp->Extensions.KHR_wait_sync);
@@ -1611,7 +1632,7 @@ eglSignalSyncKHR(EGLDisplay dpy, EGLSync sync, EGLenum mode)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE);
 
    _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
    assert(disp->Extensions.KHR_reusable_sync);
@@ -1629,7 +1650,7 @@ eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *valu
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SYNC_KHR, s, EGL_FALSE);
 
    _EGL_CHECK_SYNC(disp, s, EGL_FALSE, drv);
    assert(disp->Extensions.KHR_reusable_sync ||
@@ -1646,7 +1667,7 @@ eglGetSyncAttribKHR(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint *valu
    EGLAttrib attrib;
    EGLBoolean result;
 
-   _EGL_FUNC_START(NULL, EGL_FALSE);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
 
    if (!value)
       RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE);
@@ -1676,7 +1697,7 @@ eglSwapBuffersRegionNOK(EGLDisplay dpy, EGLSurface surface,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
 
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
 
@@ -1702,7 +1723,7 @@ eglCreateDRMImageMESA(EGLDisplay dpy, const EGLint *attr_list)
    _EGLImage *img;
    EGLImage ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_NO_IMAGE_KHR, drv);
    if (!disp->Extensions.MESA_drm_image)
@@ -1723,7 +1744,7 @@ eglExportDRMImageMESA(EGLDisplay dpy, EGLImage image,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    assert(disp->Extensions.MESA_drm_image);
@@ -1746,7 +1767,7 @@ eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    assert(disp->Extensions.WL_bind_wayland_display);
@@ -1766,7 +1787,7 @@ eglUnbindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    assert(disp->Extensions.WL_bind_wayland_display);
@@ -1787,7 +1808,7 @@ eglQueryWaylandBufferWL(EGLDisplay dpy, struct wl_resource *buffer,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    assert(disp->Extensions.WL_bind_wayland_display);
@@ -1809,7 +1830,7 @@ eglCreateWaylandBufferFromImageWL(EGLDisplay dpy, EGLImage image)
    _EGLDriver *drv;
    struct wl_buffer *ret;
 
-   _EGL_FUNC_START(disp, NULL);
+   _EGL_FUNC_START(disp, EGL_OBJECT_DISPLAY_KHR, NULL, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, NULL, drv);
    assert(disp->Extensions.WL_create_wayland_buffer_from_image);
@@ -1833,7 +1854,7 @@ eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
 
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
 
@@ -1855,7 +1876,7 @@ eglGetSyncValuesCHROMIUM(EGLDisplay display, EGLSurface surface,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_SURFACE_KHR, surf, EGL_FALSE);
 
    _EGL_CHECK_SURFACE(disp, surf, EGL_FALSE, drv);
    if (!disp->Extensions.CHROMIUM_sync_control)
@@ -1879,7 +1900,7 @@ eglExportDMABUFImageQueryMESA(EGLDisplay dpy, EGLImage image,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    assert(disp->Extensions.MESA_image_dma_buf_export);
@@ -1902,7 +1923,7 @@ eglExportDMABUFImageMESA(EGLDisplay dpy, EGLImage image,
    _EGLDriver *drv;
    EGLBoolean ret;
 
-   _EGL_FUNC_START(disp, EGL_FALSE);
+   _EGL_FUNC_START(disp, EGL_OBJECT_IMAGE_KHR, img, EGL_FALSE);
 
    _EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
    assert(disp->Extensions.MESA_image_dma_buf_export);
@@ -1922,14 +1943,18 @@ eglLabelObjectKHR(
       EGLObjectKHR object,
       EGLLabelKHR label)
 {
-   _EGL_FUNC_START(NULL, EGL_BAD_ALLOC);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_BAD_ALLOC);
 
    if (objectType == EGL_OBJECT_THREAD_KHR) {
       _EGLThreadInfo *t = _eglGetCurrentThread();
       if (!_eglIsCurrentThreadDummy()) {
          t->Label = label;
+         return EGL_SUCCESS;
+      } else {
+         _eglDebugReportFull(EGL_BAD_ALLOC, __func__, __func__,
+               EGL_DEBUG_MSG_CRITICAL_KHR, NULL, NULL);
+         return EGL_BAD_ALLOC;
       }
-      return EGL_SUCCESS;
    } else {
       _EGLDisplay *disp = _eglLookupDisplay(dpy);
       if (disp == NULL) {
@@ -1981,7 +2006,7 @@ eglLabelObjectKHR(
 static EGLint
 eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list)
 {
-   _EGL_FUNC_START(NULL, EGL_BAD_ALLOC);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_BAD_ALLOC);
 
    mtx_lock(_eglGlobal.Mutex);
 
@@ -2002,8 +2027,8 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list
                // On error, set the last error code, call the current
                // debug callback, and return the error code.
                mtx_unlock(_eglGlobal.Mutex);
-               _eglReportError(EGL_BAD_ATTRIBUTE, "eglDebugMessageControlKHR", NULL,
-               "Invalid attribute 0x%04lx", (unsigned long) attrib_list[i]);
+               _eglReportError(EGL_BAD_ATTRIBUTE, NULL,
+                     "Invalid attribute 0x%04lx", (unsigned long) attrib_list[i]);
                return EGL_BAD_ATTRIBUTE;
             }
          }
@@ -2023,7 +2048,7 @@ eglDebugMessageControlKHR(EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list
 static EGLBoolean
 eglQueryDebugKHR(EGLint attribute, EGLAttrib *value)
 {
-   _EGL_FUNC_START(NULL, EGL_BAD_ALLOC);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_BAD_ALLOC);
 
    mtx_lock(_eglGlobal.Mutex);
    if (attribute >= EGL_DEBUG_MSG_CRITICAL_KHR &&
@@ -2037,7 +2062,7 @@ eglQueryDebugKHR(EGLint attribute, EGLAttrib *value)
       *value = (EGLAttrib) _eglGlobal.debugCallback;
    } else {
       mtx_unlock(_eglGlobal.Mutex);
-      _eglReportError(EGL_BAD_ATTRIBUTE, "eglQueryDebugKHR", NULL,
+      _eglReportError(EGL_BAD_ATTRIBUTE, NULL,
               "Invalid attribute 0x%04lx", (unsigned long) attribute);
       return EGL_FALSE;
    }
@@ -2135,7 +2160,7 @@ eglGetProcAddress(const char *procname)
    if (!procname)
       RETURN_EGL_SUCCESS(NULL, NULL);
 
-   _EGL_FUNC_START(NULL, NULL);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, NULL);
 
    ret = NULL;
    if (strncmp(procname, "egl", 3) == 0) {
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index f5f4d26..986d5aa 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -39,7 +39,7 @@
 
 /* This should be kept in sync with _eglInitThreadInfo() */
 #define _EGL_THREAD_INFO_INITIALIZER \
-   { EGL_SUCCESS, { NULL }, 0 }
+   { EGL_SUCCESS, { NULL }, 0, NULL, NULL, NULL }
 
 /* a fallback thread info to guarantee that every thread always has one */
 static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
@@ -292,7 +292,7 @@ _eglError(EGLint errCode, const char *msg)
          type = EGL_DEBUG_MSG_ERROR_KHR;
       }
 
-      _eglDebugReport(errCode, NULL, msg, type, NULL, NULL);
+      _eglDebugReport(errCode, msg, type, NULL);
    } else {
       _eglInternalError(errCode, msg);
    }
@@ -309,9 +309,9 @@ _eglGetThreadLabel(void)
    return t->Label;
 }
 
-void
-_eglDebugReport(EGLenum error, const char *command, const char *funcName,
-      EGLint type, EGLLabelKHR objectLabel, const char *message, ...)
+static void
+_eglDebugReportFullv(EGLenum error, const char *command, const char *funcName,
+      EGLint type, EGLLabelKHR objectLabel, const char *message, va_list args)
 {
    EGLDEBUGPROCKHR callback = NULL;
 
@@ -321,24 +321,13 @@ _eglDebugReport(EGLenum error, const char *command, const char *funcName,
    }
    mtx_unlock(_eglGlobal.Mutex);
 
-   if (command == NULL) {
-      _EGLThreadInfo *thr = _eglGetCurrentThread();
-      command = thr->CurrentFuncName;
-   }
-   if (funcName == NULL) {
-      funcName = command;
-   }
-
    if (callback != NULL) {
       char *buf = NULL;
 
       if (message != NULL) {
-         va_list args;
-         va_start(args, message);
          if (vasprintf(&buf, message, args) < 0) {
             buf = NULL;
          }
-         va_end(args);
       }
       callback(error, command, type, _eglGetThreadLabel(), objectLabel, buf);
       free(buf);
@@ -348,3 +337,29 @@ _eglDebugReport(EGLenum error, const char *command, const char *funcName,
       _eglInternalError(error, funcName);
    }
 }
+
+void
+_eglDebugReportFull(EGLenum error, const char *command, const char *funcName,
+      EGLint type, EGLLabelKHR objectLabel, const char *message, ...)
+{
+   va_list args;
+   va_start(args, message);
+   _eglDebugReportFullv(error, command, funcName, type, objectLabel, message, args);
+   va_end(args);
+}
+
+void
+_eglDebugReport(EGLenum error, const char *funcName,
+      EGLint type, const char *message, ...)
+{
+   _EGLThreadInfo *thr = _eglGetCurrentThread();
+   va_list args;
+
+   if (funcName == NULL) {
+      funcName = thr->CurrentFuncName;
+   }
+
+   va_start(args, message);
+   _eglDebugReportFullv(error, thr->CurrentFuncName, funcName, type, thr->CurrentObjectLabel, message, args);
+   va_end(args);
+}
diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h
index c2fed69..9ec07ba 100644
--- a/src/egl/main/eglcurrent.h
+++ b/src/egl/main/eglcurrent.h
@@ -61,6 +61,7 @@ struct _egl_thread_info
     * used to report the function name to the EGL_KHR_debug callback.
     */
    const char *CurrentFuncName;
+   EGLLabelKHR CurrentObjectLabel;
 };
 
 
@@ -102,20 +103,24 @@ extern EGLLabelKHR
 _eglGetThreadLabel(void);
 
 extern void
-_eglDebugReport(EGLenum error, const char *command, const char *funcName,
+_eglDebugReportFull(EGLenum error, const char *command, const char *funcName,
       EGLint type, EGLLabelKHR objectLabel, const char *message, ...);
 
-#define _eglReportCritical(error, funcName, objLabel, ...) \
-    _eglDebugReport(error, NULL, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, objLabel, __VA_ARGS__)
+extern void
+_eglDebugReport(EGLenum error, const char *funcName,
+      EGLint type, const char *message, ...);
 
-#define _eglReportError(error, funcName, objLabel, ...) \
-    _eglDebugReport(error, NULL, funcName, EGL_DEBUG_MSG_ERROR_KHR, objLabel, __VA_ARGS__)
+#define _eglReportCritical(error, funcName, ...) \
+    _eglDebugReport(error, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, __VA_ARGS__)
 
-#define _eglReportWarn(funcName, objLabel, ...) \
-    _eglDebugReport(EGL_SUCCESS, NULL, funcName, EGL_DEBUG_MSG_WARN_KHR, objLabel, __VA_ARGS__)
+#define _eglReportError(error, funcName, ...) \
+    _eglDebugReport(error, funcName, EGL_DEBUG_MSG_ERROR_KHR, __VA_ARGS__)
 
-#define _eglReportInfo(funcName, objLabel, ...) \
-    _eglDebugReport(EGL_SUCCESS, NULL, funcName, EGL_DEBUG_MSG_INFO_KHR, objLabel, __VA_ARGS__)
+#define _eglReportWarn(funcName, ...) \
+    _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_WARN_KHR, __VA_ARGS__)
+
+#define _eglReportInfo(funcName, ...) \
+    _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_INFO_KHR, __VA_ARGS__)
 
 #ifdef __cplusplus
 }
-- 
2.9.3



More information about the mesa-dev mailing list