egl: Fix attrib_list[0] == EGL_NONE check
_eglGetSurfacelessDisplay(), _eglGetWaylandDisplay() and
_eglGetGbmDisplay() handle the attrib_list[0] == EGL_NONE
case incorrectly by returning an EGL_BAD_ATTRIBUTE error.
Fix this bug, and switch the functions to use switch/case
in order to have the same structure as the sibling
_eglGetXXXDisplay() functions which support multiple attributes.
Fixes: c237539d62 ("egl: Implement EGL_EXT_explicit_device")
Signed-off-by: Robert Foss <rfoss@kernel.org>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24394>
This commit is contained in:
+51
-24
@@ -570,14 +570,23 @@ _eglGetGbmDisplay(struct gbm_device *native_display,
|
|||||||
|
|
||||||
/* This platform recognizes only EXT_explicit_device */
|
/* This platform recognizes only EXT_explicit_device */
|
||||||
if (attrib_list) {
|
if (attrib_list) {
|
||||||
if (attrib_list[0] != EGL_DEVICE_EXT) {
|
for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
|
||||||
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
|
EGLAttrib attrib = attrib_list[i];
|
||||||
return NULL;
|
EGLAttrib value = attrib_list[i + 1];
|
||||||
}
|
|
||||||
dev = _eglLookupDevice((void *)attrib_list[1]);
|
switch (attrib) {
|
||||||
if (!dev) {
|
case EGL_DEVICE_EXT:
|
||||||
_eglError(EGL_BAD_DEVICE_EXT, "eglGetPlatformDisplay");
|
dev = _eglLookupDevice((void *)value);
|
||||||
return NULL;
|
if (!dev) {
|
||||||
|
_eglError(EGL_BAD_DEVICE_EXT, "eglGetPlatformDisplay");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,14 +609,23 @@ _eglGetWaylandDisplay(struct wl_display *native_display,
|
|||||||
|
|
||||||
/* This platform recognizes only EXT_explicit_device */
|
/* This platform recognizes only EXT_explicit_device */
|
||||||
if (attrib_list) {
|
if (attrib_list) {
|
||||||
if (attrib_list[0] != EGL_DEVICE_EXT) {
|
for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
|
||||||
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
|
EGLAttrib attrib = attrib_list[i];
|
||||||
return NULL;
|
EGLAttrib value = attrib_list[i + 1];
|
||||||
}
|
|
||||||
dev = _eglLookupDevice((void *)attrib_list[1]);
|
switch (attrib) {
|
||||||
if (!dev) {
|
case EGL_DEVICE_EXT:
|
||||||
_eglError(EGL_BAD_DEVICE_EXT, "eglGetPlatformDisplay");
|
dev = _eglLookupDevice((void *)value);
|
||||||
return NULL;
|
if (!dev) {
|
||||||
|
_eglError(EGL_BAD_DEVICE_EXT, "eglGetPlatformDisplay");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,14 +651,23 @@ _eglGetSurfacelessDisplay(void *native_display, const EGLAttrib *attrib_list)
|
|||||||
|
|
||||||
/* This platform recognizes only EXT_explicit_device */
|
/* This platform recognizes only EXT_explicit_device */
|
||||||
if (attrib_list) {
|
if (attrib_list) {
|
||||||
if (attrib_list[0] != EGL_DEVICE_EXT) {
|
for (int i = 0; attrib_list[i] != EGL_NONE; i += 2) {
|
||||||
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
|
EGLAttrib attrib = attrib_list[i];
|
||||||
return NULL;
|
EGLAttrib value = attrib_list[i + 1];
|
||||||
}
|
|
||||||
if ((native_display && native_display != (void *)attrib_list[1]) ||
|
switch (attrib) {
|
||||||
(native_display != _eglLookupDevice(native_display))) {
|
case EGL_DEVICE_EXT:
|
||||||
_eglError(EGL_BAD_DEVICE_EXT, "eglGetPlatformDisplay");
|
if ((native_display && native_display != (void *)value) ||
|
||||||
return NULL;
|
(native_display != _eglLookupDevice(native_display))) {
|
||||||
|
_eglError(EGL_BAD_DEVICE_EXT, "eglGetPlatformDisplay");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_eglError(EGL_BAD_ATTRIBUTE, "eglGetPlatformDisplay");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user