From db5ca3370cf6facf5f01f3fc779926cd0b405440 Mon Sep 17 00:00:00 2001 From: Kyle Brenneman Date: Mon, 29 Nov 2021 07:22:14 -0700 Subject: [PATCH] EGL: Add support for eglQueryDisplayAttribKHR and NV. There are KHR, EXT, and NV versions of eglQueryDisplayAttrib, so add support for all of them. Define separate eglQueryDisplayAttribEXT, eglQueryDisplayAttribKHR, and eglQueryDisplayAttribNV functions. They all call into the same common function, with the only difference being the name passed to an error callback. When loading a vendor library, check for the vendor's eglQueryDisplayAttrib using all three suffixes, and use whichever one is available. --- src/EGL/libegl.c | 27 ++++++++++++++++++++------- src/EGL/libeglabipriv.h | 2 +- src/EGL/libeglvendor.c | 14 +++++++++++++- src/generate/eglFunctionList.py | 6 ++++++ 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/EGL/libegl.c b/src/EGL/libegl.c index 0cfb1d8..9fea10a 100644 --- a/src/EGL/libegl.c +++ b/src/EGL/libegl.c @@ -1043,31 +1043,31 @@ EGLBoolean EGLAPIENTRY eglQueryDevicesEXT(EGLint max_devices, } -EGLBoolean eglQueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, EGLAttrib *value) +static EGLBoolean CommonQueryDisplayAttrib(const char *name, EGLDisplay dpy, EGLint attribute, EGLAttrib *value) { __EGLvendorInfo *vendor; if (value == NULL) { - __eglReportError(EGL_BAD_PARAMETER, "eglQueryDisplayAttribEXT", NULL, + __eglReportError(EGL_BAD_PARAMETER, name, NULL, "Missing value pointer"); return EGL_FALSE; } vendor = __eglGetVendorFromDisplay(dpy); if (vendor == NULL) { - __eglReportError(EGL_BAD_DISPLAY, "eglQueryDisplayAttribEXT", NULL, + __eglReportError(EGL_BAD_DISPLAY, name, NULL, "Invalid EGLDisplay handle"); return EGL_FALSE; } - if (vendor->staticDispatch.queryDisplayAttribEXT == NULL) { - __eglReportError(EGL_BAD_DISPLAY, "eglQueryDisplayAttribEXT", NULL, - "Driver does not support eglQueryDisplayAttribEXT"); + if (vendor->staticDispatch.queryDisplayAttrib == NULL) { + __eglReportError(EGL_BAD_DISPLAY, name, NULL, + "Driver does not support eglQueryDisplayAttrib"); return EGL_FALSE; } __eglSetLastVendor(vendor); - if (!vendor->staticDispatch.queryDisplayAttribEXT(dpy, attribute, value)) { + if (!vendor->staticDispatch.queryDisplayAttrib(dpy, attribute, value)) { return EGL_FALSE; } @@ -1082,6 +1082,19 @@ EGLBoolean eglQueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, EGLAttrib return EGL_TRUE; } +EGLBoolean eglQueryDisplayAttribEXT(EGLDisplay dpy, EGLint attribute, EGLAttrib *value) +{ + return CommonQueryDisplayAttrib("eglQueryDisplayAttribEXT", dpy, attribute, value); +} +EGLBoolean eglQueryDisplayAttribKHR(EGLDisplay dpy, EGLint attribute, EGLAttrib *value) +{ + return CommonQueryDisplayAttrib("eglQueryDisplayAttribKHR", dpy, attribute, value); +} +EGLBoolean eglQueryDisplayAttribNV(EGLDisplay dpy, EGLint attribute, EGLAttrib *value) +{ + return CommonQueryDisplayAttrib("eglQueryDisplayAttribNV", dpy, attribute, value); +} + // TODO: The function hash is the same as in GLX. It should go into a common // file. typedef struct { diff --git a/src/EGL/libeglabipriv.h b/src/EGL/libeglabipriv.h index 315464c..bf7d3e3 100644 --- a/src/EGL/libeglabipriv.h +++ b/src/EGL/libeglabipriv.h @@ -91,7 +91,7 @@ typedef struct __EGLdispatchTableStaticRec { // Extension functions that libEGL cares about. EGLBoolean (* queryDevicesEXT) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); - EGLBoolean (* queryDisplayAttribEXT) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); + EGLBoolean (* queryDisplayAttrib) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); EGLint (* debugMessageControlKHR) (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); diff --git a/src/EGL/libeglvendor.c b/src/EGL/libeglvendor.c index 414f956..acece59 100644 --- a/src/EGL/libeglvendor.c +++ b/src/EGL/libeglvendor.c @@ -242,13 +242,25 @@ static GLboolean LookupVendorEntrypoints(__EGLvendorInfo *vendor) LOADENTRYPOINT(createPlatformPixmapSurface, "eglCreatePlatformPixmapSurface" ); LOADENTRYPOINT(waitSync, "eglWaitSync" ); LOADENTRYPOINT(queryDevicesEXT, "eglQueryDevicesEXT" ); - LOADENTRYPOINT(queryDisplayAttribEXT, "eglQueryDisplayAttribEXT" ); LOADENTRYPOINT(debugMessageControlKHR, "eglDebugMessageControlKHR" ); LOADENTRYPOINT(queryDebugKHR, "eglQueryDebugKHR" ); LOADENTRYPOINT(labelObjectKHR, "eglLabelObjectKHR" ); #undef LOADENTRYPOINT + // eglQueryDisplayAttrib has KHR, EXT, and NV versions. They're all + // interchangeable, but the vendor might not support all of them. + vendor->staticDispatch.queryDisplayAttrib = + vendor->eglvc.getProcAddress("eglQueryDisplayAttribKHR"); + if (vendor->staticDispatch.queryDisplayAttrib == NULL) { + vendor->staticDispatch.queryDisplayAttrib = + vendor->eglvc.getProcAddress("eglQueryDisplayAttribEXT"); + } + if (vendor->staticDispatch.queryDisplayAttrib == NULL) { + vendor->staticDispatch.queryDisplayAttrib = + vendor->eglvc.getProcAddress("eglQueryDisplayAttribNV"); + } + return GL_TRUE; } diff --git a/src/generate/eglFunctionList.py b/src/generate/eglFunctionList.py index 2be8d9c..c5e316b 100644 --- a/src/generate/eglFunctionList.py +++ b/src/generate/eglFunctionList.py @@ -142,6 +142,12 @@ EGL_FUNCTIONS = ( # EGL_EXT_device_query _eglExt("eglQueryDisplayAttribEXT", "custom"), + # EGL_KHR_display_reference + _eglExt("eglQueryDisplayAttribKHR", "custom"), + + # EGL_NV_stream_metadata + _eglExt("eglQueryDisplayAttribNV", "custom"), + # EGL_KHR_debug _eglExt("eglDebugMessageControlKHR", "custom"), _eglExt("eglQueryDebugKHR", "custom"),