[Mesa-dev] [PATCH 2/7] EGL: Implement eglLabelObjectKHR

Adam Jackson ajax at redhat.com
Thu Sep 8 17:46:57 UTC 2016


From: Kyle Brenneman <kbrenneman at nvidia.com>

Added a label to the _EGLThreadInfo, _EGLDisplay, and EGLResource
structs. Implemented the function eglLabelObjectKHR.

Reviewed-by: Adam Jackson <ajax at redhat.com>
---
 src/egl/main/eglapi.c     | 63 +++++++++++++++++++++++++++++++++++++++++++++++
 src/egl/main/eglcurrent.c |  9 +++++++
 src/egl/main/eglcurrent.h |  4 +++
 src/egl/main/egldisplay.h |  4 +++
 4 files changed, 80 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index df2dcd6..31b842f 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -1791,6 +1791,68 @@ eglExportDMABUFImageMESA(EGLDisplay dpy, EGLImage image,
    RETURN_EGL_EVAL(disp, ret);
 }
 
+static EGLint EGLAPIENTRY
+eglLabelObjectKHR(
+      EGLDisplay dpy,
+      EGLenum objectType,
+      EGLObjectKHR object,
+      EGLLabelKHR label)
+{
+   if (objectType == EGL_OBJECT_THREAD_KHR) {
+      _EGLThreadInfo *t = _eglGetCurrentThread();
+      if (!_eglIsCurrentThreadDummy()) {
+         t->Label = label;
+      }
+      return EGL_SUCCESS;
+   } else {
+      _EGLDisplay *disp = _eglLookupDisplay(dpy);
+      if (disp == NULL) {
+         _eglError(EGL_BAD_DISPLAY, "eglLabelObjectKHR");
+         return EGL_BAD_DISPLAY;
+      }
+
+      if (objectType == EGL_OBJECT_DISPLAY_KHR) {
+         if (dpy != (EGLDisplay) object) {
+            _eglError(EGL_BAD_PARAMETER, "eglLabelObjectKHR");
+            return EGL_BAD_PARAMETER;
+         }
+         disp->Label = label;
+         return EGL_SUCCESS;
+      } else {
+         _EGLResourceType type;
+         switch (objectType)
+         {
+            case EGL_OBJECT_CONTEXT_KHR:
+               type = _EGL_RESOURCE_CONTEXT;
+               break;
+            case EGL_OBJECT_SURFACE_KHR:
+               type = _EGL_RESOURCE_SURFACE;
+               break;
+            case EGL_OBJECT_IMAGE_KHR:
+               type = _EGL_RESOURCE_IMAGE;
+               break;
+            case EGL_OBJECT_SYNC_KHR:
+               type = _EGL_RESOURCE_SYNC;
+               break;
+            case EGL_OBJECT_STREAM_KHR:
+            default:
+                _eglError(EGL_BAD_PARAMETER, "eglLabelObjectKHR");
+               return EGL_BAD_PARAMETER;
+         }
+
+         if (_eglCheckResource(object, type, disp)) {
+            _EGLResource *res = (_EGLResource *) object;
+            res->Label = label;
+            return EGL_SUCCESS;
+         } else {
+            _eglError(EGL_BAD_PARAMETER, "eglLabelObjectKHR");
+            return EGL_BAD_PARAMETER;
+         }
+      }
+   }
+}
+
+
 __eglMustCastToProperFunctionPointerType EGLAPIENTRY
 eglGetProcAddress(const char *procname)
 {
@@ -1870,6 +1932,7 @@ eglGetProcAddress(const char *procname)
       { "eglGetSyncValuesCHROMIUM", (_EGLProc) eglGetSyncValuesCHROMIUM },
       { "eglExportDMABUFImageQueryMESA", (_EGLProc) eglExportDMABUFImageQueryMESA },
       { "eglExportDMABUFImageMESA", (_EGLProc) eglExportDMABUFImageMESA },
+      { "eglLabelObjectKHR", (_EGLProc) eglLabelObjectKHR },
       { NULL, NULL }
    };
    EGLint i;
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index 345f4cc..6dd6f4c 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -279,3 +279,12 @@ _eglError(EGLint errCode, const char *msg)
 
    return EGL_FALSE;
 }
+
+/**
+ * Returns the label set for the current thread.
+ */
+EGLLabelKHR _eglGetThreadLabel(void)
+{
+   _EGLThreadInfo *t = _eglGetCurrentThread();
+   return t->Label;
+}
diff --git a/src/egl/main/eglcurrent.h b/src/egl/main/eglcurrent.h
index b922435..e139271 100644
--- a/src/egl/main/eglcurrent.h
+++ b/src/egl/main/eglcurrent.h
@@ -54,6 +54,7 @@ struct _egl_thread_info
    EGLint LastError;
    _EGLContext *CurrentContext;
    EGLenum CurrentAPI;
+   EGLLabelKHR Label;
 };
 
 
@@ -91,6 +92,9 @@ _eglGetCurrentContext(void);
 extern EGLBoolean
 _eglError(EGLint errCode, const char *msg);
 
+extern EGLLabelKHR
+_eglGetThreadLabel(void);
+
 
 #ifdef __cplusplus
 }
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 6bfc858..d27f63a 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -79,6 +79,8 @@ struct _egl_resource
    EGLBoolean IsLinked;
    EGLint RefCount;
 
+   EGLLabelKHR Label;
+
    /* used to link resources of the same type */
    _EGLResource *Next;
 };
@@ -165,6 +167,8 @@ struct _egl_display
 
    /* lists of resources */
    _EGLResource *ResourceLists[_EGL_NUM_RESOURCES];
+
+   EGLLabelKHR Label;
 };
 
 
-- 
2.9.3



More information about the mesa-dev mailing list