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

2016-10-29 Thread Chad Versace
On Wed 19 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 18:33, Chad Versace  wrote:
> > 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

> Which reminds me that we might want to add support for testsuite(s)
> where each test, uses the same setup/teardown [to cmocka] and drop the
> above define/undef foo is related (rather nasty) macros.

Yes. The test file needs cleanups like that.

> Either way, with the small fixes in 4 and 5 the series is
> Reviewed-by: Emil Velikov 
> 
> Separating surfaceless/null and "platform FOO does not display
> anything" wss a great move, imho.
> 
> Nicely done !

Thanks for the review!
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


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

2016-10-29 Thread Chad Versace
On Wed 19 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 18:33, Chad Versace  wrote:
> > Now waffle_init() supports WAFFLE_PLATFORM_SURFACELESS_EGL.
> >
> > Cc: Gurchetan Singh 
> > Cc: Haixia Shi 
> > ---
> >  include/waffle/waffle.h  |   1 +
> >  man/waffle_init.3.xml|   9 ++
> >  src/waffle/CMakeLists.txt|   9 ++
> >  src/waffle/api/waffle_init.c |  12 +++
> >  src/waffle/egl/wegl_platform.c   |   6 ++
> >  src/waffle/surfaceless_egl/sl_display.c  |  70 +++
> >  src/waffle/surfaceless_egl/sl_display.h  |  45 ++
> >  src/waffle/surfaceless_egl/sl_platform.c | 144 
> > +++
> >  src/waffle/surfaceless_egl/sl_platform.h |  49 +++
> >  src/waffle/surfaceless_egl/sl_window.c   |  92 
> >  src/waffle/surfaceless_egl/sl_window.h   |  53 
> >  11 files changed, 490 insertions(+)
> >  create mode 100644 src/waffle/surfaceless_egl/sl_display.c
> >  create mode 100644 src/waffle/surfaceless_egl/sl_display.h
> >  create mode 100644 src/waffle/surfaceless_egl/sl_platform.c
> >  create mode 100644 src/waffle/surfaceless_egl/sl_platform.h
> >  create mode 100644 src/waffle/surfaceless_egl/sl_window.c
> >  create mode 100644 src/waffle/surfaceless_egl/sl_window.h
> >

> Should there be an extra case in src/waffle/core/wcore_util.c's
> wcore_enum_to_string() ?

Oops. I squashed the fix into this patch.

> > +// [chadv] I regret the design of the get_native interface, and wish to
> > +// deprecate and replace it with the interface that Ian Romanick orignally
> > +// recommended: waffle_display_get_egl_display(),
> > +// waffle_display_get_gbm_device(), waffle_display_get_xlib_display(), 
> > etc.  As
> > +// a first step towards that goal, I choose to not support the interface 
> > on new
> > +// platforms.

> Silly question: what's wrong with the current [generic] get_native_{foo,bar} ?

Each get_native function returns a non-extensible struct. The problem is
the non-extensibility.

Example 1:

On Wayland, waffle_window_get_window() returns

struct waffle_wayland_window {  
struct waffle_wayland_display display; // Definition below
struct wl_surface *wl_surface;  
struct wl_shell_surface *wl_shell_surface;  
struct wl_egl_window *wl_window;
EGLSurface egl_surface; 
};  

struct waffle_wayland_display {  
struct wl_display *wl_display;   
struct wl_compositor *wl_compositor; 
struct wl_shell *wl_shell;   
EGLDisplay egl_display;  
};   

If in the future we need to add more members to that struct, or even 
remove
members, due to changes in Wayland, then there is no good way to do 
that.

Example 2:

I want to add the ability to do KMS with waffle_window/waffle_display on
the gbm and surfaceless platforms. Again, because the get_native structs
are non-extensible, there is no good way for
waffle_window_get_native()/waffle_display_get_native() to return things
such as the CRTC.

So I see two solutions:

Solution 1: Change the get_native APIs to return "extensible" structs. If
someone is going to go through all that trouble, though, they might as
well go with solution 2, which is cleaner and less work.

Solution 2: For each possible native resourse of each Waffle resource, add
a specific getter that returns null-or-whatever if it doesn't exist.  For 
example,

EGLSurface waffle_window_get_egl_surface(...);
struct gbm_surface *waffle_window_get_gbm_surface(...);
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


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

2016-10-29 Thread Chad Versace
On Wed 19 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 18:33, Chad Versace  wrote:
> > This patch contains just the CMake changes for the new surfaceless_egl
> > platform. Code will come in the following patches.
> >
> > Cc: Gurchetan Singh 
> > Cc: Haixia Shi 
> > ---
> >  Options.cmake   |  3 +++
> >  cmake/Modules/WaffleDefineCompilerFlags.cmake   |  4 
> >  cmake/Modules/WaffleDefineInternalOptions.cmake |  3 ++-
> >  cmake/Modules/WafflePrintConfigurationSummary.cmake |  3 +++
> >  cmake/Modules/WaffleValidateOptions.cmake   | 15 ++-
> >  5 files changed, 26 insertions(+), 2 deletions(-)


> > diff --git a/cmake/Modules/WaffleDefineInternalOptions.cmake 
> > b/cmake/Modules/WaffleDefineInternalOptions.cmake
> > index 3ef7a25..b3a4f7b 100644
> > --- a/cmake/Modules/WaffleDefineInternalOptions.cmake
> > +++ b/cmake/Modules/WaffleDefineInternalOptions.cmake
> > @@ -1,4 +1,5 @@
> > -if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm)
> > +if(waffle_has_wayland OR waffle_has_x11_egl OR waffle_has_gbm OR
> > +   waffle_has_surfaceless_egl)
> >  set(waffle_has_egl TRUE)
> >  else(waffle_has_wayland OR waffle_has_x11_egl)

> IIRC expressions in the else statements are meaningless in cmake.
> 
> Can we drop the above one (which seems to be the only such case in
> waffle) ? Be that here or as separate commit ?

Done. I have a local commit that drops it. It's trivial, so I'll just
push it with this series.



> > @@ -149,6 +151,11 @@ if(waffle_on_linux)
> >  message(FATAL_ERROR "x11_egl dependency is missing: 
> > ${x11_egl_missing_deps}")
> >  endif()
> >  endif()
> > +if(waffle_has_surfaceless_egl)
> > +if(NOT egl_FOUND)
> > +message(FATAL_ERROR "surfaceless_egl dependency is missing: 
> > egl")
> > +endif()
> > +endif()

> I'm wondering if we cannot rework these (or the whole file in general)
> to minimise the boilerplate.

> Sadly no wise ideas come to mind :-(

Sigh... I felt the pain of the boilerplate when writing this patch.
Likewise, I saw no easy fix.

> > @@ -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_has_surfaceless_egl.")

> ... because the about should read s/Darwin/Windows/

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


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

2016-10-29 Thread Chad Versace
On Wed 19 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 18:33, Chad Versace  wrote:
> > 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(&surf->wcore, wc_config);
> > +if (!ok)
> > +goto fail;
> > +

> This hunk (and most of the series really) will clash with a fair bit
> of cleanups I have on the list.
> In this particular case - the wcore_window_init API has 'lost' it's
> [always return true] return type.
> 
> Re-basing either way will be fun, so let's get the new platform in
> first and then consider the cleanups.

> Please ?

Yes. I'll rebase your cleanups after the new platform lands.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 8/8] egl: Use eglGetPlatformDisplayEXT as a fallback

2016-10-27 Thread Chad Versace
If the EGL platform does not support eglGetPlatformDisplay, but does
support eglGetPlatformDisplayEXT, then use it as a fallback. Of course,
if neither is supported, we fall back all the way to eglGetDisplay.

This is useful for exercising the codepaths on Mesa, which does support
the extensions for eglGetPlatformDisplayEXT but not yet
eglGetPlatformDisplay.

Tested against Mesa master@8c78fdb with `ninja check-func` on Linux for
x11_egl, wayland, and gbm.

Reported-by: Emil Velikov 
---
 src/waffle/egl/wegl_display.c  |  7 +++
 src/waffle/egl/wegl_platform.c | 41 ++---
 src/waffle/egl/wegl_platform.h | 11 +++
 3 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index 5403cd1..dae7493 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -111,6 +111,13 @@ wegl_display_init(struct wegl_display *dpy,
 wegl_emit_error(plat, "eglGetPlatformDisplay");
 goto fail;
 }
+} else if (wegl_platform_can_use_eglGetPlatformDisplayEXT(plat)) {
+dpy->egl = plat->eglGetPlatformDisplayEXT(plat->egl_platform,
+  native_display, NULL);
+if (!dpy->egl) {
+wegl_emit_error(plat, "eglGetPlatformDisplayEXT");
+goto fail;
+}
 } else {
 dpy->egl = plat->eglGetDisplay((EGLNativeDisplayType) native_display);
 if (!dpy->egl) {
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 5887cf5..0d40301 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -66,8 +66,9 @@ wegl_platform_teardown(struct wegl_platform *self)
 bool ok = true;
 int error = 0;
 
-if (!wegl_platform_can_use_eglGetPlatformDisplay(self)
-&& self->egl_platform != EGL_PLATFORM_ANDROID_KHR) {
+if (!wegl_platform_can_use_eglGetPlatformDisplay(self) &&
+!wegl_platform_can_use_eglGetPlatformDisplayEXT(self) &&
+self->egl_platform != EGL_PLATFORM_ANDROID_KHR) {
 unsetenv("EGL_PLATFORM");
 }
 
@@ -164,14 +165,19 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 // EGL 1.5
 RETRIEVE_EGL_SYMBOL_OPTIONAL(eglGetPlatformDisplay);
 
+// EGL_EXT_platform_display
+RETRIEVE_EGL_SYMBOL_OPTIONAL(eglGetPlatformDisplayEXT);
+
 #undef RETRIEVE_EGL_SYMBOL
 #undef RETRIEVE_EGL_SYMBOL_OPTIONAL
 
 self->client_extensions =
 self->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
 
-if (!wegl_platform_can_use_eglGetPlatformDisplay(self))
+if (!wegl_platform_can_use_eglGetPlatformDisplay(self) &&
+!wegl_platform_can_use_eglGetPlatformDisplayEXT(self)) {
 setup_env(self);
+}
 
 error:
 // On failure the caller of wegl_platform_init will trigger it's own
@@ -207,3 +213,32 @@ wegl_platform_can_use_eglGetPlatformDisplay(const struct 
wegl_platform *plat)
 
 return waffle_is_extension_in_string(plat->client_extensions, ext);
 }
+
+bool
+wegl_platform_can_use_eglGetPlatformDisplayEXT(const struct wegl_platform 
*plat)
+{
+const char *ext;
+
+if (!plat->eglGetPlatformDisplayEXT)
+return false;
+
+switch (plat->egl_platform) {
+case EGL_PLATFORM_ANDROID_KHR:
+// There exist no Android extension for eglGetPlatformDisplayEXT.
+return false;
+case EGL_PLATFORM_GBM_KHR:
+ext = "EGL_MESA_platform_gbm";
+break;
+case EGL_PLATFORM_WAYLAND_KHR:
+ext = "EGL_EXT_platform_wayland";
+break;
+case EGL_PLATFORM_X11_KHR:
+ext = "EGL_EXT_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 d6788eb..c3c16b7 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -91,6 +91,10 @@ struct wegl_platform {
  const EGLint *attrib_list);
 EGLBoolean (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
 EGLBoolean (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
+
+// EGL_EXT_platform_display
+EGLDisplay (*eglGetPlatformDisplayEXT)(EGLenum platform, void 
*native_display,
+   const EGLint *attrib_list);
 };
 
 DEFINE_CONTAINER_CAST_FUNC(wegl_platform,
@@ -111,3 +115,10 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform);
 // supports the needed platform extension.
 bool
 wegl_platform_can_use_eglGetPlatformDisplay(const struct wegl_platform *plat);
+
+// Can eglGetPlatformDisplayEXT can be used for this platform?
+//
+// True if libEGL exposes the eglGetPlatformDisplayEXT function; and if EGL
+// supports the needed p

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

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 4/8] egl: Query client extensions string

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

Prepares for eventual use of eglGetPlatformDisplay.

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

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

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


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

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

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

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

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

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


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

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

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

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

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

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


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

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

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

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

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

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


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

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

This prepares for eventually using eglGetPlatformDisplay().

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

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

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

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

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

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

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

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

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


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

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

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

This branch lives at

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

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

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

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

-- 
2.10.1

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


Re: [waffle] [PATCH 0/7] 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  wrote:
> > Before EGL_EXT_platform_base and EGL 1.5, when using Mesa the best way
> > to select the EGL platform was to set the EGL_PLATFORM environment
> > variable. Now that a standard way exists, eglGetPlatformDisplay, let's
> > use it when available.
> >
> > After this series, I have a series to add support for
> > EGL_MESA_platform_surfaceless.
> >
> > This branch lives at
> > 
> > https://github.com/chadversary/waffle/commits/review/eglGetPlatformDisplay-v01
> >
> > Chad Versace (7):
> >   egl: Define EGL_PLATFORM_* enums
> >   egl: Update wegl_platform_init signature
> >   egl: Move each platform's setenv("EGL_PLATFORM") into core EGL code
> >   egl: Query client extensions string
> >   egl: Optionally dlsym eglGetPlatformDisplay
> >   egl: Update wegl_display_init signature
> >   egl: Use eglGetPlatformDisplay when possible
> >
> The questions in 5 and 7 are not blockers, by any means. Just please
> split the Android change from 3.
> 
> With that (and the extra Android change itself) are
> Reviewed-by: Emil Velikov 

THANK YOU for reviewing this. You caught some bugs. I'll submit v2 of
individual patches when I return to work on Monday.
___
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  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 = &native_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  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


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

2016-10-19 Thread Chad Versace
On Tue 18 Oct 2016, Emil Velikov wrote:
> On 18 October 2016 at 17:58, Chad Versace  wrote:
> 
> > +case EGL_PLATFORM_ANDROID_KHR:
> > +setenv("EGL_PLATFORM", "android", true);
> > +break;
> Thus hunk is a new addition. Can you please split it out ?

Sure. I'll drop this. I added it unintentionally in a flurry edits.
We can add it back it its ever needed.
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


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

2016-10-18 Thread Chad Versace
Now waffle_init() supports WAFFLE_PLATFORM_SURFACELESS_EGL.

Cc: Gurchetan Singh 
Cc: Haixia Shi 
---
 include/waffle/waffle.h  |   1 +
 man/waffle_init.3.xml|   9 ++
 src/waffle/CMakeLists.txt|   9 ++
 src/waffle/api/waffle_init.c |  12 +++
 src/waffle/egl/wegl_platform.c   |   6 ++
 src/waffle/surfaceless_egl/sl_display.c  |  70 +++
 src/waffle/surfaceless_egl/sl_display.h  |  45 ++
 src/waffle/surfaceless_egl/sl_platform.c | 144 +++
 src/waffle/surfaceless_egl/sl_platform.h |  49 +++
 src/waffle/surfaceless_egl/sl_window.c   |  92 
 src/waffle/surfaceless_egl/sl_window.h   |  53 
 11 files changed, 490 insertions(+)
 create mode 100644 src/waffle/surfaceless_egl/sl_display.c
 create mode 100644 src/waffle/surfaceless_egl/sl_display.h
 create mode 100644 src/waffle/surfaceless_egl/sl_platform.c
 create mode 100644 src/waffle/surfaceless_egl/sl_platform.h
 create mode 100644 src/waffle/surfaceless_egl/sl_window.c
 create mode 100644 src/waffle/surfaceless_egl/sl_window.h

diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
index db94a5e..82795d8 100644
--- a/include/waffle/waffle.h
+++ b/include/waffle/waffle.h
@@ -119,6 +119,7 @@ enum waffle_enum {
 WAFFLE_PLATFORM_GBM = 0x0016,
 WAFFLE_PLATFORM_WGL = 0x0017,
 WAFFLE_PLATFORM_NACL= 0x0018,
+WAFFLE_PLATFORM_SURFACELESS_EGL = 0x0019,
 
 // --
 // For waffle_config_choose()
diff --git a/man/waffle_init.3.xml b/man/waffle_init.3.xml
index 76a2dee..19d4b91 100644
--- a/man/waffle_init.3.xml
+++ b/man/waffle_init.3.xml
@@ -130,6 +130,15 @@
 
   
   
+
WAFFLE_PLATFORM_SURFACELESS_EGL
+
+  
+[Linux] Use EGL's "surfaceless" platform,
+https://www.khronos.org/registry/egl/extensions/MESA/EGL_MESA_platform_surfaceless.txt";>EGL_MESA_platform_surfaceless.
+  
+
+  
+  
 WAFFLE_PLATFORM_WAYLAND
 
   
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 9150f7d..fa00bd8 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -16,6 +16,7 @@ include_directories(
 glx
 linux
 nacl
+surfaceless_egl
 wayland
 wgl
 x11
@@ -127,6 +128,14 @@ if(waffle_on_linux)
 )
 endif()
 
+if(waffle_has_surfaceless_egl)
+list(APPEND waffle_sources
+surfaceless_egl/sl_display.c
+surfaceless_egl/sl_platform.c
+surfaceless_egl/sl_window.c
+)
+endif()
+
 if(waffle_has_wayland)
 list(APPEND waffle_sources
 wayland/wayland_display.c
diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
index d769270..c9a16cf 100644
--- a/src/waffle/api/waffle_init.c
+++ b/src/waffle/api/waffle_init.c
@@ -36,6 +36,7 @@ struct wcore_platform* xegl_platform_create(void);
 struct wcore_platform* wgbm_platform_create(void);
 struct wcore_platform* wgl_platform_create(void);
 struct wcore_platform* nacl_platform_create(void);
+struct wcore_platform* sl_platform_create(void);
 
 static bool
 waffle_init_parse_attrib_list(
@@ -111,6 +112,12 @@ waffle_init_parse_attrib_list(
 CASE_UNDEFINED_PLATFORM(NACL)
 #endif
 
+#ifdef WAFFLE_HAS_SURFACELESS_EGL
+CASE_DEFINED_PLATFORM(SURFACELESS_EGL)
+#else
+CASE_UNDEFINED_PLATFORM(SURFACELESS_EGL)
+#endif
+
 default:
 wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
  "WAFFLE_PLATFORM has bad value 0x%x",
@@ -185,6 +192,11 @@ waffle_init_create_platform(int32_t waffle_platform)
 wc_platform = nacl_platform_create();
 break;
 #endif
+#ifdef WAFFLE_HAS_SURFACELESS_EGL
+case WAFFLE_PLATFORM_SURFACELESS_EGL:
+wc_platform = sl_platform_create();
+break;
+#endif
 default:
 assert(false);
 return NULL;
diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 331cc89..2be250f 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -53,6 +53,9 @@ setup_env(const struct wegl_platform *self)
 case EGL_PLATFORM_X11_KHR:
 setenv("EGL_PLATFORM", "x11", true);
 break;
+case EGL_PLATFORM_SURFACELESS_MESA:
+setenv("EGL_PLATFORM", "surfaceless", true);
+break;
 default:
 assert(!"bad egl_platform enum");
 break;
@@ -181,6 +184,9 @@ wegl_platform_can_use_eglGetPlatformDisplay(

[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(&surf->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_has_surfaceless_egl.")
+endif()
 endif()
-

[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(&self->wegl);
+ok &= wegl_surface_teardown(&self->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(&window->wcore, wc_config);
+ok = wcore_window_init(&surf->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 (

[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 0/7] surfaceless_egl: Implement new platform

2016-10-18 Thread Chad Versace
This is my attempt to upstream some of the functionality in Chrome OS's
fork of Waffle. My plan is:

1. (this patch series) Add a new Waffle platform for
   EGL_MESA_platform_surfaceless. Initially, this platform supports
   only the basic features of EGL_MESA_platform_surfaceless, and
   waffle_window is backed by an EGL pbuffer. Support for KMS comes
   later, as I wanted to first get the basics working.

2. (future) Shuffle the gbm code so Waffle's 'gbm' platform
   and 'surfaceless_egl' platform can share it.

3. (future) Add support for KMS to the 'gbm' platform. (I'll post my
   plans for this in a separate mail).

4. (future) Add support for KMS to the 'surfaceless_egl' platform.

*. Make a new Waffle release tarball sometime after step 1.

This patch series doesn't add the new platform in one giant commit. It's
incremental:

1. First, some refactors.
2. The CMake changes.
3. Add the code in src/waffle/surfaceless_egl/.
4. Update wflinfo.
5. Update gl_basic_test.

wflinfo works. But gl_basic_test fails. I suspect it's a Mesa bug.
Haixia, Gurcheta, can you help diagnose the bug?

This patch series lives at

https://github.com/chadversary/waffle/commits/review/platform-surfaceless-v01
and depends on the previously submitted branch

https://github.com/chadversary/waffle/commits/review/eglGetPlatformDisplay-v01
and also this patch submitted to mesa-dev
https://patchwork.freedesktop.org/patch/116476/

Chad Versace (7):
  egl: Rename files wegl_window.* -> wegl_surface.*
  egl: Rename struct wegl_window -> wegl_surface
  egl: Allow pbuffers to back wegl_surface
  cmake: Add option waffle_has_surfaceless_egl
  surfaceless_egl: Implement new platform
  wflinfo: Support --platform=surfaceless_egl
  tests/gl_basic_test: Support platform surfaceless_egl

 Android.mk |   2 +-
 Options.cmake  |   3 +
 cmake/Modules/WaffleDefineCompilerFlags.cmake  |   4 +
 cmake/Modules/WaffleDefineInternalOptions.cmake|   3 +-
 .../Modules/WafflePrintConfigurationSummary.cmake  |   3 +
 cmake/Modules/WaffleValidateOptions.cmake  |  15 ++-
 include/waffle/waffle.h|   1 +
 man/waffle_init.3.xml  |   9 ++
 man/wflinfo.1.xml  |   1 +
 src/utils/wflinfo.c|   5 +-
 src/waffle/CMakeLists.txt  |  11 +-
 src/waffle/android/droid_platform.c|   2 +-
 src/waffle/android/droid_window.c  |   2 +-
 src/waffle/android/droid_window.h  |   6 +-
 src/waffle/api/waffle_init.c   |  12 ++
 src/waffle/egl/wegl_platform.c |   7 +
 src/waffle/egl/wegl_platform.h |   2 +
 src/waffle/egl/{wegl_window.c => wegl_surface.c}   |  79 ---
 src/waffle/egl/{wegl_window.h => wegl_surface.h}   |  17 ++-
 src/waffle/egl/wegl_util.c |   4 +-
 src/waffle/gbm/wgbm_window.c   |   4 +-
 src/waffle/gbm/wgbm_window.h   |   6 +-
 src/waffle/surfaceless_egl/sl_display.c|  70 ++
 src/waffle/surfaceless_egl/sl_display.h|  45 +++
 src/waffle/surfaceless_egl/sl_platform.c   | 144 +
 src/waffle/surfaceless_egl/sl_platform.h   |  49 +++
 src/waffle/surfaceless_egl/sl_window.c |  92 +
 src/waffle/surfaceless_egl/sl_window.h |  53 
 src/waffle/wayland/wayland_window.c|   4 +-
 src/waffle/wayland/wayland_window.h|   6 +-
 src/waffle/xegl/xegl_platform.c|   2 +-
 src/waffle/xegl/xegl_window.c  |   2 +-
 src/waffle/xegl/xegl_window.h  |   6 +-
 tests/functional/gl_basic_test.c   |  17 +++
 34 files changed, 636 insertions(+), 52 deletions(-)
 rename src/waffle/egl/{wegl_window.c => wegl_surface.c} (55%)
 rename src/waffle/egl/{wegl_window.h => wegl_surface.h} (80%)
 create mode 100644 src/waffle/surfaceless_egl/sl_display.c
 create mode 100644 src/waffle/surfaceless_egl/sl_display.h
 create mode 100644 src/waffle/surfaceless_egl/sl_platform.c
 create mode 100644 src/waffle/surfaceless_egl/sl_platform.h
 create mode 100644 src/waffle/surfaceless_egl/sl_window.c
 create mode 100644 src/waffle/surfaceless_egl/sl_window.h

-- 
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 5/7] egl: Optionally dlsym eglGetPlatformDisplay

2016-10-18 Thread Chad Versace
Not yet used.
---
 src/waffle/egl/wegl_imports.h  | 4 
 src/waffle/egl/wegl_platform.c | 6 ++
 src/waffle/egl/wegl_platform.h | 4 
 3 files changed, 14 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 8ce0a7b..669fe38 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -114,6 +114,9 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
egl_platform)
 goto error;\
 }
 
+#define RETRIEVE_EGL_SYMBOL_OPTIONAL(function) \
+self->function = dlsym(self->eglHandle, #function);
+
 RETRIEVE_EGL_SYMBOL(eglMakeCurrent);
 RETRIEVE_EGL_SYMBOL(eglGetProcAddress);
 
@@ -138,6 +141,9 @@ 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
 
 self->client_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.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 = &native_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, &dpy->major_version, 
&dpy->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(&self->wcore);
 return ok;
 }
+
 bool
-wegl_platform_init(struct wegl_platform *self)
+wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform)
 {
 bool ok;
 
@@ -63,6 +64,8 @@ wegl_platform_init(struct wegl_platform *self)
 if (!ok)
 goto error;
 
+self->egl_platform = egl_platform;
+
 // Most Waffle platforms will call eglCreateWindowSurface.
 self->egl_surface_type_mask = EGL_WINDOW_BIT;
 
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 00c3b8e..a3f9a79 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -35,6 +35,9 @@
 struct wegl_platform {
 struct wcore_platform wcore;
 
+// An EGL_PLATFORM_* enum, such as EGL_PLATFORM_GBM_KHR.
+EGLenum egl_platform;
+
 /// @brief Value of EGLConfig attribute EGL_SURFACE_TYPE
 ///
 /// When calling eglChooseConfig, Waffle sets the EGL_SURFACE_TYPE 
attribute
@@ -92,4 +95,4 @@ bool
 wegl_platform_teardown(struct wegl_platform *self);
 
 bool
-wegl_platform_init(struct wegl_platform *self);
+wegl_platform_init(struct wegl_platform *self, EGLenum egl_platform);
diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index 2b7f3bc..ee25a26 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -92,7 +92,7 @@ wgbm_platform_init(struct wgbm_platform *self)
 {
 bool ok = true;
 
-ok = wegl_platform_init(&self->wegl);
+ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_GBM_KHR);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/wayland/wayland_platform.c 
b/src/waffle/wayland/wayland_platform.c
index 2746ca1..3627c88 100644
--- a/src/waffle/wayland/wayland_platform.c
+++ b/src/waffle/wayland/wayland_platform.c
@@ -90,7 +90,7 @@ wayland_platform_create(void)
 if (self == NULL)
 return NULL;
 
-ok = wegl_platform_init(&self->wegl);
+ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_WAYLAND_KHR);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c
index e36a41b..66d7ed6 100644
--- a/src/waffle/xegl/xegl_platform.c
+++ b/src/waffle/xegl/xegl_platform.c
@@ -71,7 +71,7 @@ xegl_platform_create(void)
 if (self == NULL)
 return NULL;
 
-ok = wegl_platform_init(&self->wegl);
+ok = wegl_platform_init(&self->wegl, EGL_PLATFORM_X11_KHR);
 if (!ok)
 goto error;
 
-- 
2.10.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(&self->wegl, wc_plat,
-   (intptr_t) EGL_DEFAULT_DISPLAY);
+ok = wegl_display_init(&self->wegl, wc_plat, EGL_DEFAULT_DISPLAY);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index bd7d375..7a7986c 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -95,7 +95,7 @@ get_extensions(struct wegl_display *dpy)
 bool
 wegl_display_init(struct wegl_display *dpy,
   struct wcore_platform *wc_plat,
-  intptr_t native_display)
+  void *native_display)
 {
 struct wegl_platform *plat = wegl_platform(wc_plat);
 bool ok;
diff --git a/src/waffle/egl/wegl_display.h b/src/waffle/egl/wegl_display.h
index 348399d..e828257 100644
--- a/src/waffle/egl/wegl_display.h
+++ b/src/waffle/egl/wegl_display.h
@@ -57,7 +57,7 @@ DEFINE_CONTAINER_CAST_FUNC(wegl_display,
 bool
 wegl_display_init(struct wegl_display *dpy,
   struct wcore_platform *wc_plat,
-  intptr_t native_display);
+  void *native_display);
 
 bool
 wegl_display_teardown(struct wegl_display *dpy);
diff --git a/src/waffle/gbm/wgbm_display.c b/src/waffle/gbm/wgbm_display.c
index 5c8af29..b7c5397 100644
--- a/src/waffle/gbm/wgbm_display.c
+++ b/src/waffle/gbm/wgbm_display.c
@@ -154,7 +154,7 @@ wgbm_display_connect(struct wcore_platform *wc_plat,
 goto error;
 }
 
-ok = wegl_display_init(&self->wegl, wc_plat, (intptr_t) self->gbm_device);
+ok = wegl_display_init(&self->wegl, wc_plat, self->gbm_device);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/wayland/wayland_display.c 
b/src/waffle/wayland/wayland_display.c
index e2d59a8..6373056 100644
--- a/src/waffle/wayland/wayland_display.c
+++ b/src/waffle/wayland/wayland_display.c
@@ -142,7 +142,7 @@ wayland_display_connect(struct wcore_platform *wc_plat,
 goto error;
 }
 
-ok = wegl_display_init(&self->wegl, wc_plat, (intptr_t) self->wl_display);
+ok = wegl_display_init(&self->wegl, wc_plat, self->wl_display);
 if (!ok)
 goto error;
 
diff --git a/src/waffle/xegl/xegl_display.c b/src/waffle/xegl/xegl_display.c
index a1da480..1d1b7dd 100644
--- a/src/waffle/xegl/xegl_display.c
+++ b/src/waffle/xegl/xegl_display.c
@@ -62,7 +62,7 @@ xegl_display_connect(
 if (!ok)
 goto error;
 
-ok = wegl_display_init(&self->wegl, wc_plat, (intptr_t) self->x11.xlib);
+ok = wegl_display_init(&self->wegl, wc_plat, self->x11.xlib);
 if (!ok)
 goto error;
 
-- 
2.10.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 = &wgbm_platform_vtbl;
 return true;
 
diff --git a/src/waffle/wayland/wayland_platform.c 
b/src/waffle/wayland/wayland_platform.c
index 3627c88..a8fbafc 100644
--- a/src/waffle/wayland/wayland_platform.c
+++ b/src/waffle/wayland/wayland_platform.c
@@ -24,7 +24,6 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #define WL_EGL_PLATFORM 1
-#define _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
 
 #include 
 #include 
@@ -59,8 +58,6 @@ wayland_platform_destroy(struct wcore_platform *wc_self)
 if (!self)
 return true;
 
-unsetenv("EGL_PLATFORM");
-
 if (self->linux)
 ok &= linux_platform_destroy(self->linux);
 
@@ -125,8 +122,6 @@ wayland_platform_create(void)
 if (!self->linux)
 goto error;
 
-setenv("EGL_PLATFORM", "wayland", true);
-
 self->wegl.wcore.vtbl = &wayland_platform_vtbl;
 return &self->wegl.wcore;
 
diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c
index 66d7ed6..f39ab93 100644
--- a/src/waffle/xegl/xegl_platform.c
+++ b/src/waffle/xegl/xegl_platform.c
@@ -23,8 +23,6 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#define _POSIX_C_SOURCE 200112 // glib feature macro for unsetenv()
-
 #include 
 
 #include "wcore_error.h"
@@ -51,8 +49,6 @@ xegl_platform_destroy(struct wcore_platform *wc_self)
 if (!self)
 return true;
 
-unsetenv("EGL_PLATFORM");
-
 if (self->linux)
 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 = &xegl_platfor

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  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 1/2] Revert "wegl: add EGL image create/destroy"

2016-10-11 Thread Chad Versace
On Thu 21 Jul 2016, Emil Velikov wrote:
> This reverts commit 1a8e8ef3b8072fa1135dbe2a04dc6bb9f8e3a12f.
> 
> The symbols were added as they are required by the null/surfaceless
> platform. Since that one hasn't landed yet, just remove the patch.
> 
> Furthermore, using dlsym is non-compatible (according to the spec) since
> the symbols are part of an extension. eglGetProcAddress should be used.
> 
> Feel free to bring it back, when needed.
> 
> Cc: Frank Henigman 
> Cc: Chad Versace 
> ---
> 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.

> As with the GBM symbols a while back - getting these back in is should
> be a piece of pie. But until we need them, let's remove the dead code.

Yep, I agree.

For the series,
Reviewed-by: Chad Versace 

And pushed.
___
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  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 
> > > 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 
> > > ---
> > >  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 

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-24 Thread Chad Versace
On Wed 22 Jun 2016, Jason Ekstrand wrote:
> On Tue, Jun 21, 2016 at 9:06 PM, Chad Versace 
> wrote:
> 
> > On Mon 20 Jun 2016, Chad Versace wrote:

> > 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.
> >
> 
> This makes me a bit sad.  One of the problems that Michael's patch does
> *not* solve is that, thanks to a Wayland header update (yay improvements!)
> the waffle build broke.  All that's been accomplished on that front is that
> the problem is papered over (we added the new entrypoing) and the next time
> a Wayland header update comes along that uses another new entrypoint,
> waffle will break again.  Maybe this is considered acceptable; that's not
> really my call.

It was a hard decision to make. I carefully considered the problem that
you point out. Both options were bad, from my point of view, and both
helped/harmed clients in equal but different ways. So I did my best to
choose the "easiest" option, from a maintainer's perspective.
___
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  wrote:
> > > On Sat, Apr 16, 2016 at 4:12 PM, Emil Velikov 
> > > wrote:
> > >>
> > >> On 16 April 2016 at 22:06, Jason Ekstrand  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 00/13] Do less validation of the context version

2016-06-15 Thread Chad Versace
On Tue 14 Jun 2016, Chad Versace wrote:
> On Tue 26 Apr 2016, Emil Velikov wrote:
> > 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.

> I'm holding off on patches 7 and above until I diagnose the regressions.

The regressions caused by patch 7 are fixed, and Intel CI gave the green
light on the remainder of the patch series. So it' all merged now.
___
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  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 
> > Signed-off-by: Chad Versace 
> > ---
> >  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 
> Signed-off-by: Chad Versace 
> ---
>  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/29] Rework the functionality test(s)

2016-06-14 Thread Chad Versace
On Tue 14 Jun 2016, Emil Velikov wrote:
> On 14 June 2016 at 18:10, Chad Versace  wrote:
> > 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.
> 
> I'm slightly leaning towards having that symbol, as with it (and a gbm
> cleanup) one should be able to run the waffle tests on Travis CI
> (which has old wayland). I won't insist on it though.
> Alternatively we should really bump the minimum required wayland version to 
> 1.4.
> 
> Which one would you prefer ?

If adding that symbol will allow Waffle to use Travis, then please add
the symbol.
___
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 
Signed-off-by: Chad Versace 
---
 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 2/2] examples/gl_basic: Make GL symbol queries more robust

2016-06-14 Thread Chad Versace
Analagous to the previous patch to tests/functional/gl_basic_test.c.

Suggested-by: Emil Velikov 
Signed-off-by: Chad Versace 
---
 examples/gl_basic.c | 36 ++--
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/examples/gl_basic.c b/examples/gl_basic.c
index 80794a0..1b8a313 100644
--- a/examples/gl_basic.c
+++ b/examples/gl_basic.c
@@ -37,6 +37,7 @@
 #define WAFFLE_API_VERSION 0x0106
 #define WAFFLE_API_EXPERIMENTAL
 
+#include 
 #include 
 #include 
 #include 
@@ -425,6 +426,29 @@ error_unrecognized_arg:
 usage_error_printf("unrecognized option '%s'", optarg);
 }
 
+// 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(const struct options *opts, const const char *name)
+{
+void *sym = NULL;
+
+if (waffle_dl_can_open(opts->dl)) {
+sym = waffle_dl_sym(opts->dl, name);
+}
+
+if (!sym) {
+sym = waffle_get_proc_address(name);
+}
+
+return sym;
+}
+
 static bool
 draw(struct waffle_window *window, bool resize)
 {
@@ -615,27 +639,27 @@ main(int argc, char **argv)
  waffle_enum_to_string(opts.context_api));
 }
 
-glClear = waffle_dl_sym(opts.dl, "glClear");
+glClear = get_gl_symbol(&opts, "glClear");
 if (!glClear)
 error_get_gl_symbol("glClear");
 
-glClearColor = waffle_dl_sym(opts.dl, "glClearColor");
+glClearColor = get_gl_symbol(&opts, "glClearColor");
 if (!glClearColor)
 error_get_gl_symbol("glClearColor");
 
-glGetError = waffle_dl_sym(opts.dl, "glGetError");
+glGetError = get_gl_symbol(&opts, "glGetError");
 if (!glGetError)
 error_get_gl_symbol("glGetError");
 
-glGetIntegerv = waffle_dl_sym(opts.dl, "glGetIntegerv");
+glGetIntegerv = get_gl_symbol(&opts, "glGetIntegerv");
 if (!glGetIntegerv)
 error_get_gl_symbol("glGetIntegerv");
 
-glReadPixels = waffle_dl_sym(opts.dl, "glReadPixels");
+glReadPixels = get_gl_symbol(&opts, "glReadPixels");
 if (!glReadPixels)
 error_get_gl_symbol("glReadPixels");
 
-glViewport = waffle_dl_sym(opts.dl, "glViewport");
+glViewport = get_gl_symbol(&opts, "glViewport");
 if (!glViewport)
 error_get_gl_symbol("glViewport");
 
-- 
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


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

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

> Would also be nice if Chad merged his get-current branch
> into master, as I use it in v2.

My get-current branch is now merged. And Intel's Jenkins claims that it
didn't regress any Piglit tests.
___
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 
Cc: Emil Velikov 
Signed-off-by: Chad Versace 
---
 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] egl: Support robust access contexts with EGL 1.5.

2016-05-02 Thread Chad Versace
On Sat 16 Apr 2016, Emil Velikov wrote:

> On 15 April 2016 at 22:04, Bas Nieuwenhuizen  wrote:
> > EGL 1.5 also supports the EGL_CONTEXT_OPENGL_ROBUST_ACCESS
> > attribute without any extensions for both ES and non-ES.
> >
> > Signed-off-by: Bas Nieuwenhuizen 
> > ---
> >  src/waffle/egl/wegl_config.c  | 9 ++---
> >  src/waffle/egl/wegl_context.c | 9 +++--
> >  src/waffle/egl/wegl_display.c | 3 +--
> >  src/waffle/egl/wegl_display.h | 2 ++
> >  4 files changed, 16 insertions(+), 7 deletions(-)


> > diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
> > index 67cbc04..4b208fa 100644
> > --- a/src/waffle/egl/wegl_context.c
> > +++ b/src/waffle/egl/wegl_context.c
> > @@ -96,8 +96,13 @@ create_real_context(struct wegl_config *config,
> >  }
> >
> >  if (attrs->context_robust) {
> > -assert(dpy->KHR_create_context);
> > -context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
> > +if (dpy->major_version > 1 || dpy->minor_version >= 5) {
> > +attrib_list[i++] = 
> > EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
> We want EGL_CONTEXT_OPENGL_ROBUST_ACCESS (note missing _EXT) here.
> For whatever reason the two differ 0x31B2 vs 0x30BF (according to the
> includes in mesa).


> 
> With the s/_EXT//g issue above
> Reviewed-by: Emil Velikov 

I fixed this and pushed the patch.
___
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-22 Thread Chad Versace
On 04/15/2016 03:35 PM, Emil Velikov wrote:
> On 15 April 2016 at 20:04, Chad Versace  wrote:

> Looking at another hunk from the spec makes me wonder:
> 
> created. Forward-compatible contexts are defined only for OpenGL
> versions 3.0 and later.
> 
> So one cannot get a fwd compat context with 3.0 or 3.1, if they don't
> support OpenGL 3.2. Not sure I'm getting why they choose to make it
> its way - there must be something subtle :-) Regardless, updated
> patches coming in a second.

The subtlety is that OpenGL 3.2 mandates the existence GLX_ARB_create_context,
but the converse is not true. In fact, Mesa supported GLX_ARB_create_context
long before it supported OpenGL 3.2.

___
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 
>>>> 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.
>>
> 
> 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 wayland-client-protocol.h was split out
from wayland-client.h.

> Another option would be to add a wrapper around
> wl_proxy_marsh

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 

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(&opts);
> -if (!ok)
> -error_waffle();
> +char *info;
> +switch (opts.format) {
> +case FORMAT_ORIGINAL:
> +ok = print_wflinfo(&opts);
> +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 03/12] core: store current context in wcore_display

2016-04-08 Thread Chad Versace
n 01/08/2016 04:15 AM, Emil Velikov wrote:
> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>> For core functions that need to know the current context, like the
>> forthcoming wflinfo-like function.
>>
>> Signed-off-by: Frank Henigman 
>> ---
>>  src/waffle/api/waffle_gl_misc.c | 11 +++
>>  src/waffle/core/wcore_display.c |  1 +
>>  src/waffle/core/wcore_display.h |  2 ++
>>  3 files changed, 10 insertions(+), 4 deletions(-)

>> diff --git a/src/waffle/core/wcore_display.c 
>> b/src/waffle/core/wcore_display.c
>> index 18262c3..bcaeacb 100644
>> --- a/src/waffle/core/wcore_display.c
>> +++ b/src/waffle/core/wcore_display.c
>> @@ -52,6 +52,7 @@ wcore_display_init(struct wcore_display *self,
>>  mtx_unlock(&mutex);
>>
>>  self->platform = platform;
>> +self->current_context = NULL;

> We calloc the struct so we should need this ?

I think the explicit assignment to NULL is appropriate here, as the call to 
calloc
is in another file. The explicit assignment makes it easy to *locally* verify 
that
the code is correct. If the call to calloc were local to this function, then I 
would feel
differently.


>> diff --git a/src/waffle/core/wcore_display.h 
>> b/src/waffle/core/wcore_display.h
>> index 6e374e3..1ccff6f 100644

>>  struct wcore_display {
>>  struct api_object api;
>> +struct wcore_context *current_context;

> Not 100% if wcore_display is the "right" struct, but keeping a
> reference in waffle sounds great imho. The alternative (using every
> permutation of GetCurrentContext) does feel like an overkill.

Waffle should keep a reference to the current context, but storing it in the
display is incorrect. The problem is that, at least in GLX and EGL, there
exists no context current to the *display*. Instead, a context may be current
to a *thread*. The distinction is significant, because a single display may be
bound to multiple threads, with a different context bound in each thread. In
other words, a display may have multiple current contexts, one per thread.

As a consequence, the thread's current context must be stored in thread-local
storage.

In response to this patch, I wrote my own patch [1] on my personal branch
'get-current' [2] that does exactly that: adds the current context and display
to Waffle's TLS. I plan on committing the patch after I submit to Intel's CI
and verify it doesn't interfere with any Piglit tests. (Intel's Mesa CI is down
for maintenance for today).

[1] 
https://github.com/chadversary/waffle/commit/1fdf3bd7f68bd1efa703c2cec4cd8a193c2182b5
[2] https://github.com/chadversary/waffle/commits/get-current

For reference, I quote below a comment from the patch that explains in more
detail the topic of "current objects".

Frank, wherever your patch series uses wcore_display::current_context, it 
should use
wcore_tinfo::current_context instead.

 snip 

/// A note on the current display and context:
///
///   EGL allows a thread to have current one the below combinations of display,
///   context, and surface.
///
/// a. No display, no context, no surface.
///
///This case occurs when the thread has not previously called
///eglMakeCurrent(), or when the thread has calls
///eglMakeCurrent(EGL_DISPLAY_NONE, EGL_NO_SURFACE, EGL_NO_SURFACE,
///EGL_NO_CONTEXT). Note that the EGL 1.5 specification mandates that
///calling eglMakeCurrent() with EGL_DISPLAY_NONE generate an error,
///but some implementations allow it anyway according to the footnote
///in the EGL 1.5 specification (2014.08.27), p59:
///
///  Some implementations have chosen to allow EGL_NO_DISPLAY as
///  a valid dpy parameter for eglMakeCurrent. This behavior is not
///  portable to all EGL implementations, and should be considered as
///  an undocumented vendor extension.
///
/// b. One display, no context, no surface.
///
///This case occurs when the thread calls eglMakeCurrent() with
///a valid display but no context.
///
/// c. One display, one context, no surface.
///
///Supported by EGL 1.5, EGL_KHR_surfaceless_context, and
///EGL_KHR_create_context.
///
/// d. One display; one context, and both a draw and read surface.
///
///The classic case.
///
///EGL permits a context to be current to at most one thread. Same for
///surfaces.  However, a display may be current to multiple threads.
///
///Therefore, to support waffle_get_current(), Waffle must track all three
///objects (display, context, and waffle_window) in thread-specific storage.
///It is insufficient to maintain a reference to the current context and
///window in the current display, as there may exist multiple contexts and
///surfaces, each current in different threads, but all children to the same
///display.
///
struct wcore_tinfo {
...
struct wcore_display *current_display;
struct wcore_window *current_window;
struct wcore_conte

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 0/4] Add JSON interface to wflinfo

2016-01-11 Thread Chad Versace
On 01/05/2016 11:46 AM, baker.dyla...@gmail.com wrote:
> From: Dylan Baker 
> 
> This is a second go at this series.
> 
> Notable changes from the first version:
> - Style cleanups as suggested by Chad and Frank
> - Restructuring the JSON output to have nested dictionaries for waffle
>   and OpenGL specific information (this way it can be easily
>   distinguished and easily extended with other information, like for the
>   window system)
> - Added a short -j option.
> 
> Dylan Baker (4):
>   wflinfo.c: split out flags struct
>   wflinfo.c: use ARRAY_SIZE macro
>   wflinfo.c: split version, renderer, and vendor checks
>   wflinfo.c: Add a --json flag that prints json
> 
>  src/utils/wflinfo.c | 260 
> +---
>  1 file changed, 228 insertions(+), 32 deletions(-)
> 

I pushed patches 1-3 to master. I sent more feedback to patch 4.
___
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


[waffle] Approaches to JSON

2016-01-11 Thread Chad Versace
There are two sets of very different json patchsets on the list. Each
has advantages and disadvantages.

Dylan's patchset duplicates a small amount of code. And it doesn't teach
wflinfo to print any additional info, such as GLX or EGL specific info.
However, the patchset is short, sweet, has no major flaw, and is
the correct approach for what he wished to accomplish: teach wflinfo to
print its current output in a new format, json.

Having json output makes Dylan's life easier as a Piglit developer, and
the sooner he can get json the better. So I'm inclined to expedite
Dylan's patchset and merge it soon, pending fixes.

Frank's patchset adds platform-specific info the wflinfo's output, which
is a feature it really needs. And the code for the platform-specific
info rightly belongs in core waffle, which the patchset gets right.
However, the patchset is much larger, needs lots more review, and needs
to undergo some API changes.

In other words, Frank's patches will take more time to land, and Dylan's
are nearly ready to land as-is. And I don't want to artificially stall
Dylan's Piglit work.

I've decided my preferred format for wflinfo's json output. If the
format is acceptable to everyone, then I want to see Dylan fixup
patch 4/4 of his series and resubmit.

I've been taking notes on Frank's patchset, but won't have time to
provide real feedback until Tuesday (tomorrow) morning.


JSON Format
---
Below is the json format I prefer. Is this acceptable to everyone? Did I
underspecify the format?

The major things I considered when deciding the format are:
  1. Keep it simple.
  2. Explicit is better than implicit.
  3. Make life easy for existing wflinfo parsers
 that wish to begin consuming the json. That means existing keys and
 values should closely resemble eachother, and preferably be
 identical.

Definition:
  * All key names are lower case, for consistency.
  * Key names use ' ', not '-' nor '_', as the separator. This is
consistent with wflinfo's current output and glxinfo's output.
  * For existing keys in wflinfo's current output, the JSON key names
should match modulo case.
  * For existing values in wflinfo's current output, the JSON value
should be identical.
  * The "opengl" table contains all info specific to the OpenGL context.
That includes GLSL info, as that is a property of the OpenGL
context.

  {
"waffle": {
  "platform": String,
  "api": String,
},
"opengl": {
  "vendor string": String,
  "renderer string": String,
  "version string": String,
  "shading language version string": String,
  "extensions": [String],
},

"egl": {
  "vendor string": String,
  "version string": String,
  "version": [Int, Int],
  "extensions": [String],
  "client apis": [String],
},


"glx": {
  "server": {
"vendor string": String,
"version string": String,
"extensions string": [String],
  },
  "client": {
"vendor string": String,
"version string": String,
"extensions": [String],
  }
  "common": {
"version": [Int, Int],
"extensions": [String],
  },
},

  }

The GLX and EGL tables can be extended in the future to contain
additional information, such as visual configs.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 02/12] core: store context API in wcore_context

2016-01-08 Thread Chad Versace
On 01/06/2016 11:56 AM, Frank Henigman wrote:
> Facilitates api-specific code in core functions, like the forthcoming
> wflinfo-like function.
> 
> Signed-off-by: Frank Henigman 
> ---
>  src/waffle/core/wcore_context.h | 2 ++
>  1 file changed, 2 insertions(+)



>  struct wcore_context {
>  struct api_object api;
> +int32_t context_api; // WAFFLE_CONTEXT_API enum, e.g. 
> WAFFLE_CONTEXT_OPENGL
>  struct wcore_display *display;
>  };

Like patch 1, use an enum here for gdb's sake.

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


Re: [waffle] [PATCH v2 3/4] wflinfo.c: split version, renderer, and vendor checks

2016-01-08 Thread Chad Versace
On 01/05/2016 11:46 AM, baker.dyla...@gmail.com 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 
> 
> v2: - change "const char * name" to "const char *name" (Frank)
> ---
>  src/utils/wflinfo.c | 50 --
>  1 file changed, 36 insertions(+), 14 deletions(-)

Patches 1-3 are
Reviewed-by: Chad Versace 

For patch 4, I'm waiting for you to address the `i != flag_count`
issue, and any resultant newline fixups.

I just began reading Frank's series, btw. I haven't decided yet
how your two series should interact.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 01/12] core: store platform type in wcore_platform

2016-01-08 Thread Chad Versace
On 01/08/2016 04:00 AM, Emil Velikov wrote:
> Hi Frank,
> 
> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>> Facilitates platform-specific code in core functions, like the forthcoming
>> wflinfo-like function.
>>
>> Signed-off-by: Frank Henigman 
>> ---
>>  src/waffle/api/waffle_init.c | 32 +---
>>  src/waffle/core/wcore_platform.h |  1 +
>>  2 files changed, 22 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c
>> index 60091d1..3d8d350 100644
>> --- a/src/waffle/api/waffle_init.c
>> +++ b/src/waffle/api/waffle_init.c
>> @@ -142,43 +142,53 @@ waffle_init_parse_attrib_list(
>>  static struct wcore_platform*
>>  waffle_init_create_platform(int32_t waffle_platform)
>>  {
>> +struct wcore_platform *wc_platform = NULL;
>> +
>>  switch (waffle_platform) {
>>  #ifdef WAFFLE_HAS_ANDROID
>>  case WAFFLE_PLATFORM_ANDROID:
>> -return droid_platform_create();
>> +wc_platform = droid_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_CGL
>>  case WAFFLE_PLATFORM_CGL:
>> -return cgl_platform_create();
>> +wc_platform = cgl_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_GLX
>>  case WAFFLE_PLATFORM_GLX:
>> -return glx_platform_create();
>> +wc_platform = glx_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_WAYLAND
>>  case  WAFFLE_PLATFORM_WAYLAND:
>> -return wayland_platform_create();
>> +wc_platform = wayland_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_X11_EGL
>>  case WAFFLE_PLATFORM_X11_EGL:
>> -return xegl_platform_create();
>> +wc_platform = xegl_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_GBM
>>  case WAFFLE_PLATFORM_GBM:
>> -return wgbm_platform_create();
>> +wc_platform = wgbm_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_WGL
>>  case WAFFLE_PLATFORM_WGL:
>> -return wgl_platform_create();
>> +wc_platform = wgl_platform_create();
>> +break;
>>  #endif
>>  #ifdef WAFFLE_HAS_NACL
>>  case WAFFLE_PLATFORM_NACL:
>> -return nacl_platform_create();
>> +wc_platform = nacl_platform_create();
>> +break;
>>  #endif
>> -default:
>> -assert(false);
>> -return NULL;

> If we remove the default statement the compiler will shout loudly at
> us. Just initialize wc_platform here ?

Like Emil said, the default is required to eliminate compiler warnings,
as this switch is non-exhaustive. It's best to keep the default statement
as-is (assert for debug builds, return NULL for release builds).

> 
>>  }

An empty line after the brace, please.

>> +assert(wc_platform);
>> +wc_platform->waffle_platform = waffle_platform;
>> +return wc_platform;
>>  }
>>
>>  WAFFLE_API bool
>> diff --git a/src/waffle/core/wcore_platform.h 
>> b/src/waffle/core/wcore_platform.h
>> index 780d07a..30d1c6c 100644
>> --- a/src/waffle/core/wcore_platform.h
>> +++ b/src/waffle/core/wcore_platform.h
>> @@ -139,6 +139,7 @@ struct wcore_platform_vtbl {
>>
>>  struct wcore_platform {
>>  const struct wcore_platform_vtbl *vtbl;
>> +int32_t waffle_platform; // WAFFLE_PLATFORM_* enum

> Worth using the enum here ? (same goes for patch 2)

Yes, this should be an enum. Originally, values like this were
int32_t throughout the waffle code. But then Brian Paul requested that
waffle use enums instead because it made debugging easier. (gdb understands
how to print enum names, but doesn't know the name if the value's type is
a plain int).

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


Re: [waffle] [PATCH v2 3/4] wflinfo.c: split version, renderer, and vendor checks

2016-01-08 Thread Chad Versace
On 01/06/2016 02:55 PM, Dylan Baker wrote:
> 
> 
> On Wed, Jan 6, 2016 at 1:30 PM, Emil Velikov  > wrote:
> 
> On 5 January 2016 at 19:46,   > wrote:
> > From: Dylan Baker  >

> > +static const char *
> > +get_vendor(void)
> > +{
> > +const char *vendor = (const char *) glGetString(GL_VENDOR);
> > +if (glGetError() != GL_NO_ERROR || vendor == NULL) {
> > +vendor = "WFLINFO_GL_ERROR";
> > +}
> > +

> Wish I caught you before re-spinning things. This and the other two
> can loose the brackets - those were added due to bugs in MSVC's C99
> parser. This comment is another "if things ever get to v3".
> 
> -Emil
> 
> 
> After learning GO I'm always going to use brackets, because being in
> a good habit of using brackets prevents an entire class of bugs (like
> apple's ssl return bug). Unless Chad really objects to having the
> brackets I prefer them.

Even though it's unpopular with C programmers, I prefer, like Dylan,
to use brackets everywhere. Programming in C is hard enough; deciding
when to use or not use brackets is another unneeded mental burden.
Also, I've encountered real bugs in driver code due to a missing
bracket.

I'm not entirely consistent, though. Sometimes I don't bracket when
I'm *gasp* feeling lazy.
___
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  <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,   <mailto:baker.dyla...@gmail.com>> wrote:
> >> From: Dylan Baker  <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  <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 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, &context_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] [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] [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 2/4] wcore: don't parse/validate the exact major/minor version

2015-11-10 Thread Chad Versace
On Tue 01 Sep 2015, Emil Velikov wrote:
> Keeping track what is and isn't the correct version at any given time
> sounds unfeasable.
> 
> On one hand currently we allow any random value as minor for ES2 and
> ES3, whist for GL we allow any values as long as they are >= 1.0

I agree, that inconsistency is ugly.

> If we are to keep track what versions are valid, this is going to cause
> problems as new versions of the specs get released.

In theory, I don't believe that would be a problem if Waffle validated
only the context version's *lower* bound. The lower bounds should never
change, not even when new specs are released. For OpenGL !ES, Waffle
validates only the lower bound.

For OpenGL ES, though, Waffle tries to be smarter, and therefore is
dumber. So I agree with you...

> Let's do the sane thing and remove the bookkeeping from waffle.

... let's do the sane thing and remove all the fine-grained validation.

> Note: this will break the tests. Should we update them prior, alongside
> or after this commit ?

Let's avoid regressing the unit tests. Update them in this commit.

> Signed-off-by: Emil Velikov 
> ---
>  src/waffle/core/wcore_config_attrs.c | 71 
> 
>  1 file changed, 71 deletions(-)
> 
> diff --git a/src/waffle/core/wcore_config_attrs.c 
> b/src/waffle/core/wcore_config_attrs.c
> index 4a2cb5d..3c6753a 100644
> --- a/src/waffle/core/wcore_config_attrs.c
> +++ b/src/waffle/core/wcore_config_attrs.c
> @@ -160,74 +160,6 @@ set_context_version_default(struct wcore_config_attrs 
> *attrs)
>  }
>  
>  static bool
> -parse_context_version(struct wcore_config_attrs *attrs,
> -  const int32_t attrib_list[])
> -{
> -wcore_attrib_list32_get(attrib_list, WAFFLE_CONTEXT_MAJOR_VERSION,
> -&attrs->context_major_version);
> -wcore_attrib_list32_get(attrib_list, WAFFLE_CONTEXT_MINOR_VERSION,
> -&attrs->context_minor_version);

Ack! You can't remove the above two calls. Otherwise
attrs->context_major/minor_version never get set. That leads to weird
bugs like this:

   On master, all commands fail when given bogus context version 4.7.

 $ bin/wflinfo -p gbm -a gles2 --version 4.7
 Waffle error: 0x8 WAFFLE_ERROR_BAD_ATTRIBUTE: for OpenGL ES2, the 
requested major context version must be 2
 $ bin/wflinfo -p gbm -a gl --profile core --version 4.7
 Waffle error: 0x2 WAFFLE_ERROR_UNKNOWN: eglCreateContext failed with error 
EGL_BAD_MATCH(0x3009)
 $ bin/gl_basic --platform glx --api gl --profile core --version 4.7
 gl_basic: error: WAFFLE_ERROR_UNKNOWN: glXCreateContextAttribsARB failed


   The same commands, with this patch applied. wflinfo succeeds in
   creating an OpenGL ES 4.7 context! And the other commands fail with
   incorrect error messages.

 $ bin/wflinfo -p gbm -a gles2 --version 4.7
 Mesa warning: couldn't open libtxc_dxtn.so, software DXTn
 compression/decompression unavailable
 Waffle platform: gbm
 Waffle api: gles2
 OpenGL vendor string: Intel Open Source Technology Center
 OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 5500 (Broadwell GT2)
 OpenGL version string: OpenGL ES 3.0 Mesa 11.0.4 (git-774dd01)
 $ bin/wflinfo -p gbm -a gl --profile core --version 4.7
 Waffle error: 0x8 WAFFLE_ERROR_BAD_ATTRIBUTE: for OpenGL < 3.2, 
WAFFLE_CONTEXT_PROFILE must be WAFFLE_NONE
 $ bin/gl_basic --platform glx --api gl --profile core --version 4.7
 gl_basic: error: WAFFLE_ERROR_BAD_ATTRIBUTE: for OpenGL < 3.2, 
WAFFLE_CONTEXT_PROFILE must be WAFFLE_NONE



> -
> -if (attrs->context_major_version < 1) {
> -wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> - "WAFFLE_CONTEXT_MAJOR_VERSION must be >= 1");
> -return false;
> -}
> -
> -if (attrs->context_minor_version < 0) {
> -wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> - "WAFFLE_CONTEXT_MINOR_VERSION must be >= 0");
> -return false;
> -}

I agree that all validation below this line should be killed.

However, I want to keep the above two sanity checks. Those checks do
catch completely incorrect input. For example, the checks would prevent
the user from providing WAFFLE_DONT_CARE as a context version, which
would eventually get passed to EGL/GLX/WGL as a *negative* context
version. Waffle should avoid passing negative version to GL drivers...
who knows what fun driver bugs we'll discover in requesting a -1.0
context?

> -
> -switch (attrs->context_api) {
> -case WAFFLE_CONTEXT_OPENGL:
> -if (wcore_config_attrs_version_lt(attrs, 10)) {
> -wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
> - "for OpenGL, the requested context version "
> - "must be >= 1.0");
> -return false;
> -}
> -break;
> -
> -case WAFFLE_CONTEXT_OPENGL_ES1:
> -if (!wcore_config_a

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-09 Thread Chad Versace
On Sat 05 Sep 2015, Emil Velikov wrote:
> On 3 September 2015 at 21:27, Chad Versace  wrote:

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

> Considering the churn during the conversion, we might want to do it in
> one step, namely:
> 1. Update cmocka (fix integration, add missing include)
> 2. Update existing users to cmocka 1.x
> 3. Transition/refactor each platform to a separate cmocka based test
> `gl_basic_test_$(platform)'
> 
> > 3. Add `make check` and the GBM tests to some CI system.
> I don't see any GBM tests in waffle. Am I missing something or you
> have something locally ?

I misspoke. I used to have GBM tests locally, but never pushed them
because `make check-func` was not split per platform. So, that gives us
a new task, to be done after refactoring "each platform to a separate
cmocka based test": add some GBM tests.
___
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] gbm: allow user to specify device

2015-08-21 Thread Chad Versace
On Sat 15 Aug 2015, Ilia Mirkin wrote:
> Signed-off-by: Ilia Mirkin 
> ---
>  src/waffle/gbm/wgbm_display.c | 8 
>  1 file changed, 8 insertions(+)

Hi Ilia,

The patch, as-is, silently falls back to searching udev if it fails to
open the device path given in the environment. I think that's an
unexpected and surprising failure mode, because the user thinks one
device was opened (the one in the environment) but is given no
indication that a different device was opened.

Like we discussed in IRC, I made a few changes to the patch, and also
fixed the silent failure mode. It's in master now [1]. And I'll add it
to 1.5.2 too (I'm preparing the release notes right now).

[1]: 
https://github.com/waffle-gl/waffle/commit/cef67496e379b660601f64ab2ddf7cf06307b8aa
___
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-04 Thread Chad Versace
On Thu 04 Jun 2015, Michel Dänzer wrote:
> On 03.06.2015 03:19, Emil Velikov wrote:
> > On 2 June 2015 at 18:13, Chad Versace  wrote:
> >> On Mon 01 Jun 2015, Michel Dänzer wrote:
> >>> From: Michel Dänzer 
> >>>
> >>> 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 
> >>
> >> Emil, does this patch look good to you?
> >>
> > It looks great - thanks Michel ! Perhaps we should apply it to the
> > maint branches as well ?
> > 
> > Reviewed-by: Emil Velikov 
> 
> Thank you Emil and Chad! Can one of you push this change for me please?

Done. I pushed it to master and the stable branches.
___
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 
> 
> 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 

Emil, does this patch look good to you?

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


Re: [waffle] [PATCH 00/10] null platform WIP

2015-05-12 Thread Chad Versace
Frank, sorry the late reply.

On Mon 30 Mar 2015, Frank Henigman wrote:
> This patch set adds a new platform: WAFFLE_PLATFORM_NULL.
> This platform uses EGL_PLATFORM_NULL, KHR_surfaceless_context,
> EXT_image_dma_buf_import and gbm.
> In this platform a waffle window contains gbm buffers and sets up
> rendering into them via dmabuf, EGLImage and GL framebuffer.
> These details are hidden from the user so the platform works exactly
> like other waffle platforms.
> It is also possible to show the gbm buffers on screen via DRM/KMS.
> 
> Development ongoing at https://github.com/fjhenigman/waffle/tree/null.
> The version here is tagged "null1" on github.
> 
> Prerequisites:
> - Mesa with gles2, intel, gbm (mesa gbm or minigbm) and these patches:
>   
> https://raw.githubusercontent.com/fjhenigman/waffle/mesa/0001-egl-dri2-implement-platform_null.patch
>   
> https://raw.githubusercontent.com/fjhenigman/waffle/mesa/10.3-i965-remove-read-only-restriction-of-imported-buffer.patch
> 
> This is work in progress and numerous issues remain:
> - display is upside down
> - glBindFramebuffer(0) will not have the desired effect as the waffle
>   window uses non-zero framebuffers
>   - seems this can only be fixed for apps that use waffle to look up their
> GL functions - by returning a wrapper to intercept glBindFramebuffer
> - only GLES2 supported
> - only double buffering supported
> - only tested with Mesa/i965, and only on a couple simple Chrome OS tests
>   - should try a piglit run
>   - tested almost entirely with minigbm, barely with mesa gbm
> - display works on i915 only
>   - i915-specific code is hard-wired - no graceful failure on other hardware
>   - minigbm might be a good place to stick hardware-specific code
>   - if we still want display for the GBM platform, we should try to share
> display code with it
> - errors are checked but some could be reported more informatively
> - should fail gracefully in case of missing extensions
> 
> Questions:
> - instead of copying gbm buffers for display, can we use GL to draw a quad
>   using the source buffer as a texture?

Yes, that would be nice.

>   - can we then use render nodes to render to texture, and a master node only
> to mode set and render to displayed buffer?

Yes, that's a good idea too.

>   - this would make it simple to invert the currently upside down picture
>   - this could reduce or eliminate hardware-specific code
>   - can we do this in a separate context so as not to step on user's context?

I believe a separate context will be required if Waffle makes any GL
calls.

> - should we load libdrm dynamically?

I prefer that we do. That would allow a single build of Waffle to work
on systems where the distributed libdrm does not include all libdrm
"drivers" that Waffle was built against.

> - should internal names have a wnull_ prefix for consistency with wegl and 
> wgbm?
>   - why the leading 'w?'

The leading 'w' is to prevent namespace collisions with external
libraries, collisions in readability and collisions during compilation.
It should be clear in the code whether a symbol
is defined by Waffle itself or if the is defined by the
external dependency. This convention also prevents Waffle from
accidentally overriding a symbol when linking to the external library.

> - should we save/restore mode/crtc?
>   - seems vt doesn't come back after program exits, though it does after
> changing to different vt and back

I don't have a strong preference.
- Pro: It's nice to the user when manually running
  a Waffle/NullPlatform app.
- Con: The extra modesets could significantly slow down testruns, if
  the test run starts/stops many processes.

> - how about a naming convention for selecting cards and connectors with
>   the argument to waffle_display_connect()?

Do you have a concrete proposal for the convention? Would extending
waffle_display_connect() to accept an attribute list help you achieve
this?

> - can/should we require waffle_window_show() be called before
>   waffle_make_current()?

No. I'd like to maintain the ability to render to an unmapped window.

>   - would like know to if and how the window is going to be shown before
> allocating buffers

Can you solve this problem by definition additional attributes for
waffle_window_create2()?

___
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


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  wrote:
> > From: Frank Henigman 
> >
> > 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 
> > ---
> >  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


  1   2   3   4   5   6   >