[waffle] [PATCH 3/7] egl: Allow pbuffers to back wegl_surface

2016-10-18 Thread Chad Versace
Add function wegl_pbuffer_init(), which initializes a struct
wegl_surface with eglCreatePbufferSurface().

Not yet used, but will be used later by the new surfaceless platform.

Cc: Gurchetan Singh 
Cc: Haixia Shi 
---
 src/waffle/egl/wegl_platform.c |  1 +
 src/waffle/egl/wegl_platform.h |  2 ++
 src/waffle/egl/wegl_surface.c  | 42 ++
 src/waffle/egl/wegl_surface.h  |  5 +
 4 files changed, 50 insertions(+)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 71eb29e..331cc89 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -139,6 +139,7 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 // window
 RETRIEVE_EGL_SYMBOL(eglGetConfigAttrib);
 RETRIEVE_EGL_SYMBOL(eglCreateWindowSurface);
+RETRIEVE_EGL_SYMBOL(eglCreatePbufferSurface);
 RETRIEVE_EGL_SYMBOL(eglDestroySurface);
 RETRIEVE_EGL_SYMBOL(eglSwapBuffers);
 
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index d6788eb..a5092a5 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -89,6 +89,8 @@ struct wegl_platform {
 EGLSurface (*eglCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
  EGLNativeWindowType win,
  const EGLint *attrib_list);
+EGLSurface (*eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
+  const EGLint *attrib_list);
 EGLBoolean (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
 EGLBoolean (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
 };
diff --git a/src/waffle/egl/wegl_surface.c b/src/waffle/egl/wegl_surface.c
index ccd0799..0bd0857 100644
--- a/src/waffle/egl/wegl_surface.c
+++ b/src/waffle/egl/wegl_surface.c
@@ -74,6 +74,48 @@ fail:
 }
 
 bool
+wegl_pbuffer_init(struct wegl_surface *surf,
+  struct wcore_config *wc_config,
+  int32_t width, int32_t height)
+{
+struct wegl_config *config = wegl_config(wc_config);
+struct wegl_display *dpy = wegl_display(wc_config->display);
+struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
+bool ok;
+
+ok = wcore_window_init(>wcore, wc_config);
+if (!ok)
+goto fail;
+
+// Note on pbuffers and double-buffering: The EGL spec says that pbuffers
+// are single-buffered.  But the spec also says that EGL_RENDER_BUFFER is
+// always EGL_BACK_BUFFER for pbuffers. Because EGL is weird in its
+// specification of pbuffers; and because most Piglit tests requests
+// double-buffering (and we don't want to break Piglit); allow creation of
+// pbuffers even if the user requested double-buffering.
+(void) config->wcore.attrs.double_buffered;
+
+EGLint attrib_list[] = {
+EGL_WIDTH, width,
+EGL_HEIGHT, height,
+EGL_NONE,
+};
+
+surf->egl = plat->eglCreatePbufferSurface(dpy->egl, config->egl,
+  attrib_list);
+if (!surf->egl) {
+wegl_emit_error(plat, "eglCreatePbufferSurface");
+goto fail;
+}
+
+return true;
+
+fail:
+wegl_surface_teardown(surf);
+return false;
+}
+
+bool
 wegl_surface_teardown(struct wegl_surface *surf)
 {
 struct wegl_display *dpy = wegl_display(surf->wcore.display);
diff --git a/src/waffle/egl/wegl_surface.h b/src/waffle/egl/wegl_surface.h
index b107423..51835c4 100644
--- a/src/waffle/egl/wegl_surface.h
+++ b/src/waffle/egl/wegl_surface.h
@@ -51,6 +51,11 @@ wegl_window_init(struct wegl_surface *surf,
  intptr_t native_window);
 
 bool
+wegl_pbuffer_init(struct wegl_surface *surf,
+  struct wcore_config *wc_config,
+  int32_t width, int32_t height);
+
+bool
 wegl_surface_teardown(struct wegl_surface *surf);
 
 bool
-- 
2.10.0

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


[waffle] [PATCH 6/7] wflinfo: Support --platform=surfaceless_egl

2016-10-18 Thread Chad Versace
Cc: Gurchetan Singh 
Cc: Haixia Shi 
---
 man/wflinfo.1.xml   | 1 +
 src/utils/wflinfo.c | 5 -
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/man/wflinfo.1.xml b/man/wflinfo.1.xml
index a1c2589..2f54aaa 100644
--- a/man/wflinfo.1.xml
+++ b/man/wflinfo.1.xml
@@ -75,6 +75,7 @@
   cgl
   gbm
   glx
+  surfaceless_egl (or short alias 'sl')
   wayland
   wgl
   x11_egl
diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
index af5d0b1..a3752d8 100644
--- a/src/utils/wflinfo.c
+++ b/src/utils/wflinfo.c
@@ -64,7 +64,8 @@ static const char *usage_message =
 "\n"
 "Required Parameters:\n"
 "-p, --platform \n"
-"One of: android, cgl, gbm, glx, wayland, wgl or x11_egl\n"
+"One of: android, cgl, gbm, glx, surfaceless_egl (or short\n"
+"alias 'sl'), wayland, wgl, or x11_egl.\n"
 "\n"
 "-a, --api \n"
 "One of: gl, gles1, gles2 or gles3\n"
@@ -289,6 +290,8 @@ static const struct enum_map platform_map[] = {
 {WAFFLE_PLATFORM_WAYLAND,   "wayland"   },
 {WAFFLE_PLATFORM_WGL,   "wgl"   },
 {WAFFLE_PLATFORM_X11_EGL,   "x11_egl"   },
+{WAFFLE_PLATFORM_SURFACELESS_EGL,   "surfaceless_egl" },
+{WAFFLE_PLATFORM_SURFACELESS_EGL,   "sl"  },
 {0, 0   },
 };
 
-- 
2.10.0

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


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

2016-10-18 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*.
---
 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(>wegl, wc_plat,
-   (intptr_t) EGL_DEFAULT_DISPLAY);
+ok = wegl_display_init(>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(>wegl, wc_plat, (intptr_t) self->gbm_device);
+ok = wegl_display_init(>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(>wegl, wc_plat, (intptr_t) self->wl_display);
+ok = wegl_display_init(>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(>wegl, wc_plat, (intptr_t) self->x11.xlib);
+ok = wegl_display_init(>wegl, wc_plat, self->x11.xlib);
 if (!ok)
 goto error;
 
-- 
2.10.0

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


[waffle] [PATCH 0/7] Use eglGetPlatformDisplay when possible

2016-10-18 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-v01

Chad Versace (7):
  egl: Define EGL_PLATFORM_* enums
  egl: Update wegl_platform_init signature
  egl: Move each platform's setenv("EGL_PLATFORM") into core EGL code
  egl: Query client extensions string
  egl: Optionally dlsym eglGetPlatformDisplay
  egl: Update wegl_display_init signature
  egl: Use eglGetPlatformDisplay when possible

 src/waffle/android/droid_display.c|  3 +-
 src/waffle/egl/wegl_display.c | 24 +---
 src/waffle/egl/wegl_display.h |  2 +-
 src/waffle/egl/wegl_imports.h | 30 ++
 src/waffle/egl/wegl_platform.c| 73 ++-
 src/waffle/egl/wegl_platform.h| 22 ++-
 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, 150 insertions(+), 33 deletions(-)

-- 
2.10.0

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


[waffle] [PATCH 7/7] egl: Use eglGetPlatformDisplay when possible

2016-10-18 Thread Chad Versace
Tested against Mesa master@8c78fdb with `ninja check-func` on Linux.
---
 src/waffle/egl/wegl_display.c  | 22 ++
 src/waffle/egl/wegl_platform.c | 35 +--
 src/waffle/egl/wegl_platform.h |  8 
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index 7a7986c..c924f2a 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -104,10 +104,24 @@ 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)) {
+void *fixed_native_dpy = native_display;
+if (plat->egl_platform == EGL_PLATFORM_X11_KHR)
+fixed_native_dpy = _display;
+
+dpy->egl = plat->eglGetPlatformDisplay(plat->egl_platform,
+   fixed_native_dpy,
+   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, >major_version, 
>minor_version);
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 669fe38..71eb29e 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -65,7 +65,8 @@ wegl_platform_teardown(struct wegl_platform *self)
 bool ok = true;
 int error = 0;
 
-unsetenv("EGL_PLATFORM");
+if (!wegl_platform_can_use_eglGetPlatformDisplay(self))
+unsetenv("EGL_PLATFORM");
 
 if (self->eglHandle) {
 error = dlclose(self->eglHandle);
@@ -149,10 +150,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.0

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


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

2016-10-18 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.
---
 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(>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(>wegl);
+ok = wegl_platform_init(>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(>wegl);
+ok = wegl_platform_init(>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(>wegl);
+ok = wegl_platform_init(>wegl, EGL_PLATFORM_X11_KHR);
 if (!ok)
 goto error;
 
-- 
2.10.0

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


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

2016-10-18 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().
---
 src/waffle/egl/wegl_platform.c| 28 
 src/waffle/gbm/wgbm_platform.c|  6 --
 src/waffle/wayland/wayland_platform.c |  5 -
 src/waffle/xegl/xegl_platform.c   |  6 --
 4 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 7f030bd..d6734ee 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,36 @@ 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:
+setenv("EGL_PLATFORM", "android", true);
+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;
 
+unsetenv("EGL_PLATFORM");
+
 if (self->eglHandle) {
 error = dlclose(self->eglHandle);
 if (error) {
@@ -114,6 +140,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 = _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 = _platform_vtbl;
 return >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)
 ok &= linux_platform_destroy(self->linux);
 
@@ -79,8 +75,6 @@ xegl_platform_create(void)
 if (!self->linux)
 goto error;
 
-setenv("EGL_PLATFORM", "x11", true);
-
 self->wegl.wcore.vtbl = _platform_vtbl;
 return 

[waffle] [PATCH 4/7] cmake: Add option waffle_has_surfaceless_egl

2016-10-18 Thread Chad Versace
This patch contains just the CMake changes for the new surfaceless_egl
platform. Code will come in the following patches.

Cc: Gurchetan Singh 
Cc: Haixia Shi 
---
 Options.cmake   |  3 +++
 cmake/Modules/WaffleDefineCompilerFlags.cmake   |  4 
 cmake/Modules/WaffleDefineInternalOptions.cmake |  3 ++-
 cmake/Modules/WafflePrintConfigurationSummary.cmake |  3 +++
 cmake/Modules/WaffleValidateOptions.cmake   | 15 ++-
 5 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/Options.cmake b/Options.cmake
index 4f097a0..699ec59 100644
--- a/Options.cmake
+++ b/Options.cmake
@@ -23,11 +23,14 @@ if(waffle_on_linux)
 set(gbm_default OFF)
 endif()
 
+set(surfaceless_egl_default ${egl_FOUND})
+
 # On Linux, you must enable at least one of the below options.
 option(waffle_has_glx "Build support for GLX" ${glx_default})
 option(waffle_has_wayland "Build support for Wayland" ${wayland_default})
 option(waffle_has_x11_egl "Build support for X11/EGL" ${x11_egl_default})
 option(waffle_has_gbm "Build support for GBM" ${gbm_default})
+option(waffle_has_surfaceless_egl "Build support for 
EGL_MESA_platform_surfaceless" ${surfaceless_egl_default})
 option(waffle_has_nacl "Build support for NaCl" OFF)
 
 # NaCl specific settings.
diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake 
b/cmake/Modules/WaffleDefineCompilerFlags.cmake
index 7b67325..4eb4392 100644
--- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
+++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
@@ -122,6 +122,10 @@ if(waffle_on_linux)
 add_definitions(-DWAFFLE_HAS_GBM)
 endif()
 
+if(waffle_has_surfaceless_egl)
+add_definitions(-DWAFFLE_HAS_SURFACELESS_EGL)
+endif()
+
 if(waffle_has_tls)
 add_definitions(-DWAFFLE_HAS_TLS)
 endif()
diff --git a/cmake/Modules/WaffleDefineInternalOptions.cmake 
b/cmake/Modules/WaffleDefineInternalOptions.cmake
index 3ef7a25..b3a4f7b 100644
--- a/cmake/Modules/WaffleDefineInternalOptions.cmake
+++ b/cmake/Modules/WaffleDefineInternalOptions.cmake
@@ -1,4 +1,5 @@
-if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm)
+if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm OR
+   waffle_has_surfaceless_egl)
 set(waffle_has_egl TRUE)
 else(waffle_has_wayland OR waffle_has_x11_egl)
 set(waffle_has_egl FALSE)
diff --git a/cmake/Modules/WafflePrintConfigurationSummary.cmake 
b/cmake/Modules/WafflePrintConfigurationSummary.cmake
index 1199ea3..f36555c 100644
--- a/cmake/Modules/WafflePrintConfigurationSummary.cmake
+++ b/cmake/Modules/WafflePrintConfigurationSummary.cmake
@@ -47,6 +47,9 @@ endif()
 if(waffle_has_gbm)
 message("gbm")
 endif()
+if(waffle_has_surfaceless_egl)
+message("surfaceless_egl")
+endif()
 if(waffle_on_windows)
 message("wgl")
 endif()
diff --git a/cmake/Modules/WaffleValidateOptions.cmake 
b/cmake/Modules/WaffleValidateOptions.cmake
index 1275463..8f83338 100644
--- a/cmake/Modules/WaffleValidateOptions.cmake
+++ b/cmake/Modules/WaffleValidateOptions.cmake
@@ -47,12 +47,14 @@ endif()
 if(waffle_on_linux)
 if(NOT waffle_has_glx AND NOT waffle_has_wayland AND
NOT waffle_has_x11_egl AND NOT waffle_has_gbm AND
+   NOT waffle_has_surfaceless_egl AND
NOT waffle_has_nacl)
 message(FATAL_ERROR
 "Must enable at least one of: "
 "waffle_has_glx, waffle_has_wayland, "
 "waffle_has_x11_egl, waffle_has_gbm, "
-"waffle_has_nacl.")
+"waffle_has_surfaceless_egl, "
+"waffle_has_nacl")
 endif()
 if(waffle_has_nacl)
 if(NOT EXISTS ${nacl_sdk_path})
@@ -149,6 +151,11 @@ if(waffle_on_linux)
 message(FATAL_ERROR "x11_egl dependency is missing: 
${x11_egl_missing_deps}")
 endif()
 endif()
+if(waffle_has_surfaceless_egl)
+if(NOT egl_FOUND)
+message(FATAL_ERROR "surfaceless_egl dependency is missing: egl")
+endif()
+endif()
 elseif(waffle_on_mac)
 if(waffle_has_gbm)
 message(FATAL_ERROR "Option is not supported on Darwin: 
waffle_has_gbm.")
@@ -162,6 +169,9 @@ elseif(waffle_on_mac)
 if(waffle_has_x11_egl)
 message(FATAL_ERROR "Option is not supported on Darwin: 
waffle_has_x11_egl.")
 endif()
+if(waffle_has_surfaceless_egl)
+message(FATAL_ERROR "Option is not supported on Darwin: 
waffle_has_surfaceless_egl.")
+endif()
 elseif(waffle_on_windows)
 if(waffle_has_gbm)
 message(FATAL_ERROR "Option is not supported on Windows: 
waffle_has_gbm.")
@@ -175,4 +185,7 @@ elseif(waffle_on_windows)
 if(waffle_has_x11_egl)
 message(FATAL_ERROR "Option is not supported on Windows: 
waffle_has_x11_egl.")
 endif()
+if(waffle_has_surfaceless_egl)
+message(FATAL_ERROR "Option is not supported on Darwin: 

[waffle] [PATCH 1/7] egl: Rename files wegl_window.* -> wegl_surface.*

2016-10-18 Thread Chad Versace
Today, the EGLSurface belonging to struct wegl_window (and, post-patch,
struct wegl_surface) is always created with eglCreateWindowSurface. But
future patches will extend it to allow the EGLSurface to be a pbuffer.
Hence the rename, to reduce confusion.

This patch renames the files. The next patch renames the symbols.
---
 Android.mk   | 2 +-
 src/waffle/CMakeLists.txt| 2 +-
 src/waffle/android/droid_window.h| 2 +-
 src/waffle/egl/{wegl_window.c => wegl_surface.c} | 2 +-
 src/waffle/egl/{wegl_window.h => wegl_surface.h} | 0
 src/waffle/egl/wegl_util.c   | 2 +-
 src/waffle/gbm/wgbm_window.h | 2 +-
 src/waffle/wayland/wayland_window.h  | 2 +-
 src/waffle/xegl/xegl_window.h| 2 +-
 9 files changed, 8 insertions(+), 8 deletions(-)
 rename src/waffle/egl/{wegl_window.c => wegl_surface.c} (99%)
 rename src/waffle/egl/{wegl_window.h => wegl_surface.h} (100%)

diff --git a/Android.mk b/Android.mk
index abfe4ff..d3fda69 100644
--- a/Android.mk
+++ b/Android.mk
@@ -82,7 +82,7 @@ LOCAL_SRC_FILES := \
 src/waffle/egl/wegl_display.c \
 src/waffle/egl/wegl_platform.c \
 src/waffle/egl/wegl_util.c \
-src/waffle/egl/wegl_window.c \
+src/waffle/egl/wegl_surface.c \
 src/waffle/android/droid_platform.c \
 src/waffle/android/droid_display.c \
 src/waffle/android/droid_window.c \
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index dd9fa11..9150f7d 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -102,7 +102,7 @@ if(waffle_has_egl)
 egl/wegl_display.c
 egl/wegl_platform.c
 egl/wegl_util.c
-egl/wegl_window.c
+egl/wegl_surface.c
 )
 endif()
 
diff --git a/src/waffle/android/droid_window.h 
b/src/waffle/android/droid_window.h
index deaec01..4067c98 100644
--- a/src/waffle/android/droid_window.h
+++ b/src/waffle/android/droid_window.h
@@ -27,7 +27,7 @@
 
 #include 
 
-#include "wegl_window.h"
+#include "wegl_surface.h"
 
 struct wcore_platform;
 
diff --git a/src/waffle/egl/wegl_window.c b/src/waffle/egl/wegl_surface.c
similarity index 99%
rename from src/waffle/egl/wegl_window.c
rename to src/waffle/egl/wegl_surface.c
index 753fd2f..961c0bb 100644
--- a/src/waffle/egl/wegl_window.c
+++ b/src/waffle/egl/wegl_surface.c
@@ -28,7 +28,7 @@
 #include "wegl_imports.h"
 #include "wegl_platform.h"
 #include "wegl_util.h"
-#include "wegl_window.h"
+#include "wegl_surface.h"
 
 /// On Linux, according to eglplatform.h, EGLNativeDisplayType and intptr_t
 /// have the same size regardless of platform.
diff --git a/src/waffle/egl/wegl_window.h b/src/waffle/egl/wegl_surface.h
similarity index 100%
rename from src/waffle/egl/wegl_window.h
rename to src/waffle/egl/wegl_surface.h
diff --git a/src/waffle/egl/wegl_util.c b/src/waffle/egl/wegl_util.c
index 81fdbd9..6b4f90e 100644
--- a/src/waffle/egl/wegl_util.c
+++ b/src/waffle/egl/wegl_util.c
@@ -30,7 +30,7 @@
 #include "wegl_imports.h"
 #include "wegl_platform.h"
 #include "wegl_util.h"
-#include "wegl_window.h"
+#include "wegl_surface.h"
 
 void
 wegl_emit_error(struct wegl_platform *plat, const char *egl_func_call)
diff --git a/src/waffle/gbm/wgbm_window.h b/src/waffle/gbm/wgbm_window.h
index 7827823..ed444b9 100644
--- a/src/waffle/gbm/wgbm_window.h
+++ b/src/waffle/gbm/wgbm_window.h
@@ -27,7 +27,7 @@
 
 #include 
 
-#include "wegl_window.h"
+#include "wegl_surface.h"
 
 struct wcore_platform;
 struct gbm_surface;
diff --git a/src/waffle/wayland/wayland_window.h 
b/src/waffle/wayland/wayland_window.h
index 11e6791..1893623 100644
--- a/src/waffle/wayland/wayland_window.h
+++ b/src/waffle/wayland/wayland_window.h
@@ -32,7 +32,7 @@
 #include "wcore_window.h"
 #include "wcore_util.h"
 
-#include "wegl_window.h"
+#include "wegl_surface.h"
 
 struct wcore_platform;
 
diff --git a/src/waffle/xegl/xegl_window.h b/src/waffle/xegl/xegl_window.h
index e59c02f..d994897 100644
--- a/src/waffle/xegl/xegl_window.h
+++ b/src/waffle/xegl/xegl_window.h
@@ -32,7 +32,7 @@
 
 #include "x11_window.h"
 
-#include "wegl_window.h"
+#include "wegl_surface.h"
 
 struct wcore_platform;
 
-- 
2.10.0

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


[waffle] [PATCH 2/7] egl: Rename struct wegl_window -> wegl_surface

2016-10-18 Thread Chad Versace
Today, the EGLSurface belonging to struct wegl_window (and, post-patch,
struct wegl_surface) is always created with eglCreateWindowSurface. But
future patches will extend it to allow the EGLSurface to be a pbuffer.
Hence the rename, to reduce confusion.
---
 src/waffle/android/droid_platform.c |  2 +-
 src/waffle/android/droid_window.c   |  2 +-
 src/waffle/android/droid_window.h   |  4 ++--
 src/waffle/egl/wegl_surface.c   | 35 +--
 src/waffle/egl/wegl_surface.h   | 12 ++--
 src/waffle/egl/wegl_util.c  |  2 +-
 src/waffle/gbm/wgbm_window.c|  4 ++--
 src/waffle/gbm/wgbm_window.h|  4 ++--
 src/waffle/wayland/wayland_window.c |  4 ++--
 src/waffle/wayland/wayland_window.h |  4 ++--
 src/waffle/xegl/xegl_platform.c |  2 +-
 src/waffle/xegl/xegl_window.c   |  2 +-
 src/waffle/xegl/xegl_window.h   |  4 ++--
 13 files changed, 40 insertions(+), 41 deletions(-)

diff --git a/src/waffle/android/droid_platform.c 
b/src/waffle/android/droid_platform.c
index bbf2b14..eb1407f 100644
--- a/src/waffle/android/droid_platform.c
+++ b/src/waffle/android/droid_platform.c
@@ -133,7 +133,7 @@ static const struct wcore_platform_vtbl droid_platform_vtbl 
= {
 .create = droid_window_create,
 .destroy = droid_window_destroy,
 .show = droid_window_show,
-.swap_buffers = wegl_window_swap_buffers,
+.swap_buffers = wegl_surface_swap_buffers,
 .resize = droid_window_resize,
 .get_native = NULL,
 },
diff --git a/src/waffle/android/droid_window.c 
b/src/waffle/android/droid_window.c
index 048a2bb..41def73 100644
--- a/src/waffle/android/droid_window.c
+++ b/src/waffle/android/droid_window.c
@@ -93,7 +93,7 @@ droid_window_destroy(struct wcore_window *wc_self)
 
 dpy = droid_display(self->wegl.wcore.display);
 
-ok &= wegl_window_teardown(>wegl);
+ok &= wegl_surface_teardown(>wegl);
 droid_destroy_surface(dpy->pSFContainer, self->pANWContainer);
 free(self);
 return ok;
diff --git a/src/waffle/android/droid_window.h 
b/src/waffle/android/droid_window.h
index 4067c98..5eb3ed7 100644
--- a/src/waffle/android/droid_window.h
+++ b/src/waffle/android/droid_window.h
@@ -34,14 +34,14 @@ struct wcore_platform;
 struct droid_window {
 /// Used by droid_surfaceflinger.cpp.
 struct droid_ANativeWindow_container *pANWContainer;
-struct wegl_window wegl;
+struct wegl_surface wegl;
 };
 
 static inline struct droid_window*
 droid_window(struct wcore_window *wc_self)
 {
 if (wc_self) {
-struct wegl_window *wegl_self = container_of(wc_self, struct 
wegl_window, wcore);
+struct wegl_surface *wegl_self = container_of(wc_self, struct 
wegl_surface, wcore);
 return container_of(wegl_self, struct droid_window, wegl);
 }
 else {
diff --git a/src/waffle/egl/wegl_surface.c b/src/waffle/egl/wegl_surface.c
index 961c0bb..ccd0799 100644
--- a/src/waffle/egl/wegl_surface.c
+++ b/src/waffle/egl/wegl_surface.c
@@ -33,7 +33,7 @@
 /// On Linux, according to eglplatform.h, EGLNativeDisplayType and intptr_t
 /// have the same size regardless of platform.
 bool
-wegl_window_init(struct wegl_window *window,
+wegl_window_init(struct wegl_surface *surf,
  struct wcore_config *wc_config,
  intptr_t native_window)
 {
@@ -43,7 +43,7 @@ wegl_window_init(struct wegl_window *window,
 EGLint egl_render_buffer;
 bool ok;
 
-ok = wcore_window_init(>wcore, wc_config);
+ok = wcore_window_init(>wcore, wc_config);
 if (!ok)
 goto fail;
 
@@ -57,12 +57,11 @@ wegl_window_init(struct wegl_window *window,
 EGL_NONE,
 };
 
-window->egl = plat->eglCreateWindowSurface(dpy->egl,
-   config->egl,
-   (EGLNativeWindowType)
-   native_window,
-   attrib_list);
-if (!window->egl) {
+surf->egl =
+plat->eglCreateWindowSurface(dpy->egl, config->egl,
+ (EGLNativeWindowType) native_window,
+ attrib_list);
+if (!surf->egl) {
 wegl_emit_error(plat, "eglCreateWindowSurface");
 goto fail;
 }
@@ -70,37 +69,37 @@ wegl_window_init(struct wegl_window *window,
 return true;
 
 fail:
-wegl_window_teardown(window);
+wegl_surface_teardown(surf);
 return false;
 }
 
 bool
-wegl_window_teardown(struct wegl_window *window)
+wegl_surface_teardown(struct wegl_surface *surf)
 {
-struct wegl_display *dpy = wegl_display(window->wcore.display);
+struct wegl_display *dpy = wegl_display(surf->wcore.display);
 struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
 bool result = true;
 
-if (window->egl) {
-bool ok = plat->eglDestroySurface(dpy->egl, window->egl);
+if (surf->egl) {
+

[waffle] [PATCH 7/7] tests/gl_basic_test: Support platform surfaceless_egl

2016-10-18 Thread Chad Versace
Run with `bin/gl_basic_test --platform=surfaceless_egl`.

All the tests fail! The rgba pixels returned by glReadPixels are
black (0x0, 0x0, 0x0, 0xff), but the test expects magenta (0xff, 0x0,
0xff, 0xff). I don't know why.

Cc: Gurchetan Singh 
Cc: Haixia Shi 
---
 tests/functional/gl_basic_test.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 4a90dfd..c3c7774 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -703,6 +703,17 @@ CREATE_TESTSUITE(WAFFLE_PLATFORM_GLX, glx)
 
 #endif // WAFFLE_HAS_GLX
 
+#ifdef WAFFLE_HAS_SURFACELESS_EGL
+
+#define unit_test_make(name)\
+cmocka_unit_test_setup_teardown(name, setup_surfaceless_egl, gl_basic_fini)
+
+CREATE_TESTSUITE(WAFFLE_PLATFORM_SURFACELESS_EGL, surfaceless_egl)
+
+#undef unit_test_make
+
+#endif // WAFFLE_HAS_GBM
+
 #ifdef WAFFLE_HAS_WAYLAND
 
 #define unit_test_make(name)\
@@ -819,6 +830,8 @@ static const struct enum_map platform_map[] = {
 {WAFFLE_PLATFORM_WAYLAND,   "wayland"   },
 {WAFFLE_PLATFORM_WGL,   "wgl"   },
 {WAFFLE_PLATFORM_X11_EGL,   "x11_egl"   },
+{WAFFLE_PLATFORM_SURFACELESS_EGL,   "surfaceless_egl"   },
+{WAFFLE_PLATFORM_SURFACELESS_EGL,   "sl"},
 {0, 0   },
 };
 
@@ -923,6 +936,10 @@ main(int argc, char *argv[])
 case WAFFLE_PLATFORM_GLX:
 return testsuite_glx();
 #endif
+#ifdef WAFFLE_HAS_SURFACELESS_EGL
+case WAFFLE_PLATFORM_SURFACELESS_EGL:
+return testsuite_surfaceless_egl();
+#endif
 #ifdef WAFFLE_HAS_WAYLAND
 case WAFFLE_PLATFORM_WAYLAND:
 return testsuite_wayland();
-- 
2.10.0

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


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

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

Prepares for eventual use of eglGetPlatformDisplay.
---
 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 d6734ee..8ce0a7b 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -140,6 +140,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.0

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


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

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

Define the enums to prevent the Waffle build from breaking against old
headers... like Ubuntu LTS.
---
 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.0

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


Re: [waffle] [PATCH 7/7] egl: Use eglGetPlatformDisplay when possible

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 17:58, Chad Versace  wrote:
> Tested against Mesa master@8c78fdb with `ninja check-func` on Linux.
> ---
>  src/waffle/egl/wegl_display.c  | 22 ++
>  src/waffle/egl/wegl_platform.c | 35 +--
>  src/waffle/egl/wegl_platform.h |  8 
>  3 files changed, 59 insertions(+), 6 deletions(-)
>
> diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
> index 7a7986c..c924f2a 100644
> --- a/src/waffle/egl/wegl_display.c
> +++ b/src/waffle/egl/wegl_display.c
> @@ -104,10 +104,24 @@ 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)) {
> +void *fixed_native_dpy = native_display;
> +if (plat->egl_platform == EGL_PLATFORM_X11_KHR)
> +fixed_native_dpy = _display;
> +
Silly question: wasn't the fixup applicable only for the window/pixmap surface ?


> +dpy->egl = plat->eglGetPlatformDisplay(plat->egl_platform,
> +   fixed_native_dpy,
> +   NULL);
> +if (!dpy->egl) {
> +wegl_emit_error(plat, "eglGetPlatformDisplay");
> +goto fail;
> +}
Wondering if falling back to eglGetDisplay() is a smart idea in this case?
How about EGL_EXT_platform_base/eglGetPlatformDisplayEXT (admittedly
there's no support for it atm, but it's trivial to do so) ?

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


Re: [waffle] [PATCH 4/7] cmake: Add option waffle_has_surfaceless_egl

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 18:33, Chad Versace  wrote:
> This patch contains just the CMake changes for the new surfaceless_egl
> platform. Code will come in the following patches.
>
> Cc: Gurchetan Singh 
> Cc: Haixia Shi 
> ---
>  Options.cmake   |  3 +++
>  cmake/Modules/WaffleDefineCompilerFlags.cmake   |  4 
>  cmake/Modules/WaffleDefineInternalOptions.cmake |  3 ++-
>  cmake/Modules/WafflePrintConfigurationSummary.cmake |  3 +++
>  cmake/Modules/WaffleValidateOptions.cmake   | 15 ++-
>  5 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/Options.cmake b/Options.cmake
> index 4f097a0..699ec59 100644
> --- a/Options.cmake
> +++ b/Options.cmake
> @@ -23,11 +23,14 @@ if(waffle_on_linux)
>  set(gbm_default OFF)
>  endif()
>
> +set(surfaceless_egl_default ${egl_FOUND})
> +
>  # On Linux, you must enable at least one of the below options.
>  option(waffle_has_glx "Build support for GLX" ${glx_default})
>  option(waffle_has_wayland "Build support for Wayland" ${wayland_default})
>  option(waffle_has_x11_egl "Build support for X11/EGL" ${x11_egl_default})
>  option(waffle_has_gbm "Build support for GBM" ${gbm_default})
> +option(waffle_has_surfaceless_egl "Build support for 
> EGL_MESA_platform_surfaceless" ${surfaceless_egl_default})
>  option(waffle_has_nacl "Build support for NaCl" OFF)
>
>  # NaCl specific settings.
> diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake 
> b/cmake/Modules/WaffleDefineCompilerFlags.cmake
> index 7b67325..4eb4392 100644
> --- a/cmake/Modules/WaffleDefineCompilerFlags.cmake
> +++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake
> @@ -122,6 +122,10 @@ if(waffle_on_linux)
>  add_definitions(-DWAFFLE_HAS_GBM)
>  endif()
>
> +if(waffle_has_surfaceless_egl)
> +add_definitions(-DWAFFLE_HAS_SURFACELESS_EGL)
> +endif()
> +
>  if(waffle_has_tls)
>  add_definitions(-DWAFFLE_HAS_TLS)
>  endif()
> diff --git a/cmake/Modules/WaffleDefineInternalOptions.cmake 
> b/cmake/Modules/WaffleDefineInternalOptions.cmake
> index 3ef7a25..b3a4f7b 100644
> --- a/cmake/Modules/WaffleDefineInternalOptions.cmake
> +++ b/cmake/Modules/WaffleDefineInternalOptions.cmake
> @@ -1,4 +1,5 @@
> -if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm)
> +if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm OR
> +   waffle_has_surfaceless_egl)
>  set(waffle_has_egl TRUE)
>  else(waffle_has_wayland OR waffle_has_x11_egl)
IIRC expressions in the else statements are meaningless in cmake.

Can we drop the above one (which seems to be the only such case in
waffle) ? Be that here or as separate commit ?

>  set(waffle_has_egl FALSE)
> diff --git a/cmake/Modules/WafflePrintConfigurationSummary.cmake 
> b/cmake/Modules/WafflePrintConfigurationSummary.cmake
> index 1199ea3..f36555c 100644
> --- a/cmake/Modules/WafflePrintConfigurationSummary.cmake
> +++ b/cmake/Modules/WafflePrintConfigurationSummary.cmake
> @@ -47,6 +47,9 @@ endif()
>  if(waffle_has_gbm)
>  message("gbm")
>  endif()
> +if(waffle_has_surfaceless_egl)
> +message("surfaceless_egl")
> +endif()
>  if(waffle_on_windows)
>  message("wgl")
>  endif()
> diff --git a/cmake/Modules/WaffleValidateOptions.cmake 
> b/cmake/Modules/WaffleValidateOptions.cmake
> index 1275463..8f83338 100644
> --- a/cmake/Modules/WaffleValidateOptions.cmake
> +++ b/cmake/Modules/WaffleValidateOptions.cmake
> @@ -47,12 +47,14 @@ endif()
>  if(waffle_on_linux)
>  if(NOT waffle_has_glx AND NOT waffle_has_wayland AND
> NOT waffle_has_x11_egl AND NOT waffle_has_gbm AND
> +   NOT waffle_has_surfaceless_egl AND
> NOT waffle_has_nacl)
>  message(FATAL_ERROR
>  "Must enable at least one of: "
>  "waffle_has_glx, waffle_has_wayland, "
>  "waffle_has_x11_egl, waffle_has_gbm, "
> -"waffle_has_nacl.")
> +"waffle_has_surfaceless_egl, "
> +"waffle_has_nacl")
>  endif()
>  if(waffle_has_nacl)
>  if(NOT EXISTS ${nacl_sdk_path})
> @@ -149,6 +151,11 @@ if(waffle_on_linux)
>  message(FATAL_ERROR "x11_egl dependency is missing: 
> ${x11_egl_missing_deps}")
>  endif()
>  endif()
> +if(waffle_has_surfaceless_egl)
> +if(NOT egl_FOUND)
> +message(FATAL_ERROR "surfaceless_egl dependency is missing: egl")
> +endif()
> +endif()
I'm wondering if we cannot rework these (or the whole file in general)
to minimise the boilerplate.
Sadly no wise ideas come to mind :-(

>  elseif(waffle_on_mac)
>  if(waffle_has_gbm)
>  message(FATAL_ERROR "Option is not supported on Darwin: 
> waffle_has_gbm.")
> @@ -162,6 +169,9 @@ elseif(waffle_on_mac)
>  if(waffle_has_x11_egl)
>  message(FATAL_ERROR "Option is not 

Re: [waffle] [PATCH 5/7] surfaceless_egl: Implement new platform

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 18:33, Chad Versace  wrote:
> Now waffle_init() supports WAFFLE_PLATFORM_SURFACELESS_EGL.
>
> Cc: Gurchetan Singh 
> Cc: Haixia Shi 
> ---
>  include/waffle/waffle.h  |   1 +
>  man/waffle_init.3.xml|   9 ++
>  src/waffle/CMakeLists.txt|   9 ++
>  src/waffle/api/waffle_init.c |  12 +++
>  src/waffle/egl/wegl_platform.c   |   6 ++
>  src/waffle/surfaceless_egl/sl_display.c  |  70 +++
>  src/waffle/surfaceless_egl/sl_display.h  |  45 ++
>  src/waffle/surfaceless_egl/sl_platform.c | 144 
> +++
>  src/waffle/surfaceless_egl/sl_platform.h |  49 +++
>  src/waffle/surfaceless_egl/sl_window.c   |  92 
>  src/waffle/surfaceless_egl/sl_window.h   |  53 
>  11 files changed, 490 insertions(+)
>  create mode 100644 src/waffle/surfaceless_egl/sl_display.c
>  create mode 100644 src/waffle/surfaceless_egl/sl_display.h
>  create mode 100644 src/waffle/surfaceless_egl/sl_platform.c
>  create mode 100644 src/waffle/surfaceless_egl/sl_platform.h
>  create mode 100644 src/waffle/surfaceless_egl/sl_window.c
>  create mode 100644 src/waffle/surfaceless_egl/sl_window.h
>
Should there be an extra case in src/waffle/core/wcore_util.c's
wcore_enum_to_string() ?

> +// [chadv] I regret the design of the get_native interface, and wish to
> +// deprecate and replace it with the interface that Ian Romanick orignally
> +// recommended: waffle_display_get_egl_display(),
> +// waffle_display_get_gbm_device(), waffle_display_get_xlib_display(), etc.  
> As
> +// a first step towards that goal, I choose to not support the interface on 
> new
> +// platforms.
Silly question: what's wrong with the current [generic] get_native_{foo,bar} ?

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


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

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 17:58, Chad Versace  wrote:

> +case EGL_PLATFORM_ANDROID_KHR:
> +setenv("EGL_PLATFORM", "android", true);
> +break;
Thus hunk is a new addition. Can you please split it out ?

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


Re: [waffle] [PATCH 0/7] Use eglGetPlatformDisplay when possible

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 17:58, Chad Versace  wrote:
> 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-v01
>
> Chad Versace (7):
>   egl: Define EGL_PLATFORM_* enums
>   egl: Update wegl_platform_init signature
>   egl: Move each platform's setenv("EGL_PLATFORM") into core EGL code
>   egl: Query client extensions string
>   egl: Optionally dlsym eglGetPlatformDisplay
>   egl: Update wegl_display_init signature
>   egl: Use eglGetPlatformDisplay when possible
>
The questions in 5 and 7 are not blockers, by any means. Just please
split the Android change from 3.

With that (and the extra Android change itself) are
Reviewed-by: Emil Velikov 

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