[waffle] [PATCH 5/8] egl: Optionally query for eglGetPlatformDisplay (v2)

2016-10-24 Thread Chad Versace
Not yet used.

v2: Use eglGetProcAddress, not dlsym, due the EGL 1.5 spec. (for emil)

Cc: Emil Velikov 
---
 src/waffle/egl/wegl_imports.h  |  4 
 src/waffle/egl/wegl_platform.c | 23 +++
 src/waffle/egl/wegl_platform.h |  4 
 3 files changed, 31 insertions(+)

diff --git a/src/waffle/egl/wegl_imports.h b/src/waffle/egl/wegl_imports.h
index 99e79c8..3f39b9e 100644
--- a/src/waffle/egl/wegl_imports.h
+++ b/src/waffle/egl/wegl_imports.h
@@ -35,6 +35,10 @@
 #include 
 #include 
 
+#ifndef EGL_VERSION_1_5
+typedef intptr_t EGLAttrib;
+#endif
+
 #ifndef EGL_KHR_create_context
 #define EGL_KHR_create_context 1
 #define EGL_CONTEXT_MAJOR_VERSION_KHR   
EGL_CONTEXT_CLIENT_VERSION
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 524a9a8..f52bdfa 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -116,6 +116,25 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 goto error;\
 }
 
+// Use eglGetProcAddress to get EGL 1.5 symbols, not dlsym, because the
+// EGL 1.5 spec requires that implementors support eglGetProcAddress for
+// all symbols.
+//
+// From the EGL 1.5 spec:
+//
+//   eglGetProcAddress may be queried for all EGL and client API functions
+//   supported by the implementation (whether those functions are
+//   extensions or not, and whether they are supported by the current
+//   client API context or not).
+//
+//   For functions that are queryable with eglGetProcAddress,
+//   implementations may choose to also export those functions statically
+//   from the object libraries implementing those functions. However,
+//   portable clients cannot rely on this behavior.
+//
+#define RETRIEVE_EGL_SYMBOL_OPTIONAL(function) \
+self->function = (void*) self->eglGetProcAddress(#function);
+
 RETRIEVE_EGL_SYMBOL(eglMakeCurrent);
 RETRIEVE_EGL_SYMBOL(eglGetProcAddress);
 
@@ -140,7 +159,11 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 RETRIEVE_EGL_SYMBOL(eglDestroySurface);
 RETRIEVE_EGL_SYMBOL(eglSwapBuffers);
 
+// EGL 1.5
+RETRIEVE_EGL_SYMBOL_OPTIONAL(eglGetPlatformDisplay);
+
 #undef RETRIEVE_EGL_SYMBOL
+#undef RETRIEVE_EGL_SYMBOL_OPTIONAL
 
 self->client_extensions =
 self->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 92db3b0..4573ec2 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -60,6 +60,10 @@ struct wegl_platform {
 __eglMustCastToProperFunctionPointerType
(*eglGetProcAddress)(const char *procname);
 
+// EGL 1.5
+EGLDisplay (*eglGetPlatformDisplay)(EGLenum platform, void *native_display,
+const EGLAttrib *attrib_list);
+
 // display
 EGLDisplay (*eglGetDisplay)(EGLNativeDisplayType display_id);
 EGLBoolean (*eglInitialize)(EGLDisplay dpy, EGLint *major, EGLint *minor);
-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 4/8] egl: Query client extensions string

2016-10-24 Thread Chad Versace
Query and store the EGL client extensions string as
wegl_platform::client_extensions.

Prepares for eventual use of eglGetPlatformDisplay.

Reviewed-by: Emil Velikov 
---
 src/waffle/egl/wegl_platform.c | 3 +++
 src/waffle/egl/wegl_platform.h | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index d09febc..524a9a8 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -142,6 +142,9 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 
 #undef RETRIEVE_EGL_SYMBOL
 
+self->client_extensions =
+self->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+
 setup_env(self);
 
 error:
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index a3f9a79..92db3b0 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -52,6 +52,9 @@ struct wegl_platform {
 // EGL function pointers
 void *eglHandle;
 
+// See 
https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_client_extensions.txt
+const char *client_extensions;
+
 EGLBoolean (*eglMakeCurrent)(EGLDisplay dpy, EGLSurface draw,
  EGLSurface read, EGLContext ctx);
 __eglMustCastToProperFunctionPointerType
-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 7/8] egl: Use eglGetPlatformDisplay when possible (v2)

2016-10-24 Thread Chad Versace
Tested against Mesa master@8c78fdb with `ninja check-func` on Linux for
x11_egl, wayland, and gbm. However, the new codepaths were not tested
because Mesa does not yet support the needed eglGetPlatformDisplay
extensions.

v2:
  - For x11_egl, pass a `Display*` to eglGetPlatformDisplay, not a
`Display**`. (for emil)
  - Rebase on other v2 patches.

Cc: Emil Velikov 
---
 src/waffle/egl/wegl_display.c  | 17 +
 src/waffle/egl/wegl_platform.c | 36 ++--
 src/waffle/egl/wegl_platform.h |  8 
 3 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index 7a7986c..5403cd1 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -104,10 +104,19 @@ wegl_display_init(struct wegl_display *dpy,
 if (!ok)
 goto fail;
 
-dpy->egl = plat->eglGetDisplay((EGLNativeDisplayType) native_display);
-if (!dpy->egl) {
-wegl_emit_error(plat, "eglGetDisplay");
-goto fail;
+if (wegl_platform_can_use_eglGetPlatformDisplay(plat)) {
+dpy->egl = plat->eglGetPlatformDisplay(plat->egl_platform,
+   native_display, NULL);
+if (!dpy->egl) {
+wegl_emit_error(plat, "eglGetPlatformDisplay");
+goto fail;
+}
+} else {
+dpy->egl = plat->eglGetDisplay((EGLNativeDisplayType) native_display);
+if (!dpy->egl) {
+wegl_emit_error(plat, "eglGetDisplay");
+goto fail;
+}
 }
 
 ok = plat->eglInitialize(dpy->egl, &dpy->major_version, 
&dpy->minor_version);
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index f52bdfa..5887cf5 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -66,8 +66,10 @@ wegl_platform_teardown(struct wegl_platform *self)
 bool ok = true;
 int error = 0;
 
-if (self->egl_platform != EGL_PLATFORM_ANDROID_KHR)
+if (!wegl_platform_can_use_eglGetPlatformDisplay(self)
+&& self->egl_platform != EGL_PLATFORM_ANDROID_KHR) {
 unsetenv("EGL_PLATFORM");
+}
 
 if (self->eglHandle) {
 error = dlclose(self->eglHandle);
@@ -168,10 +170,40 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 self->client_extensions =
 self->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
 
-setup_env(self);
+if (!wegl_platform_can_use_eglGetPlatformDisplay(self))
+setup_env(self);
 
 error:
 // On failure the caller of wegl_platform_init will trigger it's own
 // destruction which will execute wegl_platform_teardown.
 return ok;
 }
+
+bool
+wegl_platform_can_use_eglGetPlatformDisplay(const struct wegl_platform *plat)
+{
+const char *ext;
+
+if (!plat->eglGetPlatformDisplay)
+return false;
+
+switch (plat->egl_platform) {
+case EGL_PLATFORM_ANDROID_KHR:
+ext = "EGL_KHR_platform_android";
+break;
+case EGL_PLATFORM_GBM_KHR:
+ext = "EGL_KHR_platform_gbm";
+break;
+case EGL_PLATFORM_WAYLAND_KHR:
+ext = "EGL_KHR_platform_wayland";
+break;
+case EGL_PLATFORM_X11_KHR:
+ext = "EGL_KHR_platform_x11";
+break;
+default:
+assert(!"bad egl_platform enum");
+return false;
+}
+
+return waffle_is_extension_in_string(plat->client_extensions, ext);
+}
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 4573ec2..d6788eb 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -103,3 +103,11 @@ wegl_platform_teardown(struct wegl_platform *self);
 
 bool
 wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform);
+
+
+// Can eglGetPlatformDisplay can be used for this platform?
+//
+// True if libEGL exposes the eglGetPlatformDisplay function; and if EGL
+// supports the needed platform extension.
+bool
+wegl_platform_can_use_eglGetPlatformDisplay(const struct wegl_platform *plat);
-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 2/8] egl: Update wegl_platform_init signature

2016-10-24 Thread Chad Versace
No intended change in behavior.  Prepares for eventual use of
eglGetPlatformDisplay.

Add an `EGLenum egl_platform` parameter to wegl_platform_init() and
store it at wegl_platform::egl_platform.

Reviewed-by: Emil Velikov 
---
 src/waffle/egl/wegl_platform.c| 5 -
 src/waffle/egl/wegl_platform.h| 5 -
 src/waffle/gbm/wgbm_platform.c| 2 +-
 src/waffle/wayland/wayland_platform.c | 2 +-
 src/waffle/xegl/xegl_platform.c   | 2 +-
 5 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 492f0da..7f030bd 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -54,8 +54,9 @@ wegl_platform_teardown(struct wegl_platform *self)
 ok &= wcore_platform_teardown(&self->wcore);
 return ok;
 }
+
 bool
-wegl_platform_init(struct wegl_platform *self)
+wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform)
 {
 bool ok;
 
@@ -63,6 +64,8 @@ wegl_platform_init(struct wegl_platform *self)
 if (!ok)
 goto error;
 
+self->egl_platform = egl_platform;
+
 // Most Waffle platforms will call eglCreateWindowSurface.
 self->egl_surface_type_mask = EGL_WINDOW_BIT;
 
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 00c3b8e..a3f9a79 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -35,6 +35,9 @@
 struct wegl_platform {
 struct wcore_platform wcore;
 
+// An EGL_PLATFORM_* enum, such as EGL_PLATFORM_GBM_KHR.
+EGLenum egl_platform;
+
 /// @brief Value of EGLConfig attribute EGL_SURFACE_TYPE
 ///
 /// When calling eglChooseConfig, Waffle sets the EGL_SURFACE_TYPE 
attribute
@@ -92,4 +95,4 @@ bool
 wegl_platform_teardown(struct wegl_platform *self);
 
 bool
-wegl_platform_init(struct wegl_platform *self);
+wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform);
diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index 2b7f3bc..ee25a26 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -92,7 +92,7 @@ wgbm_platform_init(struct wgbm_platform *self)
 {
 bool ok = true;
 
-ok = wegl_platform_init(&self->wegl);
+ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_GBM_KHR);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/wayland/wayland_platform.c 
b/src/waffle/wayland/wayland_platform.c
index 2746ca1..3627c88 100644
--- a/src/waffle/wayland/wayland_platform.c
+++ b/src/waffle/wayland/wayland_platform.c
@@ -90,7 +90,7 @@ wayland_platform_create(void)
 if (self == NULL)
 return NULL;
 
-ok = wegl_platform_init(&self->wegl);
+ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_WAYLAND_KHR);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c
index e36a41b..66d7ed6 100644
--- a/src/waffle/xegl/xegl_platform.c
+++ b/src/waffle/xegl/xegl_platform.c
@@ -71,7 +71,7 @@ xegl_platform_create(void)
 if (self == NULL)
 return NULL;
 
-ok = wegl_platform_init(&self->wegl);
+ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_X11_KHR);
 if (!ok)
 goto error;
 
-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 6/8] egl: Update wegl_display_init signature

2016-10-24 Thread Chad Versace
Change the type of parameter 'native_display' from intptr_t to void*.

No intended change in behavior.  Prepares for eventual use of
eglGetPlatformDisplay, whose 'native_display' parameter has type void*.

Reviewed-by: Emil Velikov 
---
 src/waffle/android/droid_display.c   | 3 +--
 src/waffle/egl/wegl_display.c| 2 +-
 src/waffle/egl/wegl_display.h| 2 +-
 src/waffle/gbm/wgbm_display.c| 2 +-
 src/waffle/wayland/wayland_display.c | 2 +-
 src/waffle/xegl/xegl_display.c   | 2 +-
 6 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/waffle/android/droid_display.c 
b/src/waffle/android/droid_display.c
index 3f39739..5724c39 100644
--- a/src/waffle/android/droid_display.c
+++ b/src/waffle/android/droid_display.c
@@ -51,8 +51,7 @@ droid_display_connect(struct wcore_platform *wc_plat,
 if (self->pSFContainer == NULL)
 goto error;
 
-ok = wegl_display_init(&self->wegl, wc_plat,
-   (intptr_t) EGL_DEFAULT_DISPLAY);
+ok = wegl_display_init(&self->wegl, wc_plat, EGL_DEFAULT_DISPLAY);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index bd7d375..7a7986c 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -95,7 +95,7 @@ get_extensions(struct wegl_display *dpy)
 bool
 wegl_display_init(struct wegl_display *dpy,
   struct wcore_platform *wc_plat,
-  intptr_t native_display)
+  void *native_display)
 {
 struct wegl_platform *plat = wegl_platform(wc_plat);
 bool ok;
diff --git a/src/waffle/egl/wegl_display.h b/src/waffle/egl/wegl_display.h
index 348399d..e828257 100644
--- a/src/waffle/egl/wegl_display.h
+++ b/src/waffle/egl/wegl_display.h
@@ -57,7 +57,7 @@ DEFINE_CONTAINER_CAST_FUNC(wegl_display,
 bool
 wegl_display_init(struct wegl_display *dpy,
   struct wcore_platform *wc_plat,
-  intptr_t native_display);
+  void *native_display);
 
 bool
 wegl_display_teardown(struct wegl_display *dpy);
diff --git a/src/waffle/gbm/wgbm_display.c b/src/waffle/gbm/wgbm_display.c
index 5c8af29..b7c5397 100644
--- a/src/waffle/gbm/wgbm_display.c
+++ b/src/waffle/gbm/wgbm_display.c
@@ -154,7 +154,7 @@ wgbm_display_connect(struct wcore_platform *wc_plat,
 goto error;
 }
 
-ok = wegl_display_init(&self->wegl, wc_plat, (intptr_t) self->gbm_device);
+ok = wegl_display_init(&self->wegl, wc_plat, self->gbm_device);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/wayland/wayland_display.c 
b/src/waffle/wayland/wayland_display.c
index e2d59a8..6373056 100644
--- a/src/waffle/wayland/wayland_display.c
+++ b/src/waffle/wayland/wayland_display.c
@@ -142,7 +142,7 @@ wayland_display_connect(struct wcore_platform *wc_plat,
 goto error;
 }
 
-ok = wegl_display_init(&self->wegl, wc_plat, (intptr_t) self->wl_display);
+ok = wegl_display_init(&self->wegl, wc_plat, self->wl_display);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/xegl/xegl_display.c b/src/waffle/xegl/xegl_display.c
index a1da480..1d1b7dd 100644
--- a/src/waffle/xegl/xegl_display.c
+++ b/src/waffle/xegl/xegl_display.c
@@ -62,7 +62,7 @@ xegl_display_connect(
 if (!ok)
 goto error;
 
-ok = wegl_display_init(&self->wegl, wc_plat, (intptr_t) self->x11.xlib);
+ok = wegl_display_init(&self->wegl, wc_plat, self->x11.xlib);
 if (!ok)
 goto error;
 
-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 3/8] egl: Move each platform's setenv("EGL_PLATFORM") into core EGL code (v2)

2016-10-24 Thread Chad Versace
Each EGL platform 'foo' calls setenv("EGL_PLATFORM", "foo") during
foo_platform_create(), and calls unsetenv("EGL_PLATFORM") during
foo_platform_destroy(). Move the setenv/unsetenv into the core EGL code,
into wegl_platform_init() and wegl_platform_finish().

This prepares for eventually using eglGetPlatformDisplay().

v2: Don't set EGL_PLATFORM on Anroid. (for emil)

Cc: Emil Velikov 
---
 src/waffle/egl/wegl_platform.c| 30 ++
 src/waffle/gbm/wgbm_platform.c|  6 --
 src/waffle/wayland/wayland_platform.c |  5 -
 src/waffle/xegl/xegl_platform.c   |  6 --
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 7f030bd..d09febc 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -23,6 +23,8 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#define _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
+
 #include 
 
 #include "wcore_error.h"
@@ -35,12 +37,38 @@ static const char *libEGL_filename = "libEGL.so";
 static const char *libEGL_filename = "libEGL.so.1";
 #endif
 
+static void
+setup_env(const struct wegl_platform *self)
+{
+switch (self->egl_platform) {
+case EGL_PLATFORM_ANDROID_KHR:
+// Don't set EGL_PLATFORM because I don't know the impact doing so
+// on Android. Does anything other than Mesa use it?
+break;
+case EGL_PLATFORM_GBM_KHR:
+setenv("EGL_PLATFORM", "drm", true);
+break;
+case EGL_PLATFORM_WAYLAND_KHR:
+setenv("EGL_PLATFORM", "wayland", true);
+break;
+case EGL_PLATFORM_X11_KHR:
+setenv("EGL_PLATFORM", "x11", true);
+break;
+default:
+assert(!"bad egl_platform enum");
+break;
+}
+}
+
 bool
 wegl_platform_teardown(struct wegl_platform *self)
 {
 bool ok = true;
 int error = 0;
 
+if (self->egl_platform != EGL_PLATFORM_ANDROID_KHR)
+unsetenv("EGL_PLATFORM");
+
 if (self->eglHandle) {
 error = dlclose(self->eglHandle);
 if (error) {
@@ -114,6 +142,8 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 
 #undef RETRIEVE_EGL_SYMBOL
 
+setup_env(self);
+
 error:
 // On failure the caller of wegl_platform_init will trigger it's own
 // destruction which will execute wegl_platform_teardown.
diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index ee25a26..e598a05 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -23,8 +23,6 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#define _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
-
 #include 
 #include 
 
@@ -55,8 +53,6 @@ wgbm_platform_teardown(struct wgbm_platform *self)
 if (!self)
 return true;
 
-unsetenv("EGL_PLATFORM");
-
 if (self->linux)
 ok &= linux_platform_destroy(self->linux);
 
@@ -120,8 +116,6 @@ wgbm_platform_init(struct wgbm_platform *self)
 if (!self->linux)
 goto error;
 
-setenv("EGL_PLATFORM", "drm", true);
-
 self->wegl.wcore.vtbl = &wgbm_platform_vtbl;
 return true;
 
diff --git a/src/waffle/wayland/wayland_platform.c 
b/src/waffle/wayland/wayland_platform.c
index 3627c88..a8fbafc 100644
--- a/src/waffle/wayland/wayland_platform.c
+++ b/src/waffle/wayland/wayland_platform.c
@@ -24,7 +24,6 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #define WL_EGL_PLATFORM 1
-#define _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
 
 #include 
 #include 
@@ -59,8 +58,6 @@ wayland_platform_destroy(struct wcore_platform *wc_self)
 if (!self)
 return true;
 
-unsetenv("EGL_PLATFORM");
-
 if (self->linux)
 ok &= linux_platform_destroy(self->linux);
 
@@ -125,8 +122,6 @@ wayland_platform_create(void)
 if (!self->linux)
 goto error;
 
-setenv("EGL_PLATFORM", "wayland", true);
-
 self->wegl.wcore.vtbl = &wayland_platform_vtbl;
 return &self->wegl.wcore;
 
diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c
index 66d7ed6..f39ab93 100644
--- a/src/waffle/xegl/xegl_platform.c
+++ b/src/waffle/xegl/xegl_platform.c
@@ -23,8 +23,6 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#define _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
-
 #include 
 
 #include "wcore_error.h"
@@ -51,8 +49,6 @@ xegl_platform_destroy(struct wcore_platform *wc_self)
 if (!self)
 return true;
 
-unsetenv("EGL_PLATFORM");
-
 if (self->linux)
   

[waffle] [PATCH 1/8] egl: Define EGL_PLATFORM_* enums

2016-10-24 Thread Chad Versace
Prepares for use of eglGetPlatformDisplay.

Define the enums to prevent the Waffle build from breaking against old
headers... like Ubuntu LTS.

Reviewed-by: Emil Velikov 
---
 src/waffle/egl/wegl_imports.h  | 26 ++
 src/waffle/egl/wegl_platform.h |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/src/waffle/egl/wegl_imports.h b/src/waffle/egl/wegl_imports.h
index 2657a68..99e79c8 100644
--- a/src/waffle/egl/wegl_imports.h
+++ b/src/waffle/egl/wegl_imports.h
@@ -51,3 +51,29 @@
 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR0x0002
 #define EGL_OPENGL_ES3_BIT_KHR  0x0040
 #endif
+
+#ifndef EGL_KHR_platform_android
+#define EGL_KHR_platform_android 1
+#define EGL_PLATFORM_ANDROID_KHR  0x3141
+#endif /* EGL_KHR_platform_android */
+
+#ifndef EGL_KHR_platform_gbm
+#define EGL_KHR_platform_gbm 1
+#define EGL_PLATFORM_GBM_KHR  0x31D7
+#endif /* EGL_KHR_platform_gbm */
+
+#ifndef EGL_KHR_platform_wayland
+#define EGL_KHR_platform_wayland 1
+#define EGL_PLATFORM_WAYLAND_KHR  0x31D8
+#endif /* EGL_KHR_platform_wayland */
+
+#ifndef EGL_KHR_platform_x11
+#define EGL_KHR_platform_x11 1
+#define EGL_PLATFORM_X11_KHR  0x31D5
+#define EGL_PLATFORM_X11_SCREEN_KHR   0x31D6
+#endif /* EGL_KHR_platform_x11 */
+
+#ifndef EGL_MESA_platform_surfaceless
+#define EGL_MESA_platform_surfaceless 1
+#define EGL_PLATFORM_SURFACELESS_MESA 0x31DD
+#endif /* EGL_MESA_platform_surfaceless */
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 2c4d6c6..00c3b8e 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -30,6 +30,8 @@
 #include "wcore_platform.h"
 #include "wcore_util.h"
 
+#include "wegl_imports.h"
+
 struct wegl_platform {
 struct wcore_platform wcore;
 
-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 0/7] Use eglGetPlatformDisplay when possible (v2)

2016-10-24 Thread Chad Versace
Before EGL_EXT_platform_base and EGL 1.5, when using Mesa the best way
to select the EGL platform was to set the EGL_PLATFORM environment
variable. Now that a standard way exists, eglGetPlatformDisplay, let's
use it when available.

After this series, I have a series to add support for
EGL_MESA_platform_surfaceless.

This branch lives at

https://github.com/chadversary/waffle/commits/review/eglGetPlatformDisplay-v02

v2:
- Fix bugs found by Emil.
- Don't set EGL_PLATFORM=android.
- Last patch, add fallback to use eglGetPlatformDisplayEXT.

Chad Versace (8):
  egl: Define EGL_PLATFORM_* enums
  egl: Update wegl_platform_init signature
  egl: Move each platform's setenv("EGL_PLATFORM") into core EGL code (v2)
  egl: Query client extensions string
  egl: Optionally query for eglGetPlatformDisplay (v2)
  egl: Update wegl_display_init signature
  egl: Use eglGetPlatformDisplay when possible (v2)
  egl: Use eglGetPlatformDisplayEXT as a fallback

 src/waffle/android/droid_display.c|   3 +-
 src/waffle/egl/wegl_display.c |  26 +--
 src/waffle/egl/wegl_display.h |   2 +-
 src/waffle/egl/wegl_imports.h |  30 
 src/waffle/egl/wegl_platform.c| 128 +-
 src/waffle/egl/wegl_platform.h|  33 -
 src/waffle/gbm/wgbm_display.c |   2 +-
 src/waffle/gbm/wgbm_platform.c|   8 +--
 src/waffle/wayland/wayland_display.c  |   2 +-
 src/waffle/wayland/wayland_platform.c |   7 +-
 src/waffle/xegl/xegl_display.c|   2 +-
 src/waffle/xegl/xegl_platform.c   |   8 +--
 12 files changed, 218 insertions(+), 33 deletions(-)

-- 
2.10.1

___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle