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

2016-10-27 Thread Chad Versace
On Tue 25 Oct 2016, Emil Velikov wrote:
> On 24 October 2016 at 22:57, Chad Versace <chadvers...@chromium.org> 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-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
> >
> Cannot see 8/8 in the list, so I've check it via the repo.
> The lot looks great imho.
> 
> Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

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


[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 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(>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.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(>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.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 = _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)

[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


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

2016-10-19 Thread Chad Versace
On Wed 19 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 17:58, Chad Versace <chadvers...@chromium.org> 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 ?

Thanks! You're right.

> > +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) ?

I want to keep the old eglGetDisplay behavior. Otherwise, upgrading
Waffle would regress functionality on systems with old Mesa (thinking
about Ubunut LTS). And it's a no-no for upgrades to cause a gross
regression like that.

I agree that the fallback path should include eglGetPlatformDisplayEXT.
But the lack of eglGetPlatformDisplayEXT doesn't make the patch
incorrect. That can be done as a simple follow-up patch.

I'll submit a v2 in-reply-to. (But not now. I'll be off of work until
Monday).
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 5/7] egl: Optionally dlsym eglGetPlatformDisplay

2016-10-19 Thread Chad Versace
On Tue 18 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 17:58, Chad Versace <chadvers...@chromium.org> wrote:
> > +#define RETRIEVE_EGL_SYMBOL_OPTIONAL(function) \
> > +self->function = dlsym(self->eglHandle, #function);
> > +
> Not 100% sure if dlsym should be used here. Need to double-check if
> exposing the EGL 1.5 isn't "against the rules".

Yep. The patch needs fixing.

The spec says eglGetProcAddress must work on core EGL functions. dlsym
may work if the vendor chooses to support it.

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.

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


[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 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 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 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 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 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 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


[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 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 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 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 

Re: [waffle] [PATCH 1/2] Revert "wegl: add EGL image create/destroy"

2016-10-12 Thread Chad Versace
On Wed 12 Oct 2016, Emil Velikov wrote:
> On 11 October 2016 at 18:23, Chad Versace <chadvers...@chromium.org> wrote:
> > On Thu 21 Jul 2016, Emil Velikov wrote:

> >> Hi all, this is weird a reminder about getting null/surfaceless updated.
> >
> > I started working on this recently. There's also a pile of *new* patches
> > in the CrOS tree that need upstreaming.
> >
> Welcome back and thanks for getting these sorted!

Hello! I feel more settled at Google now, and am getting back into the
development flow.

> Hope you'll do a
> series here/github PR before pushing things :-)

Since people are still listening, I will :)

> Can I poke you for access about the github issues section ? IIRC
> there's a few that should be closed.

Hmm... I just (17:16:23 UTC) tried to giving you write access to the
Github Issues section. Let me know if it works. I admit that the Github
gui confounds me.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] egl: resolve build issue with pre EGL 1.5 headers

2016-10-11 Thread Chad Versace
On Fri 19 Aug 2016, Tapani Pälli wrote:
> 
> 
> On 08/18/2016 01:27 PM, Emil Velikov wrote:
> > On 20 July 2016 at 17:27, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> > > In some cases (like building on Android) the headers might not have the
> > > 1.5 definitions, leading to a build failures like the one in github
> > > issue #41.
> > > 
> > > Since the ABI is baked in stone, add a local define to resolve that.
> > > 
> > > Cc: Chad Versace <chad.vers...@intel.com>
> > > Fixes: f8a485e7cc7 ("egl: Improve support for robust GLES contexts on
> > > EGL 1.5")
> > > Issue: https://github.com/waffle-gl/waffle/issues/41
> > > Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
> > > ---
> > >  src/waffle/egl/wegl_context.c | 5 +
> > >  1 file changed, 5 insertions(+)
> > > 
> > > diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
> > > index 0e59231..97931fc 100644
> > > --- a/src/waffle/egl/wegl_context.c
> > > +++ b/src/waffle/egl/wegl_context.c
> > > @@ -34,6 +34,11 @@
> > >  #include "wegl_platform.h"
> > >  #include "wegl_util.h"
> > > 
> > > +// Pre EGL 1.5 headers lack the definition.
> > > +#ifndef EGL_CONTEXT_OPENGL_ROBUST_ACCESS
> > > +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS  0x31B2
> > > +#endif
> > > +
> > Humble poke ?
> 
> LGTM (checked that the values is correct):
> 
> Reviewed-by: Tapani Pälli <tapani.pa...@intel.com>

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


Re: [waffle] [PATCH] wayland: Wrap wl_proxy_marshal_constructor_versioned v2

2016-06-21 Thread Chad Versace
On Thu 14 Apr 2016, Michel Dänzer wrote:
> From: Michel Dänzer 
> 
> Fixes build failure due to wl_proxy_marshal_constructor_versioned being
> unresolved when building against current wayland.
> 
> This API was introduced in wayland 1.9.91 by commit 557032e3 ("Track
> protocol object versions inside wl_proxy."). The waffle code doesn't
> reference wl_proxy_marshal_constructor_versioned directly but
> indirectly via wayland-scanner.
> 
> v2:
> * Add paragraph about how wl_proxy_marshal_constructor_versioned was
>   introduced. (Emil Velikov)
> * Only resolve wl_proxy_marshal_constructor_versioned with wayland >=
>   1.9.91.
> 
> Signed-off-by: Michel Dänzer 
> ---
>  src/waffle/wayland/wayland_wrapper.c | 5 +
>  src/waffle/wayland/wayland_wrapper.h | 8 
>  2 files changed, 13 insertions(+)

Michel, thanks for the patch. It's merged to master.

I squashed a small fix into your patch: `#include `
was needed to make your version check work.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] wayland: Wrap wl_proxy_marshal_constructor_versioned v2

2016-06-21 Thread Chad Versace
On Mon 20 Jun 2016, Chad Versace wrote:
> On Sun 17 Apr 2016, Emil Velikov wrote:
> > On 17 April 2016 at 01:41, Jason Ekstrand <ja...@jlekstrand.net> wrote:
> > > On Sat, Apr 16, 2016 at 4:12 PM, Emil Velikov <emil.l.veli...@gmail.com>
> > > wrote:
> > >>
> > >> On 16 April 2016 at 22:06, Jason Ekstrand <ja...@jlekstrand.net> wrote:
> 
> > >> >> >> In either case, I think checking wayland-client-protocol.h into the
> > >> >> >> repo is
> > >> >> >> a must.
> > >> >> >
> > >> >> > I'm convinced.
> > >> >> Unfortunately I'm not ;'-(
> > >> >
> > >> >
> > >> > Are you now?
> > >> >
> > >> Not quite I'm afraid.
> > >>
> > >> As a queue, I'm doing to (slightly) beat the SDL drum.
> > >> SDL caters for everyone's needs and has a much wider exposure than
> > >> waffle. I'm suggesting the exact same approach like the one they opted
> > >> for ;-)
> > >
> > >
> > > I doubt its the "exact" same or they'd be having build breaks too.
> > They do actually [1]. The person who fixed it is familiar wayland
> > developer [2] yet he choose the same approach as me ;-)
> > 
> > > If you
> > > want to provide a sort of glue layer to an application, your suggestion of
> > > "optional" entrypoints is probably exactly what you want.
> > Indeed. Thank you.
> > 
> > >  However, waffle
> > > itself needs to call something and it either needs to be smart enough to
> > > call the right thing depending on the libwayland version it just dlopened 
> > > or
> > > it needs to just always call old ones.
> > >
> > The cases of waffle being "dumb" (not being smart enough) are so
> > infrequent, that it beats the added overhead that importing the header
> > will bring.
> > 
> > Thanks for the discussion. Hopefully you're seeing things from my POV ;-)
> > Emil
> > 
> > [1] 
> > https://github.com/spurious/SDL-mirror/tree/master/src/video/wayland/SDL_wayland{dyn.{c,h},sym.h}
> > [2] 
> > https://github.com/spurious/SDL-mirror/commit/737415012588a2636794292129a2d39f2a28fe3c
> 
> Both Jason's and Emil's approaches seem valid to me. And my preference
> flip-flops every few minutes as I read the thread.
> 
> In April, I was strongly convinced of Jason's position. Now I'm leaning
> slightly toward's Emil's.
> 
> I want to look more closely at SDL's approach (Emil, thanks for the
> links), and then make a final decision. But it's late in the day for me
> and my brain is done. Exhausted brains can't be trusted, so the decision
> will have to wait until morning.

Everyone, thanks for the lengthy discussion. The winner is... Michel's
patch v2, which is basically Emil's and SDL's position.

I decided against importing any Wayland headers, because the Wayland
headers actually contain a lot of inline function *definitions*. When
upstream Wayland applies bugfixes and improvements to those functions,
by not using imported headers Waffle automatically receives the bugfixes
and improvements simply by being rebuilt; this seems to be the intent of
the Wayland authors for client projects. If Waffle were to use imported
headers then, to receive the same improvements, someone (likely me)
would need to diligently keep the imported headers up-to-date.

As a bonus, Michel's patch is considerably smaller and requires less
maintenance than an import-some-headers patch.

And Michel's patch provides correct behavior, at least in my opinion:

- If a user or distro builds libwaffle against wayland < 1.10, then
  that same libwaffle will continue to work with wayland >= 1.10.

- If a user or distro builds libwaffle against wayland == 1.10, then
  the libwaffle will correctly emit an informative error message and
  fail if it dlopens a libwayland-client < 1.10, thanks to the 'goto
  error' in src/waffle/wayland/waylan_wrapper.c:RETRIEVE_WL_CLIENT_SYMBOL.
  Specifically, the libwaffle will not crash or do undefined
  behavior; it gracefully emits an error and fails responsibly.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] wayland: Wrap wl_proxy_marshal_constructor_versioned v2

2016-06-20 Thread Chad Versace
On Sun 17 Apr 2016, Emil Velikov wrote:
> On 17 April 2016 at 01:41, Jason Ekstrand  wrote:
> > On Sat, Apr 16, 2016 at 4:12 PM, Emil Velikov 
> > wrote:
> >>
> >> On 16 April 2016 at 22:06, Jason Ekstrand  wrote:
> >>
> >> >> Then again importing bits from other projects tend to be quite a nasty
> >> >> solution. The place where I borrowed the idea from (libSDL) does/did
> >> >> not imports the protocol.
> >> >
> >> >
> >> > I don't think this is as bad an idea as you seem to think.  I'll explain
> >> > a
> >> > bit further down.

[snip]

> >> >> >> In either case, I think checking wayland-client-protocol.h into the
> >> >> >> repo is
> >> >> >> a must.
> >> >> >
> >> >> > I'm convinced.
> >> >> Unfortunately I'm not ;'-(
> >> >
> >> >
> >> > Are you now?
> >> >
> >> Not quite I'm afraid.
> >>
> >> As a queue, I'm doing to (slightly) beat the SDL drum.
> >> SDL caters for everyone's needs and has a much wider exposure than
> >> waffle. I'm suggesting the exact same approach like the one they opted
> >> for ;-)
> >
> >
> > I doubt its the "exact" same or they'd be having build breaks too.
> They do actually [1]. The person who fixed it is familiar wayland
> developer [2] yet he choose the same approach as me ;-)
> 
> > If you
> > want to provide a sort of glue layer to an application, your suggestion of
> > "optional" entrypoints is probably exactly what you want.
> Indeed. Thank you.
> 
> >  However, waffle
> > itself needs to call something and it either needs to be smart enough to
> > call the right thing depending on the libwayland version it just dlopened or
> > it needs to just always call old ones.
> >
> The cases of waffle being "dumb" (not being smart enough) are so
> infrequent, that it beats the added overhead that importing the header
> will bring.
> 
> Thanks for the discussion. Hopefully you're seeing things from my POV ;-)
> Emil
> 
> [1] 
> https://github.com/spurious/SDL-mirror/tree/master/src/video/wayland/SDL_wayland{dyn.{c,h},sym.h}
> [2] 
> https://github.com/spurious/SDL-mirror/commit/737415012588a2636794292129a2d39f2a28fe3c

Both Jason's and Emil's approaches seem valid to me. And my preference
flip-flops every few minutes as I read the thread.

In April, I was strongly convinced of Jason's position. Now I'm leaning
slightly toward's Emil's.

I want to look more closely at SDL's approach (Emil, thanks for the
links), and then make a final decision. But it's late in the day for me
and my brain is done. Exhausted brains can't be trusted, so the decision
will have to wait until morning.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 06/12] wflinfo: add option for JSON output

2016-06-14 Thread Chad Versace
On Thu 21 Apr 2016, Frank Henigman wrote:
> On Fri, Apr 8, 2016 at 8:14 PM, Chad Versace <chad.vers...@intel.com> wrote:
> > On 01/06/2016 11:56 AM, Frank Henigman wrote:

> I really hope we can keep this simple.
> 
> I mentioned in the cover letter to this series that the next step is
> to gut wflinfo and translate json to the old format.  We can insert
> that after this patch if you like.  Option 1 is the nicest by far, if
> the translator is written in python.  It's just a few lines of code to
> read the json, plus a table that lists the correspondence between old
> format lines and json keys.  So we have some really simple C code to
> call the waffle api and get the json, and a really simple python
> script to translate to old format.  I've got this much roughed out.
> For maximum backward compatibility these two bits would be tied
> together by a script that accepts all the options currently accepted
> by wflinfo, i.e. we replace wflinfo with a script.  Which for
> portability is also written in python.  Yes this introduces a
> dependency on python to run wflinfo, but I doubt that's much of a
> problem.

I'm open to exploring that path. I just took a serious look at
wflinfo.c, and it's needless complex for the little job that it does. If
you could port it to Python, greatly reducing and simplifying the code,
I'd like to see that.

I've never used Python's C interface, so I look forward to learning
about it from your patches.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] json, approach 2, version 2

2016-06-14 Thread Chad Versace
On Thu 21 Apr 2016, Frank Henigman wrote:
> Thanks Emil and Chad for reviewing my json series.  All suggestions
> implemented in v2, except where I replied inline.  I'll hold off
> sending in case there's more back-and-forth over the first set of
> comments.  Would also be nice if Chad merged his get-current branch
> into master, as I use it in v2.

Hi Frank, I think now is a good time to send v2.

Since the patches are not on the list yet, I'll say a few comments here:

core: add JSON library
Overall, looks good. The only problem I see is
a potential buffer overflow in put().

waffle: add waffle_display_info_json()
For simplicity's sake, please drop the 'platform_too'
parameter to waffle_display_info_json(). Waffle should
return all the info, and the client the should ignore
any keys (such as platform-specific keys) that it does
not recognize.

The patch has some problems regarding "current-ness".
It says the new function "returns a JSON string
containing information about the current context on the
given display". As defined by EGL and GLX, though,
current-ness is a mapping of (thread) -> (display,
context, surfaces), and not a mapping of
(thread, display) -> (context, surfaces).

As a consequence, the waffle_display_info_json()
signature is incorrect because due to its 'display'
parameter. If the function has a display parameter, then
that allows the user to do undefined things such as
below:

struct waffle_display *dpy1 = ...;
struct waffle_display *ctx1 = ...;

struct waffle_display *dpy2 = ...;
struct waffle_display *ctx2 = ...;

waffle_make_current(dpy1, NULL, ctx1);
// use ctx1
waffle_make_current(dpy2, NULL, ctx2);
// use ctx2

// Now dpy2 and ctx2 are bound to the thread.
// So what should waffle_display_info_json() do
// when given dpy1?
waffle_display_info_json(dpy1);

wflinfo: another option for JSON output
As far as I can tell, the two JSON formats are identical
except for formatting, as they should be :). Since
they're identical, I don't understand the need to add
the new format 'json2'.

At the end of this patch series, your json is Waffle's
*real* json. So I expected this patch to remove Dylan's
json code from wflinfo.c and replace it with yours. Then
--format=json would return your json.

> When comparing my json output to the landed json output I noticed that
> the landed version omits the context flags found in the old format.
> Was that deliberate?  If so I'll remove it from my json.

It's an accident that wflinfo does not currently report the context
flags. I'd like to see them in the wflinfo output.

> Not sure if I did the right thing with glx info.  Seems like all three
> sections (server, client, common) show about the same list of
> extensions.  That can wait until I send v2, or if anyone wants to look
> now:
> https://github.com/fjhenigman/waffle/commit/b358ac50c00ce51fae6546b1e96c9adc32fcbdc7

As Emil said earlier: wflinfo should report all three sections, as they
do sometimes differ.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/2] tests/gl_basic: Make GL symbol queries more robust

2016-06-14 Thread Chad Versace
Again, with Emil's real email.

On Tue 14 Jun 2016, Chad Versace wrote:
> Emil, this patch fixes the regressions caused by your patch (still
> uncommitted):
> 
>   [PATCH 07/13] wegl: untangle dl_can_open() and support_api()
> 
> On Tue 14 Jun 2016, Chad Versace wrote:
> > The rules that dictate how to properly query a GL symbol are complex.
> > The rules depend on the OS, on the winsys API, and even on the
> > particular driver being used. The rules differ between EGL 1.4 and EGL
> > 1.5; differ between Linux, Windows, and Mac; and differ between Mesa and
> > Mali.
> > 
> > gl_basic_test didn't try very hard when querying a GL symbol. It tried
> > only dlsym. If dlsym failed, then the test failed.
> > 
> > Make gl_basic_test more robust by falling back to
> > waffle_get_proc_address() whenever dlsym fails.
> > 
> > Suggested-by: Emil Velikov <emil.l.veli...@collabora.co.uk>
> > Signed-off-by: Chad Versace <chad.vers...@intel.com>
> > ---
> >  tests/functional/gl_basic_test.c | 55 
> > +---
> >  1 file changed, 34 insertions(+), 21 deletions(-)
> > 
> > diff --git a/tests/functional/gl_basic_test.c 
> > b/tests/functional/gl_basic_test.c
> > index 7af2229..4a90dfd 100644
> > --- a/tests/functional/gl_basic_test.c
> > +++ b/tests/functional/gl_basic_test.c
> > @@ -169,19 +169,36 @@ teardown(void **state)
> >  return 0;
> >  }
> >  
> > -static int32_t
> > -libgl_from_context_api(int32_t waffle_context_api)
> > +// The rules that dictate how to properly query a GL symbol are complex. 
> > The
> > +// rules depend on the OS, on the winsys API, and even on the particular 
> > driver
> > +// being used. The rules differ between EGL 1.4 and EGL 1.5; differ between
> > +// Linux, Windows, and Mac; and differ between Mesa and Mali.
> > +//
> > +// This function hides that complexity with a naive heuristic: try, then 
> > try
> > +// again.
> > +static void *
> > +get_gl_symbol(enum waffle_enum context_api, const char *name)
> >  {
> > -switch (waffle_context_api) {
> > -case WAFFLE_CONTEXT_OPENGL: return WAFFLE_DL_OPENGL;
> > -case WAFFLE_CONTEXT_OPENGL_ES1: return WAFFLE_DL_OPENGL_ES1;
> > -case WAFFLE_CONTEXT_OPENGL_ES2: return WAFFLE_DL_OPENGL_ES2;
> > -case WAFFLE_CONTEXT_OPENGL_ES3: return WAFFLE_DL_OPENGL_ES3;
> > -
> > -default:
> > -assert_true(0);
> > -return 0;
> > +void *sym = NULL;
> > +enum waffle_enum dl = 0;
> > +
> > +switch (context_api) {
> > +case WAFFLE_CONTEXT_OPENGL: dl = WAFFLE_DL_OPENGL; break;
> > +case WAFFLE_CONTEXT_OPENGL_ES1: dl = WAFFLE_DL_OPENGL_ES1; break;
> > +case WAFFLE_CONTEXT_OPENGL_ES2: dl = WAFFLE_DL_OPENGL_ES2; break;
> > +case WAFFLE_CONTEXT_OPENGL_ES3: dl = WAFFLE_DL_OPENGL_ES3; break;
> > +default: assert_true(0); break;
> > +}
> > +
> > +if (waffle_dl_can_open(dl)) {
> > +sym = waffle_dl_sym(dl, name);
> >  }
> > +
> > +if (!sym) {
> > +sym = waffle_get_proc_address(name);
> > +}
> > +
> > +return sym;
> >  }
> >  
> >  static int
> > @@ -270,8 +287,6 @@ gl_basic_draw__(void **state, struct 
> > gl_basic_draw_args__ args)
> >  bool context_debug = args.debug;
> >  bool alpha = args.alpha;
> >  
> > -int32_t libgl;
> > -
> >  int32_t config_attrib_list[64];
> >  int i;
> >  
> > @@ -281,8 +296,6 @@ gl_basic_draw__(void **state, struct 
> > gl_basic_draw_args__ args)
> >  0,
> >  };
> >  
> > -libgl = libgl_from_context_api(waffle_context_api);
> > -
> >  i = 0;
> >  config_attrib_list[i++] = WAFFLE_CONTEXT_API;
> >  config_attrib_list[i++] = waffle_context_api;
> > @@ -353,12 +366,12 @@ gl_basic_draw__(void **state, struct 
> > gl_basic_draw_args__ args)
> >  }
> >  
> >  // Get OpenGL functions.
> > -assert_true(glClear = waffle_dl_sym(libgl, "glClear"));
> > -assert_true(glClearColor= waffle_dl_sym(libgl, "glClearColor"));
> > -assert_true(glGetError  = waffle_dl_sym(libgl, "glGetError"));
> > -assert_true(glGetIntegerv   = waffle_dl_sym(libgl, "glGetIntegerv"));
> > -assert_true(glReadPixels= waffle_dl_sym(libgl, "glReadPixels"));
> > -assert_true(glGetString

Re: [waffle] [PATCH 1/2] tests/gl_basic: Make GL symbol queries more robust

2016-06-14 Thread Chad Versace
Emil, this patch fixes the regressions caused by your patch (still
uncommitted):

  [PATCH 07/13] wegl: untangle dl_can_open() and support_api()

On Tue 14 Jun 2016, Chad Versace wrote:
> The rules that dictate how to properly query a GL symbol are complex.
> The rules depend on the OS, on the winsys API, and even on the
> particular driver being used. The rules differ between EGL 1.4 and EGL
> 1.5; differ between Linux, Windows, and Mac; and differ between Mesa and
> Mali.
> 
> gl_basic_test didn't try very hard when querying a GL symbol. It tried
> only dlsym. If dlsym failed, then the test failed.
> 
> Make gl_basic_test more robust by falling back to
> waffle_get_proc_address() whenever dlsym fails.
> 
> Suggested-by: Emil Velikov <emil.l.veli...@collabora.co.uk>
> Signed-off-by: Chad Versace <chad.vers...@intel.com>
> ---
>  tests/functional/gl_basic_test.c | 55 
> +---
>  1 file changed, 34 insertions(+), 21 deletions(-)
> 
> diff --git a/tests/functional/gl_basic_test.c 
> b/tests/functional/gl_basic_test.c
> index 7af2229..4a90dfd 100644
> --- a/tests/functional/gl_basic_test.c
> +++ b/tests/functional/gl_basic_test.c
> @@ -169,19 +169,36 @@ teardown(void **state)
>  return 0;
>  }
>  
> -static int32_t
> -libgl_from_context_api(int32_t waffle_context_api)
> +// The rules that dictate how to properly query a GL symbol are complex. The
> +// rules depend on the OS, on the winsys API, and even on the particular 
> driver
> +// being used. The rules differ between EGL 1.4 and EGL 1.5; differ between
> +// Linux, Windows, and Mac; and differ between Mesa and Mali.
> +//
> +// This function hides that complexity with a naive heuristic: try, then try
> +// again.
> +static void *
> +get_gl_symbol(enum waffle_enum context_api, const char *name)
>  {
> -switch (waffle_context_api) {
> -case WAFFLE_CONTEXT_OPENGL: return WAFFLE_DL_OPENGL;
> -case WAFFLE_CONTEXT_OPENGL_ES1: return WAFFLE_DL_OPENGL_ES1;
> -case WAFFLE_CONTEXT_OPENGL_ES2: return WAFFLE_DL_OPENGL_ES2;
> -case WAFFLE_CONTEXT_OPENGL_ES3: return WAFFLE_DL_OPENGL_ES3;
> -
> -default:
> -assert_true(0);
> -return 0;
> +void *sym = NULL;
> +enum waffle_enum dl = 0;
> +
> +switch (context_api) {
> +case WAFFLE_CONTEXT_OPENGL: dl = WAFFLE_DL_OPENGL; break;
> +case WAFFLE_CONTEXT_OPENGL_ES1: dl = WAFFLE_DL_OPENGL_ES1; break;
> +case WAFFLE_CONTEXT_OPENGL_ES2: dl = WAFFLE_DL_OPENGL_ES2; break;
> +case WAFFLE_CONTEXT_OPENGL_ES3: dl = WAFFLE_DL_OPENGL_ES3; break;
> +default: assert_true(0); break;
> +}
> +
> +if (waffle_dl_can_open(dl)) {
> +sym = waffle_dl_sym(dl, name);
>  }
> +
> +if (!sym) {
> +sym = waffle_get_proc_address(name);
> +}
> +
> +return sym;
>  }
>  
>  static int
> @@ -270,8 +287,6 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ 
> args)
>  bool context_debug = args.debug;
>  bool alpha = args.alpha;
>  
> -int32_t libgl;
> -
>  int32_t config_attrib_list[64];
>  int i;
>  
> @@ -281,8 +296,6 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ 
> args)
>  0,
>  };
>  
> -libgl = libgl_from_context_api(waffle_context_api);
> -
>  i = 0;
>  config_attrib_list[i++] = WAFFLE_CONTEXT_API;
>  config_attrib_list[i++] = waffle_context_api;
> @@ -353,12 +366,12 @@ gl_basic_draw__(void **state, struct 
> gl_basic_draw_args__ args)
>  }
>  
>  // Get OpenGL functions.
> -assert_true(glClear = waffle_dl_sym(libgl, "glClear"));
> -assert_true(glClearColor= waffle_dl_sym(libgl, "glClearColor"));
> -assert_true(glGetError  = waffle_dl_sym(libgl, "glGetError"));
> -assert_true(glGetIntegerv   = waffle_dl_sym(libgl, "glGetIntegerv"));
> -assert_true(glReadPixels= waffle_dl_sym(libgl, "glReadPixels"));
> -assert_true(glGetString = waffle_dl_sym(libgl, "glGetString"));
> +assert_true(glClear = get_gl_symbol(waffle_context_api, 
> "glClear"));
> +assert_true(glClearColor= get_gl_symbol(waffle_context_api, 
> "glClearColor"));
> +assert_true(glGetError  = get_gl_symbol(waffle_context_api, 
> "glGetError"));
> +assert_true(glGetIntegerv   = get_gl_symbol(waffle_context_api, 
> "glGetIntegerv"));
> +assert_true(glReadPixels= get_gl_symbol(waffle_context_api, 
> "glReadPixels"));
> +assert_true(glGetString = get_gl_symbol(waffle_context_api, 
> "glGetString"));
>  
>  assert_true(waffle_make_current(ts->dpy, ts->window, ts->ctx));
>  
> -- 
> 2.9.0.rc2
> 
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 1/2] tests/gl_basic: Make GL symbol queries more robust

2016-06-14 Thread Chad Versace
The rules that dictate how to properly query a GL symbol are complex.
The rules depend on the OS, on the winsys API, and even on the
particular driver being used. The rules differ between EGL 1.4 and EGL
1.5; differ between Linux, Windows, and Mac; and differ between Mesa and
Mali.

gl_basic_test didn't try very hard when querying a GL symbol. It tried
only dlsym. If dlsym failed, then the test failed.

Make gl_basic_test more robust by falling back to
waffle_get_proc_address() whenever dlsym fails.

Suggested-by: Emil Velikov <emil.l.veli...@collabora.co.uk>
Signed-off-by: Chad Versace <chad.vers...@intel.com>
---
 tests/functional/gl_basic_test.c | 55 +---
 1 file changed, 34 insertions(+), 21 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 7af2229..4a90dfd 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -169,19 +169,36 @@ teardown(void **state)
 return 0;
 }
 
-static int32_t
-libgl_from_context_api(int32_t waffle_context_api)
+// The rules that dictate how to properly query a GL symbol are complex. The
+// rules depend on the OS, on the winsys API, and even on the particular driver
+// being used. The rules differ between EGL 1.4 and EGL 1.5; differ between
+// Linux, Windows, and Mac; and differ between Mesa and Mali.
+//
+// This function hides that complexity with a naive heuristic: try, then try
+// again.
+static void *
+get_gl_symbol(enum waffle_enum context_api, const char *name)
 {
-switch (waffle_context_api) {
-case WAFFLE_CONTEXT_OPENGL: return WAFFLE_DL_OPENGL;
-case WAFFLE_CONTEXT_OPENGL_ES1: return WAFFLE_DL_OPENGL_ES1;
-case WAFFLE_CONTEXT_OPENGL_ES2: return WAFFLE_DL_OPENGL_ES2;
-case WAFFLE_CONTEXT_OPENGL_ES3: return WAFFLE_DL_OPENGL_ES3;
-
-default:
-assert_true(0);
-return 0;
+void *sym = NULL;
+enum waffle_enum dl = 0;
+
+switch (context_api) {
+case WAFFLE_CONTEXT_OPENGL: dl = WAFFLE_DL_OPENGL; break;
+case WAFFLE_CONTEXT_OPENGL_ES1: dl = WAFFLE_DL_OPENGL_ES1; break;
+case WAFFLE_CONTEXT_OPENGL_ES2: dl = WAFFLE_DL_OPENGL_ES2; break;
+case WAFFLE_CONTEXT_OPENGL_ES3: dl = WAFFLE_DL_OPENGL_ES3; break;
+default: assert_true(0); break;
+}
+
+if (waffle_dl_can_open(dl)) {
+sym = waffle_dl_sym(dl, name);
 }
+
+if (!sym) {
+sym = waffle_get_proc_address(name);
+}
+
+return sym;
 }
 
 static int
@@ -270,8 +287,6 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ 
args)
 bool context_debug = args.debug;
 bool alpha = args.alpha;
 
-int32_t libgl;
-
 int32_t config_attrib_list[64];
 int i;
 
@@ -281,8 +296,6 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ 
args)
 0,
 };
 
-libgl = libgl_from_context_api(waffle_context_api);
-
 i = 0;
 config_attrib_list[i++] = WAFFLE_CONTEXT_API;
 config_attrib_list[i++] = waffle_context_api;
@@ -353,12 +366,12 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ 
args)
 }
 
 // Get OpenGL functions.
-assert_true(glClear = waffle_dl_sym(libgl, "glClear"));
-assert_true(glClearColor= waffle_dl_sym(libgl, "glClearColor"));
-assert_true(glGetError  = waffle_dl_sym(libgl, "glGetError"));
-assert_true(glGetIntegerv   = waffle_dl_sym(libgl, "glGetIntegerv"));
-assert_true(glReadPixels= waffle_dl_sym(libgl, "glReadPixels"));
-assert_true(glGetString = waffle_dl_sym(libgl, "glGetString"));
+assert_true(glClear = get_gl_symbol(waffle_context_api, 
"glClear"));
+assert_true(glClearColor= get_gl_symbol(waffle_context_api, 
"glClearColor"));
+assert_true(glGetError  = get_gl_symbol(waffle_context_api, 
"glGetError"));
+assert_true(glGetIntegerv   = get_gl_symbol(waffle_context_api, 
"glGetIntegerv"));
+assert_true(glReadPixels= get_gl_symbol(waffle_context_api, 
"glReadPixels"));
+assert_true(glGetString = get_gl_symbol(waffle_context_api, 
"glGetString"));
 
 assert_true(waffle_make_current(ts->dpy, ts->window, ts->ctx));
 
-- 
2.9.0.rc2

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


Re: [waffle] [PATCH 00/13] Do less validation of the context version

2016-06-14 Thread Chad Versace
On Tue 26 Apr 2016, Emil Velikov wrote:
> Humble ping ?

And an embarrasedly late reply...

This year, I've taken nearly 4 months off (paternity leave + vacation
+ sabbatical) and was in a Vulkan crunch for the 3 months before that.
My schedule has finally returned to normal.

> On 5 April 2016 at 22:58, Emil Velikov  wrote:
> > Hi all,
> >
> > This is a re-spin of an ancient RFC [1] covering two (core) topics
> >  - Should waffle do fine grained checking of the context version prior
> > to feeding it to the driver ? Leaning towards no.

After considering this more, I agree with you. Waffle shouldn't add an
extra layer of validation on top of the GL/GLES/GLX/EGL drivers, except
when the validation is truly helpful.

> >  - Should we rely upon the library (libGL/libGLESv1/libGLESv2) presence
> > to determine if context of respective API is supported ? Same sentiment.

I agree. Strictly speaking, the presence of libGLFoo does not indicate
the availability of the GLFoo API.

However, patch 7 of your series regresses the gl_basic GLES1 tests. I'm
investigating that now. Maybe the bug is Waffle's, maybe Mesa's; I'm
unsure.

> >
> > And last but not least I've thrown out a bunch of the
> > wcore_error_internal() in favour of assert. Core already handles all of
> > those 'default' cases, thus we can simplify things ;-)

Yes, it does make the code cleaner.

I've submitted the first 6 patches to Intel's CI. I'll merge if there
are no regressions.

I'm holding off on patches 7 and above until I diagnose the regressions.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 00/29] Rework the functionality test(s)

2016-06-14 Thread Chad Versace
On Tue 26 Apr 2016, Emil Velikov wrote:
> Humble ping ?

And an embarassedly late merge.

Thanks for all the cleanups. All the patches in the series, except patch
1, are merged. I skipped patch 1 because it introduced a single symbol,
but that symbol was never used.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] json, approach 2, version 2

2016-06-14 Thread Chad Versace
On Thu 21 Apr 2016, Frank Henigman wrote:
> Thanks Emil and Chad for reviewing my json series.  All suggestions
> implemented in v2, except where I replied inline.  I'll hold off
> sending in case there's more back-and-forth over the first set of
> comments.  Would also be nice if Chad merged his get-current branch
> into master, as I use it in v2.

> Not sure if I did the right thing with glx info.  Seems like all three
> sections (server, client, common) show about the same list of
> extensions.  That can wait until I send v2, or if anyone wants to look
> now:
> https://github.com/fjhenigman/waffle/commit/b358ac50c00ce51fae6546b1e96c9adc32fcbdc7

Hi Frank,

I've returned from sabbatical, and am now trying to catch up with
everything.

I can't find the above sha1 in your repo. Should I be examining your
json5 branch?
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH] egl: Improve support for robust GLES contexts on EGL 1.5

2016-05-02 Thread Chad Versace
Allow the creation of robust GLES contexts when EGL 1.5 is available,
even when EGL_EXT_create_context_robustness is not.

Cc: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Cc: Emil Velikov <emil.l.veli...@gmail.com>
Signed-off-by: Chad Versace <chad.vers...@intel.com>
---
 src/waffle/egl/wegl_context.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index d88ce9e..0e59231 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -142,8 +142,14 @@ create_real_context(struct wegl_config *config,
 }
 
 if (attrs->context_robust) {
-attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
-attrib_list[i++] = EGL_TRUE;
+// The EGL 1.5 token and the EXT token have different values.
+if (dpy->major_version > 1 || dpy->minor_version >= 5) {
+attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS;
+attrib_list[i++] = EGL_TRUE;
+} else {
+attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
+attrib_list[i++] = EGL_TRUE;
+}
 }
 break;
 
-- 
2.8.1

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


Re: [waffle] json, approach 2, version 2

2016-05-02 Thread Chad Versace
On Thu 21 Apr 2016, Frank Henigman wrote:

[snip]

> When comparing my json output to the landed json output I noticed that
> the landed version omits the context flags found in the old format.
> Was that deliberate?  If so I'll remove it from my json.

The JSON should list the context flags. It's an accident that wflinfo
currently doesn't.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 07/12] waffle: support platform-specific information

2016-05-02 Thread Chad Versace
On Sun 24 Apr 2016, Frank Henigman wrote:
> On Sun, Apr 24, 2016 at 6:36 AM, Emil Velikov  
> wrote:
> > On 21 April 2016 at 21:26, Frank Henigman  wrote:
> >> On Fri, Jan 8, 2016 at 7:44 AM, Emil Velikov  
> >> wrote:
> >>> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>  Add a platform hook so platform-specific information can be included
>  by waffle_display_info_json().
> 
>  Signed-off-by: Frank Henigman 
>  ---
>   src/waffle/api/waffle_display.c  | 10 +-
>   src/waffle/core/wcore_platform.h |  4 
>   2 files changed, 13 insertions(+), 1 deletion(-)
> 
>  diff --git a/src/waffle/api/waffle_display.c 
>  b/src/waffle/api/waffle_display.c
>  index 7abe2ef..d6988ac 100644
>  --- a/src/waffle/api/waffle_display.c
>  +++ b/src/waffle/api/waffle_display.c
>  @@ -367,8 +367,16 @@ waffle_display_info_json(struct waffle_display 
>  *self, bool platform_too)
> 
>   json_appendv(jj, "{", "generic", "{", "");
>   add_generic_info(jj, wc_self->current_context);
>  -json_appendv(jj, "}", "}", "");
>  +json_append(jj, "}");
> 
>  +if (platform_too) {
>  +json_appendv(jj, "platform", "{", "");
>  +if (api_platform->vtbl->display.info_json)
>  +api_platform->vtbl->display.info_json(wc_self, jj);
> >>> The rest of waffle tends to set UNSUPPORTED_ON_PLATFORM if the backend
> >>> is missing the vfunc.
> >>
> >> I'm reluctant to set an error for something that isn't clearly an
> >> error (it might just be that a backend doesn't have platform-specific
> >> details) because it could add a burden to the user to distinguish this
> >> case from definite errors.
> > With all respect I have to disagree. Error checking/handling is not a
> > 'burden'. Even if some choose to ignore it that doesn't make it less
> > relevant ;-)
> >
> > Obviously things would be way easier/cleaner if things were split -
> > generic info vs platform specific (or even finer). As-is, with all of
> > them in one piece, no error-checking or UNSUPPORTED_ON_PLATFORM one
> > gets badly formatted/corrupted json. Thus the user has no way of
> > knowing if things failed for reason some, or the setup simply lacks
> > the information Y that they need.
> > 
> 
> You never get corrupt json.  If the hook isn't implemented you get
> different json.  In v1 you'd get an empty platform section.  In v2 the
> platform section (e.g. "glx" or "egl") is omitted.  This is better
> because:
> - the json consumer is in the best position to decide what to do about
> a missing platform section - the api shouldn't decide it's an error
> - the caller of waffle_display_info_json() doesn't have to check
> waffle error state to know if there was a "real" error, they'll know
> by the NULL return
> - we don't need to implement the hook in every back end
> 
> >>  If someone does need to act on the
> >> presence or absence or platform-specifics, they can always examine the
> >> json.

I agree with Frank here. Not every platform needs to provide json info.
For example, the CGL platform will lack json info until someone who
cares about CGL implements it.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v2] wgl: don't use ARB_create_context with pre 3.2 contexts

2016-04-22 Thread Chad Versace
On 04/17/2016 01:55 AM, Jose Fonseca wrote:
> On 15/04/16 23:48, Emil Velikov wrote:
>> Direct port of previous commit.
>>
>> v2: The version should be 3.2 and not 3.0 as originally.
>>
>> Cc: Jose Fonseca 
>> Cc: Ilia Mirkin 
>> Signed-off-by: Emil Velikov 
>> ---
>>   src/waffle/wgl/wgl_config.c  |  7 ---
>>   src/waffle/wgl/wgl_context.c | 12 +++-
>>   src/waffle/wgl/wgl_context.h | 15 +++
>>   3 files changed, 30 insertions(+), 4 deletions(-)

Patch is merged.

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


Re: [waffle] [PATCH v2] glx: don't use ARB_create_context with pre 3.2 contexts

2016-04-22 Thread Chad Versace
On 04/15/2016 03:45 PM, Emil Velikov wrote:
> This way if the user requests GL pre 3.2 context which lacks the
> flags/extra bits which require ARB_create_context one can safely fall
> back to the normal/legacy entry point.
> 
> This resolves piglits on non 3.2 capable drivers such as classic swrast,
> nouveau_vieux and alike.
> 
> v2: The version should be 3.2 and not 3.0 as originally.
> 
> Cc: Ilia Mirkin 
> Reviewed-by: Jose Fonseca  (v1)
> Signed-off-by: Emil Velikov 
> ---
>  src/waffle/glx/glx_config.c  |  7 ---
>  src/waffle/glx/glx_context.c | 12 +++-
>  src/waffle/glx/glx_context.h | 16 
>  3 files changed, 31 insertions(+), 4 deletions(-)
> 

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


Re: [waffle] [PATCH 1/3] glx: don't use ARB_create_context with pre 3.0 contexts

2016-04-15 Thread Chad Versace
On 04/15/2016 12:30 PM, Jose Fonseca wrote:
> On 15/04/16 20:04, Chad Versace wrote:
>> On 04/06/2016 02:12 AM, Jose Fonseca wrote:
>>> On 05/04/16 22:45, Emil Velikov wrote:
>>>> This way if the user requests GL pre 3.0 context which lacks the
>>>> flags/extra bits which require ARB_create_context one can safely fall
>>>> back to the normal/legacy entry point.
>>>>
>>>> This resolves piglits on non 3.0 capable drivers such as classic swrast,
>>>> nouveau_vieux and alike.
>>>>
>>>> Cc: Jose Fonseca <jfons...@vmware.com>
>>>> Cc: Ilia Mirkin <imir...@alum.mit.edu>
>>>> Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
>>
>>
>>
>>>> +static inline bool
>>>> +glx_context_needs_arb_create_context(const struct wcore_config_attrs 
>>>> *attrs)
>>>> +{
>>>> +if (attrs->context_api == WAFFLE_CONTEXT_OPENGL &&
>>>> +(wcore_config_attrs_version_ge(attrs, 30) ||
>>>> + attrs->context_forward_compatible))
>>>> +return true;
>>>> +
>>>> +if (attrs->context_debug)
>>>> +return true;
>>>> +
>>>> +return false;
>>>> +}
>>
>>> Looks good to me.  Thanks.
>>>
>>> Reviewed-by: Jose Fonseca <jfons...@vmware.com>
>>
>> I reviewed the thread on the Piglit list, and I'm in favor of this change.
>>
>> Jose and Emil, I believe the critical version should be 3.2, not 3.0. I don't
>> understand why this patch uses 3.0 as the cutoff version.  The
>> GLX_ARB_create_context spec says:
>>
>>  The presence of an OpenGL 3.2 or later implementation determines 
>> whether or
>>  not GLX_ARB_create_context_profile is required.
>>
>> And the WGL spec contains the same text.
>>
>> In other words, it never makes sense to request a 3.2 context without
>> GLX_ARB_create_context, because the availability of 3.2 mandates the
>> availability of GLX_ARB_create_context_profile.
>>
> 
> I somehow thought the requirement was introduced in 3.0, but it's indeed 3.2.

Emil, resubmit patches 1 and 2 with the version bumped to 3.2, and I'll merge 
them.

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


Re: [waffle] [PATCH] wayland: Wrap wl_proxy_marshal_constructor_versioned v2

2016-04-15 Thread Chad Versace
On 04/15/2016 09:36 AM, Jason Ekstrand wrote:
> On Fri, Apr 15, 2016 at 3:03 AM, Emil Velikov  > wrote:
> 
> On 15 April 2016 at 03:32, Michel Dänzer  > wrote:
> > On 15.04.2016 11:14, Michel Dänzer wrote:
> >> On 14.04.2016 22:16, Emil Velikov wrote:
> >>> On 14 April 2016 at 09:23, Michel Dänzer  > wrote:
>  From: Michel Dänzer  >
> 
>  Fixes build failure due to wl_proxy_marshal_constructor_versioned 
> being
>  unresolved when building against current wayland.
> 
>  This API was introduced in wayland 1.9.91 by commit 557032e3 ("Track
>  protocol object versions inside wl_proxy."). The waffle code doesn't
>  reference wl_proxy_marshal_constructor_versioned directly but
>  indirectly via wayland-scanner.
> 
>  v2:
>  * Add paragraph about how wl_proxy_marshal_constructor_versioned was
>    introduced. (Emil Velikov)
>  * Only resolve wl_proxy_marshal_constructor_versioned with wayland >=
>    1.9.91.
> 
>  Signed-off-by: Michel Dänzer  >
>  ---
>   src/waffle/wayland/wayland_wrapper.c | 5 +
>   src/waffle/wayland/wayland_wrapper.h | 8 
>   2 files changed, 13 insertions(+)
> 
>  diff --git a/src/waffle/wayland/wayland_wrapper.c 
> b/src/waffle/wayland/wayland_wrapper.c
>  index 6ffd5a9..fb66f9a 100644
>  --- a/src/waffle/wayland/wayland_wrapper.c
>  +++ b/src/waffle/wayland/wayland_wrapper.c
>  @@ -106,6 +106,11 @@ wayland_wrapper_init(void)
>   RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_add_listener);
>   RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_marshal);
>   RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_marshal_constructor);
>  +#if WAYLAND_VERSION_MAJOR == 1 && \
>  +(WAYLAND_VERSION_MINOR > 9 || \
>  + (WAYLAND_VERSION_MINOR == 9 && WAYLAND_VERSION_MICRO >= 91))
>  +
> RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_marshal_constructor_versioned);
>  +#endif
>   #undef RETRIEVE_WL_CLIENT_SYMBOL
> 
> >>> I am slightly worried about this approach. It adds a so called 'hidden
> >>> dependency' and with it a possibility of things going horribly wrong.
> >>> It is something that we try to avoid with mesa as the deps version at
> >>> build time != run-time one. Or in other words, one might build against
> >>> wayland 1.9 and things will go crazy as you run wayland 1.10, or vice
> >>> versa.

I prefer to avoid adding this "hidden dependency" (as Emil calls it) for
a Wayland function that Waffle doesn't use or need. Jason's solution of
importing wayland-client-protocol.h avoids that dependency, and it also
prevents this build-breakage problem from occuring in the future.

> I think this is actually mostly ok.  In the Wayland project, we were very
> careful to ensure that anything built against 1.9 would work when linked
> against 1.10.  This should continue to be the case even with waffle's
> shim-layer.
> 
> The problem is not that libwayland added a new symbol nor is it a problem
> that wayland-protocol.h was updated to use that new symbol.  The problem is
> that waffle sticks a shim layer in between wayland-protocol.h and libwayland.
> This makes the wayland-protocol.h file effectively internal to waffle but
> still updatable by the distro.  This is a layering violation.  To keep this
> from happening in the future, you probably want to just check a version of
> wayland-client-protocol.h into the waffle repo so that it doesn't change out
> from under you and make waffle just use wayland-client-core.h.  You can even
> check in the version from libwayland 1.9 if you'd like to keep waffle
> building against older versions.

I think I understand you, but I'm not confident. Wayland's header dependencies
are, we can all admit, confusing.

If Waffle does the following...

a. Check into the repo the wayland-client-protocol.h from Wayland 1.9.

... then ...

c. Waffle will successfully build against distro-provided Wayland headers
   for wayland >= 1.9. Specifically, the system's wayland-client.h will
   include Waffle's imported wayland-client-protocol.h, and nothing will
   explode.

d. If Waffle is built against the system's wayland-client.h from Wayland
   1.x (where x >= 9), the libwaffle can successfully dlopen and run against
   libwayland 1.y (where y > x).

Jason, is that correct?

To allow Waffle to continue building against older Wayland version, we may be
able to import Wayland 1.8's (instead of 1.9's) wayland-client-protocol.h, as
1.8 is the first release in which the 

Re: [waffle] [PATCH 1/3] glx: don't use ARB_create_context with pre 3.0 contexts

2016-04-15 Thread Chad Versace
On 04/06/2016 02:12 AM, Jose Fonseca wrote:
> On 05/04/16 22:45, Emil Velikov wrote:
>> This way if the user requests GL pre 3.0 context which lacks the
>> flags/extra bits which require ARB_create_context one can safely fall
>> back to the normal/legacy entry point.
>>
>> This resolves piglits on non 3.0 capable drivers such as classic swrast,
>> nouveau_vieux and alike.
>>
>> Cc: Jose Fonseca 
>> Cc: Ilia Mirkin 
>> Signed-off-by: Emil Velikov 



>> +static inline bool
>> +glx_context_needs_arb_create_context(const struct wcore_config_attrs *attrs)
>> +{
>> +if (attrs->context_api == WAFFLE_CONTEXT_OPENGL &&
>> +(wcore_config_attrs_version_ge(attrs, 30) ||
>> + attrs->context_forward_compatible))
>> +return true;
>> +
>> +if (attrs->context_debug)
>> +return true;
>> +
>> +return false;
>> +}

> Looks good to me.  Thanks.
> 
> Reviewed-by: Jose Fonseca 

I reviewed the thread on the Piglit list, and I'm in favor of this change.

Jose and Emil, I believe the critical version should be 3.2, not 3.0. I don't
understand why this patch uses 3.0 as the cutoff version.  The
GLX_ARB_create_context spec says:

The presence of an OpenGL 3.2 or later implementation determines whether or
not GLX_ARB_create_context_profile is required.

And the WGL spec contains the same text.

In other words, it never makes sense to request a 3.2 context without
GLX_ARB_create_context, because the availability of 3.2 mandates the
availability of GLX_ARB_create_context_profile.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 3/3] tests/gl_basic_test: query context flags only for desktop GL 3.0 or later

2016-04-15 Thread Chad Versace
On 04/05/2016 02:45 PM, Emil Velikov wrote:
> Spotted while attemting to use classic swrast with waffle.
> 
> Signed-off-by: Emil Velikov 
> ---
>  tests/functional/gl_basic_test.c | 36 +++-
>  1 file changed, 27 insertions(+), 9 deletions(-)

Emil, I pushed this patch to master. I'm still looking at the others, and the 
relevant
Piglit discussion.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 4/6] egl: Add support for robust access contexts.

2016-04-11 Thread Chad Versace
On 04/06/2016 08:59 AM, Bas Nieuwenhuizen wrote:
> Signed-off-by: Bas Nieuwenhuizen 
> ---
>  src/waffle/egl/wegl_config.c  | 16 
>  src/waffle/egl/wegl_context.c |  9 +
>  src/waffle/egl/wegl_display.c |  1 +
>  src/waffle/egl/wegl_display.h |  1 +
>  4 files changed, 27 insertions(+)
> 
> diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
> index a79bc53..1c3f416 100644
> --- a/src/waffle/egl/wegl_config.c
> +++ b/src/waffle/egl/wegl_config.c
> @@ -55,6 +55,22 @@ check_context_attrs(struct wegl_display *dpy,
>  return false;
>  }
>  
> +if (attrs->context_robust && !dpy->EXT_create_context_robustness &&
> +attrs->context_api != WAFFLE_CONTEXT_OPENGL) {
> +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
> + "EGL_EXT_create_context_robustness is required in order 
> to "
> + "request a robust access context for OpenGL ES");
> +return false;
> +}
> +
> +if (attrs->context_robust && !dpy->KHR_create_context &&
> +attrs->context_api == WAFFLE_CONTEXT_OPENGL) {
> +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
> + "EGL_KHR_create_context is required in order to "
> + "request a robust access context for OpenGL");
> +return false;
> +}
> +
>  switch (attrs->context_api) {
>  case WAFFLE_CONTEXT_OPENGL:
>  if (!wcore_config_attrs_version_eq(attrs, 10) && 
> !dpy->KHR_create_context) {
> diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
> index f4ee6cd..67cbc04 100644
> --- a/src/waffle/egl/wegl_context.c
> +++ b/src/waffle/egl/wegl_context.c
> @@ -95,6 +95,11 @@ create_real_context(struct wegl_config *config,
>  context_flags |= 
> EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
>  }
>  
> +if (attrs->context_robust) {
> +assert(dpy->KHR_create_context);
> +context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
> +}
> +
>  if (wcore_config_attrs_version_ge(attrs, 32))  {
>  assert(dpy->KHR_create_context);
>  switch (attrs->context_profile) {
> @@ -128,6 +133,10 @@ create_real_context(struct wegl_config *config,
>  assert(attrs->context_minor_version == 0);
>  }
>  
> +if (attrs->context_robust) {
> +attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
> +attrib_list[i++] = EGL_TRUE;
> +}
>  break;
>  
>  default:

Hi Bas,

This patch is correct for EGL <= 1.4. However, EGL 1.5 made
the EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT attribute (but not the flag)
legal for all OpenGL and OpenGL ES context versions.

From the EGL 1.5 (2014.08.27) spec:

3.7.1.5 OpenGL and OpenGL ES Robust Buffer Access

If the EGL_CONTEXT_OPENGL_ROBUST_ACCESS attribute is set to EGL_TRUE,
a context supporting robust buffer access will be created. OpenGL contexts
must support the GL_ARB_robustness extension, or equivalent core API
functional- ity. OpenGL ES contexts must support the GL_EXT_robustness
extension, or equivalent core API functionality.

This attribute is supported only for OpenGL and OpenGL ES contexts. If the
implementation does not support robust buffer access, context creation will
fail.

The default value of EGL_CONTEXT_OPENGL_ROBUST_ACCESS is EGL_ FALSE .

If you have time, please follow-up with a patch that unconditonally permits
WAFFLE_CONTEXT_ROBUST_ACCESS if the EGL version is >= 1.5.

If you don't have time, please let me know and I will find time to do it.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/6] wcore: Add support for robust access contexts.

2016-04-11 Thread Chad Versace
Thanks Bas. I pushed the patches to master.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/6] wcore: Add support for robust access contexts.

2016-04-11 Thread Chad Versace
On 04/11/2016 01:11 PM, Emil Velikov wrote:
> On 6 April 2016 at 16:59, Bas Nieuwenhuizen  wrote:
>> Signed-off-by: Bas Nieuwenhuizen 
>> ---
>>  include/waffle/waffle.h  |  4 
>>  man/waffle_config.3.xml  | 24 
>>  src/waffle/core/wcore_config_attrs.c |  3 +++
>>  src/waffle/core/wcore_config_attrs.h |  1 +
>>  src/waffle/core/wcore_util.c |  1 +
>>  5 files changed, 33 insertions(+)
>>
>> diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
>> index df0218e..b207f37 100644
>> --- a/include/waffle/waffle.h
>> +++ b/include/waffle/waffle.h
>> @@ -142,6 +142,10 @@ enum waffle_enum {
>>  WAFFLE_CONTEXT_DEBUG= 0x0216,
>>  #endif
>>
>> +#if WAFFLE_API_VERSION >= 0x106
>> +WAFFLE_CONTEXT_ROBUST_ACCESS= 0x0217,
>> +#endif
>> +
> Silly me should have mentioned that we decided against using feature
> (version) checks for the enums. Unless anyone feels otherwise I'd just
> say go with the patch [as-is] and nuke any such checks in one go. Both
> in the source and man pages.

Thanks for reminding me about that decision. I forgot.

The deciding email is here:

Subject: Re: [waffle] [PATCH 07/10] waffle: add full screen window 
request
From: Emil Velikov
Date: Thu, 23 Apr 2015 03:03:08 -0700


https://www.mail-archive.com/waffle%40lists.freedesktop.org/msg01161.html

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


Re: [waffle] [PATCH 1/6] wcore: Add support for robust access contexts.

2016-04-11 Thread Chad Versace
On 04/11/2016 02:04 PM, Bas Nieuwenhuizen wrote:
> Could this be also committed with those changes or do you want me to
> make a v2 that removes the version check? I don't have commit access.

Bas, you don't need to resubmit the series. It's a small change, so I'll
just do it myself as a follow-up commit.

By the way, the series is
Reviewed-by: Chad Versace <chad.vers...@intel.com>

There are some problems with the EGL patch, but those problems can be
fixed in follow-up work. I'll send my comments to that patch soon.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 6/6] nacl: Add an error when trying to use a robust access context.

2016-04-11 Thread Chad Versace
On 04/06/2016 09:59 PM, Tapani Pälli wrote:
> This looks correct to me;
> 
> Reviewed-by: Tapani Pälli 
> 
> Note that following patch is required to build waffle nacl support on any 
> recent nacl sdk versions:
> 
> https://lists.freedesktop.org/archives/waffle/2015-October/001266.html

Tapani, is your r-b for only patch 6/6 or the the complete series?
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 06/12] wflinfo: add option for JSON output

2016-04-08 Thread Chad Versace
On 01/06/2016 11:56 AM, Frank Henigman wrote:
> With "-f json" wflinfo will now print the result of
> waffle_display_info_json().
> 
> Signed-off-by: Frank Henigman 
> ---
>  src/utils/wflinfo.c | 40 
>  1 file changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
> index 268d4b8..58f5688 100644
> --- a/src/utils/wflinfo.c
> +++ b/src/utils/wflinfo.c


> @@ -1119,9 +1137,23 @@ main(int argc, char **argv)
>  glGetStringi = waffle_get_proc_address("glGetStringi");
>  }
>  
> -ok = print_wflinfo();
> -if (!ok)
> -error_waffle();
> +char *info;
> +switch (opts.format) {
> +case FORMAT_ORIGINAL:
> +ok = print_wflinfo();
> +if (!ok)
> +error_waffle();
> +break;
> +
> +case FORMAT_JSON:
> +info = waffle_display_info_json(dpy, false);
> +if (info) {
> +printf("%s\n", info);
> +free(info);
> +} else
> +error_waffle();
> +break;
> +}


I agree with the patch series's goals: teach wflinfo to print platform-specific
info (such as EGL info); extract that info inside libwaffle and expose it
through public API; that public API should provide JSON, and perhaps additional
formats.

But this patch 6/12 poses a problem. Post-patch, wflinfo can print its info in
the old format and in a json format. But, depending on the output format,
wflinfo uses completely separate code paths to obtain the information.

The actual information that wflinfo provides, and the method by which it
obtains that info, should be largely independent of the output format. When the
user chooses an output format, that choice should affect the *presentation* but
not fundamentally affect the *content*.

So...

For wflinfo's sake, we need a public waffle_get_my_info() function that returns
data that can be translated into the old format and into the json format, or 
perhaps
returns the old format and json directly.

To move forward with this patch series, I see the following options:

1. waffle_get_my_info() returns only json

  I don't like this. This would require that wflinfo decode the json in
  order to provide the old format output. I would like to avoid decoding
  json in Waffle though, because that would require either (a) Waffle
  contain a json decoder implementation or (b) Waffle rely on some json
  library. As for (a), I don't want to maintain a json-decoder (a json
  *encoder*, though, I don't object to). As for (b), Waffle is such
  a small, focused project that it feels wrong to pull in a json-decoder
  library as a dependency.

  BUT, maybe this option could work and I'm overestimating the maintenance
  overhead of decoding json.

2. waffle_get_my_info() returns only some-other-well-defined-format-FOO

   I don't like this either. Just like option 1, it would require that
   wflinfo decode the FOO format in order to provide json output.

3. waffle_get_my_info() can return a json string or a string in the old
   wflinfo format

   If option 3 can be implemented cleanly, I think it's the best choice.
   This option eliminates the need for decoding any special format.

   Perhaps we could implement this by defining a private struct...

struct wcore_display_info {
struct {
char *platform;
char *api;
} waffle;

struct {
char *vendor;
char *renderer;
...
char **extensions;
} opengl;

struct {
char *version;
char *vendor;
char *client_apis;
...
} egl;

...
};

...that waffle_get_my_info() populates and then encodes into the
respected format: JSON, the old wflinfo format, a format that
mimics glxinfo, or whatever.


Frank, what do you think?
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 04/12] core: add JSON library

2016-04-08 Thread Chad Versace
On 01/08/2016 04:17 AM, Emil Velikov wrote:
> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>> A small library for building JSON strings.
>>
>> Signed-off-by: Frank Henigman 
>> ---
>>  src/waffle/CMakeLists.txt |   1 +
>>  src/waffle/core/json.c| 235 
>> ++
>>  src/waffle/core/json.h|  93 ++

> Is the library is copied/derived from another project or written from
> scratch ? If the former should we move it to third_party/  ?

I have the same question. Was this code copied from a public Google project?
If so, the we should place in third_party/ with a note explaining its origin
and explaining how to update it in the future. If not, the the current location
in src/waffle/core/ is appropriate.

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


Re: [waffle] [PATCH v3] wflinfo: Add a --format flag that prints json or the classic output

2016-04-07 Thread Chad Versace
On 01/14/2016 04:42 PM, baker.dyla...@gmail.com wrote:
> From: Dylan Baker 
> 
> Adds a JSON formatted output.
> 
> This format doesn't honor the --verbose flag, it always provides all
> relevant information.
> 
> The option parsing code is a slightly adapted version of code Frank
> Henigman wrote.
> 
> Signed-off-by: Dylan Baker 
> ---
> v2: - Add -j short options (Frank)
> - Make context flags always an array (Chad)
> - Remove explicit returns from void functions (Chad)
> - Fix spaces around "*" in variable definitions
> - Nest waffle specific information in a waffle hash and OpenGL
>   specific information in an OpenGL hash
> - use ARRAY_SIZE macro
> - rebase on previous changes
> v3: - Fix various formatting issues
> - conform to Chad's requested JSON format
> - add some comments for ambiguous JSON commas
> - remove context flags, which are not part of Chad's JSON format
> - remove honoring verbose flag
> - use a --format flag

Hi Dylan,

I pushed your patch to master.

I took the liberty of fixing two potential crashes in your
patch, both related to strtok(). See the commit message for details.

The new JSON format is a significant new feature that warrants a new
Waffle release in the near future. I'll ping you (and the list) when
I'm ready to cut the new release. First, though, I want to merge some
more outstanding patches on the mailing list.

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


Re: [waffle] [PATCH] cmake: use the EGL CFLAGS in the waffle CFLAGS

2016-04-06 Thread Chad Versace
On 02/11/2016 03:21 PM, Mircea Gherzan wrote:
> Without them, the build will fail with a recent Mesa from the master
> branch on a system without the X headers:
> 
> include/EGL/eglplatform.h:119:22: fatal error: X11/Xlib.h: No such file
> or directory
> 
> Signed-off-by: Mircea Gherzan 

Yes, because egl_CFLAGS_OTHER contains -DMESA_EGL_NO_X11_HEADERS
when the system has no X headers.

Thanks. Patch is pushed to master.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] I'm back from paternity leave

2016-04-06 Thread Chad Versace
Hi everyone,

I abruptly left for paternity leave in early February, and now I'm a father!
My little boy is named Lucas, and he's incredible.

While on leave, I had little time to spare for non-baby activities, so it's 
been over two
months since I read any code-related mail. I returned from paternity leave 
yesterday,
and am now catching up on unread Waffle mail.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] Review Latency

2016-01-20 Thread Chad Versace
Hi everyone,

I'm aware there are a few dozen patches on the mailing list awaiting review.
I apologize for the latency. In my other role as a driver developer, I'm
occupied trying to hit a major milestone before end of month. I expect that I'll
continue to have too little time to dedicate to waffle review until the driver
work slows down, probably on Feb 1st.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v2 4/4] wflinfo.c: Add a --json flag that prints json

2016-01-11 Thread Chad Versace
On 01/05/2016 11:46 AM, baker.dyla...@gmail.com wrote:
> From: Dylan Baker 

Please use 'wflinfo', not 'wflinfo.c', as the commit's subject prefix.

> 
> This adds some code to print a JSON formatted version of data provided
> by wflinfo.
> 
> Signed-off-by: Dylan Baker 
> 
> v2: - Add -j short options (Frank)
> - Make context flags always an array (Chad)
> - Remove explicit returns from void functions (Chad)
> - Fix spaces around "*" in variable definitions
> - Nest waffle specific information in a waffle hash and OpenGL
>   specific information in an OpenGL hash
> - use ARRAY_SIZE macro
> - rebase on previous changes
> ---
>  src/utils/wflinfo.c | 178 
> +++-
>  1 file changed, 176 insertions(+), 2 deletions(-)

Dylan, please review the JSON format I documented in my earlier message
titled "Approaches to JSON". If that format is acceptable to you, and to
Frank too, then please make this patch's JSON match the documented format.
That should require only a few touchups, as the format I documented closely
resembles your patch's existing format.

> diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
> index 8ee95c6..456f91b 100644
> --- a/src/utils/wflinfo.c
> +++ b/src/utils/wflinfo.c
> @@ -85,6 +85,9 @@ static const char *usage_message =
>  "--debug-context\n"
>  "Create a debug context.\n"
>  "\n"
> +"-j, --json\n"
> +"Print a JSON formatted summary.\n"
> +"\n"
>  "-h, --help\n"
>  "Print wflinfo usage information.\n"
>  "\n"
> @@ -104,6 +107,7 @@ enum {
>  OPT_VERBOSE = 'v',
>  OPT_DEBUG_CONTEXT,
>  OPT_FORWARD_COMPATIBLE,
> +OPT_JSON = 'j',
>  OPT_HELP = 'h',
>  };
>  
> @@ -115,6 +119,7 @@ static const struct option get_opts[] = {
>  { .name = "verbose",.has_arg = no_argument,   .val = 
> OPT_VERBOSE },
>  { .name = "debug-context",  .has_arg = no_argument,   .val = 
> OPT_DEBUG_CONTEXT },
>  { .name = "forward-compatible", .has_arg = no_argument,   .val = 
> OPT_FORWARD_COMPATIBLE },
> +{ .name = "json",   .has_arg = no_argument,   .val = 
> OPT_JSON },
>  { .name = "help",   .has_arg = no_argument,   .val = 
> OPT_HELP },
>  { 0 },
>  };

[snip]

I like Frank's idea of adding an '-f|--format' option, like this:

-f , --format=
Print output in the given format. Available formats are
'flat' and 'json'. Defaults to 'flat'.

That would allow us to add additional formats in the future without
reserving a new option letter for each format. Is that change ok with you?
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [RFC 3/3] wflinfo.c: Add a --json flag that prints json

2016-01-05 Thread Chad Versace
On 12/31/2015 09:51 AM, Dylan Baker wrote:
> 
> 
> On Wed, Dec 30, 2015 at 4:32 PM, Chad Versace <chad.vers...@intel.com 
> <mailto:chad.vers...@intel.com>> wrote:
> 
> On 12/27/2015 07:49 AM, Frank Henigman wrote:
> > On Wed, Dec 16, 2015 at 8:37 PM,  <baker.dyla...@gmail.com 
> <mailto:baker.dyla...@gmail.com>> wrote:
> >> From: Dylan Baker <baker.dyla...@gmail.com 
> <mailto:baker.dyla...@gmail.com>>
> >>
> >> This adds some code to print a JSON formatted version of data provided
> >> by wflinfo.
> >>
> >> Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com 
> <mailto:dylanx.c.ba...@intel.com>>
> >> ---
> >>  src/utils/wflinfo.c | 174 
> +++-
> 
> 
> 
> >> +static void
> >> +json_print_context_flags(void)
> >> +{
> >> +int flag_count = sizeof(flags) / sizeof(flags[0]);
> 
> This should be
> 
> const int flag_count = ARRAY_SIZE(flags);
> 
> Optionally, you could even remove the flag_count variable altogether
> and use ARRAY_SIZE(flags) everywhere. But it doesn't really matter.
> 
> 
> This was copied from the original print_context_flags function. Should I 
> chang ethat to ARRAY_SIZE as well (presumably in a separate patch)?

Yes. It would be nice if you cleaned up print_context_flags in a separate patch.

> >> +
> >> +printf("[\n");
> >> +for (int i = 0; i < flag_count; i++) {
> >> +if ((flags[i].flag & context_flags) != 0) {
> >> +printf("\"%s\"", flags[i].str);
> >> +context_flags = context_flags & ~flags[i].flag;
> >> +if (i != flag_count) {
> >> +printf(",\n");
> >> +}
> >> +}
> >> +}
> >> +for (int i = 0; context_flags != 0; context_flags >>= 1, i++) {
> >> +if ((context_flags & 1) != 0) {
> >> +printf(",\n");
> >> +printf("0x%x", 1 << i);
> >> +}
> >> +}
> >> +printf("]");
> 
> Like Frank said, it would be nice if the json code didn't duplicate so 
> much of the
> original code. But, because you're not confident yet in C (as you say in 
> the cover letter),
> I'll accept the duplication in this function. I'll offer to deduplicate 
> the code myself if the patches
> go upstream.
> 
> 
> I'm curious what the (or a) good approach would be to fix this. I
> tried making a similar implementaiton in python (which I'm more
> comfortable with) and still had a hard time coming up with a good way
> to share code.
> 
> Personally I find being thrown in the deep in the best way to learn
> to swim, so if you could point me in the right (or at least a good)
> direction I'd like to take a stab at it.

Honestly, I also don't see a clean way to deduplicate the code for the
variable-length fields. Perhaps careful use of template strings that the
loops fill out with sprintf.

I suggest you don't worry about deduplication in this patch series, and
we can revisit it after the patches land. It would be silly to stall the json
output due to duplication of a tiny chunk of code.


> > I think some key strings should be a bit more specific or nested, like
> > "opengl version:" or "opengl : { version :" instead of just "version"
> > in case we expand some day to include things like egl version.
> 
> I agree. I also think the non-OpenGL key strings ("platform" and "api")
> should be prefixed with "waffle", just as they are in the normal wflinfo
> output.
> 
> 
> I started changing this locally after Frank's comments. My plan was
> to nest waffle specific information inside a waffle dict, OpenGL
> (including ES) inside of an opengl dict, and then leave room for
> other information to be in it's own data structures (say glx or egl)
> 
> something like:
> {
>  "waffle": {
>   "platform": "gbm"
>  },
>  "gl": {
>   "version": 3.1,
>   "profile": "core"
>  }
> }
> 
> Does that seem reasonable?

That looks good to me.

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


Re: [waffle] [RFC 2/3] wflinfo.c: split version, renderer, and vendor checks

2015-12-30 Thread Chad Versace
On 12/29/2015 02:37 PM, Dylan Baker wrote:
> Okay, I can fix that too.
> 
> On Sun, Dec 27, 2015 at 7:43 AM, Frank Henigman  > wrote:
> 
> On Wed, Dec 16, 2015 at 8:37 PM,   > wrote:
> > From: Dylan Baker  >
> >
> > Pull these out into helper functions, this change will be used in a
> > following patch to add a json printer.
> >
> > Signed-off-by: Dylan Baker  >
> > ---
> >  src/utils/wflinfo.c | 50 
> --
> >  1 file changed, 36 insertions(+), 14 deletions(-)

> > +const char * vendor =  get_vendor();
> > +const char * renderer = get_renderer();
> > +const char * version_str = get_version();
> 
> nit: usually no space after *

Yes. The convention in Waffle is ``const char *vendor``. Other than that,
the patch looks good.

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


Re: [waffle] [RFC 1/3] wflinfo.c: split out flags struct

2015-12-30 Thread Chad Versace
On 12/16/2015 05:37 PM, baker.dyla...@gmail.com wrote:
> From: Dylan Baker 
> 
> This is groundwork for adding a json interface to wflinfo.
> ---
>  src/utils/wflinfo.c | 19 +++
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
> index 268d4b8..905fd90 100644
> --- a/src/utils/wflinfo.c
> +++ b/src/utils/wflinfo.c
> @@ -487,17 +487,18 @@ print_extensions(bool use_stringi)
>  printf("\n");
>  }
>  
> +static struct {
> +GLint flag;
> +char *str;
> +} flags[] = {
> +{ GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "FORWARD_COMPATIBLE" },
> +{ GL_CONTEXT_FLAG_DEBUG_BIT, "DEBUG" },
> +{ GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB, "ROBUST_ACCESS" },
> +};

Since the array is now global and no longer local to the print_context_flags() 
function,
please rename it to 'context_flags'.

> +
>  static void
>  print_context_flags(void)
>  {
> -static struct {
> -GLint flag;
> -char *str;
> -} flags[] = {
> -{ GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "FORWARD_COMPATIBLE" },
> -{ GL_CONTEXT_FLAG_DEBUG_BIT, "DEBUG" },
> -{ GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB, "ROBUST_ACCESS" },
> -};
>  int flag_count = sizeof(flags) / sizeof(flags[0]);
>  GLint context_flags = 0;
>  
> @@ -526,6 +527,8 @@ print_context_flags(void)
>  }
>  }
>  printf("\n");
> +
> +return;
>  }

Like Frank said, the return is not needed. Please drop it.

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


Re: [waffle] [RFC 3/3] wflinfo.c: Add a --json flag that prints json

2015-12-30 Thread Chad Versace
On 12/27/2015 07:49 AM, Frank Henigman wrote:
> On Wed, Dec 16, 2015 at 8:37 PM,   wrote:
>> From: Dylan Baker 
>>
>> This adds some code to print a JSON formatted version of data provided
>> by wflinfo.
>>
>> Signed-off-by: Dylan Baker 
>> ---
>>  src/utils/wflinfo.c | 174 
>> +++-



>> +static void
>> +json_print_context_flags(void)
>> +{
>> +int flag_count = sizeof(flags) / sizeof(flags[0]);

This should be

const int flag_count = ARRAY_SIZE(flags);

Optionally, you could even remove the flag_count variable altogether
and use ARRAY_SIZE(flags) everywhere. But it doesn't really matter.

>> +GLint context_flags = 0;
>> +
>> +printf("\"context flags\": ");
>> +
>> +glGetIntegerv(GL_CONTEXT_FLAGS, _flags);
>> +if (glGetError() != GL_NO_ERROR) {
>> +printf("\"WFLINFO_GL_ERROR\"\n");
>> +return;
>> +}
>> +
>> +if (context_flags == 0) {
>> +printf("\"0x0\"\n");
>> +return;
>> +}

The json type of the "context flags" value is sometimes a string, sometimes an 
array.
It should always be the same type, an array. When there are no flags, I think 
it should
be an empty array.

>> +
>> +printf("[\n");
>> +for (int i = 0; i < flag_count; i++) {
>> +if ((flags[i].flag & context_flags) != 0) {
>> +printf("\"%s\"", flags[i].str);
>> +context_flags = context_flags & ~flags[i].flag;
>> +if (i != flag_count) {
>> +printf(",\n");
>> +}
>> +}
>> +}
>> +for (int i = 0; context_flags != 0; context_flags >>= 1, i++) {
>> +if ((context_flags & 1) != 0) {
>> +printf(",\n");
>> +printf("0x%x", 1 << i);
>> +}
>> +}
>> +printf("]");

Like Frank said, it would be nice if the json code didn't duplicate so much of 
the
original code. But, because you're not confident yet in C (as you say in the 
cover letter),
I'll accept the duplication in this function. I'll offer to deduplicate the 
code myself if the patches
go upstream.

>> +
>> +return;

In C, (at least in the C projects I've worked with), the dominant code style 
omits
the final return in void functions. The return is implicit.

>> +}



>> +const char * vendor =  get_vendor();
>> +const char * renderer = get_renderer();
>> +const char * version_str = get_version();

In Waffle, there should be no trailing space after the '*'. In other words, the
correct style is:

const char *vendor = ...



> I think some key strings should be a bit more specific or nested, like
> "opengl version:" or "opengl : { version :" instead of just "version"
> in case we expand some day to include things like egl version.

I agree. I also think the non-OpenGL key strings ("platform" and "api")
should be prefixed with "waffle", just as they are in the normal wflinfo
output.

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


Re: [waffle] [PATCH 3/4] glx: remove dl_can_open restriction for supports_context_api()

2015-11-10 Thread Chad Versace
On Tue 01 Sep 2015, Emil Velikov wrote:
> This seems like unnecessary book-keeping which makes the topic
> "supported by the display" vs "there is a library that one can manage"
> more convoluted than needed.
> 
> One can safely assume that if the GLX implementation exposes the
> extension(s) then it supports the API. Whether it will succeed in
> creating such a context is another topic :)
> 
> Signed-off-by: Emil Velikov 
> ---
>  src/waffle/glx/glx_display.c | 12 +++-
>  1 file changed, 3 insertions(+), 9 deletions(-)

Pushed to master. Thanks.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/4] wcore: do not use get_with_default() when default_value is the same as value

2015-11-10 Thread Chad Versace
On Tue 01 Sep 2015, Emil Velikov wrote:
> Signed-off-by: Emil Velikov 
> ---
>  src/waffle/core/wcore_config_attrs.c | 18 ++
>  1 file changed, 6 insertions(+), 12 deletions(-)

Thanks. This patch is pushed to the master branch.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] glx: provide our own GLX_ARB_create_context_profile defines

2015-11-09 Thread Chad Versace
On Tue 01 Sep 2015, Emil Velikov wrote:
> As of recently the official Nvidia driver does provide its own GL
> headers. Although they seem to be missing the defines needed to manage
> desktop GL contexts.
> 
> Include them for now to fix the build as mentioned in github issue #31.
> Tested against version 304.125, although later should also be ok.
> 
> Signed-off-by: Emil Velikov 
> ---
>  src/waffle/glx/glx_context.c | 8 
>  1 file changed, 8 insertions(+)

Thanks. This patch is pushed to the master and maint-1.5 branches.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] CI, static analisys, tests and waffle

2015-09-03 Thread Chad Versace
On Tue 01 Sep 2015, Emil Velikov wrote:
> Hello all,
> 
> Not too long ago I had the crazy idea of using some of the free
> utilities out there with waffle.
> 
> For example Coverity provides a free scan to open-source projects,
> which nicely integrates with Travis-CI,
> The latter of which supporting Linux and MacOS, while an alternative
> is available for Windows (AppVeyor).
> 
> I Travis + Linux + Coverity a try and things turned out ok. Small
> catch is the wayland functionality tests fail, as they run in a VM,
> while (the old) mesa/wayland requires hardware device.
> We can split these into separate gl_basic_foo_test (foo being
> glx,wayland etc.) or just silence the whole lot.

Running Linux + Coverity in CI system is a good idea.

As for Waffle's functional tests, we should separate them out so it's
possible to run tests for individual platforms. For example, run the GBM
tests but not the Wayland tests. Then we can configure the CI to run
just the tests that will actually work.

Being able to run the GBM tests in CI should find real bugs. As Mark
pointed out, Mesa commits have broken Waffle + Piglit before, and GBM
tests would have caught that.

> I have also moved the gl_basic_test to cmocka (after updating the
> latter to 1.0.1) and nuked waffle_test. With this each test has it's
> own setup/teardown and things are handled correctly, fixing memory
> leaks.

Nice. I look forward to the replacement of waffle_test with cmocka.

> Overall I'm soliciting feedback on the topic(s) as some of the patches
> are rather rough and/or complete.
> Do you think that these are worthy additions and which one would you
> like to see first :-)

Yes, I think this is worth doing. I prefer to see the cleanups arrive in
this order, but it's not a strong preference:

*. Fix bugs and leaks as they're discovered.
1. Replace waffle_test with cmocka.
2. Split `make check-func` into a separate target for each platform.
3. Add `make check` and the GBM tests to some CI system.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [ANNOUNCE] Waffle 1.5.2

2015-08-25 Thread Chad Versace
Waffle 1.5.2 is now available. This is a maintenance release that fixes
bugs since 1.5.1 and adds small packaging and testing improvements. The
full release notes are reproduced below.

Tarballs and other release files are posted at:

  Release Page:   http://www.waffle-gl.org/releases.html#1.5.2
  Source: 
http://www.waffle-gl.org/files/release/waffle-1.5.2/waffle-1.5.2.tar.xz
  GPG Signature:  
http://www.waffle-gl.org/files/release/waffle-1.5.2/waffle-1.5.2.tar.xz.asc
  SHA-256 Sums:   
http://www.waffle-gl.org/files/release/waffle-1.5.2/waffle-1.5.2.sha256sums.asc
  Release Notes:  
http://www.waffle-gl.org/files/release/waffle-1.5.2/waffle-1.5.2-release-notes.txt

The SHA-256 checksums are:

  d2c096cf654bf0061323a4b9231a1ef5b749a1e5c7c5bfe067e964219c2a851c  
waffle-1.5.2.tar.xz
  db080495dbfc8575813b9675cd067f861ca96da710900ae6e66c530599ac1354  
waffle-1.5.2.tar.xz.asc
  f8a88068f23504689a49467b19d381cb01cdc79f6eeae9436679a078f98e20e3  
waffle-1.5.2-release-notes.txt

You can fetch the signed v1.5.2 tag at:

  git://github.com/waffle-gl/waffle

You can verify the release tarball's integrity in several ways:

  How to verify the tarball's PGP signature:
$ wget 
http://www.waffle-gl.org/files/release/waffle-1.5.2/waffle-1.5.2.tar.xz
$ wget 
http://www.waffle-gl.org/files/release/waffle-1.5.2/waffle-1.5.2.tar.xz.asc
$ gpg --recv-keys 39EF1F22
$ gpg --verify waffle-1.5.2.tar.xz.asc

  How to verify the tarball's checksum:
$ echo 'd2c096cf654bf0061323a4b9231a1ef5b749a1e5c7c5bfe067e964219c2a851c  
waffle-1.5.2.tar.xz' | sha256sum -c

Please file bugs and issues at:

   https://github.com/waffle-gl/waffle/issues


Waffle 1.5.2 Release Notes
==

Fixes since 1.5.1
-

* Linux, all platforms
* Fix dlopen'ing the GLES libararies. Don't rely on libGLES*.so symlinks at
  runtime. Instead, pass the full SONAME (libGLES*.so.${N}) to dlopen. (See
  5c2c7e8).

* waffle_init() now returns false if it fails to dlopen libEGL or fails to
  dlsym any required symbol from libEGL. (See 2195f3e).

* wflinfo: Fix glGetStringi usage on ARM Mali drivers. (See 9dc).

* GBM
* Fix alpha channel in GBM format, fixing Piglit on some drivers. Waffle
  always chose a GBM format without alpha even the EGLConfig contained an
  alpha channel. (See 2bb9390).

* Windows
* Fix some compilation errors. (See 9a33a3d).

* Fix glGetStringi() usage. (See 9dc).

* Android
  * Don't export private symbols. Waffle neglected to add
-fvisibility=hidden to the compiler flags. (See caf8001).

  * Fix building with clang. (See fc58a6f).

  * Add wflinfo and the gl_basic demo to the build. (See ad1b0c8).

* Apple
* Don't emit unexpected errors from waffle_display_supports_context_api()
  when the system lacks the library for the queried API. (See 475b44f).

* Misc
* gl_basic: Choose an EGLConfig with an alpha plane. gl_basic depended on
  the presence of an alpha plane despite neglecting to request it. (See
  76df03e).



Features since 1.5.1


All new features introduced in minor releases are *minor* and introduce no
instability.

* gbm: Allow user to provide default device path in environment

  If waffle_display_connect() is passed name=NULL, then Waffle's GBM backend 
will
  now open the device path defined by environment variable WAFFLE_GBM_DEVICE. If
  WAFFLE_GBM_DEVICE is unset, then Waffle's behavior remains as before: it uses
  udev to search for a sensible DRM device node. (See 8d20f3a).



Changes since 1.5.1
---
Bernhard Rosenkränzer (1):
  android: Don't specify -std=gnu99 for C++ builds -- it breaks clang

Chad Versace (3):
  gbm: Fix crash when eglChooseConfig fails
  gbm: Allow user to provide device path in environment
  waffle: Bump version to 1.5.2

Emil Velikov (3):
  android: include gl_basic  wflinfo to the build
  android: export only the required functions
  cgl: do not emit an error on dl_can_open

Frank Henigman (3):
  waffle: return accurate result from wegl_platform_init()
  wflinfo: find glGetStringi on both Mali and WGL
  gl_basic: request alpha planes

Jordan Justen (2):
  debian: Update standards version to 3.9.6
  debian: Release 1.5.1-1

Jose Fonseca (2):
  wflinfo: Fix MSVC compilation error.
  man: Fix typo in WAFFLE_CONTEXT_*_PROFILE.

Michel Dänzer (1):
  linux: Use full libGLES*.so.[12] SONAMEs

Tom Stellard (1):
  gbm: Use EGLConfig to select the correct gbm format
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] linux: Use full libGLES*.so.[12] SONAMEs

2015-06-02 Thread Chad Versace
On Mon 01 Jun 2015, Michel Dänzer wrote:
 From: Michel Dänzer michel.daen...@amd.com
 
 The libGLES*.so symlinks are intended for the compile-time linker and
 not available everywhere at runtime.
 
 v2: * Continue using libGLES*.so on Android, the full SONAMEs aren't
   available there.
 * Remove stale comment line
 
 Signed-off-by: Michel Dänzer michel.daen...@amd.com

Emil, does this patch look good to you?

It looks good to me.
Reviewed-by: Chad Versace chad.vers...@intel.com
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/4] waffle: put waffle_enum items in a macro

2015-05-12 Thread Chad Versace
On Wed 06 May 2015, Jordan Justen wrote:
 On 2015-05-05 21:18:52, Chad Versace wrote:
  Since the only dynamically generated portion of waffle.h (for now, at
  least) will be the enum definitions, there's no reason to use XML if you
  feel it's overkill. (I'm also not opposed to XML, if you do want to go
  that route).
 
 Chad, you worked on piglit parsing of Khronos's OpenGL XML, right?

Yes, I wrote that.

 I know that XML format might be overkill for waffle, but would it
 work? Would it be something where we could leverage the parsing code
 from piglit, and the XML format from Khronos?

The Khronos XML format isn't very suitable for Waffle's API. Its
complexity is oriented towards tracking the set of extensions, API
profiles, and API versions that defined each entrypoint and enum. And
Piglit's Python scripts are overwhelmingly complex for Waffle's use
case; after consuming the Khronos XML, the scripts then apply
workarounds, determine which similarly named entrypoints are aliases of
eachother, and sorts all items in a non-obvious way that makes dispatch
resolution order happy. 

In short, I'm not opposed to encoding Waffle's API in XML or any other
format. And there are lessons to be learned from the Khronos XML and
Piglit scripts, if one wants to venture down the path of XML. But,
attempting to actually *reuse* the Khronos XML format and Piglit's
scripts is probably more painful and less maintainable than designing
a simpler XML format from scratch.

 One thing that capturing the function prototypes might enable is the
 ability to create language bindings.

XCB does this with its XML description. The primary language binding is,
of course, C. But the project also produces Python bindings from the
same XML source. Maybe XCB's XML format has some lessons to teach us,
but I haven't yet looked at it myself.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH] examples/gl_basic: Add --fullscreen option

2015-05-05 Thread Chad Versace
This exercises Frank's recent patch that added
the WAFFLE_WINDOW_FULLSCREEN attribute to waffle_window_create2().

Cc: Frank Henigman fjhenig...@google.com
Signed-off-by: Chad Versace chad.vers...@intel.com
---
 examples/gl_basic.c | 35 +--
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/examples/gl_basic.c b/examples/gl_basic.c
index eb57c4e..992df66 100644
--- a/examples/gl_basic.c
+++ b/examples/gl_basic.c
@@ -68,7 +68,7 @@ static const char *usage_message =
  [--forward-compatible]\n
  [--debug]\n
  [--resize-window]\n
- [--window-size=WIDTHxHEIGHT]\n
+ [--window-size=WIDTHxHEIGHT | --fullscreen]\n
 \n
 examples:\n
 gl_basic --platform=glx --api=gl\n
@@ -87,6 +87,9 @@ static const char *usage_message =
 \n
 --resize-window\n
 Resize the window between each draw call.\n
+\n
+--fullscreen\n
+Create a fullscreen window. This option overrides 
--window-size.\n
 ;
 
 enum {
@@ -98,6 +101,7 @@ enum {
 OPT_FORWARD_COMPATIBLE,
 OPT_RESIZE_WINDOW,
 OPT_WINDOW_SIZE,
+OPT_FULLSCREEN,
 };
 
 static const struct option get_opts[] = {
@@ -109,6 +113,7 @@ static const struct option get_opts[] = {
 { .name = forward-compatible, .has_arg = no_argument,   .val = 
OPT_FORWARD_COMPATIBLE },
 { .name = resize-window,  .has_arg = no_argument,   .val = 
OPT_RESIZE_WINDOW },
 { .name = window-size,.has_arg = required_argument, .val = 
OPT_WINDOW_SIZE },
+{ .name = fullscreen, .has_arg = no_argument,   .val = 
OPT_FULLSCREEN },
 { 0 },
 };
 
@@ -229,6 +234,8 @@ struct options {
 
 bool resize_window;
 
+bool fullscreen;
+
 /// @brief One of `WAFFLE_DL_*`.
 int dl;
 };
@@ -284,6 +291,7 @@ parse_args(int argc, char *argv[], struct options *opts)
 {
 bool ok;
 bool loop_get_opt = true;
+bool found_window_size = false;
 
 #ifdef __APPLE__
 removeXcodeArgs(argc, argv);
@@ -358,8 +366,12 @@ parse_args(int argc, char *argv[], struct options *opts)
 usage_error_printf('%s' is not a valid window geometry,
optarg);
 }
+found_window_size = true;
 break;
 }
+case OPT_FULLSCREEN:
+opts-fullscreen = true;
+break;
 default:
 abort();
 loop_get_opt = false;
@@ -379,6 +391,11 @@ parse_args(int argc, char *argv[], struct options *opts)
 usage_error_printf(--api is required);
 }
 
+if (opts-fullscreen  found_window_size) {
+usage_error_printf(--fullscreen and --window-size are mutually 
+   exclusive options);
+}
+
 // Set dl.
 switch (opts-context_api) {
 case WAFFLE_CONTEXT_OPENGL: opts-dl = WAFFLE_DL_OPENGL;  
break;
@@ -654,11 +671,17 @@ main(int argc, char **argv)
 
 
 i = 0;
-window_attrib_list[i++] = WAFFLE_WINDOW_WIDTH;
-window_attrib_list[i++] = window_width;
-window_attrib_list[i++] = WAFFLE_WINDOW_HEIGHT;
-window_attrib_list[i++] = window_height;
-window_attrib_list[i++] = 0;
+if (opts.fullscreen) {
+window_attrib_list[i++] = WAFFLE_WINDOW_FULLSCREEN;
+window_attrib_list[i++] = true;
+window_attrib_list[i++] = 0;
+} else {
+window_attrib_list[i++] = WAFFLE_WINDOW_WIDTH;
+window_attrib_list[i++] = window_width;
+window_attrib_list[i++] = WAFFLE_WINDOW_HEIGHT;
+window_attrib_list[i++] = window_height;
+window_attrib_list[i++] = 0;
+}
 
 window = waffle_window_create2(config, window_attrib_list);
 if (!window)
-- 
2.4.0

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


Re: [waffle] [PATCH 2/4] waffle: use enum list in waffle_enum_to_string()

2015-05-05 Thread Chad Versace
On Thu 23 Apr 2015, Emil Velikov wrote:
 On 22 April 2015 at 19:03, Frank Henigman fjhenig...@google.com wrote:
  Use the new WAFFLE_ENUM_LIST macro to implement waffle_enum_to_string()
  instead of specifying all the enums again.
  Now it will no longer be necessary to update waffle_enum_to_string()
  when adding an enum.
  Use bsearch() instead of a case statement, not because it's better,
  but to be symmetric with a new waffle_string_to_enum() function.
 
  Signed-off-by: Frank Henigman fjhenig...@google.com
  ---
   src/waffle/core/wcore_util.c | 94 
  ++--
   1 file changed, 47 insertions(+), 47 deletions(-)


  +static void
  +enum_sort()
  +{
  +static bool sorted = false;
  +if (sorted)
  +return;
  +qsort(enum_map_value, ARRAY_SIZE(enum_map_value), 
  sizeof(enum_map_value[0]),
  +  enum_cmp_value);
  +sorted = true;
  +}
  +

 FWIW I think that this is not something anyone should do at runtime.
 Regardless if we manually edit the list or generate it via the
 preprocessor/python script we can (and we should) sort it there.

I agree with Emil. The sorting should be done during compiletime.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/4] waffle: put waffle_enum items in a macro

2015-05-05 Thread Chad Versace
On Thu 23 Apr 2015, Emil Velikov wrote:
 On 23 April 2015 at 02:07, Frank Henigman fjhenig...@google.com wrote:
  On Wed, Apr 22, 2015 at 8:09 PM, Jordan Justen
  jordan.l.jus...@intel.com wrote:
  On 2015-04-22 11:03:47, Frank Henigman wrote:
  List all waffle_enum items in a big #define to avoid duplicating
  the list when a case is needed for each item, e.g. enum to string.
 
  This looks kind of yucky. :)
 
  When you recently mentioned the idea of changing wflinfo to be written
  in python, it made me think about python bindings for waffle.
 
  This lead me to think that it might be nice if the waffle API was
  defined by something like XML. This would allow us to generate
  waffle.h, python bindings, and things like this enum to string
  mapping.
 
  We do something similar (enum to string mapping) on the OpenGL API in
  piglit.
 
  -Jordan
 
  There seem to be three ways to generate the desired code:
  - manually repeating lists of stuff

Major yuk! I hate all the repetition in Waffle's codebase. I hate that
we have to sometimes add stuff in 3 separate locations.

  - with the preprocessor, as in this patch

Doable... But, I agree with Jordan and Emil. This preprocessor is too
yuk for a public header. I feel that the public header should be
readable code, a document that the user can refer to. This patch's macro
usage obfuscates the header's readability. (I point to xcb's public
headers as an example of well-readable, well-documented headers).

  - with external definitions and scripts

Generating a few source files with scripts seems like the right approach
to me. The danger here is that it's very easy to overengineer generator
scripts and their input files. However, since you currently only want to
dynamically generate enum code, I think we can safely keep the scripts
and data dumb and simple.

  What's the right tool for job?  Repetition might be ok if you only
  need something in a couple places, but gets old fast if you have to
  edit six places every time you want to add an item to a list.  XML and
  scripts might be appropriate if you need to do something complicated,
  something the preprocessor can't do.
  I chose middle ground here, to get rid of repetition as simply as possible.
  FWIW the macro list pattern has already been introduced to waffle.
  See wgbm_platform.h.
 
  Is your objection purely for aesthetic reasons or is there some
  technical drawback?
  If aesthetics are important, would it make any difference if we move
  the list macro out of the public header and into a private header?
  Then we'd be repeating the list once, but subsequent uses would employ
  the private macro. Though this would also deprive waffle users of the
  chance to use the macro.

Though this would also deprive waffle users of the chance to use the
macro. Oh no! I think we should *not* provide users any chance to use
these macros, If the header did contains these macros, then we should at
least make them *private* macros with a double-underscore prefix.
(Sigh... old friend C, why don't you have a proper module system?).

But, like I stated above, I want to avoid these macros altogether.

 
  Yucky is in the eye of the beholder.  (^:
 

:) Several people have called my gl_basic_draw() macro in
tests/functional/gl_basic_test.c weird and ugly, but I'm very proud of
it :)  That macro transforms a regular C function into a python-esque
function having optional named parameters with default values!

 FWIW I also find it yucky - be that here or in gbm_platform.h. I
 withheld my objection in the latter as I felt that 1) it's an internal
 header and 2) I may have been bashing a bit too much on your
 contributions :-)
 
 Although for a public header I would seriously object against this -
 ideally something like XML can be used, although if you (or others)
 feel like it's an overkill, I would be ok with moving it into internal
 header.

There's enough pushback on these macros from Jordan, Emil, and me, that
I think the best approach is to follow the steps of other projects, like
xcb and GL and piglit and libepoxy, and start generating waffle.h.

Since the only dynamically generated portion of waffle.h (for now, at
least) will be the enum definitions, there's no reason to use XML if you
feel it's overkill. (I'm also not opposed to XML, if you do want to go
that route).

My preference is to keep the generator scripts and their input dumb and
simple. Maybe we could add a json file somewhere that lists the enums
(and possibly their categories too).

# file: src/waffle/waffle_enums.json
{
waffle_error: [
[WAFFLE_NO_ERROR, 0x00],
[WAFFLE_ERROR_FATAL, 0x01],
...
],
waffle_enum: [
[WAFFLE_DONT_CARE, -1, generic],
[WAFFLE_NONE, 0, generic],
[WAFFLE_PLATFORM, 0x0010, waffle_init],
[WAFFLE_PLATFORM_ANDROID, 0x0011, waffle_init],
[WAFFLE_PLATFORM_CGL, 0x0011, waffle_init],
...
]
}

Re: [waffle] [PATCH 2/4] waffle: use enum list in waffle_enum_to_string()

2015-05-05 Thread Chad Versace
On Wed 22 Apr 2015, Frank Henigman wrote:
 Use the new WAFFLE_ENUM_LIST macro to implement waffle_enum_to_string()
 instead of specifying all the enums again.
 Now it will no longer be necessary to update waffle_enum_to_string()
 when adding an enum.
 Use bsearch() instead of a case statement, not because it's better,
 but to be symmetric with a new waffle_string_to_enum() function.
 
 Signed-off-by: Frank Henigman fjhenig...@google.com
 ---
  src/waffle/core/wcore_util.c | 94 
 ++--
  1 file changed, 47 insertions(+), 47 deletions(-)

[snip]

  const char*
  wcore_enum_to_string(int32_t e)
  {
 -switch (e) {
 -#define CASE(x) case x: return #x
 -
 -CASE(WAFFLE_DONT_CARE);
 -CASE(WAFFLE_NONE);
 -CASE(WAFFLE_PLATFORM);
 -CASE(WAFFLE_PLATFORM_ANDROID);
 -CASE(WAFFLE_PLATFORM_CGL);
 -CASE(WAFFLE_PLATFORM_GLX);
 -CASE(WAFFLE_PLATFORM_WAYLAND);
 -CASE(WAFFLE_PLATFORM_X11_EGL);
 -CASE(WAFFLE_PLATFORM_GBM);
 -CASE(WAFFLE_PLATFORM_WGL);
 -CASE(WAFFLE_PLATFORM_NACL);
 -CASE(WAFFLE_CONTEXT_API);
 -CASE(WAFFLE_CONTEXT_OPENGL);
 -CASE(WAFFLE_CONTEXT_OPENGL_ES1);
 -CASE(WAFFLE_CONTEXT_OPENGL_ES2);
 -CASE(WAFFLE_CONTEXT_OPENGL_ES3);
 -CASE(WAFFLE_CONTEXT_MAJOR_VERSION);
 -CASE(WAFFLE_CONTEXT_MINOR_VERSION);
 -CASE(WAFFLE_CONTEXT_PROFILE);
 -CASE(WAFFLE_CONTEXT_CORE_PROFILE);
 -CASE(WAFFLE_CONTEXT_COMPATIBILITY_PROFILE);
 -CASE(WAFFLE_CONTEXT_FORWARD_COMPATIBLE);
 -CASE(WAFFLE_CONTEXT_DEBUG);
 -CASE(WAFFLE_RED_SIZE);
 -CASE(WAFFLE_GREEN_SIZE);
 -CASE(WAFFLE_BLUE_SIZE);
 -CASE(WAFFLE_ALPHA_SIZE);
 -CASE(WAFFLE_DEPTH_SIZE);
 -CASE(WAFFLE_STENCIL_SIZE);
 -CASE(WAFFLE_SAMPLE_BUFFERS);
 -CASE(WAFFLE_SAMPLES);
 -CASE(WAFFLE_DOUBLE_BUFFERED);
 -CASE(WAFFLE_ACCUM_BUFFER);
 -CASE(WAFFLE_DL_OPENGL);
 -CASE(WAFFLE_DL_OPENGL_ES1);
 -CASE(WAFFLE_DL_OPENGL_ES2);
 -CASE(WAFFLE_DL_OPENGL_ES3);
 -CASE(WAFFLE_WINDOW_WIDTH);
 -CASE(WAFFLE_WINDOW_HEIGHT);
 -
 -default: return NULL;
 -
 -#undef CASE
 -}
 +enum_sort();
 +struct enum_map_entry key = { .value = e };
 +struct enum_map_entry *found = bsearch(key,
 +   enum_map_value,
 +   ARRAY_SIZE(enum_map_value),
 +   sizeof(enum_map_value[0]),
 +   enum_cmp_value);
 +if (!found)
 +return NULL;
 +
 +return found-name;
  }

Frank, for generating code like this, you may want to refer to very
similar enum_to_string code in Piglit for which I wrote a generator
script:


http://cgit.freedesktop.org/piglit/tree/tests/util/piglit-util-gl-enum-gen.c.mako?id=6122d1dba102b53602e5b19dd46d0975d28b6cd4

And another more complex script that generates piglit's GL dispatch:


http://cgit.freedesktop.org/piglit/tree/tests/util/piglit-dispatch-gen.c.mako?id=6122d1dba102b53602e5b19dd46d0975d28b6cd4

There's *lot* of complex generated code in Piglit that heavily uses Mako
templates. Adding Mako as a Waffle buildtime dependency might be
overkill for the little amount of code generation that Waffle needs to
do. On the other hand, for generating code, Mako templates are more
concise than ad-hoc Python scripts.

Mako, ad-hoc Python, or bash+sed --- It doesn't really matter to me
which gets used to generate this function. But I wanted to introduce you
to Piglit's Mako files anyway, just in case you ever needed to do crazy
complex code generation for some other purpose, for Waffle or any other
project.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 3/4] waffle: add waffle_string_to_enum()

2015-05-05 Thread Chad Versace
On Thu 23 Apr 2015, Emil Velikov wrote:
 On 22 April 2015 at 19:03, Frank Henigman fjhenig...@google.com wrote:
  From: Frank Henigman fjhenig...@gmail.com
 
  Add waffle_string_to_enum() which, given a string, returns the
  corresponding enum value.
  Since the main use is expected to be parsing command lines,
  the string case does not have to match, and some aliases exist.
  For example waffle_context_opengles2 will match WAFFLE_CONTEXT_OPENGL_ES2
  (note additional underscore in the enum name).
 
  Signed-off-by: Frank Henigman fjhenig...@google.com
  ---
   include/waffle/waffle.h  |  5 +
   man/waffle_enum.3.xml| 24 
   src/waffle/api/waffle_enum.c |  7 +++
   src/waffle/core/wcore_util.c | 36 
   src/waffle/core/wcore_util.h |  3 +++
   src/waffle/waffle.def.in |  1 +
   6 files changed, 76 insertions(+)


  @@ -83,6 +92,14 @@ enum_cmp_value(const void *v1, const void *v2)
 
   #define NAME_VALUE(name, value) { #name, value },
 
  +static struct enum_map_entry enum_map_name[] = {
  +WAFFLE_ENUM_LIST(NAME_VALUE)
  +// aliases
  +{ WAFFLE_CONTEXT_OPENGLES1, WAFFLE_CONTEXT_OPENGL_ES1 },
  +{ WAFFLE_CONTEXT_OPENGLES2, WAFFLE_CONTEXT_OPENGL_ES2 },
  +{ WAFFLE_CONTEXT_OPENGLES3, WAFFLE_CONTEXT_OPENGL_ES3 },

 What inspired you to add these aliases - was it wflinfo ? No
 objections here (actually I think it's a very nice idea) just curios.

I also like the aliases and the case insensitivity.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 07/10] waffle: add full screen window request

2015-04-24 Thread Chad Versace
On Thu 23 Apr 2015, Emil Velikov wrote:
 On 22 April 2015 at 20:26, Chad Versace wrote:
  On Fri 10 Apr 2015, Emil Velikov wrote:
  On 09/04/15 22:48, Chad Versace wrote:
   On Mon 30 Mar 2015, Frank Henigman wrote:
 
   diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
   index 297a487..df0218e 100644
   --- a/include/waffle/waffle.h
   +++ b/include/waffle/waffle.h
   @@ -172,6 +172,7 @@ enum waffle_enum {
  
   WAFFLE_WINDOW_WIDTH = 
   0x0310,
   WAFFLE_WINDOW_HEIGHT= 
   0x0311,
   +WAFFLE_WINDOW_FULLSCREEN=
   0x0312,
  
   wcore_enum_to_string must be taught about the new enum.
  
  Hi Chad,
 
  Should one wrap the new enum in #if WAFFLE_API_VERSION = 0x1070 ? Or it
  only makes sense for new entry points into the waffle library ?
  Considering that WAFFLE_WINDOW_{WIDTH,HEIGHT} went in without the API
  guard, I'm leaning towards the latter.
 
  I'm unsure. Other libraries that use feature test macros, what do they
  do? For the record, when adding WAFFLE_CONTEXT_FORWARD_COMPATIBLE and
  WAFFLE_CONTEXT_DEBUG, I guarded those with 0x0130. But I'm open to
  guarding only entry points if that makes more sense.
 
 That's the key that brought us here in the first place ;-) From a
 quick look at my /usr/include all of the feature test macros are used
 to guard structs (be that new ones or ABI changes) and functions
 prototypes. Haven't seen one guarding enums/defines.
 
  I think we should research what other libraries do before committing to
  a decision.
 
 Personally I would opt for dropping the guards in enums
  - GDK, xfixes, jpeglib guards only structs/functions,
  - anyone can provide a dummy/invalid value, it's up-to the API to
 disregard/ignore it :-)

Ok, then that's the policy going forward. Guard structs and functions,
but not enums. Thanks for doing the research, Emil.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-04-22 Thread Chad Versace
On Fri 10 Apr 2015, Jordan Justen wrote:
 On 2015-04-10 07:05:32, Frank Henigman wrote:
  Sorry I let this thread get stale.

I apologise too for letting it go stale.

   On 02/20/2015 01:49 PM, Jordan Justen wrote:
   My idea was just to define a one-time API that left presentation of
   the strings to the user of the library. Therefore, the Core API
   wouldn't ever need to change past that point. It was also an attempt
   to make it fairly easy to iterate through the results.
  
  I couldn't agree with this more.  I was being a bit lazy in my
  thinking before but I've seen the light.
  So we want the core to provide information in a form that can be
  used/presented by the caller as they like.
  So why not just provide JSON?  It's simple (just returns a string) and
  future-proof (new key/value pairs can be added for those who want them
  and ignored by others) and there are numerous libraries for processing
  JSON.
  I think it's the only core info API we need.
 
 I could get on board with this. It does seem like a good enough API.
 Although I'm sure it'll make things a little more annoying for some
 consumers.
 
 For example, an app might have just wanted to select the TEXT version,
 and dump it to some dialog box. Now, they'd have to deal with the JSON
 first.

I could get on board with this too. Having a canonical format makes
a lot of sense. And JSON is a sensible choice. (The only sensible
choices, I believe, are JSON and XML).

I also share Jordan's concern that JSON may cause some annoyance for
some consumers. But I think we can adopt a policy that accomodates all
consumers: This is JSON. Just deal with it. JSON is an ubiquitous
format for exchanging text data, and every language (even Bash) has
easy-to-use JSON tools. So Just deal with it is a sensible policy in
my opinion.

 I don't know who might have preferred XML, but I'm thinking JSON/XML
 has a vi/emacs sort of rivalry going on... :)

Well said :)

I think XML is overkill for the Waffle data we're discussing. And plain
text is too unstructured. JSON feels just right.

  Then wflinfo can be re-implemented (preferably in python) as something
  that gets the JSON string from the library and presents it in one or
  more ways similar to what wflinfo does now.
 
 Hmm, I like python, so this seems attractive. :)
 
 But, I don't like the thought of having to make python libraries be a
 wflinfo dependency.
 
  Those who are already parsing glxinfo or wflinfo output can continue
  to do that, but will now have the option of parsing the JSON, which
  should be more robust.  I think we can also make the raw JSON friendly
  to simple grepping, with judiciously placed newlines.
  If there are no objections to this plan, I'll work on an implementation.
 
 I'm okay with going the JSON only route.

The JSON plan sounds good to me too.

 I think I'd prefer to not convert wflinfo to python.

I also hesitate to convert wflinfo to python. After we push all the
complexity of wflinfo.c into a library call, then wflinfo.c will largely
consist of argparsing and a minimal json parser. wflinfo.c will then be
so small that I don't expect to gain much benefit in moving it to
wflinfo.py. (I expect moving it to Python might make it *more*
complicated if its argparsing code attempts to be python-2-and-3
compatible).
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 07/10] waffle: add full screen window request

2015-04-22 Thread Chad Versace
On Thu 16 Apr 2015, Frank Henigman wrote:
 On Thu, Apr 9, 2015 at 6:48 PM, Chad Versace chad.vers...@intel.com wrote:
  On Mon 30 Mar 2015, Frank Henigman wrote:
 
  You can now put WAFFLE_WINDOW_FULLSCREEN in the attribute list passed
  to waffle_window_create2() and get a full screen window.
  Only glx and x11_egl implemented so far.
 
 
  I like the idea of WAFFLE_WINDOW_FULLSCREEN. Comments below.
 
  +WAFFLE_WINDOW_FULLSCREEN= 0x0312,
 
 
  wcore_enum_to_string must be taught about the new enum.
 
 Done in v2 (sent separately).  Docs updated too.

Ok, I'll take a look at v2.

 On the topic of queries, I'd like to be able to query a window after
 creation, particularly to get the size that resulted from a full
 screen request, but other queries might be useful too.  How about
 analogues to eglQueryContext and eglQuerySurface?

Analogues to eglQueryContext and eglQuerySurface would indeed be useful.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v2] waffle: add full screen window request

2015-04-22 Thread Chad Versace
On Thu 16 Apr 2015, Frank Henigman wrote:
 You can now put WAFFLE_WINDOW_FULLSCREEN in the attribute list passed
 to waffle_window_create2() and get a full screen window.
 Only glx and x11_egl implemented so far.
 
 Signed-off-by: Frank Henigman fjhenig...@google.com
 ---
 v2
 - value, not mere presence, of WAFFLE_WINDOW_FULLSCREEN attribute
   determines full screen request
 - process all size attributes in waffle_window_create2() so the platforms
   don't have to
 - return an error from all platforms that don't support full screen
   - NOTE: I HAVE NOT EVEN COMPILED MOST OF THESE
 - update wcore_enum_to_string()
 - update documentation

Reviewed-by: Chad Versace chad.vers...@intel.com

I'll commit this to master today.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 07/10] waffle: add full screen window request

2015-04-22 Thread Chad Versace
On Fri 10 Apr 2015, Emil Velikov wrote:
 On 09/04/15 22:48, Chad Versace wrote:
  On Mon 30 Mar 2015, Frank Henigman wrote:
  You can now put WAFFLE_WINDOW_FULLSCREEN in the attribute list passed
  to waffle_window_create2() and get a full screen window.
  Only glx and x11_egl implemented so far.
  
  I like the idea of WAFFLE_WINDOW_FULLSCREEN. Comments below.
  
  Signed-off-by: Frank Henigman fjhenig...@google.com
  ---
  include/waffle/waffle.h|  1 +
  src/waffle/api/waffle_window.c | 69
  ++
  src/waffle/glx/glx_window.c| 12 ++--
  src/waffle/xegl/xegl_window.c  | 13 ++--
  4 files changed, 59 insertions(+), 36 deletions(-)
 
  diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
  index 297a487..df0218e 100644
  --- a/include/waffle/waffle.h
  +++ b/include/waffle/waffle.h
  @@ -172,6 +172,7 @@ enum waffle_enum {
 
  WAFFLE_WINDOW_WIDTH = 0x0310,
  WAFFLE_WINDOW_HEIGHT= 0x0311,
  +WAFFLE_WINDOW_FULLSCREEN=
  0x0312,
  
  wcore_enum_to_string must be taught about the new enum.
  
 Hi Chad,
 
 Should one wrap the new enum in #if WAFFLE_API_VERSION = 0x1070 ? Or it
 only makes sense for new entry points into the waffle library ?
 Considering that WAFFLE_WINDOW_{WIDTH,HEIGHT} went in without the API
 guard, I'm leaning towards the latter.

I'm unsure. Other libraries that use feature test macros, what do they
do? For the record, when adding WAFFLE_CONTEXT_FORWARD_COMPATIBLE and
WAFFLE_CONTEXT_DEBUG, I guarded those with 0x0130. But I'm open to
guarding only entry points if that makes more sense.

I think we should research what other libraries do before committing to
a decision.

 Speaking of which what is the status of waffle_display_print_info() ?
 Mostly curious than anything else.

I CC'd you today on the relevant thread.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] android: Don't specify -std=gnu99 for C++ builds -- it breaks clang

2015-04-22 Thread Chad Versace
On Thu 09 Apr 2015, Emil Velikov wrote:
 From: Bernhard Rosenkränzer bernhard.rosenkran...@linaro.org
 
 Signed-off-by: Bernhard Rosenkränzer bernhard.rosenkran...@linaro.org
 [Emil Velikov: Apply the workaround for kitkat and older]
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---
  Android.mk | 9 -
  1 file changed, 8 insertions(+), 1 deletion(-)

Thanks. I'll commit this to master and maint-1.5 today.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 00/10] nacl dl rework and header cleanups et all

2015-04-09 Thread Chad Versace

On Tue 24 Mar 2015, Emil Velikov wrote:

Hi all,

Was pondering on the trivial nacl_dl* nitpick I was talking about
earlier and I've noticed something more interesting along the way.
Namely: in some places in waffle we include headers explicitly wrapped
for C linkage (extern C { #include foo.h }).

As mentioned by Jose over at mesa-dev and Oracle's acticle [1] one
should avoid doing so as the system headers might have C++ symbols.

So with this series I've added added extra guards where needed, reworked
the header inclusion, and nacl_cl similar to other parts in waffle and
added a few missing pragma once guards.

Patch 6 is slightly on the bikeshed side, so I won't object it people
want to take it out the back and shoot it :-P


Emil, these cleanups look good to me. And I agree that bike-sheddy patch
6 does make the code a bit more readable. All patches are

Reviewed-by: Chad Versace chad.vers...@intel.com

Please add mine and Tapani's r-b's to your patches and send a pull
request. (I tried applying and pushing the patches myself, but
encountered some git-am conflicts I didn't understand).
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v2 2/3] wcore: rework non-compatible mutex initialization

2015-03-27 Thread Chad Versace
Quoting Emil Velikov (2015-03-26 19:24:21)
 On 26 March 2015 at 14:50, Chad Versace chad.vers...@intel.com wrote:
  Quoting Emil Velikov (2015-03-25 07:30:00)
  Indeed you're bang on the spot. id_counter should be locked throughout
  a series of display_{connect, disconnect}, thus we should push
  mtx_{init,destroy} up to waffle_{init,teardown}. What worries me is
  that none of the tests (ran in valgrind) point out any issues.
 
  I could be wrong, but I believe pthread_mutex_create/destroy don't
  allocate/free memory. They just initialize/reset the fields in the
  pthread_mutex_t struct. (Otherwise, how would PTHREAD_MUTEX_INITIALIZER
  work?). That may explain why you didn't see the expected Valgrind
  errors, because no allocation took place.
 
 I was thinking about thread 2 diving into display_connect() and
 attempting to lock a destroyed mutex. Afaics in such case the function
 will return EINVAL, which I naively assumed that is a undefined
 behaviour. Although with the failed locking around id_counter I assume
 another problem could have happened.

Not a naive assumption. POSIX does define that undefined behavior occurs
if you try to lock an uninitialized or destroyed mutex. From
the pthread_mutex_lock(3p) manpage:

   If mutex does not refer to an initialized mutex object, the behavior of
   pthread_mutex_lock(), pthread_mutex_trylock(), and
   pthread_mutex_unlock() is undefined.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v3 4/4] wayland: resolve wayland-client symbols at runtime (via libdl)

2015-03-26 Thread Chad Versace
Quoting Emil Velikov (2015-03-18 13:03:08)
 On 17 March 2015 at 19:54, Chad Versace chad.vers...@intel.com wrote:
  Hey Emil,
 
  The patches look good to me, though I haven't tested them yet.
  I'm going to run the patches through a Piglit run and, if I
  find no regressions, I'll push them.
 Great thanks.
 
 Looking at the next times on the top of my waffle todo:
  - Rework the waffle test - fold the test init and teardown within the
 waffle test hooks.
 Will allow us to use the waffle_init() waffle_teardown(), effectively
 reloading waffle for each test. We can even intentionally randomise
 the tests across threads, to ensure that the going from platfrom_foo
 to platform_bar does not cause problems.
 
 It will be quite some work so if I'd like your opinion on it before I
 crack on it.

Do you mean calling waffle_init() and waffle_teardown() before and after
tests/functional/gl_basic.c:gl_basic_draw(), or something similar to
that? If so, that sounds like a good idea, especially the optional
randomization of tests across threads. That should provide some good
test coverage of Waffle handling (serially, though not concurrently)
multiple platforms in one process.

  - Remove the xcb + libX11 link time dependency (rework the platforms
 to use libX11 alone).
 I'm leaning towards the latter, as it would simplify things. Although
 I'm a but uncertain if you chose the mixed design due to some
 technical reason ?

Technical reasons did drive my decision.

Originally, I tried to write Waffle's X11 code using only Xlib. After
trying for several days (I am no X expert) I gave up and moved to xcb,
which I got working after just a few hours. (I attribute my failure not
only to Xlib having an awful API but also to my lack of familiarity with
it).

I was unable to go purely with xcb, though, because the native_display
parameter of eglGetDisplay must be an Xlib Display.  Ironically, Mesa's
EGL makes exactly one Xlib call, XGetXCBConnection, and uses only xcb
afterwards.

I think we have some strong precedent for avoiding Xlib:
- Mesa's EGL decided to use only xcb and not Xlib.
- Mesa's GLX DRI2 implementation is implemented with a mixture of
  Xlib calls and rolling X protocol by hand. When keithp later wrote
  Mesa's GLX DRI3 code, he decided to do it in pure xcb.
- If we have any questions or problems with xcb, the library's
  source code is very readable.

In summary, my technical reasons were:
- XCB's API is easier to understand (for me, at least).
- The XCB API is actively extended to support new X11 protocol. Xlib
  is not, as far as I can tell.
- XCB's source is easy to understand.
- Other projects avoid Xlib too for similar reasons.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 1/3] third_party/threads: Use PTHREAD_MUTEX_RECURSIVE by default

2015-03-26 Thread Chad Versace
Quoting Emil Velikov (2015-03-19 15:26:11)
 PTHREAD_MUTEX_RECURSIVE_NP was used for compatibility with old glibc.
 Although due to the_GNU_SOURCES define the portable,
 PTHREAD_MUTEX_RECURSIVE will be available for Linuxes since at least
 1998. Simplify things giving us compatibility with musl which
 apparently does not provide the non-portable define.
 
 Inspired by almost identical commit in mesa aead7fe2e2b(c11/threads: Use
 PTHREAD_MUTEX_RECURSIVE by default) by Felix Janda.
 
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---
  third_party/threads/threads_posix.c | 10 --
  1 file changed, 4 insertions(+), 6 deletions(-)

Reviewed-by: Chad Versace chad.vers...@intel.com

This patch looks safe to land before the others in the series, so I'll
go ahead and commit it.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] gl_basic: request alpha planes

2015-03-26 Thread Chad Versace
Thanks. I'll merge this to stable branches and master.

Quoting Frank Henigman (2015-03-23 18:34:44)
 Alpha planes are written and read, so we should ask for them in the config.
 
 Signed-off-by: Frank Henigman fjhenig...@google.com
 ---
  examples/gl_basic.c | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/examples/gl_basic.c b/examples/gl_basic.c
 index ab9c78c..e59dc11 100644
 --- a/examples/gl_basic.c
 +++ b/examples/gl_basic.c
 @@ -639,6 +639,8 @@ main(int argc, char **argv)
  config_attrib_list[i++] = 8;
  config_attrib_list[i++] = WAFFLE_BLUE_SIZE;
  config_attrib_list[i++] = 8;
 +config_attrib_list[i++] = WAFFLE_ALPHA_SIZE;
 +config_attrib_list[i++] = 8;
  config_attrib_list[i++] = WAFFLE_DOUBLE_BUFFERED;
  config_attrib_list[i++] = true;
  config_attrib_list[i++] = 0;
 -- 
 2.2.0.rc0.207.ga3a616c
 
 ___
 waffle mailing list
 waffle@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/waffle
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v2 2/3] wcore: rework non-compatible mutex initialization

2015-03-26 Thread Chad Versace
Quoting Emil Velikov (2015-03-25 07:30:00)
 On 24 March 2015 at 17:37, Jose Fonseca jfons...@vmware.com wrote:
  Is wcore_display_teardown called only once, or when destroying each display?
 
  If the latter, then it's not safe to call `mtx_destroy(mutex)` on
  `wcore_display_teardown`.  Otherwise when  wcore_display_init is called
  next, wcore_display_init_once() will not be called a 2nd time, hence mutex
  will stay invalid.
 
 
  This should probably done at waffle_teardown.

Right. The mutex should be destroyed, if anywhere, in waffle_teardown().
But, we should probably not destroy it at all, because of my next
suggestion...

  BTW, if the mutex was initialized at waffle_init, then once_flag wouldn't
  even be necessary.

Technically correct, but I eventually want to deprecate waffle_init(),
moving its platform parameter to a new waffle_display_connect()
function. Using a once_flag in wcore_display_init() fits better with
that longterm goal. Let's keep Emil's once_flag in this patch.

If use a once_flag, then I believe there is no safe place to
destroy the mutex, because we can't re-initialize the mutex by calling
wcore_display_init_once() a second time.

Which leads to the question: Emil, what benefit do you expect from
destroying the mutex? If Waffle were continuously creating mutexes, then
Waffle would need to destroy them too to prevent leaks. But Waffle only
creates a small, fixed number of global mutexes during the process's
lifetime. And leaking them doesn't lead to ongoing memory loss.
Moreover, with pthreads... see my comments below.

 Indeed you're bang on the spot. id_counter should be locked throughout
 a series of display_{connect, disconnect}, thus we should push
 mtx_{init,destroy} up to waffle_{init,teardown}. What worries me is
 that none of the tests (ran in valgrind) point out any issues.

I could be wrong, but I believe pthread_mutex_create/destroy don't
allocate/free memory. They just initialize/reset the fields in the
pthread_mutex_t struct. (Otherwise, how would PTHREAD_MUTEX_INITIALIZER
work?). That may explain why you didn't see the expected Valgrind
errors, because no allocation took place.

 Might be worth looking into, once I've got waffle_teardown() hooked in there.
 
 -Emil
 ___
 waffle mailing list
 waffle@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/waffle
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v3 4/4] wayland: resolve wayland-client symbols at runtime (via libdl)

2015-03-17 Thread Chad Versace
Hey Emil,

The patches look good to me, though I haven't tested them yet.
I'm going to run the patches through a Piglit run and, if I
find no regressions, I'll push them.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 0/4] Remove link-time dependency of libwayland*

2015-03-03 Thread Chad Versace
On 03/03/2015 08:30 AM, Emil Velikov wrote:
 On 26 February 2015 at 21:26, Chad Versace chad.vers...@intel.com wrote:
 On 02/23/2015 12:32 PM, Emil Velikov wrote:
 Hello list,

 Second to last part of removing all the window specific bits from
 link-time to run-time (hail libdl).

 Note that the last patch looks a bit messy, mostly due to the wayland
 design approach to have a handful of functions defined as static inlines
 in the public header.

 This has been compiled tested only, as I don't have a wayland setup atm.
 Will see if anyone volunteers over at #wayland (touch wood).

 I run Waffle's Wayland tests inside an X session. You can run Weston
 inside an X window.

 $ sudo yum install weston
 $ nohup weston 
 $ wflinfo -p wayland -a gles2


 As usual the series can be found at my github repo in branch
 wip/no-libwayland.

 Comments, suggestions even moderate bike-shed is welcome.

 wl_display_connect() crashes with SIGSEGV. I suspect the problem
 is a symbol collision: a wl_display_connect symbol exists in
 libwaffle and in the dlopened libwayland-client. But I'm not
 confident in that guess.

 This patch series is crazy stuff :) Before it's complete
 and working, we'll probably learn a few things about linker magic.

 Maybe I should be building libwaffle with -Bsymbolic? Hmm

 I fear that -Bsymbolic does not cut it :'(
 
 I've went ahead with another solution inspired by SDL. Admittedly it's
 not pretty, but it does not violate the spec (like v1), plus it even
 works - double-checked via your instructions above.
 
 The whole things in a nutshell can be seen below:
 
 $ cat wrapper.h
 
 foo *
 (*wrapper_wl_foo)(...);
 
 #define wl_foo (*wrapper_wl_foo)
 
 #include wayland-foo.h
 
 We're nearly there :-)

Ahhh Yes, that should work. That's the same trick
used by libepoxy and piglit-dispatch.

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


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-02-26 Thread Chad Versace
On 02/20/2015 01:49 PM, Jordan Justen wrote:
 On 2015-02-20 12:58:07, Chad Versace wrote:
 On 02/17/2015 11:30 PM, Jordan Justen wrote:


 For the sake of apps who want to dump the info to a log file or to
 the console and get on
 with their lives, I think the default output format should be a
 single, giant string. But, as we're discovering in this conversation,
 a single giant string might not be appropriate as a one-size-fits-all format.
 I believe we can have it both ways, though, by adding some optional 
 parameters
 to the API.

   void*
   waffle_display_get_info(struct waffle_display *dpy,
   enum waffle_display_info_format format,
   uint32_t flags);

 Then we have the ability to define API like this:

// Returns a single, string suitable for log output. The return value
// must be cast to `char*`. One valid flag is currently defined for this
// format, WAFFLE_DISPLAY_INFO_VERBOSE_BIT.
waffle_display_get_info(dpy, WAFFLE_DISPLAY_INFO_FORMAT_SIMPLE, 0)

// Returns Jordan array of strings. The return value must be cast to 
 `char**`.
// One valid flag is currently defined for this format,
// WAFFLE_DISPLAY_INFO_VERBOSE_BIT.
waffle_display_get_info(dpy, WAFFLE_DISPLAY_INFO_FORMAT_JORDAN, 0);

// Returns a JSON string. The return valud must be cast to `char*`. Two
// flags are currently defined for this format: 
 WAFFLE_DISPLAY_INFO_VERBOSE_BIT
// and WAFFLE_DISPLAY_INFO_INDENT_BIT.
waffle_display_get_info(dpy, WAFFLE_DISPLAY_INFO_FORMAT_JSON, 0);

 Of course, the simple and jordan formats will be the first ones 
 implemented.
 People can implement other formats in the future. (The JSON format, I'm just
 using that as a hypothetical example.)

 Do you think this is a good compromise between usability and extensibility? 
 Does
 my proposal lack some important knob you think is needed? Or is my proposal 
 just
 overall a bad idea?
 
 My idea was just to define a one-time API that left presentation of
 the strings to the user of the library. Therefore, the Core API
 wouldn't ever need to change past that point. It was also an attempt
 to make it fairly easy to iterate through the results.
 
 One example of trouble we might get into could be
 WAFFLE_DISPLAY_INFO_FORMAT_GLXINFO. Meaning we try to comma separate
 and break lines.
 
 Except, we wouldn't know the best line length to use for breaking
 lines. In that case it more likely the application could best format
 it. (Assuming it was able to read the console text resolution.)
 
 But, I have to admit, your idea probably would be pretty helpful to
 some applications. For example, JSON would probably be used by piglit.
 
 Assuming you don't think the string pointers output is too horribly
 complex to document, then this seems like a good set to consider:
 * WAFFLE_DISPLAY_INFO_FORMAT_STRING_POINTERS
 * WAFFLE_DISPLAY_INFO_FORMAT_TEXT
 * WAFFLE_DISPLAY_INFO_FORMAT_JSON
 * WAFFLE_DISPLAY_INFO_FORMAT_XML
 * WAFFLE_DISPLAY_INFO_FORMAT_CSV (Eh, I'm not sure I like this one.)
 
 The last 4 would be easy to implement based on the first.
 
 This set seems like enough where we could avoid the need to add any
 more formats.

That set looks good to me, except for CSV. I don't like CSV.

The name STRING_POINTERS is clunky, but I can't think of a better
alternative.

For a first pass, I think we should implement STRING_POINTERS and
TEXT. Then, soon after that, JSON. I consider XML a nice-to-have
right now, just because I don't want to think about schema versioning.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] gbm: Use EGLConfig to select the correct gbm format

2015-02-26 Thread Chad Versace
On 02/24/2015 10:43 AM, Tom Stellard wrote:
 ---
 
 I think this is better than my original patch:
 http://lists.freedesktop.org/archives/waffle/2015-February/001070.html
 
 However, piglit tests still fail because the alpha channel is always 1.0.
 The gbm format being selected by eglGetConfigAttrib() is
 GBM_FORMAT_XRGB, and I'm not sure if this is a bug in my patch
 or something I need to fix in the EGL implementation.

Thanks. Patch is merged to maint-1.4, maint-1.5, and master branches.
It looks completely correct.

Me and Daniel Stone diagnosed the Mesa bug. See 12:36 in the irc log.
http://people.freedesktop.org/~cbrill/dri-log/?channel=dri-develhighlight_names=date=2015-02-26




signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] gbm: Use EGLConfig to select the correct gbm format

2015-02-26 Thread Chad Versace
By the way, I wrote a little Python script to ease the debugging
of GBM formats. You may find it useful too. Here's the example
usage:

$ gbm-format GBM_FORMAT_BGRA1010102
0x30334142

$ gbm-format 0x30334142
GBM_FORMAT_BGRA1010102

$ gbm-format B A 3 0
GBM_FORMAT_BGRA1010102

 -8-  file: ~/bin/gbm-format
#!/usr/bin/env python3

import os
import os.path
import re
import sys

PROGNAME = os.path.basename(sys.argv[0])

def print_usage(file=None):
print('usage: ', file=file)
print('  {0} GBM_FORMAT_'.format(PROGNAME), file=file)
print('  {0} 0xabcd1234'.format(PROGNAME), file=file)
print('  {0} a b c d'.format(PROGNAME), file=file)

def usage_error():
print_usage(sys.stderr)
sys.exit(1)

def atoi(c):
assert(len(c) == 1)
return c.encode()[0]

def gbm_fourcc_code(a, b, c, d):
return (a) | (b  8) | (c  16) | (d  24)

def gbm_iter_header():
regex = re.compile(#define\s+(GBM_FORMAT_\w+)\s+__gbm_fourcc_code\('(.)', 
'(.)', '(.)', '(.)'\))

with open('/usr/include/gbm.h') as f:
for line in f:
m = regex.match(line)
if m is None:
continue

test_name = m.group(1)
test_code = gbm_fourcc_code(*map(atoi, m.group(2, 3, 4, 5)))

yield test_name, test_code

def gbm_fourcc_code_to_name(code):
for hname, hcode in gbm_iter_header():
if hcode == code:
return hname

def gbm_fourcc_name_to_code(name):
for hname, hcode in gbm_iter_header():
if hname == name:
return hcode

def cmd_find_name(code):
name = gbm_fourcc_code_to_name(code)
if name is None:
die('failed to find name of fourcc code 0x{:x}'.format(code))
print(name)

def cmd_find_code(name):
code = gbm_fourcc_name_to_code(name)
if code is None:
die('failed to find fourcc code for {}'.format(name))
print('0x{:x}'.format(code))

def main():
if len(sys.argv) == 2:
if sys.argv[1].startswith('GBM_FORMAT_'):
name = sys.argv[1]
cmd_find_code(name)
elif sys.argv[1].startswith('0x') or sys.argv[1].startswith('0X'):
code = int(sys.argv[1], 16)
cmd_find_name(code)
else:
usage_error()
elif len(sys.argv) == 5:
code = gbm_fourcc_code(*map(atoi, sys.argv[1:5]))
cmd_find_name(code)
else:
usage_error()

if __name__ == '__main__':
main()



signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 0/4] Remove link-time dependency of libwayland*

2015-02-26 Thread Chad Versace
On 02/23/2015 12:32 PM, Emil Velikov wrote:
 Hello list,
 
 Second to last part of removing all the window specific bits from 
 link-time to run-time (hail libdl).
 
 Note that the last patch looks a bit messy, mostly due to the wayland 
 design approach to have a handful of functions defined as static inlines 
 in the public header.
 
 This has been compiled tested only, as I don't have a wayland setup atm.
 Will see if anyone volunteers over at #wayland (touch wood).

I run Waffle's Wayland tests inside an X session. You can run Weston
inside an X window.

$ sudo yum install weston
$ nohup weston 
$ wflinfo -p wayland -a gles2

 
 As usual the series can be found at my github repo in branch 
 wip/no-libwayland.
 
 Comments, suggestions even moderate bike-shed is welcome.

wl_display_connect() crashes with SIGSEGV. I suspect the problem
is a symbol collision: a wl_display_connect symbol exists in
libwaffle and in the dlopened libwayland-client. But I'm not
confident in that guess.

This patch series is crazy stuff :) Before it's complete
and working, we'll probably learn a few things about linker magic.

Maybe I should be building libwaffle with -Bsymbolic? Hmm




signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-02-20 Thread Chad Versace
On 02/17/2015 11:30 PM, Jordan Justen wrote:
 On 2015-02-10 12:09:05, Chad Versace wrote:
 On Sun, Feb 08, 2015 at 07:50:15PM -0500, Frank Henigman wrote:
 I'd like to extend wflinfo so it can print platform-specific
 information and eventually be able to replace glxinfo, eglinfo and the
 like (I only know what's on linux).  There would be a new flag to
 request the platform-specific output in addition to the existing
 output.  For example on glx you'd see glx extensions, on egl you'd see
 egl extensions.
 I've started two different implementations and I'd like to know which
 is preferred before I go any farther.  Or if there's a better idea
 than either of my approaches.  I've dubbed the two approaches native
 and core.

 native
 - all the work is done in wflinfo, no changes to waffle api
 - use waffle_display_get_native() to access platform-specific stuff
 - pro: changes limited to wflinfo, doesn't clutter up the rest of waffle
 - con: some duplicate code to open libraries and lookup symbols
 - https://github.com/fjhenigman/waffle/tree/ps_native

 core
 - add waffle_display_print_info() to waffle api
 - add print_info() method to each platform
 - pro: less code, no duplication
 - con (perhaps): some wflinfo functionality is now in core waffle
 - https://github.com/fjhenigman/waffle/tree/ps_core

 I'm leaning toward core because there is less code.  We get to
 leverage the platform libraries and functions already stored in waffle
 platform structs.  But if the consensus is it's cleaner to keep this
 stuff in wflinfo I'm ok with that too.

 I prefer core too. Not for the sake of less code, but because I like
 the idea of it being available as core API.
 
 This surprised me a bit. I wouldn't think of the waffle library
 wanting to embed a bunch of strings to fulfill such an API.

Embedding string? I don't understand. Your proposal needs embedded
strings too: the strings for the key values.

If Waffle provides the display info in one big string or in a sequence
of little strings, as you propose, the same key strings need to be
embedded into the library. Am I missing something?

 Anyway... how about this:
 
 char**
 waffle_display_info_strings(struct waffle_display *self, bool verbose);
 
 The returned array of strings could have this property:
 
 First look for a key string pointer. If it is NULL, then you are done.
 If you find non-NULL key string pointer then search for 0 or more
 non-NULL value string pointers. When a NULL pointer is seen, go back
 to looking for a key string pointer.
 
 I've attached an example program that sort of emulates wflinfo...
 
 This would allow the consumer to use comma separation and/or line
 breaks as desired.

For the sake of apps who want to dump the info to a log file or to
the console and get on
with their lives, I think the default output format should be a
single, giant string. But, as we're discovering in this conversation,
a single giant string might not be appropriate as a one-size-fits-all format.
I believe we can have it both ways, though, by adding some optional parameters
to the API.

  void*
  waffle_display_get_info(struct waffle_display *dpy,
  enum waffle_display_info_format format,
  uint32_t flags);

Then we have the ability to define API like this:

   // Returns a single, string suitable for log output. The return value
   // must be cast to `char*`. One valid flag is currently defined for this
   // format, WAFFLE_DISPLAY_INFO_VERBOSE_BIT.
   waffle_display_get_info(dpy, WAFFLE_DISPLAY_INFO_FORMAT_SIMPLE, 0)

   // Returns Jordan array of strings. The return value must be cast to 
`char**`.
   // One valid flag is currently defined for this format,
   // WAFFLE_DISPLAY_INFO_VERBOSE_BIT.
   waffle_display_get_info(dpy, WAFFLE_DISPLAY_INFO_FORMAT_JORDAN, 0);
   
   // Returns a JSON string. The return valud must be cast to `char*`. Two
   // flags are currently defined for this format: 
WAFFLE_DISPLAY_INFO_VERBOSE_BIT
   // and WAFFLE_DISPLAY_INFO_INDENT_BIT.
   waffle_display_get_info(dpy, WAFFLE_DISPLAY_INFO_FORMAT_JSON, 0);

Of course, the simple and jordan formats will be the first ones implemented.
People can implement other formats in the future. (The JSON format, I'm just
using that as a hypothetical example.)

Do you think this is a good compromise between usability and extensibility? Does
my proposal lack some important knob you think is needed? Or is my proposal just
overall a bad idea?



signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] man: fix waffle_teardown description

2015-02-17 Thread Chad Versace
On 02/16/2015 02:41 PM, Emil Velikov wrote:
 Seems like I've used a bit too many tags, which caused some issues while
 generating the man/html page.
 
 Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
 ---
  man/waffle_teardown.3.xml | 39 ++-
  1 file changed, 18 insertions(+), 21 deletions(-)

Thanks, pushed.




signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-02-11 Thread Chad Versace
On 02/10/2015 01:20 PM, Frank Henigman wrote:
 On Tue, Feb 10, 2015 at 4:08 PM, Frank Henigman fjhenig...@google.com wrote:

 Looks like Issue #3 is the format of the information.  I thought it
 was given we should duplicate existing glxinfo/eglinfo/etc as closely
 as possible, in order to be a drop-in replacement, but if I follow the
 suggestions Chad made on github
 (https://github.com/fjhenigman/waffle/commit/d0b45bb9850e6ae29ee379a2d3e8ba14afc1b872)
 we'll be diverging.  Improving on existing tools is ok with me - I
 don't have a huge investment in code to parse their output - but I
 wonder if others feel differently.

(+Jordan, +Dylan, questions below)

Oh, when I made those Github comments, I didn't know you were trying to
duplicate glxinfo output verbatim. Now I understand why the GLX lines
look so different from wflinfo's current output.

glxinfo wraps long lines for extension strings and separates extension names 
with commas.
wflinfo intentionally prints extensions strings in their original form: single 
line,
extension names separated by spaces. If I recall correctly, Jordan and Dylan 
wanted
that format so that consumers who parsed wflinfo text output would be 
guaranteed a stable
format.

If wflinfo has mixed line formats (some lines are comma-separated and wrapped, 
some
are space-separated), I fear that may cause problems for already-existing 
consumers.
Dylan, Jordan, do you have an opinion here? Does this really matter?



signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH] gbm: Don't use a config that mesa's gbm doesn't support

2015-02-11 Thread Chad Versace
On 02/11/2015 09:53 AM, Tom Stellard wrote:
 Using GBM_FORMAT_ABGR was causing the B and G components to
 be swapped for some piglit tests.
 ---
 
 I have no idea if this fix is correct, but based on an IRC discussion:
 http://people.freedesktop.org/~cbrill/dri-log/?channel=dri-develdate=2015-02-05
 
 Using the wrong format here is the reason that B and G outputs were swapped.
 I'm not sure what format we should be using instead.

This might fix the bug you're facing, but it continues the mistake that
caused the bug in the first place: Waffle is guessing, and guessing badly,
which GBM_FORMAT is backing the EGLConfig.

I think the correct fix is to eliminate the guessing. Rewriting
wgbm_config_get_gbm_format() to look like this should do the trick:

uint32_t
wgbm_config_get_gbm_format(struct wegl_config *wegl_config)
{
EGLint gbm_format;

...
ok = plat-eglGetConfigAttrib(..., EGL_NATIVE_VISUAL_ID, gbm_format);
if (!ok) {
   // emit error
   return 0;
}

return gbm_format;
}

Waffle's X11/EGL backend does something very similar when creating during window
creation. See 
[https://github.com/waffle-gl/waffle/blob/master/src/waffle/xegl/xegl_window.c#L79]

 
  src/waffle/gbm/wgbm_config.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/src/waffle/gbm/wgbm_config.c b/src/waffle/gbm/wgbm_config.c
 index 480c2bf..5229210 100644
 --- a/src/waffle/gbm/wgbm_config.c
 +++ b/src/waffle/gbm/wgbm_config.c
 @@ -50,10 +50,8 @@ wgbm_config_get_gbm_format(const struct wcore_config_attrs 
 *attrs)
  return 0;
  }
  
 -if (attrs-alpha_size = 0)
 +if (attrs-alpha_size = 8)
  return GBM_FORMAT_XRGB;
 -else if (attrs-alpha_size = 8)
 -return GBM_FORMAT_ABGR;
  
  return 0;
  }




signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH v3] nacl: add implementation for waffle_window_swap_buffers

2015-02-11 Thread Chad Versace
On 02/09/2015 06:22 AM, Tapani Pälli wrote:
 Implementation for nacl is somewhat different as for other platforms,
 platform needs to ensure that the previous swap has finished before
 issuing GL commands or more swaps. This is done by introducing a worker
 thread that does buffer swaps from a work queue and uses a semaphore to
 lock main thread until swap is finished.
 
 v2: add error messaging if pp::Graphics3D::SwapBuffers fails
 add semaphore to implement blocking swap()
 remove extra nacl_swapbuffers() c++ function (Chad, Emil)
 
 v3: destroy semaphore when thread dies
 
 Signed-off-by: Tapani Pälli tapani.pa...@intel.com
 ---
  src/waffle/nacl/nacl_container.cpp | 12 +
  src/waffle/nacl/nacl_container.h   |  2 +-
  src/waffle/nacl/nacl_swap_thread.h | 94 
 ++
  src/waffle/nacl/nacl_window.c  |  3 +-
  4 files changed, 109 insertions(+), 2 deletions(-)
  create mode 100644 src/waffle/nacl/nacl_swap_thread.h
 
 diff --git a/src/waffle/nacl/nacl_container.cpp 
 b/src/waffle/nacl/nacl_container.cpp
 index fe907ff..84ab1da 100644
 --- a/src/waffle/nacl/nacl_container.cpp
 +++ b/src/waffle/nacl/nacl_container.cpp
 @@ -28,11 +28,13 @@
  #include ppapi/cpp/module.h
  #include ppapi/c/pp_errors.h
  #include nacl_container.h
 +#include nacl_swap_thread.h
  
  namespace waffle {
  
  struct nacl_container {
  pp::Graphics3D *ctx;
 +NaclSwapThread *swapper;
  
  void *glapi;
  bool (*glInitializePPAPI) (PPB_GetInterface);
 @@ -49,6 +51,7 @@ nacl_container_dtor(waffle::nacl_container *nc)
  if (nc-glapi)
  dlclose(nc-glapi);
  
 +delete nc-swapper;
  delete nc;
  }
  
 @@ -119,6 +122,7 @@ nacl_context_init(waffle::nacl_container *nc, struct 
 nacl_config *cfg)
  return false;
  }
  
 +nc-swapper = new NaclSwapThread(pp_instance, nc-ctx);
  return true;
  }
  
 @@ -194,3 +198,11 @@ nacl_makecurrent(nacl_container *nc, bool release)
  
  return true;
  }
 +
 +extern C bool
 +nacl_swapbuffers(nacl_container *nc)
 +{
 +waffle::nacl_container *cpp_nc =
 +reinterpret_castwaffle::nacl_container*(nc);
 +return cpp_nc-swapper-swap();
 +}
 diff --git a/src/waffle/nacl/nacl_container.h 
 b/src/waffle/nacl/nacl_container.h
 index ca26a1f..579856d 100644
 --- a/src/waffle/nacl/nacl_container.h
 +++ b/src/waffle/nacl/nacl_container.h
 @@ -43,7 +43,7 @@ bool nacl_context_init(struct nacl_container *nc, struct 
 nacl_config *cfg);
  bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height);
  bool nacl_makecurrent(struct nacl_container *nc, bool release);
  void nacl_context_fini(struct nacl_container *nc);
 -
 +bool nacl_swapbuffers(struct nacl_container *nc);
  #ifdef __cplusplus
  };
  #endif
 diff --git a/src/waffle/nacl/nacl_swap_thread.h 
 b/src/waffle/nacl/nacl_swap_thread.h
 new file mode 100644
 index 000..8e8687b
 --- /dev/null
 +++ b/src/waffle/nacl/nacl_swap_thread.h
 @@ -0,0 +1,94 @@
 +// Copyright 2014 Intel Corporation
 +//
 +// All rights reserved.
 +//
 +// Redistribution and use in source and binary forms, with or without
 +// modification, are permitted provided that the following conditions are 
 met:
 +//
 +// - Redistributions of source code must retain the above copyright notice, 
 this
 +//   list of conditions and the following disclaimer.
 +//
 +// - Redistributions in binary form must reproduce the above copyright 
 notice,
 +//   this list of conditions and the following disclaimer in the 
 documentation
 +//   and/or other materials provided with the distribution.
 +//
 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS 
 IS
 +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 PURPOSE ARE
 +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 
 LIABLE
 +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 LIABILITY,
 +// 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.
 +
 +#include ppapi/cpp/graphics_3d.h
 +#include ppapi/cpp/instance.h
 +#include ppapi/utility/completion_callback_factory.h
 +#include ppapi/utility/threading/simple_thread.h
 +#include wcore_error.h
 +#include semaphore.h
 +
 +// Thread takes care that we do not issue another buffer
 +// swap before previous swap has completed.
 +class NaclSwapThread : public pp::SimpleThread
 +{
 +public:
 +explicit NaclSwapThread(const pp::InstanceHandle instance,
 +pp::Graphics3D *_ctx) :
 +pp::SimpleThread(instance),
 +ctx(_ctx),
 +cbf(this)
 +   

[waffle] EGL null platform

2015-02-11 Thread Chad Versace
Frank, I see in your Github repo that you're working on support for
Chrome OS's null platform. I'm looking forward to it, because some
of us in Intel would like to use it too. Do you have an idea when
it will be ready for upstreaming?



signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PULL] Add the waffle_teardown API

2015-02-10 Thread Chad Versace
On 02/03/2015 05:14 PM, Emil Velikov wrote:
 Hi Chad,
 
 Here is to another waffle API - waffle_teardown
 In summary:
  - It pairs up with waffle_init
  - Cleans up some memory leaks
  - Allows one to switch between platforms without the need to exit the 
 program.
 
 Let me know if you'd like me to resend the patches and/or rebase them on top 
 of any other branch.

Branch is merged. Thanks.



signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-02-10 Thread Chad Versace
On 02/10/2015 10:31 AM, Dylan Baker wrote:
 I like this idea, it would be convenient for piglit to be able to assume
 waffle info can provide all of the information we currently call out to
 multiple binaries for.

Yes, Piglit wants this. I imagine more users will begin using it too.
 
 On Sun, Feb 08, 2015 at 07:50:15PM -0500, Frank Henigman wrote:
 I'd like to extend wflinfo so it can print platform-specific
 information and eventually be able to replace glxinfo, eglinfo and the
 like (I only know what's on linux).  There would be a new flag to
 request the platform-specific output in addition to the existing
 output.  For example on glx you'd see glx extensions, on egl you'd see
 egl extensions.
 I've started two different implementations and I'd like to know which
 is preferred before I go any farther.  Or if there's a better idea
 than either of my approaches.  I've dubbed the two approaches native
 and core.

 native
 - all the work is done in wflinfo, no changes to waffle api
 - use waffle_display_get_native() to access platform-specific stuff
 - pro: changes limited to wflinfo, doesn't clutter up the rest of waffle
 - con: some duplicate code to open libraries and lookup symbols
 - https://github.com/fjhenigman/waffle/tree/ps_native

 core
 - add waffle_display_print_info() to waffle api
 - add print_info() method to each platform
 - pro: less code, no duplication
 - con (perhaps): some wflinfo functionality is now in core waffle
 - https://github.com/fjhenigman/waffle/tree/ps_core

 I'm leaning toward core because there is less code.  We get to
 leverage the platform libraries and functions already stored in waffle
 platform structs.  But if the consensus is it's cleaner to keep this
 stuff in wflinfo I'm ok with that too.

I prefer core too. Not for the sake of less code, but because I like
the idea of it being available as core API.

I've begun adding Github comments to your ps_core branch. We can do
review Github-style, if you like. If you send patches to the list,
that's ok too.

I see two significant design decisions that need to be made:

  Issue #1: Should Waffle provide a query mechanism for the native
  platform info? Or should it just dump the info as a well-formatted
  string?

 Resolved: I like the way that your waffle_display_print_info() just dumps
 the information as a string. That's much simpler and more
 extensible than a true query mechanism.

  Issue #2: How should Waffle give that information string to the user?

 I think hardcoding stdout as the destination for the information
 is too restrictive. A very simple alternative would be that
 waffle_display_print_info() return a C-string that the user is
 required to free. Or perhaps the user should pass a string
 buffer and max length to waffle_display_print_info(),
 similar to snprintf(). Or maybe something completely different.
 What do you think is the best approach?




signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-02-10 Thread Chad Versace
On 02/08/2015 04:50 PM, Frank Henigman wrote:
 I'd like to extend wflinfo so it can print platform-specific
 information and eventually be able to replace glxinfo, eglinfo and the
 like (I only know what's on linux).  There would be a new flag to
 request the platform-specific output in addition to the existing
 output.  For example on glx you'd see glx extensions, on egl you'd see
 egl extensions.

For anyone who would like to experiment with Frank's work,
I've created a throw-away 'pu' branch (proposed updates) and merged Frank's
'ps_core' branch there. The 'pu' branch isn't stable and may be rewritten
at any time.





signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [wflinfo] [RFC] platform-specific info from wflinfo

2015-02-10 Thread Chad Versace
On 02/10/2015 01:08 PM, Frank Henigman wrote:
 On Tue, Feb 10, 2015 at 3:09 PM, Chad Versace chad.vers...@intel.com wrote:

 I see two significant design decisions that need to be made:

   Issue #1: Should Waffle provide a query mechanism for the native
   platform info? Or should it just dump the info as a well-formatted
   string?

  Resolved: I like the way that your waffle_display_print_info() just 
 dumps
  the information as a string. That's much simpler and more
  extensible than a true query mechanism.

   Issue #2: How should Waffle give that information string to the user?

  I think hardcoding stdout as the destination for the information
  is too restrictive. A very simple alternative would be that
  waffle_display_print_info() return a C-string that the user is
  required to free. Or perhaps the user should pass a string
  buffer and max length to waffle_display_print_info(),
  similar to snprintf(). Or maybe something completely different.
  What do you think is the best approach?
 
 Returning a string.  If the user has to supply a buffer they won't
 know how big it needs to be.
 I think the function will want an enum or bitmask parameter for
 controlling, for example, verbosity.
 If we ever want a fancy query interface that returns structs instead
 of a string, we'll be able to
 re-implement the string-returning function over that interface for
 backward compatibility.
 I suggest calling this one waffle_display_info_string() instead of
 taking a name we might want to
 use later, like waffle_display_info or waffle_display_query.

This all sounds good to me.




signature.asc
Description: OpenPGP digital signature
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


  1   2   3   >