-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eglplatform.h: add EGL_NO_PLATFORM_SPECIFIC_TYPES flag #111
Conversation
The effect is not clear to me. I have asked the EGL WG to review since we have MESA, X11, Wayland and GBM implementors. Looking for verification that this is good. |
Ok, I'm waiting for the review from the EGL WG. Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed internally here. Looks good to NV.
Additionally, we would be in favor of making EGL_NO_X11 the default in a future change.
I would be in favour of The only reason to select one of the Wayland or GBM platform tokens is specifically to change the declared prototype signature for What's the particular reason you have for effectively ignoring |
In practice, generic types for EGLNativeDisplayType, EGLNativePixmapType, EGLNativeWindowType can be used and work for all platforms. If the Mesa library on your system supports multiple platforms (such as Wayland, DRM or X11), it's possible to dynamically choose which platform support to use by setting EGL_PLATFORM variable. #include <wayland-egl.h> ... struct wl_display *wl_dpy = wl_display_connect() EGLDisplay egl_dpy; if (!strcmp(getenv("EGL_PLATFORM"), "wayland")) { if (!strcmp(getenv("EGL_PLATFORM"), "drm")) { if (!strcmp(getenv("EGL_PLATFORM"), "x11")) { Without the proposed change, since WL_EGL_PLATFORM comes first in eglplatform.h, EGLNativeDisplayType is defined with "wl_display *" when compiling this code. But given the code above, we have no reason to use this definition instead of another platform's definition. With the proposed change, the common type "void *" is simply used when setting EGL_NO_X11 flag, without making a preferential choice. And EGL is then completely "independent of definitions and concepts specific to any platform or rendering API." Nicolas Caramelli |
Two things - firstly, you should really be using the platform methods, which allow you to explicitly specify the platform as part of the function signature, instead of using the Secondly, I can see the issue here - which is that |
Yes, EGL_PLATFORM is specific to Mesa, but this was only an example to illustrate the proposed change. And yes, using eglGetPlatformDisplayEXT() and eglCreatePlatformWindowSurfaceEXT() is portable, but as we can see in weston/shared/platform.h and as explained, EGLNativeDisplayType will be defined with "wl_display *". The purpose of the initial proposed modification is to have the possibility of using a generic type. Yes, WL_EGL_PLATFORM is defined in wayland-egl.h The proposed change is perhaps the simplest but yes it would be more explicit to have a test expression with EGL_REALLY_NO_PLATFORM_SPECIFIC_TYPES (and to leave EGL_NO_X11 in its place). typedef void *EGLNativeDisplayType; So I have updated the pull request. Nicolas Caramelli |
@fooishbar, yours to approve if resolves your reservations. |
As suggested in the review, EGL_REALLY_NO_PLATFORM_SPECIFIC_TYPES has been introduced. Is there anything missing from the proposed changes? Nicolas Caramelli |
My suggestion: drop "REALLY_" from token name, and put the types at the end of the if-elif-end chain. |
Yes sorry, this is really embarrassing. I made that suggestion as a figure of speech, not meaning it to be taken literally. |
Thanks for your comments, the idea is there and the code review is constructive. OK, I dropped "REALLY_" in the flag name. |
This avoids Xlib.h inclusion via EGL headers. See [1] for discussion. This change is based on a Weston commit [2]. [1]: KhronosGroup/EGL-Registry#111 [2]: https://gitlab.freedesktop.org/wayland/weston/commit/526765ddfdfd
This avoids Xlib.h inclusion via EGL headers. See [1] for discussion. This change is based on a Weston commit [2]. [1]: KhronosGroup/EGL-Registry#111 [2]: https://gitlab.freedesktop.org/wayland/weston/commit/526765ddfdfd
One of the annoying things about EGL headers is that they include platform headers by default, e.g. on X11, it's Xlib.h, etc. The problem with Xlib.h is that it uses the define compiler directive to declare constants and those constrants have very generic names, e.g. 'None', which typically conflict with enums, etc. In order to work around bad things coming from Xlib.h, we include fixx11.h file that contains some workarounds to redefine some Xlib's types. There's a flag or rather two flags (EGL_NO_PLATFORM_SPECIFIC_TYPES and EGL_NO_X11) that are cross-vendor and they can be used prevent EGL headers from including platform specific headers, such as Xlib.h [1] The benefit of setting those two flags is that you can simply include EGL/egl.h or epoxy/egl.h and the world won't explode due to Xlib.h MESA_EGL_NO_X11_HEADERS is set to support older versions of Mesa. [1] KhronosGroup/EGL-Registry#111
One of the annoying things about EGL headers is that they include platform headers by default, e.g. on X11, it's Xlib.h, etc. The problem with Xlib.h is that it uses the define compiler directive to declare constants and those constants have very generic names, e.g. 'None', which typically conflict with enums, etc. In order to work around bad things coming from Xlib.h, we include fixx11.h file that contains some workarounds to redefine some Xlib's types. There's a flag or rather two flags (EGL_NO_PLATFORM_SPECIFIC_TYPES and EGL_NO_X11) that are cross-vendor and they can be used to prevent EGL headers from including platform specific headers, such as Xlib.h [1] The benefit of setting those two flags is that you can simply include EGL/egl.h or epoxy/egl.h and the world won't explode due to Xlib.h MESA_EGL_NO_X11_HEADERS is set to support older versions of Mesa. [1] KhronosGroup/EGL-Registry#111
Like X11, Wayland (WL_EGL_PLATFORM) or DRM (__GBM__) also correspond to unix-based platforms.
This change allows the use of primitive types regardless of the unix-based platform.
Something like EGL_KHRONOS_TYPES might be more explicit than EGL_NO_X11, but that's a detail.
Nicolas Caramelli