Fix platform display retrieval.
We were checking if the attrib_list was NULL to verify that no
unsupported attributes are provides, but a single EGL_NONE attribute
should also be allowed.
Also use operator& to avoid confusing implicit conversion to a pointer.
Change-Id: I3c30968fddfd4d1dfbdff9c4ff291abb258e304c
Reviewed-on: https://swiftshader-review.googlesource.com/20148
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/OpenGL/libEGL/libEGL.cpp b/src/OpenGL/libEGL/libEGL.cpp
index c76f52b..fa8a529 100644
--- a/src/OpenGL/libEGL/libEGL.cpp
+++ b/src/OpenGL/libEGL/libEGL.cpp
@@ -115,7 +115,7 @@
attrib.push_back(EGL_NONE);
}
- operator const EGLAttrib*() const
+ const EGLAttrib *operator&() const
{
return &attrib[0];
}
@@ -356,7 +356,7 @@
"const EGLint *attrib_list = %p)", dpy, config, native_window, attrib_list);
EGLAttribs attribs(attrib_list);
- return CreatePlatformWindowSurface(dpy, config, native_window, attribs);
+ return CreatePlatformWindowSurface(dpy, config, native_window, &attribs);
}
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType window, const EGLint *attrib_list)
@@ -365,7 +365,7 @@
"const EGLint *attrib_list = %p)", dpy, config, window, attrib_list);
EGLAttribs attribs(attrib_list);
- return CreatePlatformWindowSurface(dpy, config, (void*)window, attribs);
+ return CreatePlatformWindowSurface(dpy, config, (void*)window, &attribs);
}
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
@@ -406,7 +406,7 @@
"const EGLint *attrib_list = %p)", dpy, config, native_pixmap, attrib_list);
EGLAttribs attribs(attrib_list);
- return CreatePlatformPixmapSurface(dpy, config, native_pixmap, attribs);
+ return CreatePlatformPixmapSurface(dpy, config, native_pixmap, &attribs);
}
EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list)
@@ -415,7 +415,7 @@
"const EGLint *attrib_list = %p)", dpy, config, pixmap, attrib_list);
EGLAttribs attribs(attrib_list);
- return CreatePlatformPixmapSurface(dpy, config, (void*)pixmap, attribs);
+ return CreatePlatformPixmapSurface(dpy, config, (void*)pixmap, &attribs);
}
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface)
@@ -1219,7 +1219,7 @@
TRACE("(EGLDisplay dpy = %p, EGLContext ctx = %p, EGLenum target = 0x%X, buffer = %p, const EGLint attrib_list = %p)", dpy, ctx, target, buffer, attrib_list);
EGLAttribs attribs(attrib_list);
- return CreateImage(dpy, ctx, target, buffer, attribs);
+ return CreateImage(dpy, ctx, target, buffer, &attribs);
}
EGLBoolean DestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
@@ -1259,17 +1259,27 @@
{
if(!libX11)
{
- return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY);
+ return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY);
}
- if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL)
+ if(native_display != (void*)EGL_DEFAULT_DISPLAY)
+ {
+ return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); // Unimplemented
+ }
+
+ if(attrib_list && attrib_list[0] != EGL_NONE)
{
return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented
}
}
else if(platform == EGL_PLATFORM_GBM_KHR)
{
- if(native_display != (void*)EGL_DEFAULT_DISPLAY || attrib_list != NULL)
+ if(native_display != (void*)EGL_DEFAULT_DISPLAY)
+ {
+ return error(EGL_BAD_PARAMETER, EGL_NO_DISPLAY); // Unimplemented
+ }
+
+ if(attrib_list && attrib_list[0] != EGL_NONE)
{
return error(EGL_BAD_ATTRIBUTE, EGL_NO_DISPLAY); // Unimplemented
}
@@ -1288,7 +1298,7 @@
TRACE("(EGLenum platform = 0x%X, void *native_display = %p, const EGLint *attrib_list = %p)", platform, native_display, attrib_list);
EGLAttribs attribs(attrib_list);
- return GetPlatformDisplay(platform, native_display, attribs);
+ return GetPlatformDisplay(platform, native_display, &attribs);
}
EGLSync CreateSync(EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list)
@@ -1329,7 +1339,7 @@
TRACE("(EGLDisplay dpy = %p, EGLunum type = %x, EGLint *attrib_list=%p)", dpy, type, attrib_list);
EGLAttribs attribs(attrib_list);
- return CreateSync(dpy, type, attribs);
+ return CreateSync(dpy, type, &attribs);
}
EGLBoolean DestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)