[Mesa-dev] [PATCH 2/6] EGL: Implement eglLableObjectKHR.
Kyle Brenneman
kbrenneman at nvidia.com
Wed Jul 6 16:33:43 UTC 2016
Added a label to the _EGLThreadInfo, _EGLDisplay, and EGLResource structs.
Implemented the function eglLabelObjectKHR.
---
src/egl/main/eglapi.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++
src/egl/main/eglcurrent.c | 10 ++++++++
src/egl/main/eglcurrent.h | 5 ++++
src/egl/main/egldisplay.h | 4 +++
4 files changed, 83 insertions(+)
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 4700dbe..bba8a98 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -1809,6 +1809,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)
{
@@ -1888,6 +1950,7 @@ eglGetProcAddress(const char *procname)
{ "eglGetSyncValuesCHROMIUM", (_EGLProc) eglGetSyncValuesCHROMIUM },
{ "eglExportDMABUFImageQueryMESA", (_EGLProc) eglExportDMABUFImageQueryMESA },
{ "eglExportDMABUFImageMESA", (_EGLProc) eglExportDMABUFImageMESA },
+ { "eglLabelObjectKHR", (_EGLProc) eglLabelObjectKHR },
{ NULL, NULL }
};
EGLint i;
@@ -1981,3 +2044,4 @@ MesaGLInteropEGLExportObject(EGLDisplay dpy, EGLContext context,
_eglUnlockDisplay(disp);
return ret;
}
+
diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
index 835631d..e75e804 100644
--- a/src/egl/main/eglcurrent.c
+++ b/src/egl/main/eglcurrent.c
@@ -290,3 +290,13 @@ _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 1e386ac..ce926aa 100644
--- a/src/egl/main/eglcurrent.h
+++ b/src/egl/main/eglcurrent.h
@@ -60,6 +60,8 @@ struct _egl_thread_info
_EGLContext *CurrentContexts[_EGL_API_NUM_APIS];
/* use index for fast access to current context */
EGLint CurrentAPIIndex;
+
+ EGLLabelKHR Label;
};
@@ -118,6 +120,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;
};
--
1.9.1
More information about the mesa-dev
mailing list