From: Kyle Brenneman
Added a member to _EGLThreadInfo to hold the name of the current EGL
function. Each EGL entrypoint will now set that at the beginning.
_eglError will now call the debug callback function, using the function
name stored in the current _EGLThreadInfo struct.
This should allow the EGL_KHR_debug callback to work correctly without
having to rewrite all of the _eglError calls. It also avoids having to
pass the EGL function names down to driver and platform functions that
may be called from multiple entrypoints.
This is really the bare minimum functionality for EGL_KHR_debug, since
the callback will be missing object labels and messages in most cases.
Later changes can update the _eglError calls to provide more info.
Reviewed-by: Adam Jackson
---
src/egl/main/eglapi.c | 142 --
src/egl/main/eglcurrent.c | 35 ++--
src/egl/main/eglcurrent.h | 26 +
src/egl/main/eglglobals.c | 5 +-
4 files changed, 187 insertions(+), 21 deletions(-)
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index e5b098e..087077d 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -250,6 +250,27 @@ _eglUnlockDisplay(_EGLDisplay *dpy)
mtx_unlock(>Mutex);
}
+#define _EGL_FUNC_START(disp, ret) \
+ do { \
+ if (!_eglSetFuncName(__func__)) { \
+ if (disp) \
+_eglUnlockDisplay(disp); \
+ return ret; \
+ } \
+ } while(0)
+
+static EGLBoolean
+_eglSetFuncName(const char *funcName)
+{
+ _EGLThreadInfo *thr = _eglGetCurrentThread();
+ if (!_eglIsCurrentThreadDummy()) {
+ thr->CurrentFuncName = funcName;
+ return EGL_TRUE;
+ } else {
+ _eglDebugReport(EGL_BAD_ALLOC, funcName, funcName,
EGL_DEBUG_MSG_CRITICAL_KHR, NULL, NULL);
+ return EGL_FALSE;
+ }
+}
static EGLint *
_eglConvertAttribsToInt(const EGLAttrib *attr_list)
@@ -287,6 +308,8 @@ eglGetDisplay(EGLNativeDisplayType nativeDisplay)
_EGLDisplay *dpy;
void *native_display_ptr;
+ _EGL_FUNC_START(NULL, EGL_NO_DISPLAY);
+
STATIC_ASSERT(sizeof(void*) == sizeof(nativeDisplay));
native_display_ptr = (void*) nativeDisplay;
@@ -301,6 +324,8 @@ eglGetPlatformDisplayEXT(EGLenum platform, void
*native_display,
{
_EGLDisplay *dpy;
+ _EGL_FUNC_START(NULL, EGL_NO_DISPLAY);
+
switch (platform) {
#ifdef HAVE_X11_PLATFORM
case EGL_PLATFORM_X11_EXT:
@@ -331,8 +356,11 @@ eglGetPlatformDisplay(EGLenum platform, void
*native_display,
const EGLAttrib *attrib_list)
{
EGLDisplay display;
- EGLint *int_attribs = _eglConvertAttribsToInt(attrib_list);
+ EGLint *int_attribs;
+ _EGL_FUNC_START(NULL, EGL_NO_DISPLAY);
+
+ int_attribs = _eglConvertAttribsToInt(attrib_list);
if (attrib_list && !int_attribs)
RETURN_EGL_ERROR(NULL, EGL_BAD_ALLOC, NULL);
@@ -473,6 +501,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGL_FUNC_START(disp, EGL_FALSE);
+
if (!disp)
RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
@@ -523,6 +553,8 @@ eglTerminate(EGLDisplay dpy)
{
_EGLDisplay *disp = _eglLockDisplay(dpy);
+ _EGL_FUNC_START(disp, EGL_FALSE);
+
if (!disp)
RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
@@ -545,6 +577,8 @@ 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);
}
@@ -575,6 +609,8 @@ eglGetConfigs(EGLDisplay dpy, EGLConfig *configs,
_EGLDriver *drv;
EGLBoolean ret;
+ _EGL_FUNC_START(disp, EGL_FALSE);
+
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
ret = drv->API.GetConfigs(drv, disp, configs, config_size, num_config);
@@ -590,6 +626,8 @@ eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list,
EGLConfig *configs,
_EGLDriver *drv;
EGLBoolean ret;
+ _EGL_FUNC_START(disp, EGL_FALSE);
+
_EGL_CHECK_DISPLAY(disp, EGL_FALSE, drv);
ret = drv->API.ChooseConfig(drv, disp, attrib_list, configs,
config_size, num_config);
@@ -607,6 +645,8 @@ eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config,
_EGLDriver *drv;
EGLBoolean ret;
+ _EGL_FUNC_START(disp, EGL_FALSE);
+
_EGL_CHECK_CONFIG(disp, conf, EGL_FALSE, drv);
ret = drv->API.GetConfigAttrib(drv, disp, conf, attribute, value);
@@ -625,6 +665,8 @@ eglCreateContext(EGLDisplay dpy, EGLConfig config,
EGLContext share_list,
_EGLContext *context;
EGLContext ret;
+ _EGL_FUNC_START(disp, EGL_NO_CONTEXT);
+
_EGL_CHECK_DISPLAY(disp, EGL_NO_CONTEXT, drv);
if (!config && !disp->Extensions.MESA_configless_context)
@@ -648,6 +690,8 @@ eglDestroyContext(EGLDisplay dpy, EGLContext ctx)
_EGLDriver