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

Kyle Brenneman kbrenneman at nvidia.com
Wed Jul 6 16:33:46 UTC 2016


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.
---
 src/egl/main/eglapi.c     | 191 ++++++++++++++++++++++++++--------------------
 src/egl/main/eglcurrent.c |  48 ++++++++----
 src/egl/main/eglcurrent.h |  23 +++---
 3 files changed, 155 insertions(+), 107 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 6e39bca..038cea0 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)
@@ -1158,13 +1176,15 @@ eglWaitClient(void)
 EGLBoolean EGLAPIENTRY
 eglWaitGL(void)
 {
-   _EGLThreadInfo *t = _eglGetCurrentThread();
-   EGLint api_index = t->CurrentAPIIndex;
+   _EGLThreadInfo *t;
+   EGLint api_index;
    EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API);
    EGLBoolean ret;
 
-   _EGL_FUNC_START(NULL, EGL_FALSE);
+   _EGL_FUNC_START(NULL, EGL_NONE, NULL, EGL_FALSE);
 
+   t = _eglGetCurrentThread();
+   api_index = t->CurrentAPIIndex;
    if (api_index != es_index && _eglIsCurrentThreadDummy())
       RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, EGL_FALSE);
 
@@ -1186,7 +1206,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);
@@ -1237,7 +1257,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);
@@ -1290,10 +1310,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);
 
@@ -1333,7 +1354,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);
 
@@ -1354,7 +1375,7 @@ eglReleaseThread(void)
       EGLint api_index = t->CurrentAPIIndex;
       EGLint i;
 
-      _eglSetFuncName(__func__);
+      _EGL_FUNC_START(NULL, EGL_OBJECT_THREAD_KHR, NULL, EGL_FALSE);
 
       for (i = 0; i < _EGL_API_NUM_APIS; i++) {
          _EGLContext *ctx = t->CurrentContexts[i];
@@ -1390,7 +1411,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)
@@ -1418,7 +1439,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)
@@ -1438,7 +1459,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)
@@ -1454,11 +1475,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;
@@ -1470,7 +1490,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);
 
@@ -1501,8 +1521,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);
 }
 
@@ -1510,8 +1531,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);
 }
 
@@ -1519,8 +1541,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);
 }
 
@@ -1533,7 +1556,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 ||
@@ -1554,7 +1577,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 ||
@@ -1593,7 +1616,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);
@@ -1631,7 +1654,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);
@@ -1649,7 +1672,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 ||
@@ -1666,7 +1689,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);
@@ -1696,7 +1719,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);
 
@@ -1722,7 +1745,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)
@@ -1743,7 +1766,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);
@@ -1766,7 +1789,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);
@@ -1786,7 +1809,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);
@@ -1807,7 +1830,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);
@@ -1829,7 +1852,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);
@@ -1853,7 +1876,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);
 
@@ -1875,7 +1898,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)
@@ -1899,7 +1922,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);
@@ -1922,7 +1945,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);
@@ -1942,14 +1965,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) {
@@ -2001,7 +2028,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);
 
@@ -2022,8 +2049,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;
             }
          }
@@ -2043,7 +2070,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 &&
@@ -2057,7 +2084,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;
    }
@@ -2155,7 +2182,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 2000f10..5a9459b 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;
@@ -303,7 +303,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);
    }
@@ -320,9 +320,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;
 
@@ -332,24 +332,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);
@@ -359,3 +348,30 @@ _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 a7b6abf..3ef29c1 100644
--- a/src/egl/main/eglcurrent.h
+++ b/src/egl/main/eglcurrent.h
@@ -68,6 +68,7 @@ struct _egl_thread_info
     * used to report the function name to the EGL_KHR_debug callback.
     */
    const char *CurrentFuncName;
+   EGLLabelKHR CurrentObjectLabel;
 };
 
 
@@ -130,20 +131,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 _eglReportCritical(error, funcName, ...) \
+    _eglDebugReport(error, funcName, EGL_DEBUG_MSG_CRITICAL_KHR, __VA_ARGS__)
 
-#define _eglReportError(error, funcName, objLabel, ...) \
-    _eglDebugReport(error, NULL, funcName, EGL_DEBUG_MSG_ERROR_KHR, objLabel, __VA_ARGS__)
+#define _eglReportError(error, funcName, ...) \
+    _eglDebugReport(error, funcName, EGL_DEBUG_MSG_ERROR_KHR, __VA_ARGS__)
 
-#define _eglReportWarn(funcName, objLabel, ...) \
-    _eglDebugReport(EGL_SUCCESS, NULL, funcName, EGL_DEBUG_MSG_WARN_KHR, objLabel, __VA_ARGS__)
+#define _eglReportWarn(funcName, ...) \
+    _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_WARN_KHR, __VA_ARGS__)
 
-#define _eglReportInfo(funcName, objLabel, ...) \
-    _eglDebugReport(EGL_SUCCESS, NULL, funcName, EGL_DEBUG_MSG_INFO_KHR, objLabel, __VA_ARGS__)
+#define _eglReportInfo(funcName, ...) \
+    _eglDebugReport(EGL_SUCCESS, funcName, EGL_DEBUG_MSG_INFO_KHR, __VA_ARGS__)
 
 #ifdef __cplusplus
 }
-- 
1.9.1



More information about the mesa-dev mailing list