<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 11/02/2018 01:06 PM, Emil Velikov wrote:<br>
<blockquote
cite="mid:20181102190614.32084-2-emil.l.velikov@gmail.com"
type="cite">
<pre wrap="">From: Emil Velikov <a class="moz-txt-link-rfc2396E" href="mailto:emil.velikov@collabora.com"><emil.velikov@collabora.com></a>
If the user provides an invalid display or device the ToVendor lookup
will fail.
In this case, the local [Mesa vendor] error code will be set. Thus on
sequential eglGetError(), the error will be EGL_SUCCESS.
To be more specific, GLVND remembers the last vendor and calls back
into it's eglGetError, although there's no guarantee to ever have had
one.
Piglit: tests/egl/spec/egl_ext_device_query
Fixes: ce562f9e3fa ("EGL: Implement the libglvnd interface for EGL (v3)")
Cc: Kyle Brenneman <a class="moz-txt-link-rfc2396E" href="mailto:kbrenneman@nvidia.com"><kbrenneman@nvidia.com></a>
Cc: Eric Engestrom <a class="moz-txt-link-rfc2396E" href="mailto:eric@engestrom.ch"><eric@engestrom.ch></a>
Signed-off-by: Emil Velikov <a class="moz-txt-link-rfc2396E" href="mailto:emil.velikov@collabora.com"><emil.velikov@collabora.com></a>
---
src/egl/main/egldispatchstubs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/egl/main/egldispatchstubs.c b/src/egl/main/egldispatchstubs.c
index bfc3195c779..e39fd6197a6 100644
--- a/src/egl/main/egldispatchstubs.c
+++ b/src/egl/main/egldispatchstubs.c
@@ -54,9 +54,17 @@ static __eglMustCastToProperFunctionPointerType FetchVendorFunc(__EGLvendorInfo
{
__eglMustCastToProperFunctionPointerType func = NULL;
- if (vendor != NULL) {
- func = exports->fetchDispatchEntry(vendor, __EGL_DISPATCH_FUNC_INDICES[index]);
+ if (vendor == NULL) {
+ // XXX: How can we end here with EGL_SUCCESS?
+ if (errorCode != EGL_SUCCESS) {
+ // Since we have no vendor, the follow-up eglGetError() call will
+ // end up using the GLVND error code. Set it here.
+ exports->setEGLError(errorCode);
+ }
+ return NULL;
}
+
+ func = exports->fetchDispatchEntry(vendor, __EGL_DISPATCH_FUNC_INDICES[index]);
if (func == NULL) {
if (errorCode != EGL_SUCCESS) {
_eglError(errorCode, __EGL_DISPATCH_FUNC_NAMES[index]);
</pre>
</blockquote>
The (vendor == NULL) branch should still call _eglError so that it
calls the debug callback function. Other than that, this looks right
to me.<br>
<br>
In answer to the question in the comment, getting an EGL_SUCCESS
error code is inherited from the code in libglvnd itself to handle
the eglWait* functions. If there's no current context for those
functions, then they're a no-op and don't set an error code.<br>
<br>
Mesa doesn't have any EGL dispatch stubs that look at the current
context, though, so you could just remove
__eglDispatchFetchByCurrent and the (errorCode != EGL_SUCCESS)
checks.<br>
</body>
</html>