[waffle] [ANNOUNCE] waffle 1.6.1

2020-03-31 Thread Emil Velikov
Hi all,

I'd like to announce waffle 1.6.1 as available for download immediately.

The release focuses on bugfixes and brings us:
 - wflinfo: Correctly install the bash completion file
 - GLX/WGL: Handle ARB_create_context appropriatelly
 - Wayland: Build fix for -fno-common, default with GCC10
 - Surfaceless: Implement window_resize

Additionally we have additional tests to cover above issues and GitLab
CI enabled on branch.


NOTE: addressing the -fno-common build issue, required us to bump the
wayland-client requirement to v1.10 - released in Feb 2016, 4 years ago.


Due to technical issues with GitLab/Pages, the website might be out of
date. All the files are available in the git repository:

https://gitlab.freedesktop.org/mesa/waffle/-/raw/website/files/release/waffle-1.6.1/waffle-1.6.1.tar.xz
https://gitlab.freedesktop.org/mesa/waffle/-/raw/website/files/release/waffle-1.6.1/waffle-1.6.1.tar.xz.asc
https://gitlab.freedesktop.org/mesa/waffle/-/raw/website/files/release/waffle-1.6.1/waffle-1.6.1.sha256sums
https://gitlab.freedesktop.org/mesa/waffle/-/raw/website/files/release/waffle-1.6.1/waffle-1.6.1.sha256sums.asc


Emil
___
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 Emil Velikov
On 29 October 2016 at 18:59, Chad Versace <chadvers...@chromium.org> wrote:
> On Wed 19 Oct 2016, Emil Velikov wrote:
>> On 18 October 2016 at 18:33, Chad Versace <chadvers...@chromium.org> wrote:
>> > Now waffle_init() supports WAFFLE_PLATFORM_SURFACELESS_EGL.
>> >
>> > Cc: Gurchetan Singh <gurchetansi...@chromium.org>
>> > Cc: Haixia Shi <h...@chromium.org>
>> > ---
>> >  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(...);

IMHO the only part that prevents one to extend the structs is the
embedded waffle_$platform_display into the confirg/context/window
structs. With those converted to struct * things should be just fine.
On the removal side - I cannot think of any way to make that happen
w/o breaking the API/ABI. Be that with the current or proposed
solution.

If anything I'd opt/suggest the struct * route since it will results
in less code - within waffle, its API and the users.
The work for ^^ will be mostly copy/paste afaics.

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


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

2016-10-25 Thread Emil Velikov
On 24 October 2016 at 22:57, Chad Versace <chadvers...@chromium.org> wrote:
> Before EGL_EXT_platform_base and EGL 1.5, when using Mesa the best way
> to select the EGL platform was to set the EGL_PLATFORM environment
> variable. Now that a standard way exists, eglGetPlatformDisplay, let's
> use it when available.
>
> After this series, I have a series to add support for
> EGL_MESA_platform_surfaceless.
>
> This branch lives at
> 
> https://github.com/chadversary/waffle/commits/review/eglGetPlatformDisplay-v02
>
> v2:
> - Fix bugs found by Emil.
> - Don't set EGL_PLATFORM=android.
> - Last patch, add fallback to use eglGetPlatformDisplayEXT.
>
> Chad Versace (8):
>   egl: Define EGL_PLATFORM_* enums
>   egl: Update wegl_platform_init signature
>   egl: Move each platform's setenv("EGL_PLATFORM") into core EGL code (v2)
>   egl: Query client extensions string
>   egl: Optionally query for eglGetPlatformDisplay (v2)
>   egl: Update wegl_display_init signature
>   egl: Use eglGetPlatformDisplay when possible (v2)
>   egl: Use eglGetPlatformDisplayEXT as a fallback
>
Cannot see 8/8 in the list, so I've check it via the repo.
The lot looks great imho.

Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

-Emil
___
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-21 Thread Emil Velikov
On 19 October 2016 at 22:52, Chad Versace <chadvers...@chromium.org> wrote:
> On Wed 19 Oct 2016, Emil Velikov wrote:
>> On 18 October 2016 at 17:58, Chad Versace <chadvers...@chromium.org> wrote:
>> > Tested against Mesa master@8c78fdb with `ninja check-func` on Linux.
>> > ---
>> >  src/waffle/egl/wegl_display.c  | 22 ++
>> >  src/waffle/egl/wegl_platform.c | 35 +--
>> >  src/waffle/egl/wegl_platform.h |  8 
>> >  3 files changed, 59 insertions(+), 6 deletions(-)
>> >
>> > diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
>> > index 7a7986c..c924f2a 100644
>> > --- a/src/waffle/egl/wegl_display.c
>> > +++ b/src/waffle/egl/wegl_display.c
>> > @@ -104,10 +104,24 @@ wegl_display_init(struct wegl_display *dpy,
>> >  if (!ok)
>> >  goto fail;
>> >
>> > -dpy->egl = plat->eglGetDisplay((EGLNativeDisplayType) native_display);
>> > -if (!dpy->egl) {
>> > -wegl_emit_error(plat, "eglGetDisplay");
>> > -goto fail;
>> > +if (wegl_platform_can_use_eglGetPlatformDisplay(plat)) {
>> > +void *fixed_native_dpy = native_display;
>> > +if (plat->egl_platform == EGL_PLATFORM_X11_KHR)
>> > +fixed_native_dpy = _display;
>> > +
>
>> Silly question: wasn't the fixup applicable only for the window/pixmap 
>> surface ?
>
> Thanks! You're right.
>
>> > +dpy->egl = plat->eglGetPlatformDisplay(plat->egl_platform,
>> > +   fixed_native_dpy,
>> > +   NULL);
>> > +if (!dpy->egl) {
>> > +wegl_emit_error(plat, "eglGetPlatformDisplay");
>> > +goto fail;
>> > +}
>
>> Wondering if falling back to eglGetDisplay() is a smart idea in this case?
>> How about EGL_EXT_platform_base/eglGetPlatformDisplayEXT (admittedly
>> there's no support for it atm, but it's trivial to do so) ?
>
> I want to keep the old eglGetDisplay behavior. Otherwise, upgrading
> Waffle would regress functionality on systems with old Mesa (thinking
> about Ubunut LTS). And it's a no-no for upgrades to cause a gross
> regression like that.
>
> I agree that the fallback path should include eglGetPlatformDisplayEXT.
> But the lack of eglGetPlatformDisplayEXT doesn't make the patch
> incorrect. That can be done as a simple follow-up patch.
>
Agreed.

It just hit me that current mesa does not advertise the KHR (EGL 1.5)
extensions so with this series one is still using the old
eglGetDisplay. Having a closer look at Mesa - advertising them won't
be able in the short term, if at all. That's due to the fact that we
depend on quering the dri module(s) in order to advertise some of the
EGL 1.5 requirements/extensions.

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

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

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


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

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

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

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

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

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

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

With that (and the extra Android change itself) are
Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

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


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

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


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

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


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

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

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

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


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

2016-10-14 Thread Emil Velikov
On 12 October 2016 at 18:17, Chad Versace  wrote:
> 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.

Just closed an old/obsolete PR request, so it seems to work fine.

On the GUI side, yeah it is 'interesting' at times :-)
Emil
___
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-12 Thread Emil Velikov
On 11 October 2016 at 18:23, Chad Versace <chadvers...@chromium.org> wrote:
> 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 <fjhenig...@google.com>
>> Cc: Chad Versace <chad.vers...@intel.com>
>> ---
>> 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! Hope you'll do a
series here/github PR before pushing things :-)
Can I poke you for access about the github issues section ? IIRC
there's a few that should be closed.

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


Re: [waffle] [PATCH] gbm: add WAFFLE_GBM_RENDER_NODE for multi-GPU systems

2016-09-09 Thread Emil Velikov
Hi Marek,

On 9 September 2016 at 14:14, Marek Olšák  wrote:
> From: Marek Olšák 
>
> ---
>  src/waffle/gbm/wgbm_display.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/waffle/gbm/wgbm_display.c b/src/waffle/gbm/wgbm_display.c
> index 5c8af29..f622f39 100644
> --- a/src/waffle/gbm/wgbm_display.c
> +++ b/src/waffle/gbm/wgbm_display.c
> @@ -104,9 +104,13 @@ static int
>  wgbm_get_default_fd(void)
>  {
>  int fd;
> +const char *render_node = getenv("WAFFLE_GBM_RENDER_NODE");
> +
Using WAFFLE_GBM_DEVICE one can control the exact node/device they
want to use. Does it not work for you ?

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


Re: [waffle] [PATCH 0/4] Implement gbm window_resize

2016-08-19 Thread Emil Velikov
On 18 August 2016 at 11:41, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> On 16 May 2016 at 11:48, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>> Hi all,
>>
>> This is a respin of Emmanuel (linkmauve)'s work [1] without all the
>> unneeded coping. On gbm one needs to teardown the old window (which this
>> series does only if we can create the new one and make it current).
>>
>> Note: this adds a rather hacky looking link to the config in struct
>> wgbm_window, so I'm open to suggestions how to resolve/remove it.
>>
>> https://github.com/evelikov/waffle/tree/for-upstream/gbm-window_resize
>>
>> Thanks
>> Emil
>>
>> [1] https://github.com/waffle-gl/waffle/pull/32
>>
> Humble ping ?
>
> Note: Since the patch queue is quite large and I have even more
> patches that I haven't sent out, I'm planning to start pushing the
> less controversial patches.
> The idea is:
>  * "ping"
>  * wait 3 days/a week
>  * run the tests (to double check for regressions)
>  * push
>

So giving it a --dry-run earlier I've noticed that I don't have commit
access to the repo. Guess I've misunderstood Chad'd message a while
back.

So here goes my plan to flush some of the trivial patches :-\
Emil
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 0/4] Implement gbm window_resize

2016-08-18 Thread Emil Velikov
On 16 May 2016 at 11:48, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> Hi all,
>
> This is a respin of Emmanuel (linkmauve)'s work [1] without all the
> unneeded coping. On gbm one needs to teardown the old window (which this
> series does only if we can create the new one and make it current).
>
> Note: this adds a rather hacky looking link to the config in struct
> wgbm_window, so I'm open to suggestions how to resolve/remove it.
>
> https://github.com/evelikov/waffle/tree/for-upstream/gbm-window_resize
>
> Thanks
> Emil
>
> [1] https://github.com/waffle-gl/waffle/pull/32
>
Humble ping ?

Note: Since the patch queue is quite large and I have even more
patches that I haven't sent out, I'm planning to start pushing the
less controversial patches.
The idea is:
 * "ping"
 * wait 3 days/a week
 * run the tests (to double check for regressions)
 * push

Hope I'll get a pair of eyes to check/confirm things beforehand ;-)

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


Re: [waffle] [PATCH 00/13] Core waffle cleanups

2016-08-18 Thread Emil Velikov
On 21 June 2016 at 11:33, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> On 16 May 2016 at 11:57, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>> On 16 May 2016 at 11:54, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>>> Hi all,
>>>
>>> While looking at the gbm/egl I've noticed a few interesting bits.
>>>  - We do NULL checking for values that are guaranteed by API to be
>>> non-NULL.
>>>  - wcore_*_init does not need a return type, plus in some places we were
>>> not calling it in the correct time.
>>>  - wcore_*_teardown is a simple wrapper around assert, which (at the
>>> time the function should be called) is too late/not needed.
>>>
>>> So this series simplifies these, giving us a nice -350 line count ;-)
>>>
>>> The whole thing can be found in
>>> https://github.com/evelikov/waffle/tree/for-upstream/core-cleanups
>>>
>> For some reason git send-email seems to be choking on patches 08/13
>> and 09/13. Please check those out via the above repo or let me know if
>> you'd prefer them in other format.
>>
> I might have gone overboard (too much) folding the error label(s) in
> 09/13 "core: remove wcore_*_init() return type". I can split those up
> if people prefer.
>
Humble poke.

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

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


[waffle] [PATCH 2/2] gbm: coding style cleanup

2016-07-21 Thread Emil Velikov
Waffle aims to keep the main code path in it's core, with the
error path diverging via goto labels and alike.

Follow the approach and update the gbm code.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/gbm/wgbm_platform.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index 0fc0352..9ba1340 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -137,11 +137,11 @@ wgbm_platform_create(void)
 if (self == NULL)
 return NULL;
 
-if (wgbm_platform_init(self))
-return >wegl.wcore;
-
-wgbm_platform_destroy(>wegl.wcore);
-return NULL;
+if (!wgbm_platform_init(self)) {
+wgbm_platform_destroy(>wegl.wcore);
+return NULL;
+}
+return >wegl.wcore;
 }
 
 bool
-- 
2.9.0

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


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

2016-07-21 Thread Emil Velikov
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.

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.
---
 src/waffle/egl/wegl_platform.c | 9 +
 src/waffle/egl/wegl_platform.h | 4 
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index 0c9eb44..800025e 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -72,11 +72,8 @@ wegl_platform_init(struct wegl_platform *self)
 goto error;
 }
 
-#define OPTIONAL_EGL_SYMBOL(function)  \
-self->function = dlsym(self->eglHandle, #function);
-
 #define RETRIEVE_EGL_SYMBOL(function)  \
-OPTIONAL_EGL_SYMBOL(function)  \
+self->function = dlsym(self->eglHandle, #function);\
 if (!self->function) { \
 wcore_errorf(WAFFLE_ERROR_FATAL, \
  "dlsym(\"%s\", \"" #function "\") failed: %s",\
@@ -85,9 +82,6 @@ wegl_platform_init(struct wegl_platform *self)
 goto error;\
 }
 
-OPTIONAL_EGL_SYMBOL(eglCreateImageKHR);
-OPTIONAL_EGL_SYMBOL(eglDestroyImageKHR);
-
 RETRIEVE_EGL_SYMBOL(eglMakeCurrent);
 RETRIEVE_EGL_SYMBOL(eglGetProcAddress);
 
@@ -112,7 +106,6 @@ wegl_platform_init(struct wegl_platform *self)
 RETRIEVE_EGL_SYMBOL(eglDestroySurface);
 RETRIEVE_EGL_SYMBOL(eglSwapBuffers);
 
-#undef OPTIONAL_EGL_SYMBOL
 #undef RETRIEVE_EGL_SYMBOL
 
 error:
diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
index 7ae0490..645c3f8 100644
--- a/src/waffle/egl/wegl_platform.h
+++ b/src/waffle/egl/wegl_platform.h
@@ -26,7 +26,6 @@
 #pragma once
 
 #include 
-#include 
 
 #include "wcore_platform.h"
 #include "wcore_util.h"
@@ -69,9 +68,6 @@ struct wegl_platform {
  const EGLint *attrib_list);
 EGLBoolean (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
 EGLBoolean (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
-
-EGLImageKHR (*eglCreateImageKHR) (EGLDisplay dpy, EGLContext ctx, EGLenum 
target, EGLClientBuffer buffer, const EGLint *attrib_list);
-EGLBoolean (*eglDestroyImageKHR)(EGLDisplay dpy, EGLImageKHR image);
 };
 
 DEFINE_CONTAINER_CAST_FUNC(wegl_platform,
-- 
2.9.0

___
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-22 Thread Emil Velikov
On 23 June 2016 at 00:58, Jason Ekstrand <ja...@jlekstrand.net> wrote:
>
>
> On Tue, Jun 21, 2016 at 9:06 PM, Chad Versace <chad.vers...@intel.com>
> wrote:
>>
>> On Mon 20 Jun 2016, Chad Versace wrote:
>> > On Sun 17 Apr 2016, Emil Velikov wrote:
>> > > On 17 April 2016 at 01:41, Jason Ekstrand <ja...@jlekstrand.net>
>> > > wrote:
>> > > > On Sat, Apr 16, 2016 at 4:12 PM, Emil Velikov
>> > > > <emil.l.veli...@gmail.com>
>> > > > wrote:
>> > > >>
>> > > >> On 16 April 2016 at 22:06, Jason Ekstrand <ja...@jlekstrand.net>
>> > > >> wrote:
>> >
>> > > >> >> >> In either case, I think checking wayland-client-protocol.h
>> > > >> >> >> into the
>> > > >> >> >> repo is
>> > > >> >> >> a must.
>> > > >> >> >
>> > > >> >> > I'm convinced.
>> > > >> >> Unfortunately I'm not ;'-(
>> > > >> >
>> > > >> >
>> > > >> > Are you now?
>> > > >> >
>> > > >> Not quite I'm afraid.
>> > > >>
>> > > >> As a queue, I'm doing to (slightly) beat the SDL drum.
>> > > >> SDL caters for everyone's needs and has a much wider exposure than
>> > > >> waffle. I'm suggesting the exact same approach like the one they
>> > > >> opted
>> > > >> for ;-)
>> > > >
>> > > >
>> > > > I doubt its the "exact" same or they'd be having build breaks too.
>> > > They do actually [1]. The person who fixed it is familiar wayland
>> > > developer [2] yet he choose the same approach as me ;-)
>> > >
>> > > > If you
>> > > > want to provide a sort of glue layer to an application, your
>> > > > suggestion of
>> > > > "optional" entrypoints is probably exactly what you want.
>> > > Indeed. Thank you.
>> > >
>> > > >  However, waffle
>> > > > itself needs to call something and it either needs to be smart
>> > > > enough to
>> > > > call the right thing depending on the libwayland version it just
>> > > > dlopened or
>> > > > it needs to just always call old ones.
>> > > >
>> > > The cases of waffle being "dumb" (not being smart enough) are so
>> > > infrequent, that it beats the added overhead that importing the header
>> > > will bring.
>> > >
>> > > Thanks for the discussion. Hopefully you're seeing things from my POV
>> > > ;-)
>> > > Emil
>> > >
>> > > [1]
>> > > https://github.com/spurious/SDL-mirror/tree/master/src/video/wayland/SDL_wayland{dyn.{c,h},sym.h}
>> > > [2]
>> > > https://github.com/spurious/SDL-mirror/commit/737415012588a2636794292129a2d39f2a28fe3c
>> >
>> > Both Jason's and Emil's approaches seem valid to me. And my preference
>> > flip-flops every few minutes as I read the thread.
>> >
>> > In April, I was strongly convinced of Jason's position. Now I'm leaning
>> > slightly toward's Emil's.
>> >
>> > I want to look more closely at SDL's approach (Emil, thanks for the
>> > links), and then make a final decision. But it's late in the day for me
>> > and my brain is done. Exhausted brains can't be trusted, so the decision
>> > will have to wait until morning.
>>
>> Everyone, thanks for the lengthy discussion. The winner is... Michel's
>> patch v2, which is basically Emil's and SDL's position.
>>
>> I decided against importing any Wayland headers, because the Wayland
>> headers actually contain a lot of inline function *definitions*. When
>> upstream Wayland applies bugfixes and improvements to those functions,
>> by not using imported headers Waffle automatically receives the bugfixes
>> and improvements simply by being rebuilt; this seems to be the intent of
>> the Wayland authors for client projects. If Waffle were to use imported
>> headers then, to receive the same improvements, someone (likely me)
>> would need to diligently keep the imported headers up-to-date.
>>
>> As a bonus, Michel's patch is considerably smaller and requires less
>> maintenance than an import-some-headers patch.
>>
>> And Mi

Re: [waffle] [PATCH 00/13] Core waffle cleanups

2016-06-21 Thread Emil Velikov
On 16 May 2016 at 11:57, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> On 16 May 2016 at 11:54, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>> Hi all,
>>
>> While looking at the gbm/egl I've noticed a few interesting bits.
>>  - We do NULL checking for values that are guaranteed by API to be
>> non-NULL.
>>  - wcore_*_init does not need a return type, plus in some places we were
>> not calling it in the correct time.
>>  - wcore_*_teardown is a simple wrapper around assert, which (at the
>> time the function should be called) is too late/not needed.
>>
>> So this series simplifies these, giving us a nice -350 line count ;-)
>>
>> The whole thing can be found in
>> https://github.com/evelikov/waffle/tree/for-upstream/core-cleanups
>>
> For some reason git send-email seems to be choking on patches 08/13
> and 09/13. Please check those out via the above repo or let me know if
> you'd prefer them in other format.
>
I might have gone overboard (too much) folding the error label(s) in
09/13 "core: remove wcore_*_init() return type". I can split those up
if people prefer.

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


Re: [waffle] long-standing wgl pixel format issue

2016-06-20 Thread Emil Velikov
On 20 June 2016 at 15:46, Brian Paul <bri...@vmware.com> wrote:
> On 06/17/2016 07:59 PM, Emil Velikov wrote:
>>
>> On 17 June 2016 at 16:53, Brian Paul <bri...@vmware.com> wrote:
>>>
>>>
>>> I spent a few hours yesterday pulling out my hair trying to understand
>>> why
>>> the piglit fbo-mipmap-copypix test was failing on Windows.  But it was
>>> only
>>> failing when I ran it directly.  It passed when I ran it via
>>> piglit-run.py
>>>
>>> The key difference was the -fbo option.  With -fbo the test used an RGBA8
>>> framebuffer but without -fbo the test used an RGB565 framebuffer.
>>>
>>> So why is a 565 framebuffer being used?  It boils down to the fact that
>>> wglChoosePixelFormatARB() does not work like glXChooseFBConfig().
>>>
>>>  From the glXChooseFBConfig man page:
>>> """
>>>GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_BLUE_SIZE, GLX_ALPHA_SIZE
>>>
>>>   Each attribute, if present, must be followed by a nonnegative
>>> minimum
>>> size
>>>  specification or GLX_DONT_CARE.
>>>  The largest available total RGBA color buffer size (sum of
>>> GLX_RED_SIZE,
>>>  GLX_GREEN_SIZE, GLX_BLUE_SIZE, and GLX_ALPHA_SIZE)
>>>  of at least the minimum size specified for each color component is
>>> preferred.
>>> """
>>>
>>> So if you specify GLX_RED_SIZE, BLUE_SIZE, etc to be 1 and there are both
>>> RGB565 and RGBA8 formats available, the _later_ (the largest) will be
>>> chosen.
>>>
>>> But the wglChoosePixelFormatARB docs say:
>>> """
>>> Some attribute values must match the pixel format value exactly when
>>>  the attribute is specified while others specify a minimum criteria,
>>>  meaning that the pixel format value must meet or exceed the
>>>  specified value.
>>>
>>>   Attribute  TypeMatch Criteria
>>>   WGL_RED_BITS_ARB   integer minimum
>>>   WGL_GREEN_BITS_ARB integer minimum
>>>   WGL_BLUE_BITS_ARB  integer minimum
>>>   WGL_ALPHA_BITS_ARB integer minimum
>>> """
>>>
>>> So if you specify WGL_RED/GREEN/BLUE_BITS_ARB to be 1 and there are both
>>> RGB565 and RGBA8 formats available, the _former_ may be chosen.  Note
>>> that
>>> some WGL apps use WGL_COLOR_BITS_ARB=24 and avoid this.
>>>
>>> Piglit's call to piglit_wfl_framework_init() uses an attribute list with
>>> WAFFLE_RED/GREEN/BLUE_SIZE = 1 and that winds up going directly to
>>> wglChoosePixelFormatARB and glXChooseFBConfig so this difference in
>>> behavior
>>> effects the window's pixel format.
>>>
>> Thanks for this Brian and apologies I did not spot these differences
>> as I was writing the WGL backend.
>>
>> Here's a bit more comprehensive list, listing all the waffle backends
>> and attributes.
>>
>> GLX/EGL:
>> Largest - red, green, blue, alpha plus their accum counterparts + depth
>> Smallest - buffer, stencil
>>
>> If requested size is zero - "largest" become "smallest" (but it's not
>> said it will be zero), "smallest" become "zero".
>>
>> CGL
>> One that "most closely matches the specified size is preferred"
>>
>> WGL/NaCL
>> "At least", meaning that there's not definition if it's the "smallest"
>> or "largest". Furthermore there's not mention that it will give you
>> the smallest if you specify 0 :-\
>>
>>
>>> The Waffle docs for waffle_config_choose() say:
>>>
>>> """
>>> WAFFLE_RED_SIZE
>>> WAFFLE_GREEN_SIZE
>>> WAFFLE_BLUE_SIZE
>>> WAFFLE_ALPHA_SIZE
>>> WAFFLE_DEPTH_SIZE
>>> WAFFLE_STENCIL_SIZE
>>>
>>>  The default value for each size attribute is 0. Valid values are the
>>> non-negative integers and WAFFLE_DONT_CARE. If the requested size for a
>>> channel is 0, then any surface created with the config will lack that
>>> channel. If the requested size for a channel is positive, then the number
>>> of
>>> bits in that channel for any surface created with the config will be at
>>> least the requested size.
>>> """
>>>
>>> There's some ambiguity here because if several di

Re: [waffle] long-standing wgl pixel format issue

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 16:53, Brian Paul  wrote:
>
> I spent a few hours yesterday pulling out my hair trying to understand why
> the piglit fbo-mipmap-copypix test was failing on Windows.  But it was only
> failing when I ran it directly.  It passed when I ran it via piglit-run.py
>
> The key difference was the -fbo option.  With -fbo the test used an RGBA8
> framebuffer but without -fbo the test used an RGB565 framebuffer.
>
> So why is a 565 framebuffer being used?  It boils down to the fact that
> wglChoosePixelFormatARB() does not work like glXChooseFBConfig().
>
> From the glXChooseFBConfig man page:
> """
>   GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_BLUE_SIZE, GLX_ALPHA_SIZE
>
>  Each attribute, if present, must be followed by a nonnegative minimum
> size
> specification or GLX_DONT_CARE.
> The largest available total RGBA color buffer size (sum of GLX_RED_SIZE,
> GLX_GREEN_SIZE, GLX_BLUE_SIZE, and GLX_ALPHA_SIZE)
> of at least the minimum size specified for each color component is
> preferred.
> """
>
> So if you specify GLX_RED_SIZE, BLUE_SIZE, etc to be 1 and there are both
> RGB565 and RGBA8 formats available, the _later_ (the largest) will be
> chosen.
>
> But the wglChoosePixelFormatARB docs say:
> """
> Some attribute values must match the pixel format value exactly when
> the attribute is specified while others specify a minimum criteria,
> meaning that the pixel format value must meet or exceed the
> specified value.
>
>  Attribute  TypeMatch Criteria
>  WGL_RED_BITS_ARB   integer minimum
>  WGL_GREEN_BITS_ARB integer minimum
>  WGL_BLUE_BITS_ARB  integer minimum
>  WGL_ALPHA_BITS_ARB integer minimum
> """
>
> So if you specify WGL_RED/GREEN/BLUE_BITS_ARB to be 1 and there are both
> RGB565 and RGBA8 formats available, the _former_ may be chosen.  Note that
> some WGL apps use WGL_COLOR_BITS_ARB=24 and avoid this.
>
> Piglit's call to piglit_wfl_framework_init() uses an attribute list with
> WAFFLE_RED/GREEN/BLUE_SIZE = 1 and that winds up going directly to
> wglChoosePixelFormatARB and glXChooseFBConfig so this difference in behavior
> effects the window's pixel format.
>
Thanks for this Brian and apologies I did not spot these differences
as I was writing the WGL backend.

Here's a bit more comprehensive list, listing all the waffle backends
and attributes.

GLX/EGL:
Largest - red, green, blue, alpha plus their accum counterparts + depth
Smallest - buffer, stencil

If requested size is zero - "largest" become "smallest" (but it's not
said it will be zero), "smallest" become "zero".

CGL
One that "most closely matches the specified size is preferred"

WGL/NaCL
"At least", meaning that there's not definition if it's the "smallest"
or "largest". Furthermore there's not mention that it will give you
the smallest if you specify 0 :-\


> The Waffle docs for waffle_config_choose() say:
>
> """
> WAFFLE_RED_SIZE
> WAFFLE_GREEN_SIZE
> WAFFLE_BLUE_SIZE
> WAFFLE_ALPHA_SIZE
> WAFFLE_DEPTH_SIZE
> WAFFLE_STENCIL_SIZE
>
> The default value for each size attribute is 0. Valid values are the
> non-negative integers and WAFFLE_DONT_CARE. If the requested size for a
> channel is 0, then any surface created with the config will lack that
> channel. If the requested size for a channel is positive, then the number of
> bits in that channel for any surface created with the config will be at
> least the requested size.
> """
>
> There's some ambiguity here because if several different pixel formats (such
> as RGB565 and RGBA8) both meet the WAFFLE_RED/GREEN/BLUE_SIZE minimums,
> which should be preferred?
>
> I can fix my Windows Piglit issue by changing Piglit's
> choose_config_attribs() function to specify WAFFLE_RED/GREEN/BLUE_SIZE=8
> instead of 1, but that's not a final solution.
>
>
> I propose:
>
> 1. The Waffle docs should be clarified to specify whether the largest or
> smallest color format should be used when several meet the WAFFLE_*_SIZE
> minimums.  My suggesting is "smallest", like WGL.
>
> 2. The Waffle code for either GLX or WGL should be modified to follow that
> part of the spec.  Following my suggestion, the GLX format chooser code
> would need to be modified.
>
> 3. The Piglit code to specify the Waffle pixel format should be updated,
> probably replacing '1' with '8' as above.  And maybe falling back to the
> former if the later fails (though I doubt anyone runs piglit on less than a
> 24-bit display nowadays).
>
> 4. If Waffle wants to get fancy, we could consider new attributes like
> WAFFLE_MIN_RED_SIZE, WAFFLE_MAX_RED_SIZE and WAFFLE_EXACT_RED_SIZE to
> provide more control over format selection.  But I think my suggestion in
> (1) would avoid this for now.
>
> Thoughts?
>
I'm somewhat inclined that the GLX/EGL behaviour might be the better
choice. Then again I don't might if people choose another route -
always smallest, always 

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

2016-06-14 Thread Emil Velikov
On 14 June 2016 at 22:22, Chad Versace <chad.vers...@intel.com> wrote:
> 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()
>>
Fortunate me did not see the issue since I have both libGLESv1_CM and
libGLESv2 libraries :-)

That aside:
Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

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


Re: [waffle] [PATCH 4/4] gbm: implement window_resize

2016-06-14 Thread Emil Velikov
On 16 May 2016 at 11:48, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> From: Emil Velikov <emil.veli...@collabora.com>
>
> Reuse the existing init/teardown functions to create a new window and
> nuke the old one on success.
>
> Note: as we need the original config, we keep a reference to it in
> struct wcore_config. Ideally there will be a generic way to query it.
>
> Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
> ---
>  src/waffle/gbm/wgbm_platform.c |  1 +
>  src/waffle/gbm/wgbm_window.c   | 43 
> ++
>  src/waffle/gbm/wgbm_window.h   |  5 +
>  3 files changed, 49 insertions(+)
>
> diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
> index 5e36534..f4147af 100644
> --- a/src/waffle/gbm/wgbm_platform.c
> +++ b/src/waffle/gbm/wgbm_platform.c
> @@ -210,6 +210,7 @@ static const struct wcore_platform_vtbl 
> wgbm_platform_vtbl = {
>  .destroy = wgbm_window_destroy,
>  .show = wgbm_window_show,
>  .swap_buffers = wgbm_window_swap_buffers,
> +.resize = wgbm_window_resize,
>  .get_native = wgbm_window_get_native,
>  },
>  };
> diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
> index 12ae197..d9dcba0 100644
> --- a/src/waffle/gbm/wgbm_window.c
> +++ b/src/waffle/gbm/wgbm_window.c
> @@ -32,8 +32,10 @@
>
>  #include "wcore_attrib_list.h"
>  #include "wcore_error.h"
> +#include "wcore_tinfo.h"
>
>  #include "wegl_config.h"
> +#include "wegl_util.h"
>
>  #include "wgbm_config.h"
>  #include "wgbm_display.h"
> @@ -92,6 +94,7 @@ wgbm_window_init(struct wgbm_window *self,
>  if (!ok)
>  return false;
>
> +self->wc_config = wc_config;
>  return true;
>  }
>
> @@ -155,6 +158,46 @@ wgbm_window_swap_buffers(struct wcore_window *wc_self)
>  return true;
>  }
>
> +bool
> +wgbm_window_resize(struct wcore_window *wc_self,
> +   int32_t width, int32_t height)
> +{
> +struct wcore_display *wc_dpy = wc_self->display;
> +struct wcore_platform *wc_plat = wc_self->display->platform;
> +struct wgbm_window *self = wgbm_window(wc_self);
> +struct wgbm_window backup_self;
> +struct wcore_context *wc_ctx;
> +struct wcore_tinfo *tinfo;
> +bool ok = true;
> +
> +// Backup the old window/surface so that we can restore it upon failure.
> +backup_self = *self;
> +
> +ok = wgbm_window_init(self, wc_plat, self->wc_config, width, height);
> +if (!ok)
> +goto error;
> +
> +tinfo = wcore_tinfo_get();
> +wc_ctx = tinfo->current_context;
> +
> +// XXX: Can/should we use waffle_make_current() here ?
> +ok = wegl_make_current(wc_plat, wc_dpy, wc_self, wc_ctx);
> +if (!ok)
> +goto error;
> +
> +// We don't need to set current_display or current_window
> +tinfo->current_context = wc_ctx;
> +
Self note: in 99.99% of the time we won't need the above line. Thus we
could drop the XXX: comment a couple of lines before it.

Note for all: I'm wondering if some drivers won't have odd behaviour
if waffle_window_resize() is called where wc_ctx = NULL. Not 100%
familiar if the spec ensures that things are sane.

Any ideas ?

Emil
___
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 Emil Velikov
On 14 June 2016 at 18:10, Chad Versace <chad.vers...@intel.com> 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 ?

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


Re: [waffle] [PATCH 00/13] Core waffle cleanups

2016-05-16 Thread Emil Velikov
On 16 May 2016 at 11:54, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> Hi all,
>
> While looking at the gbm/egl I've noticed a few interesting bits.
>  - We do NULL checking for values that are guaranteed by API to be
> non-NULL.
>  - wcore_*_init does not need a return type, plus in some places we were
> not calling it in the correct time.
>  - wcore_*_teardown is a simple wrapper around assert, which (at the
> time the function should be called) is too late/not needed.
>
> So this series simplifies these, giving us a nice -350 line count ;-)
>
> The whole thing can be found in
> https://github.com/evelikov/waffle/tree/for-upstream/core-cleanups
>
For some reason git send-email seems to be choking on patches 08/13
and 09/13. Please check those out via the above repo or let me know if
you'd prefer them in other format.

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


[waffle] [PATCH 13/13] linux: remove 'self' NULL check

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

All the callers already ensure this never happens.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/linux/linux_platform.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/waffle/linux/linux_platform.c 
b/src/waffle/linux/linux_platform.c
index 56f6fe6..1abdbb0 100644
--- a/src/waffle/linux/linux_platform.c
+++ b/src/waffle/linux/linux_platform.c
@@ -48,9 +48,6 @@ linux_platform_destroy(struct linux_platform *self)
 {
 bool ok = true;
 
-if (!self)
-return true;
-
 // FIXME: Waffle is unable to emit a sequence of errors.
 ok &= linux_dl_close(self->libgl);
 ok &= linux_dl_close(self->libgles1);
-- 
2.6.2

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


[waffle] [PATCH 12/13] android: remove 'self' NULL checks

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Similar to earlier commits - the API layer already does these for us.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/android/droid_window.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/src/waffle/android/droid_window.c 
b/src/waffle/android/droid_window.c
index 7826acb..620569f 100644
--- a/src/waffle/android/droid_window.c
+++ b/src/waffle/android/droid_window.c
@@ -100,12 +100,7 @@ bool
 droid_window_show(struct wcore_window *wc_self)
 {
 struct droid_window *self = droid_window(wc_self);
-struct droid_display *dpy;
-
-if (!self)
-return false;
-
-dpy = droid_display(wc_self->display);
+struct droid_display *dpy = droid_display(wc_self->display);
 
 return droid_show_surface(dpy->pSFContainer, self->pANWContainer);
 }
@@ -116,12 +111,7 @@ droid_window_resize(struct wcore_window *wc_self,
 int32_t height)
 {
 struct droid_window *self = droid_window(wc_self);
-struct droid_display *dpy;
-
-if (!self)
-return false;
-
-dpy = droid_display(wc_self->display);
+struct droid_display *dpy = droid_display(wc_self->display);
 
 return droid_resize_surface(dpy->pSFContainer, self->pANWContainer,
 width, height);
-- 
2.6.2

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


[waffle] [PATCH 11/13] wayland: tweak wayland_wrapper_init()

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Analogous to previous commit.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/wayland/wayland_wrapper.c | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/waffle/wayland/wayland_wrapper.c 
b/src/waffle/wayland/wayland_wrapper.c
index 6ffd5a9..ab11456 100644
--- a/src/waffle/wayland/wayland_wrapper.c
+++ b/src/waffle/wayland/wayland_wrapper.c
@@ -72,15 +72,14 @@ wayland_wrapper_teardown(void)
 bool
 wayland_wrapper_init(void)
 {
-bool ok = true;
-
+// On failure the caller of wayland_wrapper_init will trigger it's own
+// destruction which will execute wayland_wrapper_teardown.
 dl_wl_client = dlopen(libwl_client_filename, RTLD_LAZY | RTLD_LOCAL);
 if (!dl_wl_client) {
 wcore_errorf(WAFFLE_ERROR_FATAL,
  "dlopen(\"%s\") failed: %s",
  libwl_client_filename, dlerror());
-ok = false;
-goto error;
+return false;
 }
 
 #define RETRIEVE_WL_CLIENT_SYMBOL(S)\
@@ -89,8 +88,7 @@ wayland_wrapper_init(void)
 wcore_errorf(WAFFLE_ERROR_FATAL,\
  "dlsym(\"%s\", \"" #S "\") failed: %s",\
  libwl_client_filename, dlerror()); \
-ok = false; \
-goto error; \
+return false;   \
 }
 
 RETRIEVE_WL_CLIENT_SYMBOL(wl_compositor_interface);
@@ -108,8 +106,5 @@ wayland_wrapper_init(void)
 RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_marshal_constructor);
 #undef RETRIEVE_WL_CLIENT_SYMBOL
 
-error:
-// On failure the caller of wayland_wrapper_init will trigger it's own
-// destruction which will execute wayland_wrapper_teardown.
-return ok;
+return true;
 }
-- 
2.6.2

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


[waffle] [PATCH 10/13] egl: tweak wegl_platform_init()

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Drop the goto label and bail directly from the macro. The current
strange construct has gotten us once, so we might as well try to avoid
it for the future.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/egl/wegl_platform.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
index a59b070..350e6a1 100644
--- a/src/waffle/egl/wegl_platform.c
+++ b/src/waffle/egl/wegl_platform.c
@@ -56,15 +56,14 @@ wegl_platform_teardown(struct wegl_platform *self)
 bool
 wegl_platform_init(struct wegl_platform *self)
 {
-bool ok = true;
-
+// On failure the caller of wegl_platform_init will trigger it's own
+// destruction which will execute wegl_platform_teardown.
 self->eglHandle = dlopen(libEGL_filename, RTLD_LAZY | RTLD_LOCAL);
 if (!self->eglHandle) {
 wcore_errorf(WAFFLE_ERROR_FATAL,
  "dlopen(\"%s\") failed: %s",
  libEGL_filename, dlerror());
-ok = false;
-goto error;
+return false;
 }
 
 #define OPTIONAL_EGL_SYMBOL(function)  \
@@ -73,11 +72,10 @@ wegl_platform_init(struct wegl_platform *self)
 #define RETRIEVE_EGL_SYMBOL(function)  \
 OPTIONAL_EGL_SYMBOL(function)  \
 if (!self->function) { \
-wcore_errorf(WAFFLE_ERROR_FATAL, \
+wcore_errorf(WAFFLE_ERROR_FATAL,   \
  "dlsym(\"%s\", \"" #function "\") failed: %s",\
  libEGL_filename, dlerror());  \
-ok = false;\
-goto error;\
+return false;  \
 }
 
 OPTIONAL_EGL_SYMBOL(eglCreateImageKHR);
@@ -110,8 +108,5 @@ wegl_platform_init(struct wegl_platform *self)
 #undef OPTIONAL_EGL_SYMBOL
 #undef RETRIEVE_EGL_SYMBOL
 
-error:
-// On failure the caller of wegl_platform_init will trigger it's own
-// destruction which will execute wegl_platform_teardown.
-return ok;
+return true;
 }
-- 
2.6.2

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


[waffle] [PATCH 04/13] all: remove 'self' NULL check from *_display_destroy()

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Analogous to previous commit

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/android/droid_display.c   | 3 ---
 src/waffle/cgl/cgl_display.m | 3 ---
 src/waffle/gbm/wgbm_display.c| 8 ++--
 src/waffle/glx/glx_display.c | 7 ++-
 src/waffle/nacl/nacl_display.c   | 7 ++-
 src/waffle/wayland/wayland_display.c | 7 ++-
 src/waffle/wgl/wgl_display.c | 3 ---
 src/waffle/x11/x11_display.c | 2 --
 src/waffle/xegl/xegl_display.c   | 7 ++-
 9 files changed, 10 insertions(+), 37 deletions(-)

diff --git a/src/waffle/android/droid_display.c 
b/src/waffle/android/droid_display.c
index 3f39739..46cfb9d 100644
--- a/src/waffle/android/droid_display.c
+++ b/src/waffle/android/droid_display.c
@@ -69,9 +69,6 @@ droid_display_disconnect(struct wcore_display *wc_self)
 struct droid_display *self = droid_display(wc_self);
 bool ok = true;
 
-if (!self)
-return true;
-
 if (self->pSFContainer)
 droid_deinit_gl(self->pSFContainer);
 
diff --git a/src/waffle/cgl/cgl_display.m b/src/waffle/cgl/cgl_display.m
index 015ca32..3ed8e5d 100644
--- a/src/waffle/cgl/cgl_display.m
+++ b/src/waffle/cgl/cgl_display.m
@@ -36,9 +36,6 @@ cgl_display_destroy(struct wcore_display *wc_self)
 struct cgl_display *self = cgl_display(wc_self);
 bool ok = true;
 
-if (!self)
-return ok;
-
 ok &= wcore_display_teardown(>wcore);
 free(self);
 return ok;
diff --git a/src/waffle/gbm/wgbm_display.c b/src/waffle/gbm/wgbm_display.c
index 5c8af29..e8dc6ea 100644
--- a/src/waffle/gbm/wgbm_display.c
+++ b/src/waffle/gbm/wgbm_display.c
@@ -46,14 +46,10 @@ wgbm_display_destroy(struct wcore_display *wc_self)
 struct wgbm_display *self = wgbm_display(wc_self);
 struct wcore_platform *wc_plat = wc_self->platform;
 struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
-bool ok = true;
+bool ok;
 int fd;
 
-if (!self)
-return ok;
-
-
-ok &= wegl_display_teardown(>wegl);
+ok = wegl_display_teardown(>wegl);
 
 if (self->gbm_device) {
 fd = plat->gbm_device_get_fd(self->gbm_device);
diff --git a/src/waffle/glx/glx_display.c b/src/waffle/glx/glx_display.c
index 0c6851d..0e8da35 100644
--- a/src/waffle/glx/glx_display.c
+++ b/src/waffle/glx/glx_display.c
@@ -37,12 +37,9 @@ bool
 glx_display_destroy(struct wcore_display *wc_self)
 {
 struct glx_display *self = glx_display(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
-ok &= x11_display_teardown(>x11);
+ok = x11_display_teardown(>x11);
 ok &= wcore_display_teardown(>wcore);
 free(self);
 return ok;
diff --git a/src/waffle/nacl/nacl_display.c b/src/waffle/nacl/nacl_display.c
index 7e18ba3..d91fb2e 100644
--- a/src/waffle/nacl/nacl_display.c
+++ b/src/waffle/nacl/nacl_display.c
@@ -31,12 +31,9 @@ bool
 nacl_display_destroy(struct wcore_display *wc_self)
 {
 struct nacl_display *self = nacl_display(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
-ok &= wcore_display_teardown(>wcore);
+ok = wcore_display_teardown(>wcore);
 
 free(self);
 return ok;
diff --git a/src/waffle/wayland/wayland_display.c 
b/src/waffle/wayland/wayland_display.c
index e2d59a8..96e7a4d 100644
--- a/src/waffle/wayland/wayland_display.c
+++ b/src/waffle/wayland/wayland_display.c
@@ -45,12 +45,9 @@ bool
 wayland_display_destroy(struct wcore_display *wc_self)
 {
 struct wayland_display *self = wayland_display(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
-ok &= wegl_display_teardown(>wegl);
+ok = wegl_display_teardown(>wegl);
 
 if (self->wl_display)
 wl_display_disconnect(self->wl_display);
diff --git a/src/waffle/wgl/wgl_display.c b/src/waffle/wgl/wgl_display.c
index c0b547a..ee5abc5 100644
--- a/src/waffle/wgl/wgl_display.c
+++ b/src/waffle/wgl/wgl_display.c
@@ -40,9 +40,6 @@ wgl_display_destroy(struct wcore_display *wc_self)
 struct wgl_display *self = wgl_display(wc_self);
 bool ok = true;
 
-if (!self)
-return true;
-
 if (self->hWnd) {
 if (self->hglrc) {
 ok &= wglDeleteContext(self->hglrc);
diff --git a/src/waffle/x11/x11_display.c b/src/waffle/x11/x11_display.c
index 8a3524d..bdf223c 100644
--- a/src/waffle/x11/x11_display.c
+++ b/src/waffle/x11/x11_display.c
@@ -58,8 +58,6 @@ x11_display_teardown(struct x11_display *self)
 {
 int error = 0;
 
-assert(self);
-
 if (!self->xlib)
return !error;
 
diff --git a/src/waffle/xegl/xegl_display.c b/src/waffle/xegl/xegl_display.c
index a1da480..fb57268 100644
--- a/src/waffle/xegl/xegl_display.c
+++ b/src/waffle/xegl/xegl_display.c
@@ -35,12 +35,9 @@ bool
 xegl_display_destroy(str

[waffle] [PATCH 05/13] all: remove 'self' NULL check from *_window_destroy()

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Analogous to previous commit

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/android/droid_window.c   | 11 +++
 src/waffle/cgl/cgl_window.m |  7 ++-
 src/waffle/gbm/wgbm_window.c|  7 ++-
 src/waffle/glx/glx_window.c |  7 ++-
 src/waffle/nacl/nacl_window.c   |  7 ++-
 src/waffle/wayland/wayland_window.c |  7 ++-
 src/waffle/wgl/wgl_window.c |  4 
 src/waffle/x11/x11_window.c |  2 --
 src/waffle/xegl/xegl_window.c   |  7 ++-
 9 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/src/waffle/android/droid_window.c 
b/src/waffle/android/droid_window.c
index 048a2bb..b11d079 100644
--- a/src/waffle/android/droid_window.c
+++ b/src/waffle/android/droid_window.c
@@ -85,15 +85,10 @@ bool
 droid_window_destroy(struct wcore_window *wc_self)
 {
 struct droid_window *self = droid_window(wc_self);
-struct droid_display *dpy;
-bool ok = true;
-
-if (!self)
-return ok;
-
-dpy = droid_display(self->wegl.wcore.display);
+struct droid_display *dpy = droid_display(self->wegl.wcore.display);
+bool ok;
 
-ok &= wegl_window_teardown(>wegl);
+ok = wegl_window_teardown(>wegl);
 droid_destroy_surface(dpy->pSFContainer, self->pANWContainer);
 free(self);
 return ok;
diff --git a/src/waffle/cgl/cgl_window.m b/src/waffle/cgl/cgl_window.m
index 91273c5..cde2e7c 100644
--- a/src/waffle/cgl/cgl_window.m
+++ b/src/waffle/cgl/cgl_window.m
@@ -36,10 +36,7 @@ bool
 cgl_window_destroy(struct wcore_window *wc_self)
 {
 struct cgl_window *self = cgl_window(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
 if (self->gl_view)
 [self->gl_view release];
@@ -47,7 +44,7 @@ cgl_window_destroy(struct wcore_window *wc_self)
 if (self->ns_window)
 [self->ns_window release];
 
-ok &= wcore_window_teardown(>wcore);
+ok = wcore_window_teardown(>wcore);
 free(self);
 return ok;
 }
diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
index 313304b..4c652c7 100644
--- a/src/waffle/gbm/wgbm_window.c
+++ b/src/waffle/gbm/wgbm_window.c
@@ -46,12 +46,9 @@ wgbm_window_destroy(struct wcore_window *wc_self)
 struct wcore_platform *wc_plat = wc_self->display->platform;
 struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
 struct wgbm_window *self = wgbm_window(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
-ok &= wegl_window_teardown(>wegl);
+ok = wegl_window_teardown(>wegl);
 plat->gbm_surface_destroy(self->gbm_surface);
 free(self);
 return ok;
diff --git a/src/waffle/glx/glx_window.c b/src/waffle/glx/glx_window.c
index 52efb61..0708347 100644
--- a/src/waffle/glx/glx_window.c
+++ b/src/waffle/glx/glx_window.c
@@ -39,12 +39,9 @@ bool
 glx_window_destroy(struct wcore_window *wc_self)
 {
 struct glx_window *self = glx_window(wc_self);
-bool ok = true;
-
-if (!wc_self)
-return ok;
+bool ok;
 
-ok &= x11_window_teardown(>x11);
+ok = x11_window_teardown(>x11);
 ok &= wcore_window_teardown(wc_self);
 free(self);
 return ok;
diff --git a/src/waffle/nacl/nacl_window.c b/src/waffle/nacl/nacl_window.c
index 1191f51..ed704c5 100644
--- a/src/waffle/nacl/nacl_window.c
+++ b/src/waffle/nacl/nacl_window.c
@@ -34,12 +34,9 @@ bool
 nacl_window_destroy(struct wcore_window *wc_self)
 {
 struct nacl_window *self = nacl_window(wc_self);
-bool ok = true;
-
-if (!wc_self)
-return ok;
+bool ok;
 
-ok &= wcore_window_teardown(wc_self);
+ok = wcore_window_teardown(wc_self);
 free(self);
 return ok;
 }
diff --git a/src/waffle/wayland/wayland_window.c 
b/src/waffle/wayland/wayland_window.c
index 2c4ebc8..c734f57 100644
--- a/src/waffle/wayland/wayland_window.c
+++ b/src/waffle/wayland/wayland_window.c
@@ -50,12 +50,9 @@ wayland_window_destroy(struct wcore_window *wc_self)
 struct wcore_platform *wc_plat = wc_self->display->platform;
 struct wayland_platform *plat = wayland_platform(wegl_platform(wc_plat));
 struct wayland_window *self = wayland_window(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
-ok &= wegl_window_teardown(>wegl);
+ok = wegl_window_teardown(>wegl);
 
 if (self->wl_window)
 plat->wl_egl_window_destroy(self->wl_window);
diff --git a/src/waffle/wgl/wgl_window.c b/src/waffle/wgl/wgl_window.c
index 316fb1d..897ec39 100644
--- a/src/waffle/wgl/wgl_window.c
+++ b/src/waffle/wgl/wgl_window.c
@@ -37,7 +37,6 @@ wgl_window_destroy(struct wcore_window *wc_self)
 {
 struct wgl_window *self = wgl_window(wc_self);
 
-assert(self);
 assert(self->hWnd);
 
 self->created = false;
@@ -51,9 

[waffle] [PATCH 07/13] all: remove 'self' NULL check from *_config_destroy()

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Analogous to previous commit

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/cgl/cgl_config.m   | 11 +++
 src/waffle/egl/wegl_config.c  |  7 ++-
 src/waffle/glx/glx_config.c   |  7 ++-
 src/waffle/nacl/nacl_config.c |  7 ++-
 src/waffle/wgl/wgl_config.c   |  3 ---
 5 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/src/waffle/cgl/cgl_config.m b/src/waffle/cgl/cgl_config.m
index 898ee24..fdab9a8 100644
--- a/src/waffle/cgl/cgl_config.m
+++ b/src/waffle/cgl/cgl_config.m
@@ -45,18 +45,13 @@
 bool
 cgl_config_destroy(struct wcore_config *wc_self)
 {
-struct cgl_config *self;
-bool ok = true;
-
-if (wc_self == NULL)
-return ok;
-
-self = cgl_config(wc_self);
+struct cgl_config *self = cgl_config(wc_self);
+bool ok;
 
 if (self->pixel_format)
 CGLReleasePixelFormat(self->pixel_format);
 
-ok &= wcore_config_teardown(wc_self);
+ok = wcore_config_teardown(wc_self);
 free(self);
 return ok;
 }
diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index 08e06fb..6ffde4e 100644
--- a/src/waffle/egl/wegl_config.c
+++ b/src/waffle/egl/wegl_config.c
@@ -262,12 +262,9 @@ bool
 wegl_config_destroy(struct wcore_config *wc_config)
 {
 struct wegl_config *config = wegl_config(wc_config);
-bool result = true;
+bool result;
 
-if (!config)
-return true;
-
-result &= wcore_config_teardown(wc_config);
+result = wcore_config_teardown(wc_config);
 free(config);
 return result;
 }
diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c
index 7f3d3ed..5de70e1 100644
--- a/src/waffle/glx/glx_config.c
+++ b/src/waffle/glx/glx_config.c
@@ -40,12 +40,9 @@
 bool
 glx_config_destroy(struct wcore_config *wc_self)
 {
-bool ok = true;
-
-if (wc_self == NULL)
-return ok;
+bool ok;
 
-ok &= wcore_config_teardown(wc_self);
+ok = wcore_config_teardown(wc_self);
 free(glx_config(wc_self));
 return ok;
 }
diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c
index 668657b..e078b92 100644
--- a/src/waffle/nacl/nacl_config.c
+++ b/src/waffle/nacl/nacl_config.c
@@ -33,12 +33,9 @@
 bool
 nacl_config_destroy(struct wcore_config *wc_self)
 {
-bool ok = true;
-
-if (wc_self == NULL)
-return ok;
+bool ok;
 
-ok &= wcore_config_teardown(wc_self);
+ok = wcore_config_teardown(wc_self);
 free(nacl_config(wc_self));
 return ok;
 }
diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c
index a912bba..3c793f8 100644
--- a/src/waffle/wgl/wgl_config.c
+++ b/src/waffle/wgl/wgl_config.c
@@ -44,9 +44,6 @@ wgl_config_destroy(struct wcore_config *wc_self)
 struct wgl_config *self = wgl_config(wc_self);
 bool ok = true;
 
-if (!self)
-return true;
-
 if (self->window)
 ok &= wgl_window_priv_destroy(>window->wcore);
 
-- 
2.6.2

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


[waffle] [PATCH 02/13] egl: inline wegl_context_{init, teardown}() in the respective callers

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Seems like an overkill to keep them separate considering the caller and
callee are just a single function call.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/egl/wegl_context.c | 75 +++
 src/waffle/egl/wegl_context.h |  8 -
 2 files changed, 25 insertions(+), 58 deletions(-)

diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 0e59231..41334eb 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -177,15 +177,22 @@ create_real_context(struct wegl_config *config,
 return ctx;
 }
 
-bool
-wegl_context_init(struct wegl_context *ctx,
-  struct wcore_config *wc_config,
-  struct wcore_context *wc_share_ctx)
+struct wcore_context*
+wegl_context_create(struct wcore_platform *wc_plat,
+struct wcore_config *wc_config,
+struct wcore_context *wc_share_ctx)
 {
+struct wegl_context *ctx;
 struct wegl_config *config = wegl_config(wc_config);
 struct wegl_context *share_ctx = wegl_context(wc_share_ctx);
 bool ok;
 
+(void) wc_plat;
+
+ctx = wcore_calloc(sizeof(*ctx));
+if (!ctx)
+return NULL;
+
 ok = wcore_context_init(>wcore, >wcore);
 if (!ok)
 goto fail;
@@ -197,64 +204,32 @@ wegl_context_init(struct wegl_context *ctx,
 if (ctx->egl == EGL_NO_CONTEXT)
 goto fail;
 
-return true;
+return >wcore;
 
 fail:
-wegl_context_teardown(ctx);
-return false;
-}
-
-struct wcore_context*
-wegl_context_create(struct wcore_platform *wc_plat,
-struct wcore_config *wc_config,
-struct wcore_context *wc_share_ctx)
-{
-struct wegl_context *ctx;
-
-(void) wc_plat;
-
-ctx = wcore_calloc(sizeof(*ctx));
-if (!ctx)
-return NULL;
-
-if (!wegl_context_init(ctx, wc_config, wc_share_ctx)) {
-wegl_context_destroy(>wcore);
-return NULL;
-}
-
-return >wcore;
+wegl_context_destroy(>wcore);
+return NULL;
 }
 
 bool
-wegl_context_teardown(struct wegl_context *ctx)
+wegl_context_destroy(struct wcore_context *wc_ctx)
 {
 bool result = true;
 
-if (!ctx)
-return result;
+if (wc_ctx) {
+struct wegl_context *ctx = wegl_context(wc_ctx);
 
-if (ctx->egl != EGL_NO_CONTEXT) {
-struct wegl_display *dpy = wegl_display(ctx->wcore.display);
-struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
+if (ctx && ctx->egl != EGL_NO_CONTEXT) {
+struct wegl_display *dpy = wegl_display(ctx->wcore.display);
+struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
 
-if (!plat->eglDestroyContext(dpy->egl, ctx->egl)) {
-wegl_emit_error(plat, "eglDestroyContext");
-result = false;
+if (!plat->eglDestroyContext(dpy->egl, ctx->egl)) {
+wegl_emit_error(plat, "eglDestroyContext");
+result = false;
+}
 }
-}
-
-result &= wcore_context_teardown(>wcore);
-return result;
-}
-
-bool
-wegl_context_destroy(struct wcore_context *wc_ctx)
-{
-bool result = true;
 
-if (wc_ctx) {
-struct wegl_context *ctx = wegl_context(wc_ctx);
-result = wegl_context_teardown(ctx);
+result &= wcore_context_teardown(>wcore);
 free(ctx);
 }
 return result;
diff --git a/src/waffle/egl/wegl_context.h b/src/waffle/egl/wegl_context.h
index b7d4d6a..19f9932 100644
--- a/src/waffle/egl/wegl_context.h
+++ b/src/waffle/egl/wegl_context.h
@@ -43,14 +43,6 @@ DEFINE_CONTAINER_CAST_FUNC(wegl_context,
struct wcore_context,
wcore)
 
-bool
-wegl_context_init(struct wegl_context *ctx,
-  struct wcore_config *wc_config,
-  struct wcore_context *wc_share_ctx);
-
-bool
-wegl_context_teardown(struct wegl_context *ctx);
-
 struct wcore_context*
 wegl_context_create(struct wcore_platform *wc_plat,
 struct wcore_config *wc_config,
-- 
2.6.2

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


[waffle] [PATCH 01/13] x11: straighten code flow

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Having goto statements jump over each other makes the code harder/more
annoying to read.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/x11/x11_window.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/waffle/x11/x11_window.c b/src/waffle/x11/x11_window.c
index 308d4ce..5df4839 100644
--- a/src/waffle/x11/x11_window.c
+++ b/src/waffle/x11/x11_window.c
@@ -79,7 +79,6 @@ x11_window_init(struct x11_window *self,
 assert(self);
 assert(dpy);
 
-bool ok = true;
 xcb_connection_t *conn = dpy->xcb;
 
 const xcb_setup_t *setup = xcb_get_setup(conn);
@@ -157,10 +156,9 @@ x11_window_init(struct x11_window *self,
 
 self->display = dpy;
 self->xcb = window;
-goto end;
+return true;
 
 error:
-ok = false;
 
 if (colormap)
 xcb_free_colormap(conn, colormap);
@@ -168,8 +166,7 @@ error:
 if (window)
 xcb_destroy_window(conn, window);
 
-end:
-return ok;
+return false;
 }
 
 bool
-- 
2.6.2

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


[waffle] [PATCH 00/13] Core waffle cleanups

2016-05-16 Thread Emil Velikov
Hi all,

While looking at the gbm/egl I've noticed a few interesting bits.
 - We do NULL checking for values that are guaranteed by API to be 
non-NULL.
 - wcore_*_init does not need a return type, plus in some places we were 
not calling it in the correct time.
 - wcore_*_teardown is a simple wrapper around assert, which (at the 
time the function should be called) is too late/not needed.

So this series simplifies these, giving us a nice -350 line count ;-)

The whole thing can be found in
https://github.com/evelikov/waffle/tree/for-upstream/core-cleanups

Thanks
Emil

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


[waffle] [PATCH 1/4] egl: fix build against old headers

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Namely add the EGL_CONTEXT_OPENGL_ROBUST_ACCESS define, if missing.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/egl/wegl_context.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 0e59231..083200e 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -34,6 +34,10 @@
 #include "wegl_platform.h"
 #include "wegl_util.h"
 
+#ifndef EGL_CONTEXT_OPENGL_ROBUST_ACCESS
+#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS  0x31B2
+#endif
+
 static bool
 bind_api(struct wegl_platform *plat, int32_t waffle_context_api)
 {
-- 
2.6.2

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


[waffle] [PATCH 2/4] egl: fold eglGetConfigAttrib() within wegl_config_choose()

2016-05-16 Thread Emil Velikov
Rather than having the call in multiple places and multiple times, just
query the native visual id once and store it for later use.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/egl/wegl_config.c   |  7 +++
 src/waffle/egl/wegl_config.h   |  1 +
 src/waffle/gbm/wgbm_config.c   | 39 ---
 src/waffle/gbm/wgbm_config.h   | 10 --
 src/waffle/gbm/wgbm_platform.c |  2 +-
 src/waffle/gbm/wgbm_window.c   |  7 ++-
 src/waffle/xegl/xegl_window.c  | 13 +
 7 files changed, 12 insertions(+), 67 deletions(-)

diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index 08e06fb..892bfef 100644
--- a/src/waffle/egl/wegl_config.c
+++ b/src/waffle/egl/wegl_config.c
@@ -230,6 +230,7 @@ wegl_config_choose(struct wcore_platform *wc_plat,
struct wcore_display *wc_dpy,
const struct wcore_config_attrs *attrs)
 {
+struct wegl_platform *plat = wegl_platform(wc_plat);
 struct wegl_display *dpy = wegl_display(wc_dpy);
 struct wegl_config *config;
 bool ok;
@@ -251,6 +252,12 @@ wegl_config_choose(struct wcore_platform *wc_plat,
 if (!config->egl)
 goto fail;
 
+ok = plat->eglGetConfigAttrib(dpy->egl, config->egl,
+  EGL_NATIVE_VISUAL_ID, >visual);
+
+if (!ok)
+goto fail;
+
 return >wcore;
 
 fail:
diff --git a/src/waffle/egl/wegl_config.h b/src/waffle/egl/wegl_config.h
index a9e3cb9..3e3cec9 100644
--- a/src/waffle/egl/wegl_config.h
+++ b/src/waffle/egl/wegl_config.h
@@ -40,6 +40,7 @@ struct wcore_config_attrs;
 struct wegl_config {
 struct wcore_config wcore;
 EGLConfig egl;
+EGLint visual;
 };
 
 DEFINE_CONTAINER_CAST_FUNC(wegl_config,
diff --git a/src/waffle/gbm/wgbm_config.c b/src/waffle/gbm/wgbm_config.c
index 1d64b71..7383425 100644
--- a/src/waffle/gbm/wgbm_config.c
+++ b/src/waffle/gbm/wgbm_config.c
@@ -30,45 +30,6 @@
 #include "wgbm_config.h"
 #include "wgbm_display.h"
 
-struct wcore_config*
-wgbm_config_choose(struct wcore_platform *wc_plat,
-   struct wcore_display *wc_dpy,
-   const struct wcore_config_attrs *attrs)
-{
-struct wcore_config *wc_config = wegl_config_choose(wc_plat, wc_dpy, 
attrs);
-if (!wc_config)
-return NULL;
-
-if (wgbm_config_get_gbm_format(wc_plat, wc_dpy, wc_config) == 0) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "requested config is unsupported on GBM");
-wegl_config_destroy(wc_config);
-return NULL;
-}
-
-return wc_config;
-}
-
-uint32_t
-wgbm_config_get_gbm_format(struct wcore_platform *wc_plat,
-   struct wcore_display *wc_display,
-   struct wcore_config *wc_config)
-{
-EGLint gbm_format;
-struct wegl_display *dpy = wegl_display(wc_display);
-struct wegl_platform *plat = wegl_platform(wc_plat);
-struct wegl_config *egl_config = wegl_config(wc_config);
-bool ok = plat->eglGetConfigAttrib(dpy->egl,
-   egl_config->egl,
-   EGL_NATIVE_VISUAL_ID,
-   _format);
-
-if (!ok) {
-return 0;
-}
-return gbm_format;
-}
-
 union waffle_native_config*
 wgbm_config_get_native(struct wcore_config *wc_config)
 {
diff --git a/src/waffle/gbm/wgbm_config.h b/src/waffle/gbm/wgbm_config.h
index 2c58321..6ee2cdd 100644
--- a/src/waffle/gbm/wgbm_config.h
+++ b/src/waffle/gbm/wgbm_config.h
@@ -34,15 +34,5 @@
 
 union waffle_native_config;
 
-struct wcore_config*
-wgbm_config_choose(struct wcore_platform *wc_plat,
-   struct wcore_display *wc_dpy,
-   const struct wcore_config_attrs *attrs);
-
-uint32_t
-wgbm_config_get_gbm_format(struct wcore_platform *wc_plat,
-   struct wcore_display *wc_dpy,
-   struct wcore_config *wc_config);
-
 union waffle_native_config*
 wgbm_config_get_native(struct wcore_config *wc_config);
diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index 0fc0352..5e36534 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -194,7 +194,7 @@ static const struct wcore_platform_vtbl wgbm_platform_vtbl 
= {
 },
 
 .config = {
-.choose = wgbm_config_choose,
+.choose = wegl_config_choose,
 .destroy = wegl_config_destroy,
 .get_native = wgbm_config_get_native,
 },
diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
index 313304b..d217992 100644
--- a/src/waffle/gbm/wgbm_window.c
+++ b/src/waffle/gbm/wgbm_window.c
@@ -67,7 +67,6 @@ wgbm_window_create(struct wcore_platform *wc_plat,
 struct wgbm_display *dpy = wgbm_display(wc_config->display);
 struct wgbm_platform *plat = wgbm_platform(weg

[waffle] [PATCH 3/4] gbm: factor out gbm_window_{init,teardown}

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

We'll need then with next patch as we implement window_resize().

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/gbm/wgbm_window.c | 69 +---
 1 file changed, 46 insertions(+), 23 deletions(-)

diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
index d217992..12ae197 100644
--- a/src/waffle/gbm/wgbm_window.c
+++ b/src/waffle/gbm/wgbm_window.c
@@ -40,23 +40,61 @@
 #include "wgbm_platform.h"
 #include "wgbm_window.h"
 
+static bool
+wgbm_window_teardown(struct wgbm_window *self)
+{
+struct wcore_platform *wc_plat = self->wegl.wcore.display->platform;
+struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
+bool ok;
+
+ok = wegl_window_teardown(>wegl);
+plat->gbm_surface_destroy(self->gbm_surface);
+
+return ok;
+}
+
 bool
 wgbm_window_destroy(struct wcore_window *wc_self)
 {
-struct wcore_platform *wc_plat = wc_self->display->platform;
-struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
 struct wgbm_window *self = wgbm_window(wc_self);
 bool ok = true;
 
 if (!self)
 return ok;
 
-ok &= wegl_window_teardown(>wegl);
-plat->gbm_surface_destroy(self->gbm_surface);
+ok &= wgbm_window_teardown(self);
 free(self);
 return ok;
 }
 
+static bool
+wgbm_window_init(struct wgbm_window *self,
+ struct wcore_platform *wc_plat,
+ struct wcore_config *wc_config,
+ int32_t width, int32_t height)
+{
+struct wgbm_display *dpy = wgbm_display(wc_config->display);
+struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
+bool ok = true;
+
+self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device,
+ width, height,
+ 
wegl_config(wc_config)->visual,
+ GBM_BO_USE_RENDERING);
+if (!self->gbm_surface) {
+wcore_errorf(WAFFLE_ERROR_UNKNOWN,
+ "gbm_surface_create failed");
+return false;
+}
+
+ok = wegl_window_init(>wegl, wc_config,
+  (intptr_t) self->gbm_surface);
+if (!ok)
+return false;
+
+return true;
+}
+
 struct wcore_window*
 wgbm_window_create(struct wcore_platform *wc_plat,
struct wcore_config *wc_config,
@@ -64,8 +102,6 @@ wgbm_window_create(struct wcore_platform *wc_plat,
int32_t height,
const intptr_t attrib_list[])
 {
-struct wgbm_display *dpy = wgbm_display(wc_config->display);
-struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat));
 struct wgbm_window *self;
 bool ok = true;
 
@@ -84,26 +120,13 @@ wgbm_window_create(struct wcore_platform *wc_plat,
 if (self == NULL)
 return NULL;
 
-self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device,
- width, height,
- 
wegl_config(wc_config)->visual,
- GBM_BO_USE_RENDERING);
-if (!self->gbm_surface) {
-wcore_errorf(WAFFLE_ERROR_UNKNOWN,
- "gbm_surface_create failed");
-goto error;
+ok = wgbm_window_init(self, wc_plat, wc_config, width, height);
+if (!ok) {
+wgbm_window_destroy(>wegl.wcore);
+return NULL;
 }
 
-ok = wegl_window_init(>wegl, wc_config,
-  (intptr_t) self->gbm_surface);
-if (!ok)
-goto error;
-
 return >wegl.wcore;
-
-error:
-wgbm_window_destroy(>wegl.wcore);
-return NULL;
 }
 
 
-- 
2.6.2

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


[waffle] [PATCH 0/4] Implement gbm window_resize

2016-05-16 Thread Emil Velikov
Hi all,

This is a respin of Emmanuel (linkmauve)'s work [1] without all the 
unneeded coping. On gbm one needs to teardown the old window (which this 
series does only if we can create the new one and make it current).

Note: this adds a rather hacky looking link to the config in struct 
wgbm_window, so I'm open to suggestions how to resolve/remove it.

https://github.com/evelikov/waffle/tree/for-upstream/gbm-window_resize

Thanks
Emil

[1] https://github.com/waffle-gl/waffle/pull/32

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


[waffle] [PATCH 4/4] gbm: implement window_resize

2016-05-16 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

Reuse the existing init/teardown functions to create a new window and
nuke the old one on success.

Note: as we need the original config, we keep a reference to it in
struct wcore_config. Ideally there will be a generic way to query it.

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 src/waffle/gbm/wgbm_platform.c |  1 +
 src/waffle/gbm/wgbm_window.c   | 43 ++
 src/waffle/gbm/wgbm_window.h   |  5 +
 3 files changed, 49 insertions(+)

diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index 5e36534..f4147af 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -210,6 +210,7 @@ static const struct wcore_platform_vtbl wgbm_platform_vtbl 
= {
 .destroy = wgbm_window_destroy,
 .show = wgbm_window_show,
 .swap_buffers = wgbm_window_swap_buffers,
+.resize = wgbm_window_resize,
 .get_native = wgbm_window_get_native,
 },
 };
diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c
index 12ae197..d9dcba0 100644
--- a/src/waffle/gbm/wgbm_window.c
+++ b/src/waffle/gbm/wgbm_window.c
@@ -32,8 +32,10 @@
 
 #include "wcore_attrib_list.h"
 #include "wcore_error.h"
+#include "wcore_tinfo.h"
 
 #include "wegl_config.h"
+#include "wegl_util.h"
 
 #include "wgbm_config.h"
 #include "wgbm_display.h"
@@ -92,6 +94,7 @@ wgbm_window_init(struct wgbm_window *self,
 if (!ok)
 return false;
 
+self->wc_config = wc_config;
 return true;
 }
 
@@ -155,6 +158,46 @@ wgbm_window_swap_buffers(struct wcore_window *wc_self)
 return true;
 }
 
+bool
+wgbm_window_resize(struct wcore_window *wc_self,
+   int32_t width, int32_t height)
+{
+struct wcore_display *wc_dpy = wc_self->display;
+struct wcore_platform *wc_plat = wc_self->display->platform;
+struct wgbm_window *self = wgbm_window(wc_self);
+struct wgbm_window backup_self;
+struct wcore_context *wc_ctx;
+struct wcore_tinfo *tinfo;
+bool ok = true;
+
+// Backup the old window/surface so that we can restore it upon failure.
+backup_self = *self;
+
+ok = wgbm_window_init(self, wc_plat, self->wc_config, width, height);
+if (!ok)
+goto error;
+
+tinfo = wcore_tinfo_get();
+wc_ctx = tinfo->current_context;
+
+// XXX: Can/should we use waffle_make_current() here ?
+ok = wegl_make_current(wc_plat, wc_dpy, wc_self, wc_ctx);
+if (!ok)
+goto error;
+
+// We don't need to set current_display or current_window
+tinfo->current_context = wc_ctx;
+
+// Everything went fine, so teardown the old window.
+wgbm_window_teardown(_self);
+return true;
+
+error:
+// Nuke the new window and restore the old one.
+wgbm_window_teardown(self);
+*self = backup_self;
+return false;
+}
 
 union waffle_native_window*
 wgbm_window_get_native(struct wcore_window *wc_self)
diff --git a/src/waffle/gbm/wgbm_window.h b/src/waffle/gbm/wgbm_window.h
index 7827823..d4015a0 100644
--- a/src/waffle/gbm/wgbm_window.h
+++ b/src/waffle/gbm/wgbm_window.h
@@ -35,6 +35,7 @@ struct gbm_surface;
 struct wgbm_window {
 struct gbm_surface *gbm_surface;
 struct wegl_window wegl;
+struct wcore_config *wc_config;
 };
 
 static inline struct wgbm_window*
@@ -65,5 +66,9 @@ wgbm_window_show(struct wcore_window *wc_self);
 bool
 wgbm_window_swap_buffers(struct wcore_window *wc_self);
 
+bool
+wgbm_window_resize(struct wcore_window *wc_self,
+   int32_t width, int32_t height);
+
 union waffle_native_window*
 wgbm_window_get_native(struct wcore_window *wc_self);
-- 
2.6.2

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


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

2016-04-26 Thread Emil Velikov
On 21 April 2016 at 21:27, Frank Henigman <fjhenig...@google.com> 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.
>
Would be nice to see the series fly by the ML, although from a quick
look they look great.
We could use it to resolve some nasty implementations details in
nacl/android/others and get GBM's window_resize working.

> 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.
>
I'll refer Chad to that one.

> 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 may be true for some vendors, but it's not the rule afaict. On my
systems running mesa + i965 and nouveau the lists do differ.
How useful the separate lists are is another topic ;-)

> That can wait until I send v2, or if anyone wants to look
> now:
> https://github.com/fjhenigman/waffle/commit/b358ac50c00ce51fae6546b1e96c9adc32fcbdc7
I've not looked in details in the github branch, but considering that
wcore_[cm]alloc is used (instead of [cm]alloc or strdup), the leak is
plugged and people are happy with the other two topics (loose common
GL data, even if we fail in print_platform_specific) (don't print
anything and/or error if print_platform_specific() is not
implemented), I'd say just do with the series.

Reviewed-by: Emil Velikov <emil.veli...@collabora.com>

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


Re: [waffle] [PATCH 17/29] UPSTREAM: cmocka: include strings.h for strcasecmp

2016-04-26 Thread Emil Velikov
Ftr this patch has landed in upstream cmocka. If people prefer we can
re-sync out local copy with the latest version.

Personally I'm fine either way.
Emil
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [RFC PATCH 0/8] Android: plus memory leaks

2016-04-26 Thread Emil Velikov
[Adding Juha-Pekka since he did a bunch of fixes in the area]

Juha-Pekka, all,

Does anyone have some recommended reading on the topic of smart
pointers and Android ?
Can anyone spare a few cycles and skim through the series ?

Thanks
Emil

On 5 April 2016 at 23:52, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> Hi all,
>
> Some ~3 month old patches that I had lying around. As they are untested,
> and likely wrong to a degree, I'm sending them as RFC.
>
> Key note here is that we're dealing with smart pointers and my C++ in
> this area isn't exactly stellar. Any input as to why some (or even all)
> of the proposed changes are wrong is greatly appreciated.
>
> Thanks
> Emil
>
___
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-04-26 Thread Emil Velikov
Humble ping ?

On 5 April 2016 at 22:58, Emil Velikov <emil.l.veli...@gmail.com> 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.
>  - Should we rely upon the library (libGL/libGLESv1/libGLESv2) presence
> to determine if context of respective API is supported ? Same sentiment.
>
> 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 ;-)
>
> The series can be found in branch for-upstream/context-cleanups-et-al
>
> Comments and suggestion are appreciated.
> Emil
>
> [1] https://lists.freedesktop.org/archives/waffle/2015-November/001269.html
>
___
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-04-26 Thread Emil Velikov
Humble ping ?

On 6 January 2016 at 21:27, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> Hi all,
>
> Recently I had the chance to finish a lenghty series started some months
> ago. Namely - rework gl_basic_tests and kick waffle_test out the door.
>
> It starts with a couple of symbol fixes (maint material afaict), caught
> while experimenting with Travis-CI.
>
> Patch 3 adds a trivial --platform param and wires up the build (make
> check-func) to generate and use all possible combinations.
>
> Patches 06 through 14 add a bunch of macros, which minimise the
> duplication, and make things substantially easier/shorter add new
> platform (patch 28, platform gbm).
>
> We might want patches 15, 16 and 17 squashed, although I chose to keep
> the "import latest cmoka", "make sure it builds" and "fix the build
> warning" (this one is on the cmocka ML), separate to ease review.
>
> With patch 18, the existing cmocka user is updated - things build even
> without it, but we no longer use the deprecated API.
>
> With 20, we disable the functionality tests as we cannot convert the
> whole file at once. Immediatelly after (21) we nuke waffle_test.
>
> Patch 22, introduce a handy macro (not perfect due to cmocka API
> shortage), that makes the "add new platform" a ~10 line diff :-)
>
> The remaining patches convert the remaining platforms, one at a time, to
> top up with a small cleanup.
>
>
> The lot can be found in branch for-upstream/rework-tests over at
> https://github.com/evelikov/waffle/
>
> TL;DR - update cmocka, and use it over waffle_test. Cut gl_basic_test.c
> from ~1.2k to 0.9 loc, while adding GBM support and platform selection
> ;-) No more memory leaks with valgrind-check-func (barring driver ones).
>
> NOTE: I'll gladly rework any formatting and macro names. If possible,
> let's avoid rebase chaos (i.e. if thinking about the test... macros) and
> do them on top ?
>
> Thanks
> Emil
>
___
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-04-26 Thread Emil Velikov
On 25 April 2016 at 04:30, Frank Henigman <fjhenig...@google.com> wrote:
> On Sun, Apr 24, 2016 at 5:04 PM, Emil Velikov <emil.l.veli...@gmail.com> 
> wrote:
>> On 24 April 2016 at 20:52, Frank Henigman <fjhenig...@google.com> wrote:
>>> On Sun, Apr 24, 2016 at 6:36 AM, Emil Velikov <emil.l.veli...@gmail.com> 
>>> wrote:
>>>> On 21 April 2016 at 21:26, Frank Henigman <fjhenig...@google.com> wrote:
>>>>> On Fri, Jan 8, 2016 at 7:44 AM, Emil Velikov <emil.l.veli...@gmail.com> 
>>>>> wrote:
>>>>>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com> wrote:
>>>>>>> Add a platform hook so platform-specific information can be included
>>>>>>> by waffle_display_info_json().
>>>>>>>
>>>>>>> Signed-off-by: Frank Henigman <fjhenig...@google.com>
>>>>>>> ---
>>>>>>>  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
>> So when someone gets an OOM (even if it's during the platform
>> specifics) NULL is returned ? That does sound a bit strange, yet again
>> I would not read too much into it.
>
> That's true - when memory runs out the whole string is lost.  I guess
> that's the trade off for the simplicity of the error handling.  I'm
> quite happy with that trade off.
>
>> As long as others are happy go with it.
>>
>>> - we don't need to implement the hook in every back end
>>>
>> Need, perhaps not. It would be pretty good though ;-)
>
> I don't want to have to try to land code (even a stub) in back ends
> which I've never even compiled (and which would be a pain in the butt
> to set up for compiling).  Waffle needs continuous integration.  (:

I could wire up waffle's github repo with Travis-CI (for Linux/MacOS
builds) and Appveyor (for Windows ones), those depend on a lengthy
series that I have on the mailing list.
For Android I'm out of ideas.

https://lists.freedesktop.org/archives/waffle/2016-January/001292.html

- Resolves issues due to old wayland/gbm on CI systems.
- Removes the leaky waffle-tests, use cmocka.
- Allows the tests to be ran independently
- Adds GBM tests.

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


Re: [waffle] [PATCH 05/12] waffle: add waffle_display_info_json()

2016-04-24 Thread Emil Velikov
On 24 April 2016 at 20:50, Frank Henigman <fjhenig...@google.com> wrote:
> On Sun, Apr 24, 2016 at 6:42 AM, Emil Velikov <emil.l.veli...@gmail.com> 
> wrote:
>> On 21 April 2016 at 21:25, Frank Henigman <fjhenig...@google.com> wrote:
>>> On Fri, Jan 8, 2016 at 7:40 AM, Emil Velikov <emil.l.veli...@gmail.com> 
>>> wrote:
>>>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com> wrote:
>>>>> Duplicate wflinfo functionality in the API, with the difference that the
>>>>> information is returned in JSON form.
>>>>> The function has a parameter for including platform-specific information,
>>>>> but it is ignored for now.
>>>>>
>>>>> Signed-off-by: Frank Henigman <fjhenig...@google.com>
>>>>> ---
>>>>>  include/waffle/waffle.h |   5 +
>>>>>  man/waffle_display.3.xml|  19 +++
>>>>>  src/waffle/api/waffle_display.c | 284 
>>>>> +++-
>>>>>  src/waffle/waffle.def.in|   1 +
>>>>>  4 files changed, 308 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
>>>>> index df0218e..1800399 100644
>>>>> --- a/include/waffle/waffle.h
>>>>> +++ b/include/waffle/waffle.h
>>>>> @@ -214,6 +214,11 @@ bool
>>>>>  waffle_display_supports_context_api(struct waffle_display *self,
>>>>>  int32_t context_api);
>>>>>
>>>>> +#if WAFFLE_API_VERSION >= 0x0106
>>>>> +char*
>>>>> +waffle_display_info_json(struct waffle_display *self, bool platform_too);
>>>> The function does not work solely with the display, but it requires a
>>>> (bound) context. Thus it does not really fit waffle naming scheme. I'm
>>>> afraid that I'm short of suggestions though (barring my "returning
>>>> json formatted data sounds iffy, lets use tokens" rant from earlier)
>>>>
>>>>
>>>>> +#endif
>>>>> +
>>>>>  union waffle_native_display*
>>>>>  waffle_display_get_native(struct waffle_display *self);
>>>>>
>>>>> diff --git a/man/waffle_display.3.xml b/man/waffle_display.3.xml
>>>>> index 9896247..5358472 100644
>>>>> --- a/man/waffle_display.3.xml
>>>>> +++ b/man/waffle_display.3.xml
>>>>> @@ -24,6 +24,7 @@
>>>>>  waffle_display
>>>>>  waffle_display_connect
>>>>>  waffle_display_disconnect
>>>>> +waffle_display_info_json
>>>>>  waffle_display_supports_context_api
>>>>>  waffle_display_get_native
>>>>>  class waffle_display
>>>>> @@ -58,6 +59,12 @@ struct waffle_display;
>>>>>
>>>>>
>>>>>
>>>>> +char* 
>>>>> waffle_display_info_json
>>>>> +struct waffle_display 
>>>>> *self
>>>>> +bool platform_info
>>>>> +  
>>>>> +
>>>>> +  
>>>>>  bool 
>>>>> waffle_display_supports_context_api
>>>>>  struct waffle_display 
>>>>> *self
>>>>>  int32_t context_api
>>>>> @@ -129,6 +136,18 @@ struct waffle_display;
>>>>>
>>>>>
>>>>>
>>>>> +waffle_display_info_json()
>>>>> +
>>>>> +  
>>>>> +Return a JSON string containing information about the 
>>>>> current context on the given display, including Waffle platform and API, 
>>>>> GL version/vendor/renderer and extensions.
>>>>> +If platform_info is true, 
>>>>> platform-specific information (such as GLX or EGL versions and 
>>>>> extensions) will be included as available.
>>>>> +Returns NULL on error.
>>>>> +The string should be deallocated with 
>>>>> free3.
>>>>> +  
>>>>> +
>>>>> +  
>>>>> +
>>>>> +  
>>>>>  
>>>>> waffle_display_supports_context_api()
>>>&g

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

2016-04-24 Thread Emil Velikov
On 6 January 2016 at 19:56, Frank Henigman  wrote:

> +static void
> +put(struct json *jj, char *s)
> +{
> +if (!jj->buf)
> +return;
> +
> +for (;;) {
> +if (!(*jj->pos = *s++))
> +break;
> +if (++jj->pos == jj->buf + jj->size) {
> +size_t z = jj->size * 2;
> +jj->buf = realloc(jj->buf, z);
> +if (!jj->buf)

As I did not look closely at the patch this piece made me believe it
will corrupt the output. Although it will only leak memory.
Namely: if realloc fails, the old pointer is lost yet the data isn't freed.


> +char *buf = malloc(strlen(s) * 3 + 2);
> +if (!buf)
Nit: Just return NULL and drop the label ? Imho there is no point in
jumping only to free(NULL).

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


Re: [waffle] [PATCH 10/12] egl: implement platform-specific information

2016-04-24 Thread Emil Velikov
On 24 April 2016 at 20:52, Frank Henigman <fjhenig...@google.com> wrote:
> On Sat, Apr 23, 2016 at 2:51 PM, Emil Velikov <emil.l.veli...@gmail.com> 
> wrote:
>> On 21 April 2016 at 21:27, Frank Henigman <fjhenig...@google.com> wrote:
>>> On Fri, Jan 8, 2016 at 7:50 AM, Emil Velikov <emil.l.veli...@gmail.com>
>>> wrote:
>>>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com> wrote:
>>>>> Implement the platform hook of waffle_display_info_json() so it can
>>>>> pick up egl-specific information.
>>>>>
>>>>> Signed-off-by: Frank Henigman <fjhenig...@google.com>
>>>>> ---
>>>>>  src/waffle/egl/wegl_display.c  | 32 ++--
>>>>>  src/waffle/egl/wegl_display.h  |  4 
>>>>>  src/waffle/egl/wegl_platform.h |  3 +++
>>>>>  3 files changed, 37 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/src/waffle/egl/wegl_display.c
>>>>> b/src/waffle/egl/wegl_display.c
>>>>> index 88fce7a..dcfe934 100644
>>>>> --- a/src/waffle/egl/wegl_display.c
>>>>> +++ b/src/waffle/egl/wegl_display.c
>>>>> @@ -25,6 +25,8 @@
>>>>>
>>>>>  #include 
>>>>>
>>>>> +#include "json.h"
>>>>> +
>>>>>  #include "wcore_error.h"
>>>>>  #include "wcore_platform.h"
>>>>>
>>>>> @@ -63,7 +65,6 @@ wegl_display_init(struct wegl_display *dpy,
>>>>>  {
>>>>>  struct wegl_platform *plat = wegl_platform(wc_plat);
>>>>>  bool ok;
>>>>> -EGLint major, minor;
>>>>>
>>>>>  ok = wcore_display_init(>wcore, wc_plat);
>>>>>  if (!ok)
>>>>> @@ -75,7 +76,7 @@ wegl_display_init(struct wegl_display *dpy,
>>>>>  goto fail;
>>>>>  }
>>>>>
>>>>> -ok = plat->eglInitialize(dpy->egl, , );
>>>>> +ok = plat->eglInitialize(dpy->egl, >major, >minor);
>>>>>  if (!ok) {
>>>>>  wegl_emit_error(plat, "eglInitialize");
>>>>>  goto fail;
>>>>> @@ -139,3 +140,30 @@ wegl_display_supports_context_api(struct
>>>>> wcore_display *wc_dpy,
>>>>>
>>>>>  return wc_plat->vtbl->dl_can_open(wc_plat, waffle_dl);
>>>>>  }
>>>>> +
>>>>> +void
>>>>> +wegl_display_info_json(struct wcore_display *wc_dpy, struct json *jj)
>>>>> +{
>>>>> +struct wegl_display *dpy = wegl_display(wc_dpy);
>>>>> +struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
>>>>> +
>>>>> +const char *version = plat->eglQueryString(dpy->egl, EGL_VERSION);
>>>>> +const char *vendor = plat->eglQueryString(dpy->egl, EGL_VENDOR);
>>>>> +#ifdef EGL_VERSION_1_2
>>>>> +const char *apis = plat->eglQueryString(dpy->egl, EGL_CLIENT_APIS);
>>>>> +#endif
>>>> I would suggesting adding the define on top ifndef EGL_VERSION_1_2,
>>>> and dropping the checks here and below.
>>>
>>> Sorry, not sure what you mean by this.  It sounds like skipping the
>>> whole thing ifndef EGL_VERSION_1_2 ?  And that's ok because no one
>>> uses <= 1.2 anymore?
>>
>> Was talking about adding the following at the top:
>>
>> #ifndef EGL_VERSION_1_2
>> #define EGL_CLIENT_APIS XXX
>> #endif
>>
>> Then again, I have to fully agree with you here. I doubt that there are
>> (m)any pre 1.2 EGL implementations let alone testing those with waffle.
>> I would just drop the guard.
>
> I'm feeling exceptionally slow.  I still don't see (if we care about
> egl <= 1.2) how to avoid a guard around eglQueryString(dpy,
> EGL_CLIENT_APIS).  What is XXX?
XXX is the numerical value that the macro should hold. I was lazy
enough to grep it.

The thing I'm talking about is a common practise for dEQP and piglit
(to a point) amongst others. Here is an example:

$ cat fancy_app.c

#include ...
#include 

#ifndef EGL_VERSION_1_2 // or you can check EGL_CLIENT_APIS
#define EGL_CLIENT_APIS   0x308D
#endif

/* some code */

  // Just use the pname. If it's invalid (old implementation) we'll
get EGL_BAD_PARAMETER.
  // Otherwise we are restricting our runtime, based on a compile time
decision (outdated header).
  bar = eglQueryString(dpy, EGL_CLIENT_APIS);

/* rest of the file */

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


[waffle] [PATCH 05/12] waffle: add waffle_display_info_json()

2016-04-24 Thread Emil Velikov
On 21 April 2016 at 21:25, Frank Henigman <fjhenig...@google.com> wrote:
> On Fri, Jan 8, 2016 at 7:40 AM, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com> wrote:
>>> Duplicate wflinfo functionality in the API, with the difference that the
>>> information is returned in JSON form.
>>> The function has a parameter for including platform-specific information,
>>> but it is ignored for now.
>>>
>>> Signed-off-by: Frank Henigman <fjhenig...@google.com>
>>> ---
>>>  include/waffle/waffle.h |   5 +
>>>  man/waffle_display.3.xml|  19 +++
>>>  src/waffle/api/waffle_display.c | 284 
>>> +++-
>>>  src/waffle/waffle.def.in|   1 +
>>>  4 files changed, 308 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
>>> index df0218e..1800399 100644
>>> --- a/include/waffle/waffle.h
>>> +++ b/include/waffle/waffle.h
>>> @@ -214,6 +214,11 @@ bool
>>>  waffle_display_supports_context_api(struct waffle_display *self,
>>>  int32_t context_api);
>>>
>>> +#if WAFFLE_API_VERSION >= 0x0106
>>> +char*
>>> +waffle_display_info_json(struct waffle_display *self, bool platform_too);
>> The function does not work solely with the display, but it requires a
>> (bound) context. Thus it does not really fit waffle naming scheme. I'm
>> afraid that I'm short of suggestions though (barring my "returning
>> json formatted data sounds iffy, lets use tokens" rant from earlier)
>>
>>
>>> +#endif
>>> +
>>>  union waffle_native_display*
>>>  waffle_display_get_native(struct waffle_display *self);
>>>
>>> diff --git a/man/waffle_display.3.xml b/man/waffle_display.3.xml
>>> index 9896247..5358472 100644
>>> --- a/man/waffle_display.3.xml
>>> +++ b/man/waffle_display.3.xml
>>> @@ -24,6 +24,7 @@
>>>  waffle_display
>>>  waffle_display_connect
>>>  waffle_display_disconnect
>>> +waffle_display_info_json
>>>  waffle_display_supports_context_api
>>>  waffle_display_get_native
>>>  class waffle_display
>>> @@ -58,6 +59,12 @@ struct waffle_display;
>>>
>>>
>>>
>>> +char* 
>>> waffle_display_info_json
>>> +struct waffle_display 
>>> *self
>>> +bool platform_info
>>> +  
>>> +
>>> +  
>>>  bool 
>>> waffle_display_supports_context_api
>>>  struct waffle_display 
>>> *self
>>>  int32_t context_api
>>> @@ -129,6 +136,18 @@ struct waffle_display;
>>>
>>>
>>>
>>> +waffle_display_info_json()
>>> +
>>> +  
>>> +Return a JSON string containing information about the current 
>>> context on the given display, including Waffle platform and API, GL 
>>> version/vendor/renderer and extensions.
>>> +If platform_info is true, 
>>> platform-specific information (such as GLX or EGL versions and extensions) 
>>> will be included as available.
>>> +Returns NULL on error.
>>> +The string should be deallocated with 
>>> free3.
>>> +  
>>> +
>>> +  
>>> +
>>> +  
>>>  
>>> waffle_display_supports_context_api()
>>>  
>>>
>>> diff --git a/src/waffle/api/waffle_display.c 
>>> b/src/waffle/api/waffle_display.c
>>> index fa19462..7abe2ef 100644
>>> --- a/src/waffle/api/waffle_display.c
>>> +++ b/src/waffle/api/waffle_display.c
>>> @@ -23,13 +23,61 @@
>>>  // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
>>> THE USE
>>>  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>>>
>>> +#include 
>>> +#include 
>>> +
>>>  #include "api_priv.h"
>>>
>>> -#include "wcore_error.h"
>>> +#include "json.h"
>>> +
>>> +#include "wcore_context.h"
>>>  #include "wcore_display.h"
>>> +#include "wcore_error.h"
>>>  #include "wcore_platform.

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

2016-04-24 Thread Emil Velikov
On 21 April 2016 at 21:26, Frank Henigman <fjhenig...@google.com> wrote:
> On Fri, Jan 8, 2016 at 7:44 AM, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com> wrote:
>>> Add a platform hook so platform-specific information can be included
>>> by waffle_display_info_json().
>>>
>>> Signed-off-by: Frank Henigman <fjhenig...@google.com>
>>> ---
>>>  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.


>  If someone does need to act on the
> presence or absence or platform-specifics, they can always examine the
> json.
Personally I'd just discard the check and use the function
unconditionally. For platforms that I'm unsure I'll just put a uniform
stub alike "not-implemented", thus any users parsing the data will
have clear feedback.

Does that sound reasonable ?
Emil
___
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-24 Thread Emil Velikov
On 21 April 2016 at 21:25, Frank Henigman <fjhenig...@google.com> wrote:
> On Fri, Apr 8, 2016 at 7:38 PM, Chad Versace <chad.vers...@intel.com> wrote:
>> On 01/08/2016 04:17 AM, Emil Velikov wrote:
>>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com> wrote:
>>>> A small library for building JSON strings.
>>>>
>>>> Signed-off-by: Frank Henigman <fjhenig...@google.com>
>>>> ---
>>>>  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.
>
> I wrote it.  I didn't really want to write a json lib, but I did want
> the json-building code (the code that calls a json lib) to be as clear
> and simple as I could make it, and it seemed I needed to write
> something to facilitate that.  I'm open to a third party solution, if
> it doesn't require uglier code to use it.  I didn't think of it at the
> time, but maybe a little wrapping around some third party lib could do
> the job.  But by now I don't remember anything about the third party
> libs I looked at.
I think it's fine as is (i.e. not replying upon (linking against)
third party libs). Just asking because I have a few suggestions if
it's an waffle specific implementation:

Namely:
Pipe through all the memory allocation functions -
malloc/calloc/strdup via the waffle wrappers. They will set the error
state, thus you won't need to bother up the call chain (as mentioned
in other patch). Just need to propagate if the function(s) has failed
or not.

Also, please don't use goto statements to jump back [in time].
Thinking about the case in json_append().

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


[waffle] [PATCH 10/12] egl: implement platform-specific information

2016-04-23 Thread Emil Velikov
On 21 April 2016 at 21:27, Frank Henigman <fjhenig...@google.com
<javascript:;>> wrote:
> On Fri, Jan 8, 2016 at 7:50 AM, Emil Velikov <emil.l.veli...@gmail.com
<javascript:;>> wrote:
>> On 6 January 2016 at 21:56, Frank Henigman <fjhenig...@google.com
<javascript:;>> wrote:
>>> Implement the platform hook of waffle_display_info_json() so it can
>>> pick up egl-specific information.
>>>
>>> Signed-off-by: Frank Henigman <fjhenig...@google.com <javascript:;>>
>>> ---
>>>  src/waffle/egl/wegl_display.c  | 32 ++--
>>>  src/waffle/egl/wegl_display.h  |  4 
>>>  src/waffle/egl/wegl_platform.h |  3 +++
>>>  3 files changed, 37 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/waffle/egl/wegl_display.c
b/src/waffle/egl/wegl_display.c
>>> index 88fce7a..dcfe934 100644
>>> --- a/src/waffle/egl/wegl_display.c
>>> +++ b/src/waffle/egl/wegl_display.c
>>> @@ -25,6 +25,8 @@
>>>
>>>  #include 
>>>
>>> +#include "json.h"
>>> +
>>>  #include "wcore_error.h"
>>>  #include "wcore_platform.h"
>>>
>>> @@ -63,7 +65,6 @@ wegl_display_init(struct wegl_display *dpy,
>>>  {
>>>  struct wegl_platform *plat = wegl_platform(wc_plat);
>>>  bool ok;
>>> -EGLint major, minor;
>>>
>>>  ok = wcore_display_init(>wcore, wc_plat);
>>>  if (!ok)
>>> @@ -75,7 +76,7 @@ wegl_display_init(struct wegl_display *dpy,
>>>  goto fail;
>>>  }
>>>
>>> -ok = plat->eglInitialize(dpy->egl, , );
>>> +ok = plat->eglInitialize(dpy->egl, >major, >minor);
>>>  if (!ok) {
>>>  wegl_emit_error(plat, "eglInitialize");
>>>  goto fail;
>>> @@ -139,3 +140,30 @@ wegl_display_supports_context_api(struct
wcore_display *wc_dpy,
>>>
>>>  return wc_plat->vtbl->dl_can_open(wc_plat, waffle_dl);
>>>  }
>>> +
>>> +void
>>> +wegl_display_info_json(struct wcore_display *wc_dpy, struct json *jj)
>>> +{
>>> +struct wegl_display *dpy = wegl_display(wc_dpy);
>>> +struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
>>> +
>>> +const char *version = plat->eglQueryString(dpy->egl, EGL_VERSION);
>>> +const char *vendor = plat->eglQueryString(dpy->egl, EGL_VENDOR);
>>> +#ifdef EGL_VERSION_1_2
>>> +const char *apis = plat->eglQueryString(dpy->egl, EGL_CLIENT_APIS);
>>> +#endif
>> I would suggesting adding the define on top ifndef EGL_VERSION_1_2,
>> and dropping the checks here and below.
>
> Sorry, not sure what you mean by this.  It sounds like skipping the
> whole thing ifndef EGL_VERSION_1_2 ?  And that's ok because no one
> uses <= 1.2 anymore?

Was talking about adding the following at the top:

#ifndef EGL_VERSION_1_2
#define EGL_CLIENT_APIS XXX
#endif

Then again, I have to fully agree with you here. I doubt that there are
(m)any pre 1.2 EGL implementations let alone testing those with waffle.
I would just drop the guard.

Regards
Emil
___
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-17 Thread Emil Velikov
On 17 April 2016 at 01:41, Jason Ekstrand <ja...@jlekstrand.net> wrote:
> On Sat, Apr 16, 2016 at 4:12 PM, Emil Velikov <emil.l.veli...@gmail.com>
> wrote:
>>
>> On 16 April 2016 at 22:06, Jason Ekstrand <ja...@jlekstrand.net> wrote:
>>
>> >> 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.
>> >
>>  If it's a good idea why aren't others doing it ?> cheeky>
>> Please don't take the above too seriously.
>>
>> >> This is precisely the subtlety in the whole thing. The wayland
>> >> protocol tried (and I believe so far is) backwards compatible, then
>> >> again the library that we use is not. This is a fundamental difference
>> >> that causes these headaches.
>> >>
>> >> If one is to import protocol vX, what happens as libwayland tries to
>> >> use feature A or B introduced in newer protocols via the same API ?
>> >> They have to reimplement everything on their own - bad idea.
>> >>
>> >> How about the earlier patch was resolving another ABI break ? The
>> >> developers rightfully broke it because things were racy. Do we want to
>> >> check-in old version and be forced to use the racy interface ?
>> >
>> >
>> > Client-side libwayland has *never* had an ABI break since version 1.0.
>> > The
>> > libwayland-client ABI is very small (one or two dozen functions) and has
>> > always maintained backwards-compatibility.  We've made some pretty crazy
>> > changes to libwayland's internals and worked very hard to maintain
>> > compatibility.
>> >
>> > What has changed over time is the header file and the exact functions
>> > that
>> > it calls.  The protocol headers (as opposed to wayland-client-core.h)
>> > contain only static inline wrapper functions that implement the protocol
>> > in
>> > terms of the stable ABI provided by libwayland-client.so.  As new
>> > features
>> > get added to libwayland-client to remove race conditions, provide object
>> > versioning, or any other improvements, the wayland-client-protocol
>> > headers
>> > get updated to take advantage of the new functionality.  That way
>> > clients
>> > built against new versions of libwayland-client automatically get the
>> > upgrade without any developer intervention.  It's really a pretty good
>> > system.
>> >
>> Interesting. Not too long ago I asked around (#xorg-devel iirc) about
>> the proper terminology in a similar case and ABI popped up.
>>
>> I believe the term ABI is correct, as if we compile program X against
>> wayland N+1 it may not be compatible with wayland N. Where if the very
>> same application is rebuilt against wayland N it will work just fine.
>> Note: program X has only a single code path - it does not detect nor
>> differentiate between the different versions of wayland.
>> This does sound like the definition of ABI break to me.
>>
>> I'm likely missing something here. If the above is off what is the
>> correct terminology ?
>> How are the symbols provided by libwayland called ? How about the
>> user/programmer facing ones, provided by the headers ?
>
>
> Let's start with terms.  API or Application Programming Interface is a
> general term referring to the functions, types, structs, enums, etc that
> allows an application (or other library) to interact with a library.  ABI or
> Application Binary Interface refers to the binary mechanism for interacting
> with a library.
>
> As an example of the distinction, let's say I have an enum value.  If I
> change the name but not the value, that's an API change but not an ABI
> change.  Applications compiled against an old header will work just fine
> with a new version of the library because they pass in the same old value
> it's expecting.  Applications compiled against a new version will have to be
> updated because the name of the thing changed.
>
> On the other side of the fence, suppose I change the value but not the name.
> This is an ABI change but not an API change.  Applications built against an
> old version will fail on newer versions because they will pass in the wrong
> value.  However, if you rebuild your application against the new version, it
> will build just fine (it has 

Re: [waffle] [PATCH] egl: Support robust access contexts with EGL 1.5.

2016-04-15 Thread Emil Velikov
Hi Bas,

On 15 April 2016 at 22:04, Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl> 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 <b...@basnieuwenhuizen.nl>
> ---
>  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_config.c b/src/waffle/egl/wegl_config.c
> index 1c3f416..08e06fb 100644
> --- a/src/waffle/egl/wegl_config.c
> +++ b/src/waffle/egl/wegl_config.c
> @@ -56,17 +56,20 @@ check_context_attrs(struct wegl_display *dpy,
>  }
>
>  if (attrs->context_robust && !dpy->EXT_create_context_robustness &&
> +dpy->major_version == 1 && dpy->minor_version < 5 &&
>  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");
> + "EGL_EXT_create_context_robustness or EGL 1.5 is "
> + "required in order to request a robust access context "
> + "for OpenGL ES");
>  return false;
>  }
>
>  if (attrs->context_robust && !dpy->KHR_create_context &&
> +dpy->major_version == 1 && dpy->minor_version < 5 &&
>  attrs->context_api == WAFFLE_CONTEXT_OPENGL) {
>  wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
> - "EGL_KHR_create_context is required in order to "
> + "EGL_KHR_create_context or EGL 1.5 is required in order 
> to "
>   "request a robust access context for OpenGL");
>  return false;
>  }
> 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).

> +attrib_list[i++] = EGL_TRUE;
> +} else {
> +assert(dpy->KHR_create_context);
> +context_flags |= 
> EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
> +}
>  }
>
>  if (wcore_config_attrs_version_ge(attrs, 32))  {
> diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
> index 16af142..a5e3429 100644
> --- a/src/waffle/egl/wegl_display.c
> +++ b/src/waffle/egl/wegl_display.c
> @@ -64,7 +64,6 @@ wegl_display_init(struct wegl_display *dpy,
>  {
>  struct wegl_platform *plat = wegl_platform(wc_plat);
>  bool ok;
> -EGLint major, minor;
>
>  ok = wcore_display_init(>wcore, wc_plat);
>  if (!ok)
> @@ -76,7 +75,7 @@ wegl_display_init(struct wegl_display *dpy,
>  goto fail;
>  }
>
> -ok = plat->eglInitialize(dpy->egl, , );
> +ok = plat->eglInitialize(dpy->egl, >major_version, 
> >minor_version);
>  if (!ok) {
>  wegl_emit_error(plat, "eglInitialize");
>  goto fail;
> diff --git a/src/waffle/egl/wegl_display.h b/src/waffle/egl/wegl_display.h
> index b82a2ec..0d03ec8 100644
> --- a/src/waffle/egl/wegl_display.h
> +++ b/src/waffle/egl/wegl_display.h
> @@ -39,6 +39,8 @@ struct wegl_display {
>  EGLDisplay egl;
>  bool EXT_create_context_robustness;
>  bool KHR_create_context;
> +EGLint major_version;
> +EGLint minor_version;

While working on a similar version specific EGL bits, I've added a
single boolean as it seemed easer/shorter to check (yes I'm that
lazy).
Just throwing the idea out there, unless others insist you don't have
to do any of that.

With the s/_EXT//g issue above
Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

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


Re: [waffle] [PATCH] egl: correctly set the attrib/bits for robust contexts

2016-04-15 Thread Emil Velikov
On 16 April 2016 at 00:34, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> The EXT_create_context_robustness extension covers only GLES contexts,
> while the latter EGL_KHR_create_context works for both GL and GLES ones.
>
Actually the second extension seems a bit inconsistent. The following
section clearly lists GLES

OpenGL and OpenGL ES Context Flags
--

If the EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR bit is set in
EGL_CONTEXT_FLAGS_KHR, then a context supporting  will be created.

Then it continues with

Robust buffer access is defined in the
GL_ARB_robustness extension specification, and the resulting context
must also support either the GL_ARB_robustness extension, or a
version of OpenGL incorporating equivalent functionality. This bit
is supported for OpenGL contexts.


Then issues 7 and 10 go to confirm that GLES and robustness is not a
thing in this extension, yet no-one bothered moving the hunk to the
OpenGL only section :'-(

This spec is quite and interesting read - forward compat seems to be
in the exact same boat. While debug is funnier - added with the GL +
GLES section initially, discarded as not supported in issue 7, then
brought back with issue 9.

So overall I should bring the KHR_create_context bits back into OpenGL
denominator.

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


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

2016-04-15 Thread Emil Velikov
Direct port of previous commit.

v2: The version should be 3.2 and not 3.0 as originally.

Cc: Jose Fonseca <jfons...@vmware.com>
Cc: Ilia Mirkin <imir...@alum.mit.edu>
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 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(-)

diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c
index 59a70a6..43bcfa5 100644
--- a/src/waffle/wgl/wgl_config.c
+++ b/src/waffle/wgl/wgl_config.c
@@ -32,6 +32,7 @@
 #include "wcore_error.h"
 
 #include "wgl_config.h"
+#include "wgl_context.h"
 #include "wgl_display.h"
 #include "wgl_error.h"
 #include "wgl_platform.h"
@@ -73,11 +74,11 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
 
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
-if (!wcore_config_attrs_version_eq(attrs, 10) && 
!dpy->ARB_create_context) {
+if (wgl_context_needs_arb_create_context(attrs) &&
+!dpy->ARB_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "WGL_ARB_create_context is required in order to "
- "request an OpenGL version not equal to the 
default "
- "value 1.0");
+ "request an OpenGL version greater or equal than 
3.2");
 return false;
 }
 else if (wcore_config_attrs_version_ge(attrs, 32) && 
!dpy->ARB_create_context_profile) {
diff --git a/src/waffle/wgl/wgl_context.c b/src/waffle/wgl/wgl_context.c
index dd45f81..32b2e2d 100644
--- a/src/waffle/wgl/wgl_context.c
+++ b/src/waffle/wgl/wgl_context.c
@@ -152,7 +152,17 @@ wgl_context_create_native(struct wgl_config *config,
 HGLRC real_share_ctx = share_ctx ? share_ctx->hglrc : NULL;
 HGLRC hglrc;
 
-if (dpy->ARB_create_context) {
+// Use ARB_create_context when we have
+// - OpenGL version 1.0, or
+// - OpenGL version 3.2 or greater, or
+// - OpenGL with fwd_compat, or
+// - Debug context
+//
+// The first one of the four is optional, the remainder hard requirement
+// for the use of ARB_create_context.
+if (dpy->ARB_create_context &&
+(wcore_config_attrs_version_eq(>wcore.attrs, 10) ||
+ wgl_context_needs_arb_create_context(>wcore.attrs))) {
 bool ok;
 
 // Choose a large size to prevent accidental overflow.
diff --git a/src/waffle/wgl/wgl_context.h b/src/waffle/wgl/wgl_context.h
index c55ad58..28c25c9 100644
--- a/src/waffle/wgl/wgl_context.h
+++ b/src/waffle/wgl/wgl_context.h
@@ -27,6 +27,7 @@
 
 #include 
 
+#include "wcore_config_attrs.h"
 #include "wcore_context.h"
 #include "wcore_util.h"
 
@@ -51,3 +52,17 @@ wgl_context_create(struct wcore_platform *wc_plat,
 
 bool
 wgl_context_destroy(struct wcore_context *wc_self);
+
+static inline bool
+wgl_context_needs_arb_create_context(const struct wcore_config_attrs *attrs)
+{
+if (attrs->context_api == WAFFLE_CONTEXT_OPENGL &&
+(wcore_config_attrs_version_ge(attrs, 32) ||
+ attrs->context_forward_compatible))
+return true;
+
+if (attrs->context_debug)
+return true;
+
+return false;
+}
-- 
2.8.0

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


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

2016-04-15 Thread Emil Velikov
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 <imir...@alum.mit.edu>
Reviewed-by: Jose Fonseca <jfons...@vmware.com> (v1)
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 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(-)

diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c
index 7792aa0..259e538 100644
--- a/src/waffle/glx/glx_config.c
+++ b/src/waffle/glx/glx_config.c
@@ -32,6 +32,7 @@
 #include "wcore_error.h"
 
 #include "glx_config.h"
+#include "glx_context.h"
 #include "glx_display.h"
 #include "glx_platform.h"
 #include "glx_wrappers.h"
@@ -70,11 +71,11 @@ glx_config_check_context_attrs(struct glx_display *dpy,
 
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
-if (!wcore_config_attrs_version_eq(attrs, 10) && 
!dpy->ARB_create_context) {
+if (glx_context_needs_arb_create_context(attrs) &&
+!dpy->ARB_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "GLX_ARB_create_context is required in order to "
- "request an OpenGL version not equal to the 
default "
- "value 1.0");
+ "request an OpenGL version greater or equal than 
3.2");
 return false;
 }
 else if (wcore_config_attrs_version_ge(attrs, 32) && 
!dpy->ARB_create_context_profile) {
diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c
index 1f9290b..cb10e32 100644
--- a/src/waffle/glx/glx_context.c
+++ b/src/waffle/glx/glx_context.c
@@ -169,7 +169,17 @@ glx_context_create_native(struct glx_config *config,
 struct glx_display *dpy = glx_display(config->wcore.display);
 struct glx_platform *platform = glx_platform(dpy->wcore.platform);
 
-if (dpy->ARB_create_context) {
+// Use ARB_create_context when we have
+// - OpenGL version 1.0, or
+// - OpenGL version 3.2 or greater, or
+// - OpenGL with fwd_compat, or
+// - Debug context
+//
+// The first one of the four is optional, the remainder hard requirement
+// for the use of ARB_create_context.
+if (dpy->ARB_create_context &&
+(wcore_config_attrs_version_eq(>wcore.attrs, 10) ||
+ glx_context_needs_arb_create_context(>wcore.attrs))) {
 bool ok;
 
 // Choose a large size to prevent accidental overflow.
diff --git a/src/waffle/glx/glx_context.h b/src/waffle/glx/glx_context.h
index bb2a4dd..23ffd74 100644
--- a/src/waffle/glx/glx_context.h
+++ b/src/waffle/glx/glx_context.h
@@ -29,6 +29,7 @@
 
 #include 
 
+#include "wcore_config_attrs.h"
 #include "wcore_context.h"
 #include "wcore_util.h"
 
@@ -55,3 +56,18 @@ glx_context_destroy(struct wcore_context *wc_self);
 
 union waffle_native_context*
 glx_context_get_native(struct wcore_context *wc_self);
+
+
+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, 32) ||
+ attrs->context_forward_compatible))
+return true;
+
+if (attrs->context_debug)
+return true;
+
+return false;
+}
-- 
2.8.0

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

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.

-Emil
___
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 Emil Velikov
On 15 April 2016 at 21:56, Chad Versace <chad.vers...@intel.com> wrote:
> On 04/15/2016 09:36 AM, Jason Ekstrand wrote:
>> On Fri, Apr 15, 2016 at 3:03 AM, Emil Velikov <emil.l.veli...@gmail.com 
>> <mailto:emil.l.veli...@gmail.com>> wrote:
>>
>> On 15 April 2016 at 03:32, Michel Dänzer <mic...@daenzer.net 
>> <mailto:mic...@daenzer.net>> 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 <mic...@daenzer.net 
>> <mailto:mic...@daenzer.net>> wrote:
>> >>>> From: Michel Dänzer <michel.daen...@amd.com 
>> <mailto:michel.daen...@amd.com>>
>> >>>>
>> >>>> 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 <michel.daen...@amd.com 
>> <mailto:michel.daen...@amd.com>>
>> >>>> ---
>> >>>>  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.
>
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 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

[waffle] [PATCH] wayland: Wrap wl_proxy_marshal_constructor_versioned v2

2016-04-15 Thread Emil Velikov
From: Michel Dänzer <michel.daen...@amd.com>

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 <michel.daen...@amd.com>

v3:
* Always resolve wl_proxy_marshal_constructor_versioned, yet do not
error out if it's missing.

Cc: Jason Ekstrand <ja...@jlekstrand.net>
Cc: Chad Versace <chad.vers...@intel.com>
Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---

Gents, I've taken the liberty to update Michel patch with what I have in 
mind. Why ? I'm wondering if some of the things mentioned are not 
getting across, and as we all know 'a patch speaks a thousand words'

-Emil

 src/waffle/wayland/wayland_wrapper.c | 8 
 src/waffle/wayland/wayland_wrapper.h | 8 
 2 files changed, 16 insertions(+)

diff --git a/src/waffle/wayland/wayland_wrapper.c 
b/src/waffle/wayland/wayland_wrapper.c
index 6ffd5a9..d08e3b5 100644
--- a/src/waffle/wayland/wayland_wrapper.c
+++ b/src/waffle/wayland/wayland_wrapper.c
@@ -106,6 +106,14 @@ 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);
+
+#define OPTIONAL_WL_CLIENT_SYMBOL(S)\
+wfl_##S = (__typeof__(wfl_##S))dlsym(dl_wl_client, #S);
+
+// Introduced with Wayland 1.10. Used over wl_proxy_marshal_constructor
+OPTIONAL_WL_CLIENT_SYMBOL(wl_proxy_marshal_constructor_versioned);
+
+#undef OPTIONAL_WL_CLIENT_SYMBOL
 #undef RETRIEVE_WL_CLIENT_SYMBOL
 
 error:
diff --git a/src/waffle/wayland/wayland_wrapper.h 
b/src/waffle/wayland/wayland_wrapper.h
index 40a581a..3282587 100644
--- a/src/waffle/wayland/wayland_wrapper.h
+++ b/src/waffle/wayland/wayland_wrapper.h
@@ -75,6 +75,13 @@ struct wl_proxy *
 const struct wl_interface *interface,
 ...);
 
+struct wl_proxy *
+(*wfl_wl_proxy_marshal_constructor_versioned)(struct wl_proxy *proxy,
+ uint32_t opcode,
+ const struct wl_interface 
*interface,
+ uint32_t version,
+ ...);
+
 #ifdef _WAYLAND_CLIENT_H
 #error Do not include wayland-client.h ahead of wayland_wrapper.h
 #endif
@@ -92,3 +99,4 @@ struct wl_proxy *
 #define wl_proxy_add_listener (*wfl_wl_proxy_add_listener)
 #define wl_proxy_marshal (*wfl_wl_proxy_marshal)
 #define wl_proxy_marshal_constructor (*wfl_wl_proxy_marshal_constructor)
+#define wl_proxy_marshal_constructor_versioned 
(*wfl_wl_proxy_marshal_constructor_versioned)
-- 
2.8.0

___
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 Emil Velikov
On 15 April 2016 at 03:32, Michel Dänzer <mic...@daenzer.net> 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 <mic...@daenzer.net> wrote:
>>>> From: Michel Dänzer <michel.daen...@amd.com>
>>>>
>>>> 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 <michel.daen...@amd.com>
>>>> ---
>>>>  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.
>>>
>>> Obviously that's not perfect, although unavoidable. Why ? As distros
>>> do not know about the requirement (i.e. it's not mandated at configure
>>> time) they won't rebuild and things won't work. At the same time if
>>> they do rebuild (again without the explicit requirement), things will
>>> break if one needs to revert to older (yet still in version range as
>>> per the deps list) wayland.
>>
>> That's not true at least for Debian and derivatives, which keep track of
>> which symbols were added in which version and generate accordingly
>> versioned dependencies.
>
> It occurred to me (just after sending out the previous post, sigh...)
> that this automatic mechanism might not work for waffle's dependency on
> wayland if we don't link the wayland libraries directly. Even so, IME
> this is a common issue distro maintainers of libraries have to deal
> with, nothing particularly tricky.
>
Interesting - last time I've played around with Debian/derivatives, it
did track the symbols exposed by the libraries although it did not
check if anyone that depends on the new symbol needs to be rebuild and
more importantly the versions need to be bumped. Sadly other
distributions do not do that to this moment (afaict) - Arch, Gentoo,
Fedora (?), Suse (?).

To put it bluntly - with one approach things will eventually break
[and get fixed by distro maintainers], while with the other things
will just work.

Afaict the latter does add much more code/complexity over the former, right ?

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


Re: [waffle] [PATCH] wayland: add support for wl_proxy_marshal_constructor_versioned

2016-04-14 Thread Emil Velikov
On 14 April 2016 at 19:12, Dylan Baker  wrote:
> This fixes waffle to build against wayland 1.10.
>
> Thanks to Jason Eckstrand for help getting this working.
>
I can never get names right, although this one seems off -
s/Eckstrand/Ekstrand/ ;-)

> Fixes #38
>
> cc: Chad Versace 
> cc: Mark Janes 
Michel already sent v2 [1] although I'm a little concerned with the
approach. If things are urgent please apply it locally until we hear
from Chad/Michel/others.

-Emil

[1] https://lists.freedesktop.org/archives/waffle/2016-April/001423.html
___
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-14 Thread Emil Velikov
On 14 April 2016 at 09:23, Michel Dänzer <mic...@daenzer.net> wrote:
> From: Michel Dänzer <michel.daen...@amd.com>
>
> 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 <michel.daen...@amd.com>
> ---
>  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.

Obviously that's not perfect, although unavoidable. Why ? As distros
do not know about the requirement (i.e. it's not mandated at configure
time) they won't rebuild and things won't work. At the same time if
they do rebuild (again without the explicit requirement), things will
break if one needs to revert to older (yet still in version range as
per the deps list) wayland.

TL;DR: The situation is quite sensitive and fragile. The only robust
solutions that I can think of are: a) non-fatal (only for newer
symbols) dlsym or b) bumping the req. version at configure time.

-Emil
___
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 Emil Velikov
On 11 April 2016 at 21:11, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> On 6 April 2016 at 16:59, Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl> wrote:
>> Signed-off-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
>> ---
>>  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.
>
To hasty to press "Send"

The series is:
Reviewed-by: Emil Velikov <emil.veli...@collabora.com>

Thanks Bas !

-Emil
___
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 Emil Velikov
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.

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


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

2016-04-07 Thread Emil Velikov
Hi Michel,

On 7 April 2016 at 09:20, 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.
>
Thanks for that patch. Can you please add the commit (and/or version)
where this API is introduced ?
I recently sent out a similar patch [1] can you please take a look ? I
would love to hear your input on the proposed topic.

Thanks
Emil

[1] https://lists.freedesktop.org/archives/waffle/2016-April/001406.html
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


Re: [waffle] [PATCH 01/29] wayland: add wl_proxy_create wrapper

2016-04-07 Thread Emil Velikov
On 6 April 2016 at 13:20, Emil Velikov <emil.l.veli...@gmail.com> wrote:
> On 6 January 2016 at 21:27, Emil Velikov <emil.l.veli...@gmail.com> wrote:
>> libwayland has broken its ABI by replacing wl_proxy_create +
>> wl_proxy_marshal with wfl_wl_proxy_marshal_constructor with commit
s/wfl_wl_proxy_marshal_constructor/wl_proxy_marshal_constructor/

>> 853c24e6998(client: Introduce functions to allocate and marshal proxies
>> atomically).
>>
>> Add the wrapper to keep compatibility with wayland 1.3.90 and earlier.
>>
>> Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
>> ---
>>  src/waffle/wayland/wayland_wrapper.h | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/src/waffle/wayland/wayland_wrapper.h 
>> b/src/waffle/wayland/wayland_wrapper.h
>> index 40a581a..e2c96ca 100644
>> --- a/src/waffle/wayland/wayland_wrapper.h
>> +++ b/src/waffle/wayland/wayland_wrapper.h
>> @@ -66,6 +66,10 @@ int
>>  (*wfl_wl_proxy_add_listener)(struct wl_proxy *proxy,
>>   void (**implementation)(void), void *data);
>>
>> +struct wl_proxy *
>> +(*wfl_wl_proxy_create)(struct wl_proxy *factory,
>> +   const struct wl_interface *interface);
>> +
>>  void
>>  (*wfl_wl_proxy_marshal)(struct wl_proxy *p, uint32_t opcode, ...);
>>
>> @@ -90,5 +94,6 @@ struct wl_proxy *
>>  #define wl_display_roundtrip (*wfl_wl_display_roundtrip)
>>  #define wl_proxy_destroy (*wfl_wl_proxy_destroy)
>>  #define wl_proxy_add_listener (*wfl_wl_proxy_add_listener)
>> +#define wl_proxy_create (*wfl_wl_proxy_create)
>>  #define wl_proxy_marshal (*wfl_wl_proxy_marshal)
>>  #define wl_proxy_marshal_constructor (*wfl_wl_proxy_marshal_constructor)
>
> A small note I had lying around - XXX: Double check that it works
> (might need the following hunk).
>
>
> diff --git a/src/waffle/wayland/wayland_wrapper.c
> b/src/waffle/wayland/wayland_wrapper.c
> index 6ffd5a9..729f860 100644
> --- a/src/waffle/wayland/wayland_wrapper.c
> +++ b/src/waffle/wayland/wayland_wrapper.c
> @@ -104,6 +104,7 @@ wayland_wrapper_init(void)
> RETRIEVE_WL_CLIENT_SYMBOL(wl_display_roundtrip);
> RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_destroy);
> RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_add_listener);
> +RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_create);
> RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_marshal);
> RETRIEVE_WL_CLIENT_SYMBOL(wl_proxy_marshal_constructor);
> #undef RETRIEVE_WL_CLIENT_SYMBOL
>
So yes, in order for this to work on older platforms we need the hunk,
plus we must make the dlsym(... "wl_proxy_marshal_constructor") non
fatal. This way even if the symbol is missing (in case of old
libwayland) we don't care as it won't be used.

The alternative is to bump the requirement to 1.4 although not many
platforms have/use it. I would opt for using the workaround for now
(perhaps with a comment).

How would others feel on the topic ?

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


[waffle] [PATCH 3/8] android: annotate static functions as such

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/android/droid_surfaceflingerlink.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp 
b/src/waffle/android/droid_surfaceflingerlink.cpp
index a0251c1..9930e47 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -59,7 +59,7 @@ const uint32_t droid_magic_surface_width = 32;
 const uint32_t droid_magic_surface_height = 32;
 const int32_t  droid_magic_surface_z = 0x7FFF;
 
-void
+static void
 droid_tear_down_surfaceflinger_link(
 waffle::droid_surfaceflinger_container* pSFContainer)
 {
@@ -74,7 +74,7 @@ droid_tear_down_surfaceflinger_link(
 delete pSFContainer;
 }
 
-droid_surfaceflinger_container*
+static droid_surfaceflinger_container*
 droid_setup_surfaceflinger_link()
 {
 bool bRVal;
@@ -100,7 +100,7 @@ error:
 return NULL;
 }
 
-void
+static void
 droid_destroy_surface(
 droid_surfaceflinger_container* pSFContainer,
 droid_ANativeWindow_container* pANWContainer)
@@ -111,7 +111,7 @@ droid_destroy_surface(
 delete pANWContainer;
 }
 
-droid_ANativeWindow_container*
+static droid_ANativeWindow_container*
 droid_setup_surface(
 int width,
 int height,
@@ -196,7 +196,7 @@ error:
 return NULL;
 }
 
-bool
+static bool
 droid_show_surface(
 droid_surfaceflinger_container* pSFContainer,
 droid_ANativeWindow_container* pANWContainer)
@@ -215,7 +215,7 @@ droid_show_surface(
 return true;
 }
 
-bool
+static bool
 droid_resize_surface(
 droid_surfaceflinger_container* pSFContainer,
 droid_ANativeWindow_container* pANWContainer,
-- 
2.8.0

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


[waffle] [PATCH 4/8] android: cleanup surfaceflinger_link management

2016-04-05 Thread Emil Velikov
If the C++ runtime fails to create the relevant object(s) an exception
will be raised, thus the NULL checks will never get hit.

While we're here replace the opencoded SurfaceComposerClient dtor with
the proper one.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/android/droid_surfaceflingerlink.cpp | 13 +
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp 
b/src/waffle/android/droid_surfaceflingerlink.cpp
index 9930e47..e8c31ab 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -63,14 +63,7 @@ static void
 droid_tear_down_surfaceflinger_link(
 waffle::droid_surfaceflinger_container* pSFContainer)
 {
-if( pSFContainer == NULL)
-return;
-
-if (pSFContainer->composer_client != NULL) {
-pSFContainer->composer_client->dispose();
-pSFContainer->composer_client = NULL;
-}
-
+delete pSFContainer->composer_client;
 delete pSFContainer;
 }
 
@@ -82,10 +75,6 @@ droid_setup_surfaceflinger_link()
 droid_surfaceflinger_container* pSFContainer;
 
 pSFContainer = new droid_surfaceflinger_container;
-
-if (pSFContainer == NULL)
-goto error;
-
 pSFContainer->composer_client = new SurfaceComposerClient;
 iRVal = pSFContainer->composer_client->initCheck();
 if (iRVal != NO_ERROR) {
-- 
2.8.0

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


[waffle] [PATCH 2/8] android: move droid_destroy_surface() further up the file

2016-04-05 Thread Emil Velikov
Analogous to previous commit, minus the case where the setup (wrongly)
open-codes it.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/android/droid_surfaceflingerlink.cpp | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp 
b/src/waffle/android/droid_surfaceflingerlink.cpp
index 75803f3..a0251c1 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -100,6 +100,17 @@ error:
 return NULL;
 }
 
+void
+droid_destroy_surface(
+droid_surfaceflinger_container* pSFContainer,
+droid_ANativeWindow_container* pANWContainer)
+{
+pSFContainer->composer_client->openGlobalTransaction();
+pANWContainer->surface_control->clear();
+pSFContainer->composer_client->closeGlobalTransaction();
+delete pANWContainer;
+}
+
 droid_ANativeWindow_container*
 droid_setup_surface(
 int width,
@@ -225,17 +236,6 @@ droid_resize_surface(
 return true;
 }
 
-void
-droid_destroy_surface(
-droid_surfaceflinger_container* pSFContainer,
-droid_ANativeWindow_container* pANWContainer)
-{
-pSFContainer->composer_client->openGlobalTransaction();
-pANWContainer->surface_control->clear();
-pSFContainer->composer_client->closeGlobalTransaction();
-delete pANWContainer;
-}
-
 }; // namespace waffle
 
 extern "C" struct droid_surfaceflinger_container*
-- 
2.8.0

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


[waffle] [PATCH 1/8] android: avoid unneeded (function) forward declaration

2016-04-05 Thread Emil Velikov
There is no specific reason why we cannot move the teardown function
prior to the setup one. Most (rest of) waffle does so already.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/android/droid_surfaceflingerlink.cpp | 32 +++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp 
b/src/waffle/android/droid_surfaceflingerlink.cpp
index dc55a8a..75803f3 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -59,8 +59,20 @@ const uint32_t droid_magic_surface_width = 32;
 const uint32_t droid_magic_surface_height = 32;
 const int32_t  droid_magic_surface_z = 0x7FFF;
 
-void droid_tear_down_surfaceflinger_link(
-droid_surfaceflinger_container* pSFContainer);
+void
+droid_tear_down_surfaceflinger_link(
+waffle::droid_surfaceflinger_container* pSFContainer)
+{
+if( pSFContainer == NULL)
+return;
+
+if (pSFContainer->composer_client != NULL) {
+pSFContainer->composer_client->dispose();
+pSFContainer->composer_client = NULL;
+}
+
+delete pSFContainer;
+}
 
 droid_surfaceflinger_container*
 droid_setup_surfaceflinger_link()
@@ -224,22 +236,6 @@ droid_destroy_surface(
 delete pANWContainer;
 }
 
-
-void
-droid_tear_down_surfaceflinger_link(
-waffle::droid_surfaceflinger_container* pSFContainer)
-{
-if( pSFContainer == NULL)
-return;
-
-if (pSFContainer->composer_client != NULL) {
-pSFContainer->composer_client->dispose();
-pSFContainer->composer_client = NULL;
-}
-
-delete pSFContainer;
-}
-
 }; // namespace waffle
 
 extern "C" struct droid_surfaceflinger_container*
-- 
2.8.0

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


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

2016-04-05 Thread Emil Velikov
Calling dl_can_open() to determine whether the API is supported is
confusing and somewhat incorrect.

Instead, determine the supported APIs based on the string provided by
eglQueryString(EGL_CLIENT_APIS) and cross that with the minimum EGL
requirement (for eglBindAPI) for each one.

Note: we're added a minimum requirement of EGL 1.2 as things will
explode badly with versions prior to it.

v2: Completely reword commit message, finish implementation.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/egl/wegl_config.c  | 37 ++---
 src/waffle/egl/wegl_display.c | 63 ++-
 src/waffle/egl/wegl_display.h |  2 ++
 3 files changed, 48 insertions(+), 54 deletions(-)

diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index a79bc53..ef35b45 100644
--- a/src/waffle/egl/wegl_config.c
+++ b/src/waffle/egl/wegl_config.c
@@ -41,8 +41,6 @@ static bool
 check_context_attrs(struct wegl_display *dpy,
 const struct wcore_config_attrs *attrs)
 {
-struct wcore_platform *plat = dpy->wcore.platform;
-
 if (attrs->context_forward_compatible) {
 assert(attrs->context_api == WAFFLE_CONTEXT_OPENGL);
 assert(wcore_config_attrs_version_ge(attrs, 30));
@@ -57,6 +55,14 @@ check_context_attrs(struct wegl_display *dpy,
 
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
+if (!dpy->supports_opengl) {
+wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ "EGL 1.4 of later and 
eglQueryString(EGL_CLIENT_APIS) "
+ "== OpenGL are required in order to request an 
OpenGL "
+ "context.");
+return false;
+}
+
 if (!wcore_config_attrs_version_eq(attrs, 10) && 
!dpy->KHR_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "KHR_EXT_create_context is required in order to "
@@ -77,32 +83,11 @@ check_context_attrs(struct wegl_display *dpy,
 return false;
 }
 
-if (!plat->vtbl->dl_can_open(plat, WAFFLE_DL_OPENGL)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL library");
-return false;
-}
-
 return true;
 
 case WAFFLE_CONTEXT_OPENGL_ES1:
-if (!plat->vtbl->dl_can_open(plat, WAFFLE_DL_OPENGL_ES1)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES1 library");
-return false;
-}
-
-return true;
-
 case WAFFLE_CONTEXT_OPENGL_ES2:
-if (!plat->vtbl->dl_can_open(plat, WAFFLE_DL_OPENGL_ES2)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES2 library");
-return false;
-}
-
 return true;
-
 case WAFFLE_CONTEXT_OPENGL_ES3:
 if (!dpy->KHR_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
@@ -111,12 +96,6 @@ check_context_attrs(struct wegl_display *dpy,
 return false;
 }
 
-if (!plat->vtbl->dl_can_open(plat, WAFFLE_DL_OPENGL_ES3)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES3 library");
-return false;
-}
-
 return true;
 
 default:
diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index b3d0d88..c9368fc 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -24,6 +24,7 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include 
+#include 
 
 #include "wcore_error.h"
 #include "wcore_platform.h"
@@ -34,22 +35,46 @@
 #include "wegl_platform.h"
 
 static bool
-get_extensions(struct wegl_display *dpy)
+parse_version_extensions(struct wegl_display *dpy, EGLint major, EGLint minor)
 {
 struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
-const char *extensions = plat->eglQueryString(dpy->egl, EGL_EXTENSIONS);
+const char *apis = plat->eglQueryString(dpy->egl, EGL_CLIENT_APIS);
+const char *extensions;
 
-if (!extensions) {
-wegl_emit_error(plat, "eglQueryString(EGL_EXTENSIONS)");
+// Our minimum requirement - EGL 1.2 ...
+if (major != 1 || minor < 2) {
+wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ "EGL 1.2 or later is required");
 return false;
 }
 
-// wa

[waffle] [PATCH 08/13] glx: remove dl_can_open() logic from supports_api()

2016-04-05 Thread Emil Velikov
As mentioned earlier with similar EGL commit - one should two to keep
the two separate.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/glx/glx_config.c | 22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c
index 58d241e..fc88a7a 100644
--- a/src/waffle/glx/glx_config.c
+++ b/src/waffle/glx/glx_config.c
@@ -54,8 +54,6 @@ static bool
 glx_config_check_context_attrs(struct glx_display *dpy,
const struct wcore_config_attrs *attrs)
 {
-struct glx_platform *plat = glx_platform(dpy->wcore.platform);
-
 if (attrs->context_forward_compatible) {
 assert(attrs->context_api == WAFFLE_CONTEXT_OPENGL);
 assert(wcore_config_attrs_version_ge(attrs, 30));
@@ -104,12 +102,6 @@ glx_config_check_context_attrs(struct glx_display *dpy,
  "to create an OpenGL ES1 context");
 return false;
 }
-else if (!linux_platform_dl_can_open(plat->linux,
-WAFFLE_DL_OPENGL_ES1)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES1 library");
-return false;
-}
 
 return true;
 
@@ -122,12 +114,7 @@ glx_config_check_context_attrs(struct glx_display *dpy,
  "to create an OpenGL ES2 context");
 return false;
 }
-if (!linux_platform_dl_can_open(plat->linux,
-WAFFLE_DL_OPENGL_ES2)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES2 library");
-return false;
-}
+
 return true;
 
 case WAFFLE_CONTEXT_OPENGL_ES3:
@@ -138,13 +125,6 @@ glx_config_check_context_attrs(struct glx_display *dpy,
 return false;
 }
 
-if (!linux_platform_dl_can_open(plat->linux,
-WAFFLE_DL_OPENGL_ES3)) {
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES3 library");
-return false;
-}
-
 return true;
 
 default:
-- 
2.8.0

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


[waffle] [PATCH 06/13] wegl: add closing bracket in error message

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/egl/wegl_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index 88fce7a..b3d0d88 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -40,7 +40,7 @@ get_extensions(struct wegl_display *dpy)
 const char *extensions = plat->eglQueryString(dpy->egl, EGL_EXTENSIONS);
 
 if (!extensions) {
-wegl_emit_error(plat, "eglQueryString(EGL_EXTENSIONS");
+wegl_emit_error(plat, "eglQueryString(EGL_EXTENSIONS)");
 return false;
 }
 
-- 
2.8.0

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


[waffle] [PATCH 02/13] wgl: indent with spaces, not tabs

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/wgl/wgl_config.h   | 2 +-
 src/waffle/wgl/wgl_context.h  | 2 +-
 src/waffle/wgl/wgl_display.h  | 2 +-
 src/waffle/wgl/wgl_platform.h | 2 +-
 src/waffle/wgl/wgl_window.h   | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/waffle/wgl/wgl_config.h b/src/waffle/wgl/wgl_config.h
index 77f8905..58b352e 100644
--- a/src/waffle/wgl/wgl_config.h
+++ b/src/waffle/wgl/wgl_config.h
@@ -49,7 +49,7 @@ struct wgl_config {
 static inline struct wgl_config*
 wgl_config(struct wcore_config *wcore)
 {
-   return (struct wgl_config *)wcore;
+return (struct wgl_config *)wcore;
 }
 
 struct wcore_config*
diff --git a/src/waffle/wgl/wgl_context.h b/src/waffle/wgl/wgl_context.h
index c55ad58..72fd08b 100644
--- a/src/waffle/wgl/wgl_context.h
+++ b/src/waffle/wgl/wgl_context.h
@@ -41,7 +41,7 @@ struct wgl_context {
 static inline struct wgl_context*
 wgl_context(struct wcore_context *wcore)
 {
-   return (struct wgl_context *)wcore;
+return (struct wgl_context *)wcore;
 }
 
 struct wcore_context*
diff --git a/src/waffle/wgl/wgl_display.h b/src/waffle/wgl/wgl_display.h
index d0d94fe..cf05486 100644
--- a/src/waffle/wgl/wgl_display.h
+++ b/src/waffle/wgl/wgl_display.h
@@ -66,7 +66,7 @@ struct wgl_display {
 static inline struct wgl_display*
 wgl_display(struct wcore_display *wcore)
 {
-   return (struct wgl_display*)wcore;
+return (struct wgl_display*)wcore;
 }
 
 struct wcore_display*
diff --git a/src/waffle/wgl/wgl_platform.h b/src/waffle/wgl/wgl_platform.h
index a25d2f4..f514bad 100644
--- a/src/waffle/wgl/wgl_platform.h
+++ b/src/waffle/wgl/wgl_platform.h
@@ -46,7 +46,7 @@ struct wgl_platform {
 static inline struct wgl_platform*
 wgl_platform(struct wcore_platform *wcore)
 {
-   return (struct wgl_platform*)wcore;
+return (struct wgl_platform*)wcore;
 }
 
 struct wcore_platform*
diff --git a/src/waffle/wgl/wgl_window.h b/src/waffle/wgl/wgl_window.h
index 9b11509..43bea24 100644
--- a/src/waffle/wgl/wgl_window.h
+++ b/src/waffle/wgl/wgl_window.h
@@ -42,7 +42,7 @@ struct wgl_window {
 static inline struct wgl_window*
 wgl_window(struct wcore_window *wcore)
 {
-   return (struct wgl_window*)wcore;
+return (struct wgl_window*)wcore;
 }
 
 struct wcore_window*
-- 
2.8.0

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


[waffle] [PATCH 01/13] wgl: remove unneeded asserts

2016-04-05 Thread Emil Velikov
fwd_compat is already handled at the top of the function, while
version checks will become invalid with a later patch.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/wgl/wgl_config.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c
index 59a70a6..a21ba71 100644
--- a/src/waffle/wgl/wgl_config.c
+++ b/src/waffle/wgl/wgl_config.c
@@ -101,10 +101,6 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
 return true;
 
 case WAFFLE_CONTEXT_OPENGL_ES1:
-assert(wcore_config_attrs_version_eq(attrs, 10) ||
-   wcore_config_attrs_version_eq(attrs, 11));
-assert(!attrs->context_forward_compatible);
-
 if (!dpy->EXT_create_context_es_profile) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "WGL_EXT_create_context_es_profile is required "
@@ -115,9 +111,6 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
 return true;
 
 case WAFFLE_CONTEXT_OPENGL_ES2:
-assert(attrs->context_major_version == 2);
-assert(!attrs->context_forward_compatible);
-
 if (!dpy->EXT_create_context_es2_profile
 && !dpy->EXT_create_context_es_profile) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
@@ -130,8 +123,6 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
 return true;
 
 case WAFFLE_CONTEXT_OPENGL_ES3:
-assert(attrs->context_major_version == 3);
-
 if (!dpy->EXT_create_context_es_profile) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "WGL_EXT_create_context_es_profile is required "
-- 
2.8.0

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


[waffle] [PATCH 04/13] wcore: don't parse/validate the exact major/minor version

2016-04-05 Thread Emil Velikov
Keeping track what is and isn't the correct version at any given time
sounds unfeasible.

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

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

Let's do the sane thing and remove all the fine-grained validation from
waffle.

v2 (Suggestions from Chad):
 - Keep < 1.0 check to prevent WAFFLE_DONT_CARE as context version.
 - Update the unit tests alongside this intended functionality change.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/core/wcore_config_attrs.c  | 45 ---
 src/waffle/core/wcore_config_attrs_unittest.c | 64 ---
 2 files changed, 109 deletions(-)

diff --git a/src/waffle/core/wcore_config_attrs.c 
b/src/waffle/core/wcore_config_attrs.c
index 4a2cb5d..bb38fed 100644
--- a/src/waffle/core/wcore_config_attrs.c
+++ b/src/waffle/core/wcore_config_attrs.c
@@ -179,51 +179,6 @@ parse_context_version(struct wcore_config_attrs *attrs,
  "WAFFLE_CONTEXT_MINOR_VERSION must be >= 0");
 return false;
 }
-
-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_attrs_version_eq(attrs, 10) &&
-!wcore_config_attrs_version_eq(attrs, 11)) {
-wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
- "for OpenGL ES1, the requested context version "
- "must be 1.0 or 1.1");
-return false;
-}
-break;
-
-case WAFFLE_CONTEXT_OPENGL_ES2:
-if (attrs->context_major_version != 2) {
-wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
- "for OpenGL ES2, the requested major context "
- "version must be 2");
-return false;
-}
-break;
-
-case WAFFLE_CONTEXT_OPENGL_ES3:
-if (attrs->context_major_version != 3) {
-wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
- "for OpenGL ES3, the requested major context "
- "version must be 3");
-return false;
-}
-break;
-
-default:
-wcore_error_internal("attrs->context_api has bad value 0x%x",
- attrs->context_api);
-return false;
-}
-
 return true;
 }
 
diff --git a/src/waffle/core/wcore_config_attrs_unittest.c 
b/src/waffle/core/wcore_config_attrs_unittest.c
index 501e30f..cd745d1 100644
--- a/src/waffle/core/wcore_config_attrs_unittest.c
+++ b/src/waffle/core/wcore_config_attrs_unittest.c
@@ -445,21 +445,6 @@ test_wcore_config_attrs_gles11(void **state) {
 }
 
 static void
-test_wcore_config_attrs_gles12_is_bad(void **state) {
-struct test_state_wcore_config_attrs *ts = *state;
-
-const int32_t attrib_list[] = {
-WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL_ES1,
-WAFFLE_CONTEXT_MAJOR_VERSION,   1,
-WAFFLE_CONTEXT_MINOR_VERSION,   2,
-0,
-};
-
-assert_false(wcore_config_attrs_parse(attrib_list, >actual_attrs));
-assert_int_equal(wcore_error_get_code(), WAFFLE_ERROR_BAD_ATTRIBUTE);
-}
-
-static void
 test_wcore_config_attrs_gles20(void **state) {
 struct test_state_wcore_config_attrs *ts = *state;
 
@@ -492,21 +477,6 @@ test_wcore_config_attrs_gles21(void **state) {
 }
 
 static void
-test_wcore_config_attrs_gles2_with_version_30(void **state) {
-struct test_state_wcore_config_attrs *ts = *state;
-
-const int32_t attrib_list[] = {
-WAFFLE_CONTEXT_API, WAFFLE_CONTEXT_OPENGL_ES2,
-WAFFLE_CONTEXT_MAJOR_VERSION,   3,
-WAFFLE_CONTEXT_MINOR_VERSION,   0,
-0,
-};
-
-assert_false(wcore_config_attrs_parse(attrib_list, >actual_attrs));
-assert_int_equal(wcore_error_get_code(), WAFFLE_ERROR_BAD_ATTRIBUTE);
-}
-
-static void
 test_wcore_config_attrs_gles30(void **state) {
 struct test_state_wcore_config_attrs *ts = *state;
 
@@ -539,36 +509,6 @@ test_wcore_config_attrs_gles31(void **state) {
 }
 
 static void
-test_wcore_config_attrs_gles3_with_version_20(void **state) {
-struct test_state_wcore_config_attrs *ts = *state;
-
-const int32_t attrib_list[] = {
-WAFFLE_CON

[waffle] [PATCH 10/13] cgl: fold all ES handling in supports_api()

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/cgl/cgl_display.m | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/waffle/cgl/cgl_display.m b/src/waffle/cgl/cgl_display.m
index 1820e6c..1ec5e39 100644
--- a/src/waffle/cgl/cgl_display.m
+++ b/src/waffle/cgl/cgl_display.m
@@ -75,9 +75,7 @@ cgl_display_supports_context_api(struct wcore_display 
*wc_self,
 case WAFFLE_CONTEXT_OPENGL:
 return true;
 case WAFFLE_CONTEXT_OPENGL_ES1:
-return false;
 case WAFFLE_CONTEXT_OPENGL_ES2:
-return false;
 case WAFFLE_CONTEXT_OPENGL_ES3:
 return false;
 default:
-- 
2.8.0

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


[waffle] [PATCH 12/13] linux: cosmetic/coding style fixes

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/linux/linux_platform.c | 16 +---
 src/waffle/linux/linux_platform.h | 10 +++---
 2 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/waffle/linux/linux_platform.c 
b/src/waffle/linux/linux_platform.c
index 92c36c1..1cdf805 100644
--- a/src/waffle/linux/linux_platform.c
+++ b/src/waffle/linux/linux_platform.c
@@ -62,16 +62,14 @@ linux_platform_destroy(struct linux_platform *self)
 }
 
 static struct linux_dl*
-linux_platform_get_dl(
-struct linux_platform *self,
-int32_t waffle_dl)
+linux_platform_get_dl(struct linux_platform *self, int32_t waffle_dl)
 {
 struct linux_dl **dl;
 
 switch (waffle_dl) {
 case WAFFLE_DL_OPENGL: dl = >libgl;break;
 case WAFFLE_DL_OPENGL_ES1: dl = >libgles1; break;
-case WAFFLE_DL_OPENGL_ES2: dl = >libgles2; break;
+case WAFFLE_DL_OPENGL_ES2:
 case WAFFLE_DL_OPENGL_ES3: dl = >libgles2; break;
 default:
 assert(false);
@@ -85,9 +83,7 @@ linux_platform_get_dl(
 }
 
 bool
-linux_platform_dl_can_open(
-struct linux_platform *self,
-int32_t waffle_dl)
+linux_platform_dl_can_open(struct linux_platform *self, int32_t waffle_dl)
 {
 struct linux_dl *dl = NULL;
 WCORE_ERROR_DISABLED({
@@ -97,10 +93,8 @@ linux_platform_dl_can_open(
 }
 
 void*
-linux_platform_dl_sym(
-struct linux_platform *self,
-int32_t waffle_dl,
-const char *name)
+linux_platform_dl_sym(struct linux_platform *self, int32_t waffle_dl,
+  const char *name)
 {
 struct linux_dl *dl = linux_platform_get_dl(self, waffle_dl);
 if (!dl)
diff --git a/src/waffle/linux/linux_platform.h 
b/src/waffle/linux/linux_platform.h
index 4ba1652..b5617b4 100644
--- a/src/waffle/linux/linux_platform.h
+++ b/src/waffle/linux/linux_platform.h
@@ -38,12 +38,8 @@ linux_platform_destroy(struct linux_platform *self);
 
 /// @copydoc waffle_dl_can_open()
 bool
-linux_platform_dl_can_open(
-struct linux_platform *self,
-int32_t waffle_dl);
+linux_platform_dl_can_open(struct linux_platform *self, int32_t waffle_dl);
 
 void*
-linux_platform_dl_sym(
-struct linux_platform *self,
-int32_t waffle_dl,
-const char *name);
+linux_platform_dl_sym(struct linux_platform *self, int32_t waffle_dl,
+  const char *name);
-- 
2.8.0

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


[waffle] [PATCH 09/13] waffle: replace wcore_error_internal with assert()

2016-04-05 Thread Emil Velikov
The upper layer (api/core) already checks and bails out if the provided
value for context_api is invalid. Change the condition to an assert so
that we can catch it as (if) we extend the API and forget to update one
of the backends.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/cgl/cgl_display.m | 3 +--
 src/waffle/core/wcore_config_attrs.c | 3 +--
 src/waffle/egl/wegl_config.c | 6 ++
 src/waffle/egl/wegl_context.c| 6 ++
 src/waffle/egl/wegl_display.c| 3 +--
 src/waffle/glx/glx_config.c  | 3 +--
 src/waffle/glx/glx_display.c | 3 +--
 src/waffle/nacl/nacl_display.c   | 3 +--
 src/waffle/wgl/wgl_config.c  | 3 +--
 src/waffle/wgl/wgl_display.c | 3 +--
 10 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/src/waffle/cgl/cgl_display.m b/src/waffle/cgl/cgl_display.m
index 015ca32..1820e6c 100644
--- a/src/waffle/cgl/cgl_display.m
+++ b/src/waffle/cgl/cgl_display.m
@@ -81,8 +81,7 @@ cgl_display_supports_context_api(struct wcore_display 
*wc_self,
 case WAFFLE_CONTEXT_OPENGL_ES3:
 return false;
 default:
-wcore_error_internal("waffle_context_api has bad value %#x",
- context_api);
+assert(false);
 return false;
 }
 }
diff --git a/src/waffle/core/wcore_config_attrs.c 
b/src/waffle/core/wcore_config_attrs.c
index 8f362a9..c7c02d4 100644
--- a/src/waffle/core/wcore_config_attrs.c
+++ b/src/waffle/core/wcore_config_attrs.c
@@ -151,8 +151,7 @@ set_context_version_default(struct wcore_config_attrs 
*attrs)
 attrs->context_minor_version = 0;
 return true;
 default:
-wcore_error_internal("attrs->context_api has bad value 0x%x",
- attrs->context_api);
+assert(false);
 return false;
 }
 }
diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index ef35b45..bfa0b95 100644
--- a/src/waffle/egl/wegl_config.c
+++ b/src/waffle/egl/wegl_config.c
@@ -99,8 +99,7 @@ check_context_attrs(struct wegl_display *dpy,
 return true;
 
 default:
-wcore_error_internal("context_api has bad value %#x",
- attrs->context_api);
+assert(false);
 return false;
 }
 }
@@ -164,8 +163,7 @@ choose_real_config(struct wegl_display *dpy,
 attrib_list[renderable_index] = EGL_OPENGL_ES3_BIT_KHR;
 break;
 default:
-wcore_error_internal("waffle_context_api has bad value %#x",
- attrs->context_api);
+assert(false);
 return NULL;
 }
 
diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index f4ee6cd..fff8f94 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -49,8 +49,7 @@ bind_api(struct wegl_platform *plat, int32_t 
waffle_context_api)
 ok &= plat->eglBindAPI(EGL_OPENGL_ES_API);
 break;
 default:
-wcore_error_internal("waffle_context_api has bad value #x%x",
- waffle_context_api);
+assert(false);
 return false;
 }
 
@@ -131,8 +130,7 @@ create_real_context(struct wegl_config *config,
 break;
 
 default:
-wcore_error_internal("waffle_context_api has bad value %#x",
- waffle_context_api);
+assert(false);
 return EGL_NO_CONTEXT;
 }
 
diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c
index c9368fc..f05815f 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -147,8 +147,7 @@ wegl_display_supports_context_api(struct wcore_display 
*wc_dpy,
 case WAFFLE_CONTEXT_OPENGL_ES3:
 return dpy->KHR_create_context;
 default:
-wcore_error_internal("waffle_context_api has bad value %#x",
- waffle_context_api);
+assert(false);
 return false;
 }
 }
diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c
index fc88a7a..94fe040 100644
--- a/src/waffle/glx/glx_config.c
+++ b/src/waffle/glx/glx_config.c
@@ -128,8 +128,7 @@ glx_config_check_context_attrs(struct glx_display *dpy,
 return true;
 
 default:
-wcore_error_internal("context_api has bad value %#x",
- attrs->context_api);
+assert(false);
 return false;
 }
 }
diff --git a/src/waffle/glx/glx_display.c b/src/waffle/glx/glx_display.c
index 24e967c..a0a8782 100644
--- a/src/waffle/glx/glx_display.c
+++ b/src/waffle/glx/glx_display.c
@@ -128,8 +128,7 @@ glx_display_supp

[waffle] [PATCH 05/13] wcore: indent with spaces, not tabs

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/core/wcore_config_attrs.c | 32 +++-
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/waffle/core/wcore_config_attrs.c 
b/src/waffle/core/wcore_config_attrs.c
index bb38fed..8f362a9 100644
--- a/src/waffle/core/wcore_config_attrs.c
+++ b/src/waffle/core/wcore_config_attrs.c
@@ -77,27 +77,25 @@ check_keys(const int32_t attrib_list[])
 }
 
 static bool
-parse_bool(const int32_t attrib_list[],
-  int32_t attrib_name,
-  bool *value,
-  bool default_value)
+parse_bool(const int32_t attrib_list[], int32_t attrib_name,
+   bool *value, bool default_value)
 {
-   int32_t raw_value;
+int32_t raw_value;
 
-   wcore_attrib_list32_get_with_default(attrib_list, attrib_name,
+wcore_attrib_list32_get_with_default(attrib_list, attrib_name,
_value, default_value);
 
-   if (raw_value == WAFFLE_DONT_CARE) {
-   *value = default_value;
-   } else if (raw_value == true || raw_value == false) {
-   *value = raw_value;
-   } else {
-   wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
-"%s has bad value 0x%x. "
-"Must be true(1), false(0), or 
WAFFLE_DONT_CARE(-1)",
-wcore_enum_to_string(attrib_name), 
raw_value);
-   return false;
-   }
+if (raw_value == WAFFLE_DONT_CARE) {
+*value = default_value;
+} else if (raw_value == true || raw_value == false) {
+*value = raw_value;
+} else {
+wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE,
+"%s has bad value 0x%x. "
+"Must be true(1), false(0), or WAFFLE_DONT_CARE(-1)",
+wcore_enum_to_string(attrib_name), raw_value);
+return false;
+}
 
 return true;
 }
-- 
2.8.0

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


[waffle] [PATCH 0/3] Pre OpenGL 3.0, ARB_create_context and waffle

2016-04-05 Thread Emil Velikov
Hi all,

A few fixes, all maint material considering we all agree on the idea.

Long story short, piglit explicitly feeds in a requested version in the 
range 10-15 which waffle interprets as "I must use 
{GLX,WGL}_ARB_create_context". Jose and Ilia managed to convince me that 
this should really be handled by waffle, so here is the result.

The lot can be found in branch for-upstream/ARB_create_context-for-pre-3.0
over at https://github.com/evelikov/waffle

-Emil

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


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

2016-04-05 Thread Emil Velikov
Spotted while attemting to use classic swrast with waffle.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 tests/functional/gl_basic_test.c | 36 +++-
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 19b0dac..d6b14d4 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -34,6 +34,7 @@
 /// 4. Verify the window contents with glReadPixels.
 /// 5. Tear down all waffle state.
 
+#include 
 #include 
 #include 
 #include 
@@ -103,6 +104,7 @@ typedef float   GLclampf;   /* single precision 
float in [0,1] */
 typedef double  GLdouble;   /* double precision float */
 typedef double  GLclampd;   /* double precision float in [0,1] */
 
+#define GL_VERSION  0x1F02
 #define GL_UNSIGNED_BYTE0x1401
 #define GL_UNSIGNED_INT 0x1405
 #define GL_FLOAT0x1406
@@ -123,6 +125,7 @@ typedef double  GLclampd;   /* double precision 
float in [0,1] */
 #endif
 
 static GLenum (APIENTRY *glGetError)(void);
+static const GLubyte *(APIENTRY *glGetString)(GLenum name);
 static void (APIENTRY *glGetIntegerv)(GLenum pname, GLint *params);
 static void (APIENTRY *glClearColor)(GLclampf red,
  GLclampf green,
@@ -301,20 +304,35 @@ gl_basic_draw__(struct gl_basic_draw_args__ args)
 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(waffle_make_current(dpy, window, ctx));
 
-GLint context_flags = 0;
-if (context_forward_compatible || context_debug) {
-glGetIntegerv(GL_CONTEXT_FLAGS, _flags);
-}
+const char *version_str;
+int major, dummy, count;
 
-if (context_forward_compatible) {
-ASSERT_TRUE(context_flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT);
-}
+ASSERT_GL(version_str = (const char *) glGetString(GL_VERSION));
+ASSERT_TRUE(version_str != NULL);
 
-if (context_debug) {
-ASSERT_TRUE(context_flags & GL_CONTEXT_FLAG_DEBUG_BIT);
+while (*version_str != '\0' && !isdigit(*version_str))
+version_str++;
+
+count = sscanf(version_str, "%d.%d", , );
+ASSERT_TRUE(count == 2);
+
+if (waffle_context_api == WAFFLE_CONTEXT_OPENGL && major >= 3) {
+GLint context_flags = 0;
+if (context_forward_compatible || context_debug) {
+glGetIntegerv(GL_CONTEXT_FLAGS, _flags);
+}
+
+if (context_forward_compatible) {
+ASSERT_TRUE(context_flags & 
GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT);
+}
+
+if (context_debug) {
+ASSERT_TRUE(context_flags & GL_CONTEXT_FLAG_DEBUG_BIT);
+}
 }
 
 // Draw.
-- 
2.8.0

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


[waffle] [PATCH 2/3] wgl: don't use ARB_create_context with pre 3.0 contexts

2016-04-05 Thread Emil Velikov
Direct port of previous commit.

Cc: Jose Fonseca <jfons...@vmware.com>
Cc: Ilia Mirkin <imir...@alum.mit.edu>
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 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(-)

diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c
index 59a70a6..29a9b7c 100644
--- a/src/waffle/wgl/wgl_config.c
+++ b/src/waffle/wgl/wgl_config.c
@@ -32,6 +32,7 @@
 #include "wcore_error.h"
 
 #include "wgl_config.h"
+#include "wgl_context.h"
 #include "wgl_display.h"
 #include "wgl_error.h"
 #include "wgl_platform.h"
@@ -73,11 +74,11 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
 
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
-if (!wcore_config_attrs_version_eq(attrs, 10) && 
!dpy->ARB_create_context) {
+if (wgl_context_needs_arb_create_context(attrs) &&
+!dpy->ARB_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "WGL_ARB_create_context is required in order to "
- "request an OpenGL version not equal to the 
default "
- "value 1.0");
+ "request an OpenGL version greater or equal than 
3.0");
 return false;
 }
 else if (wcore_config_attrs_version_ge(attrs, 32) && 
!dpy->ARB_create_context_profile) {
diff --git a/src/waffle/wgl/wgl_context.c b/src/waffle/wgl/wgl_context.c
index dd45f81..125ad7d 100644
--- a/src/waffle/wgl/wgl_context.c
+++ b/src/waffle/wgl/wgl_context.c
@@ -152,7 +152,17 @@ wgl_context_create_native(struct wgl_config *config,
 HGLRC real_share_ctx = share_ctx ? share_ctx->hglrc : NULL;
 HGLRC hglrc;
 
-if (dpy->ARB_create_context) {
+// Use ARB_create_context when we have
+// - OpenGL version 1.0, or
+// - OpenGL version 3.0 or greater, or
+// - OpenGL with fwd_compat, or
+// - Debug context
+//
+// The first one of the four is optional, the remainder hard requirement
+// for the use of ARB_create_context.
+if (dpy->ARB_create_context &&
+(wcore_config_attrs_version_eq(>wcore.attrs, 10) ||
+ wgl_context_needs_arb_create_context(>wcore.attrs))) {
 bool ok;
 
 // Choose a large size to prevent accidental overflow.
diff --git a/src/waffle/wgl/wgl_context.h b/src/waffle/wgl/wgl_context.h
index c55ad58..6d74aeb 100644
--- a/src/waffle/wgl/wgl_context.h
+++ b/src/waffle/wgl/wgl_context.h
@@ -27,6 +27,7 @@
 
 #include 
 
+#include "wcore_config_attrs.h"
 #include "wcore_context.h"
 #include "wcore_util.h"
 
@@ -51,3 +52,17 @@ wgl_context_create(struct wcore_platform *wc_plat,
 
 bool
 wgl_context_destroy(struct wcore_context *wc_self);
+
+static inline bool
+wgl_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;
+}
-- 
2.8.0

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


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

2016-04-05 Thread Emil Velikov
This way if the user requests GL pre 3.0 context which lacks the
flags/extra bits which require ARB_create_context one can safely fall
back to the normal/legacy entry point.

This resolves piglits on non 3.0 capable drivers such as classic swrast,
nouveau_vieux and alike.

Cc: Jose Fonseca <jfons...@vmware.com>
Cc: Ilia Mirkin <imir...@alum.mit.edu>
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 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(-)

diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c
index 7792aa0..5d02bc3 100644
--- a/src/waffle/glx/glx_config.c
+++ b/src/waffle/glx/glx_config.c
@@ -32,6 +32,7 @@
 #include "wcore_error.h"
 
 #include "glx_config.h"
+#include "glx_context.h"
 #include "glx_display.h"
 #include "glx_platform.h"
 #include "glx_wrappers.h"
@@ -70,11 +71,11 @@ glx_config_check_context_attrs(struct glx_display *dpy,
 
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
-if (!wcore_config_attrs_version_eq(attrs, 10) && 
!dpy->ARB_create_context) {
+if (glx_context_needs_arb_create_context(attrs) &&
+!dpy->ARB_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "GLX_ARB_create_context is required in order to "
- "request an OpenGL version not equal to the 
default "
- "value 1.0");
+ "request an OpenGL version greater or equal than 
3.0");
 return false;
 }
 else if (wcore_config_attrs_version_ge(attrs, 32) && 
!dpy->ARB_create_context_profile) {
diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c
index 1f9290b..8d532d3 100644
--- a/src/waffle/glx/glx_context.c
+++ b/src/waffle/glx/glx_context.c
@@ -169,7 +169,17 @@ glx_context_create_native(struct glx_config *config,
 struct glx_display *dpy = glx_display(config->wcore.display);
 struct glx_platform *platform = glx_platform(dpy->wcore.platform);
 
-if (dpy->ARB_create_context) {
+// Use ARB_create_context when we have
+// - OpenGL version 1.0, or
+// - OpenGL version 3.0 or greater, or
+// - OpenGL with fwd_compat, or
+// - Debug context
+//
+// The first one of the four is optional, the remainder hard requirement
+// for the use of ARB_create_context.
+if (dpy->ARB_create_context &&
+(wcore_config_attrs_version_eq(>wcore.attrs, 10) ||
+ glx_context_needs_arb_create_context(>wcore.attrs))) {
 bool ok;
 
 // Choose a large size to prevent accidental overflow.
diff --git a/src/waffle/glx/glx_context.h b/src/waffle/glx/glx_context.h
index bb2a4dd..b471b0e 100644
--- a/src/waffle/glx/glx_context.h
+++ b/src/waffle/glx/glx_context.h
@@ -29,6 +29,7 @@
 
 #include 
 
+#include "wcore_config_attrs.h"
 #include "wcore_context.h"
 #include "wcore_util.h"
 
@@ -55,3 +56,18 @@ glx_context_destroy(struct wcore_context *wc_self);
 
 union waffle_native_context*
 glx_context_get_native(struct wcore_context *wc_self);
+
+
+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;
+}
-- 
2.8.0

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


Re: [waffle] [PATCH] add robust access context support

2016-04-04 Thread Emil Velikov
Hi Bas,

Big thanks for adding this. It's been on my radar for a while but
considering no mesa drivers supported it I never got to it.

Top-level question, can we please split this into a separate patches -
waffle.h + core, egl, glx, wgl.

On 4 April 2016 at 12:31, Bas Nieuwenhuizen  wrote:
> Signed-off-by: Bas Nieuwenhuizen 
> ---
>  include/waffle/waffle.h  |  2 ++
>  src/waffle/core/wcore_config_attrs.c |  3 +++
>  src/waffle/core/wcore_config_attrs.h |  1 +
>  src/waffle/core/wcore_util.c |  1 +
>  src/waffle/egl/wegl_config.c | 16 
>  src/waffle/egl/wegl_context.c|  6 ++
>  src/waffle/egl/wegl_display.c|  3 ++-
>  src/waffle/egl/wegl_display.h|  1 +
>  src/waffle/glx/glx_config.c  |  7 +++
>  src/waffle/glx/glx_context.c |  4 
>  src/waffle/glx/glx_display.c |  1 +
>  src/waffle/glx/glx_display.h |  1 +
>  src/waffle/wgl/wgl_config.c  |  7 +++
>  src/waffle/wgl/wgl_context.c |  4 
>  src/waffle/wgl/wgl_display.h |  1 +
>  15 files changed, 57 insertions(+), 1 deletion(-)
>
> diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
> index df0218e..cd13119 100644
> --- a/include/waffle/waffle.h
> +++ b/include/waffle/waffle.h
> @@ -142,6 +142,8 @@ enum waffle_enum {
>  WAFFLE_CONTEXT_DEBUG= 0x0216,
>  #endif
>
> +WAFFLE_CONTEXT_ROBUST_ACCESS= 0x0217,
Please the documentation as well:

man/waffle_config.3.xml
man/waffle_context.3.xml
man/waffle_enums.3.xml


> --- 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..00cd251 100644
> --- a/src/waffle/egl/wegl_context.c
> +++ b/src/waffle/egl/wegl_context.c
> @@ -112,6 +112,8 @@ create_real_context(struct wegl_config *config,
>  return EGL_NO_CONTEXT;
>  }
>  }
> +if (attrs->context_robust)
> +context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
Can you please move this next to the context_forward_compatible one.
Perhaps with a similar assert.


> --- a/src/waffle/egl/wegl_display.c
> +++ b/src/waffle/egl/wegl_display.c
> @@ -49,7 +49,8 @@ get_extensions(struct wegl_display *dpy)
>  // pending emission.
>  assert(wcore_error_get_code() == 0);
>
> -dpy->KHR_create_context = waffle_is_extension_in_string(extensions, 
> "EGL_KHR_create_context");
> +dpy->EXT_create_context_robustness = 
> waffle_is_extension_in_string(extensions, 
> "EGL_EXT_create_context_robustness");
> +dpy->KHR_create_context= 
> waffle_is_extension_in_string(extensions, "EGL_KHR_create_context");
>
Please keep drop the whilespace alignment.


> --- a/src/waffle/glx/glx_display.c
> +++ b/src/waffle/glx/glx_display.c
> @@ -63,6 +63,7 @@ glx_display_set_extensions(struct glx_display *self)
>
>  self->ARB_create_context = 
> waffle_is_extension_in_string(s, "GLX_ARB_create_context");
>  self->ARB_create_context_profile = 
> waffle_is_extension_in_string(s, "GLX_ARB_create_context_profile");
> +self->ARB_create_context_robustness  = 
> waffle_is_extension_in_string(s, "GLX_ARB_create_context_robustness");
We are missing analogous hunk for WGL, aren't we ?


Have you looked at CGL/NaCl support ? Afaics both of them lack similar
API, correct ? If so one should add
wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM...) to
{nacl,cgl}_config.[cm].

Tapani, do you know if NaCl has functionality analogous to
GLX_ARB_create_context_robustness ?

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


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

2016-01-08 Thread Emil Velikov
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/  ?

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


Re: [waffle] [PATCH 03/12] core: store current context in wcore_display

2016-01-08 Thread Emil Velikov
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/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c
> index 138974d..4161ce8 100644
> --- a/src/waffle/api/waffle_gl_misc.c
> +++ b/src/waffle/api/waffle_gl_misc.c
> @@ -94,10 +94,13 @@ waffle_make_current(
>  if (!api_check_entry(obj_list, len))
>  return false;
>
> -return api_platform->vtbl->make_current(api_platform,
> -wc_dpy,
> -wc_window,
> -wc_ctx);
> +bool ok = api_platform->vtbl->make_current(api_platform,
> +   wc_dpy,
> +   wc_window,
> +   wc_ctx);
> +if (ok)
> +wc_dpy->current_context = wc_ctx;
> +return ok;
>  }
>
>  WAFFLE_API void*
> 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();
>
>  self->platform = platform;
> +self->current_context = NULL;
We calloc the struct so we should need this ?

>
>  if (self->api.display_id == 0) {
>  fprintf(stderr, "waffle: error: internal counter wrapped to 0\n");
> diff --git a/src/waffle/core/wcore_display.h b/src/waffle/core/wcore_display.h
> index 6e374e3..1ccff6f 100644
> --- a/src/waffle/core/wcore_display.h
> +++ b/src/waffle/core/wcore_display.h
> @@ -37,12 +37,14 @@
>  extern "C" {
>  #endif
>
> +struct wcore_context;
>  struct wcore_display;
>  struct wcore_platform;
>  union waffle_native_display;
>
>  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.

-Emil
___
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 Emil Velikov
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 ?

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

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


Re: [waffle] [PATCH 05/12] waffle: add waffle_display_info_json()

2016-01-08 Thread Emil Velikov
On 6 January 2016 at 21:56, Frank Henigman  wrote:
> Duplicate wflinfo functionality in the API, with the difference that the
> information is returned in JSON form.
> The function has a parameter for including platform-specific information,
> but it is ignored for now.
>
> Signed-off-by: Frank Henigman 
> ---
>  include/waffle/waffle.h |   5 +
>  man/waffle_display.3.xml|  19 +++
>  src/waffle/api/waffle_display.c | 284 
> +++-
>  src/waffle/waffle.def.in|   1 +
>  4 files changed, 308 insertions(+), 1 deletion(-)
>
> diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h
> index df0218e..1800399 100644
> --- a/include/waffle/waffle.h
> +++ b/include/waffle/waffle.h
> @@ -214,6 +214,11 @@ bool
>  waffle_display_supports_context_api(struct waffle_display *self,
>  int32_t context_api);
>
> +#if WAFFLE_API_VERSION >= 0x0106
> +char*
> +waffle_display_info_json(struct waffle_display *self, bool platform_too);
The function does not work solely with the display, but it requires a
(bound) context. Thus it does not really fit waffle naming scheme. I'm
afraid that I'm short of suggestions though (barring my "returning
json formatted data sounds iffy, lets use tokens" rant from earlier)


> +#endif
> +
>  union waffle_native_display*
>  waffle_display_get_native(struct waffle_display *self);
>
> diff --git a/man/waffle_display.3.xml b/man/waffle_display.3.xml
> index 9896247..5358472 100644
> --- a/man/waffle_display.3.xml
> +++ b/man/waffle_display.3.xml
> @@ -24,6 +24,7 @@
>  waffle_display
>  waffle_display_connect
>  waffle_display_disconnect
> +waffle_display_info_json
>  waffle_display_supports_context_api
>  waffle_display_get_native
>  class waffle_display
> @@ -58,6 +59,12 @@ struct waffle_display;
>
>
>
> +char* 
> waffle_display_info_json
> +struct waffle_display 
> *self
> +bool platform_info
> +  
> +
> +  
>  bool 
> waffle_display_supports_context_api
>  struct waffle_display 
> *self
>  int32_t context_api
> @@ -129,6 +136,18 @@ struct waffle_display;
>
>
>
> +waffle_display_info_json()
> +
> +  
> +Return a JSON string containing information about the current 
> context on the given display, including Waffle platform and API, GL 
> version/vendor/renderer and extensions.
> +If platform_info is true, 
> platform-specific information (such as GLX or EGL versions and extensions) 
> will be included as available.
> +Returns NULL on error.
> +The string should be deallocated with 
> free3.
> +  
> +
> +  
> +
> +  
>  
> waffle_display_supports_context_api()
>  
>
> diff --git a/src/waffle/api/waffle_display.c b/src/waffle/api/waffle_display.c
> index fa19462..7abe2ef 100644
> --- a/src/waffle/api/waffle_display.c
> +++ b/src/waffle/api/waffle_display.c
> @@ -23,13 +23,61 @@
>  // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
> USE
>  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>
> +#include 
> +#include 
> +
>  #include "api_priv.h"
>
> -#include "wcore_error.h"
> +#include "json.h"
> +
> +#include "wcore_context.h"
>  #include "wcore_display.h"
> +#include "wcore_error.h"
>  #include "wcore_platform.h"
>  #include "wcore_util.h"
>
> +typedef unsigned int GLint;
> +typedef unsigned int GLenum;
> +typedef unsigned char GLubyte;
> +
> +enum {
> +// Copied from .
> +GL_NO_ERROR = 0,
> +
> +GL_CONTEXT_FLAGS = 0x821e,
> +GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT = 0x0001,
> +GL_CONTEXT_FLAG_DEBUG_BIT  = 0x0002,
> +GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB  = 0x0004,
> +
> +GL_VENDOR  = 0x1F00,
> +GL_RENDERER= 0x1F01,
> +GL_VERSION = 0x1F02,
> +GL_EXTENSIONS  = 0x1F03,
> +GL_NUM_EXTENSIONS  = 0x821D,
> +GL_SHADING_LANGUAGE_VERSION= 0x8B8C,
> +};
> +
> +#ifndef _WIN32
> +#define APIENTRY
> +#else
> +#ifndef APIENTRY
> +#define APIENTRY __stdcall
> +#endif
> +#endif
> +
> +static GLenum (APIENTRY *glGetError)(void);
> +static void (APIENTRY *glGetIntegerv)(GLenum pname, GLint *params);
> +static const GLubyte * (APIENTRY *glGetString)(GLenum name);
> +static const GLubyte * (APIENTRY *glGetStringi)(GLenum name, GLint i);
> +
> +#if defined(__GNUC__)
> +#define NORETURN __attribute__((noreturn))
> +#elif defined(_MSC_VER)
> +#define NORETURN __declspec(noreturn)
> +#else
> +#define NORETURN
> +#endif
> +
>  WAFFLE_API struct waffle_display*
>  waffle_display_connect(const char *name)
>  {
> @@ -90,6 +138,240 @@ waffle_display_supports_context_api(
>  

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

2016-01-06 Thread Emil Velikov
On 5 January 2016 at 19:46,   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(-)
>
> diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c
> index 4b9..8ee95c6 100644
> --- a/src/utils/wflinfo.c
> +++ b/src/utils/wflinfo.c
> @@ -460,6 +460,39 @@ parse_version(const char *version)
>  return (major * 10) + minor;
>  }
>
> +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
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 03/29] tests/gl_basic: introduce --platform param

2016-01-06 Thread Emil Velikov
From: Emil Velikov <emil.veli...@collabora.com>

This will allow us to selectively run the tests we want, and even run
the sets in parallel.

Fixes #33: https://github.com/waffle-gl/waffle/issues/33
Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
 tests/functional/CMakeLists.txt  |  51 +--
 tests/functional/gl_basic_test.c | 193 ---
 2 files changed, 221 insertions(+), 23 deletions(-)

diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt
index f1388b2..91d1273 100644
--- a/tests/functional/CMakeLists.txt
+++ b/tests/functional/CMakeLists.txt
@@ -32,19 +32,52 @@ add_executable(gl_basic_test
 target_link_libraries(gl_basic_test
 ${waffle_libname}
 waffle_test
+${GETOPT_LIBRARIES}
 )
 
-add_custom_target(gl_basic_test_run
-COMMAND gl_basic_test
-)
+# 
+# Per platform functionality tests
+# 
 
-add_dependencies(check-func gl_basic_test_run)
+function(add_functest platform_name)
+add_custom_target(gl_basic_test_${platform_name}_run
+COMMAND gl_basic_test --platform ${platform_name}
+)
+add_dependencies(check-func gl_basic_test_${platform_name}_run)
 
-if(VALGRIND_EXECUTABLE)
-add_custom_target(valgrind_gl_basic_test_run
-DEPENDS gl_basic_test
-COMMAND ${VALGRIND_EXECUTABLE} $
+if(VALGRIND_EXECUTABLE)
+add_custom_target(valgrind_gl_basic_test_${platform_name}_run
+DEPENDS gl_basic_test
+COMMAND ${VALGRIND_EXECUTABLE} $ 
--platform ${platform_name}
 )
 
-add_dependencies(valgrind-check-func valgrind_gl_basic_test_run)
+add_dependencies(valgrind-check-func 
valgrind_gl_basic_test_${platform_name}_run)
+endif()
+endfunction()
+
+
+if(waffle_on_mac)
+add_functest(cgl)
+endif()
+
+if(waffle_on_linux)
+if(waffle_has_glx)
+add_functest(glx)
+endif()
+
+if(waffle_has_wayland)
+add_functest(wayland)
+endif()
+
+if(waffle_has_x11_egl)
+add_functest(x11_egl)
+endif()
+
+#if(waffle_has_gbm)
+#add_functest(gbm)
+#endif()
+endif()
+
+if(waffle_on_windows)
+add_functest(wgl)
 endif()
diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 19b0dac..d19b8ae 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -34,9 +34,11 @@
 /// 4. Verify the window contents with glReadPixels.
 /// 5. Tear down all waffle state.
 
+#include  // for va_start, va_end
 #include 
 #include 
 #include 
+#include 
 #if !defined(_WIN32)
 #include 
 #else
@@ -1086,13 +1088,48 @@ testsuite_wgl(void)
 }
 #endif // WAFFLE_HAS_WGL
 
-static void
-usage_error(void)
+
+static const char *usage_message =
+"Usage:\n"
+"gl_basic_test  [Options]\n"
+"\n"
+"Description:\n"
+"Run the basic functionality tests.\n"
+"\n"
+"Required Parameter:\n"
+"-p, --platform\n"
+"One of: cgl, glx, wayland, wgl or x11_egl\n"
+"\n"
+"Options:\n"
+"-h, --help\n"
+"Print gl_basic_test usage information.\n"
+;
+
+#if defined(__GNUC__)
+#define NORETURN __attribute__((noreturn))
+#elif defined(_MSC_VER)
+#define NORETURN __declspec(noreturn)
+#else
+#define NORETURN
+#endif
+
+static void NORETURN
+write_usage_and_exit(FILE *f, int exit_code)
 {
-fprintf(stderr, "gl_basic_test: usage error\n");
-exit(1);
+fprintf(f, "%s", usage_message);
+exit(exit_code);
 }
 
+enum {
+OPT_PLATFORM = 'p',
+OPT_HELP = 'h',
+};
+
+static const struct option get_opts[] = {
+{ .name = "platform",   .has_arg = required_argument, .val = 
OPT_PLATFORM },
+{ .name = "help",   .has_arg = no_argument,   .val = 
OPT_HELP },
+};
+
 #ifdef _WIN32
 static DWORD __stdcall
 worker_thread(LPVOID lpParam)
@@ -1199,27 +1236,155 @@ run_testsuite(void (*testsuite)(void))
 
 #endif // _WIN32
 
+static void NORETURN
+usage_error_printf(const char *fmt, ...)
+{
+fprintf(stderr, "gl_basic_test usage error: ");
+
+if (fmt) {
+va_list ap;
+va_start(ap, fmt);
+vfprintf(stderr, fmt, ap);
+va_end(ap);
+fprintf(stderr, " ");
+}
+
+fprintf(stderr, "(see gl_basic_test --help)\n");
+exit(EXIT_FAILURE);
+}
+
+struct enum_map {
+int i;
+const char *s;
+};
+
+static const struct enum_map platform_map[] = {
+{WAFFLE_PLATFORM_CGL,   "cgl",  },
+{WAFFLE_PLATFORM_GLX,   "glx"   },
+{WAFFLE_PLATFORM_WAYLAND,   "wayland"   },
+{WAFFLE_PLATFORM_WGL,   &qu

[waffle] [PATCH 09/29] tests/gl_basic: add test_glXX_core() test macro

2016-01-06 Thread Emil Velikov
... and use it to minimise the duplication across the file.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 tests/functional/gl_basic_test.c | 168 ---
 1 file changed, 52 insertions(+), 116 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 9ccf822..f8cf2a1 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -387,6 +387,15 @@ static void 
test_gl_basic_gl##waffle_version##_fwdcompat(void)  \
   .expect_error=WAFFLE_##error);\
 }
 
+#define test_glXX_core(waffle_version, error)   \
+static void test_gl_basic_gl##waffle_version##_core(void)   \
+{   \
+gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,   \
+  .version=waffle_version,  \
+  .profile=WAFFLE_CONTEXT_CORE_PROFILE, \
+  .expect_error=WAFFLE_##error);\
+}
+
 test_XX_rgb(gl, OPENGL, NO_ERROR)
 test_XX_rgba(gl, OPENGL, NO_ERROR)
 
@@ -423,12 +432,7 @@ test_glXX_fwdcompat(30, NO_ERROR)
 test_glXX(31, NO_ERROR)
 test_glXX_fwdcompat(31, NO_ERROR)
 
-TEST(gl_basic, all_but_cgl_gl32_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=32,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
+test_glXX_core(32, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gl32_core_fwdcompat)
 {
@@ -438,40 +442,11 @@ TEST(gl_basic, all_but_cgl_gl32_core_fwdcompat)
   .forward_compatible=true);
 }
 
-TEST(gl_basic, all_but_cgl_gl33_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=33,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
-
-TEST(gl_basic, all_but_cgl_gl40_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=40,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
-
-TEST(gl_basic, all_but_cgl_gl41_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=41,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
-
-TEST(gl_basic, all_but_cgl_gl42_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=42,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
-
-TEST(gl_basic, all_but_cgl_gl43_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=43,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
+test_glXX_core(33, NO_ERROR)
+test_glXX_core(40, NO_ERROR)
+test_glXX_core(41, NO_ERROR)
+test_glXX_core(42, NO_ERROR)
+test_glXX_core(43, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gl32_compat)
 {
@@ -609,52 +584,12 @@ test_glXX_fwdcompat(30, ERROR_UNSUPPORTED_ON_PLATFORM)
 test_glXX(31, NO_ERROR)
 test_glXX_fwdcompat(31, ERROR_UNSUPPORTED_ON_PLATFORM)
 
-TEST(gl_basic, cgl_gl32_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=32,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE);
-}
-
-TEST(gl_basic, cgl_gl33_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=33,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
-TEST(gl_basic, cgl_gl40_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=40,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
-TEST(gl_basic, cgl_gl41_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=41,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
-TEST(gl_basic, cgl_gl42_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=42,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
-TEST(gl_basic, cgl_gl43_core)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=43,
-  .profile=WAFFLE_CONTEXT_CORE_PROFILE,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
+test_glXX_core(32, NO_ERROR)
+test_glXX_core(33, ERROR_UNSUPPORTED_ON_PLATFORM)
+test_glXX_core(40, ERROR_UNSUPPORTED_ON_PLATFORM)
+test_glXX_core(41, ERROR_UNSUPPORTED_ON_PLATFORM)
+test_glXX_core(42, ERROR_UNSUPPORTED_ON_PLATFORM)
+test_glXX_core(43, ERROR_UNSUPPORTED_ON_PLATFORM)
 
 TEST(gl_basic, cgl_gl32_compat)
 {
@@ -732,12 +667,12 @@ testsuite_cgl(void)
 TEST_RUN(gl_basic, gl31);
 TEST_RUN(gl_basic, gl31_fwdcompat);
 
-TEST_RUN(gl_basic, cgl_gl32_core);
-TEST_RUN(gl_basic, cgl_gl33_core);
-TEST_RUN(gl_basic, cgl_gl40_core);
-TEST_RUN(gl

[waffle] [PATCH 06/29] tests/gl_basic: add test_XX_rgb{,a} macro

2016-01-06 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 tests/functional/gl_basic_test.c | 141 ---
 1 file changed, 56 insertions(+), 85 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 55d078d..03c4a0b 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -355,17 +355,24 @@ gl_basic_draw__(struct gl_basic_draw_args__ args)
 // List of tests common to all platforms.
 //
 
-TEST(gl_basic, all_gl_rgb)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL);
+#define test_XX_rgb(context_api, waffle_api, error) \
+static void test_gl_basic_##context_api##_rgb(void) \
+{   \
+gl_basic_draw(.api=WAFFLE_CONTEXT_##waffle_api, \
+  .expect_error=WAFFLE_##error);\
 }
 
-TEST(gl_basic, all_gl_rgba)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .alpha=true);
+#define test_XX_rgba(context_api, waffle_api, error)\
+static void test_gl_basic_##context_api##_rgba(void)\
+{   \
+gl_basic_draw(.api=WAFFLE_CONTEXT_##waffle_api, \
+  .alpha=true,  \
+  .expect_error=WAFFLE_##error);\
 }
 
+test_XX_rgb(gl, OPENGL, NO_ERROR)
+test_XX_rgba(gl, OPENGL, NO_ERROR)
+
 TEST(gl_basic, all_gl10)
 {
 gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
@@ -558,16 +565,8 @@ TEST(gl_basic, all_but_cgl_gl43_compat)
   .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE);
 }
 
-TEST(gl_basic, all_but_cgl_gles1_rgb)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1);
-}
-
-TEST(gl_basic, all_but_cgl_gles1_rgba)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1,
-  .alpha=true);
-}
+test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR)
+test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gles10)
 {
@@ -590,16 +589,8 @@ TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute)
   .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE);
 }
 
-TEST(gl_basic, all_but_cgl_gles2_rgb)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2);
-}
-
-TEST(gl_basic, all_but_cgl_gles2_rgba)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2,
-  .alpha=true);
-}
+test_XX_rgb(gles2, OPENGL_ES2, NO_ERROR)
+test_XX_rgba(gles2, OPENGL_ES2, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gles20)
 {
@@ -614,16 +605,8 @@ TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute)
   .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE);
 }
 
-TEST(gl_basic, all_but_cgl_gles3_rgb)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3);
-}
-
-TEST(gl_basic, all_but_cgl_gles3_rgba)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3,
-  .alpha=true);
-}
+test_XX_rgb(gles3, OPENGL_ES3, NO_ERROR)
+test_XX_rgba(gles3, OPENGL_ES3, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gles30)
 {
@@ -787,9 +770,8 @@ testsuite_cgl(void)
 TEST_RUN(gl_basic, cgl_gles1_unsupported);
 TEST_RUN(gl_basic, cgl_gles2_unsupported);
 
-TEST_RUN2(gl_basic, cgl_gl_rgb, all_gl_rgb);
-TEST_RUN2(gl_basic, cgl_gl_rgba, all_gl_rgba);
-
+TEST_RUN(gl_basic, gl_rgb);
+TEST_RUN(gl_basic, gl_rgba);
 TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported);
 TEST_RUN(gl_basic, cgl_gl_fwdcompat_bad_attribute);
 
@@ -832,8 +814,8 @@ testsuite_glx(void)
 {
 TEST_RUN(gl_basic, glx_init);
 
-TEST_RUN2(gl_basic, glx_gl_rgb, all_gl_rgb);
-TEST_RUN2(gl_basic, glx_gl_rgba, all_gl_rgb);
+TEST_RUN(gl_basic, gl_rgb);
+TEST_RUN(gl_basic, gl_rgba);
 TEST_RUN2(gl_basic, glx_gl_debug, all_but_cgl_gl_debug);
 TEST_RUN2(gl_basic, glx_gl_fwdcompat_bad_attribute, 
all_but_cgl_gl_fwdcompat_bad_attribute);
 
@@ -867,23 +849,20 @@ testsuite_glx(void)
 TEST_RUN2(gl_basic, glx_gl42_compat, all_but_cgl_gl42_compat);
 TEST_RUN2(gl_basic, glx_gl43_compat, all_but_cgl_gl43_compat);
 
-TEST_RUN2(gl_basic, glx_gles1_rgb, all_but_cgl_gles1_rgb);
-TEST_RUN2(gl_basic, glx_gles1_rgba, all_but_cgl_gles1_rgba);
+TEST_RUN(gl_basic, gles1_rgb);
+TEST_RUN(gl_basic, gles1_rgba);
 TEST_RUN2(gl_basic, glx_gles1_fwdcompat_bad_attribute, 
all_but_cgl_gles1_fwdcompat_bad_attribute);
-
 TEST_RUN2(gl_basic, glx_gles10, all_but_cgl_gles10);
 TEST_RUN2(gl_basic, glx_gles11, all_but_cgl_gles10);
 
-TEST_RUN2(gl_basic, glx_gles2_rgb, all_but_cgl_gles2_rgb);
-TEST_RUN2(gl_basic, glx_gles2_rgba, all_but_cgl_gles2_rgba);
+TEST_RUN(gl_basic, gles2_rgb);
+TEST_RUN(gl_basic, gles2_rgba);
 TEST_RUN2(gl_basic, glx_gles2_fwdcompat_bad_attribute, 
all_but_cgl_gles2_fwdcompat_bad_attribute);
-
 TEST_RUN2(gl_basic, glx_gles20, all_but_cgl_gles20);
 
-TES

[waffle] [PATCH 01/29] wayland: add wl_proxy_create wrapper

2016-01-06 Thread Emil Velikov
libwayland has broken its ABI by replacing wl_proxy_create +
wl_proxy_marshal with wfl_wl_proxy_marshal_constructor with commit
853c24e6998(client: Introduce functions to allocate and marshal proxies
atomically).

Add the wrapper to keep compatibility with wayland 1.3.90 and earlier.

Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 src/waffle/wayland/wayland_wrapper.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/waffle/wayland/wayland_wrapper.h 
b/src/waffle/wayland/wayland_wrapper.h
index 40a581a..e2c96ca 100644
--- a/src/waffle/wayland/wayland_wrapper.h
+++ b/src/waffle/wayland/wayland_wrapper.h
@@ -66,6 +66,10 @@ int
 (*wfl_wl_proxy_add_listener)(struct wl_proxy *proxy,
  void (**implementation)(void), void *data);
 
+struct wl_proxy *
+(*wfl_wl_proxy_create)(struct wl_proxy *factory,
+   const struct wl_interface *interface);
+
 void
 (*wfl_wl_proxy_marshal)(struct wl_proxy *p, uint32_t opcode, ...);
 
@@ -90,5 +94,6 @@ struct wl_proxy *
 #define wl_display_roundtrip (*wfl_wl_display_roundtrip)
 #define wl_proxy_destroy (*wfl_wl_proxy_destroy)
 #define wl_proxy_add_listener (*wfl_wl_proxy_add_listener)
+#define wl_proxy_create (*wfl_wl_proxy_create)
 #define wl_proxy_marshal (*wfl_wl_proxy_marshal)
 #define wl_proxy_marshal_constructor (*wfl_wl_proxy_marshal_constructor)
-- 
2.6.2

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


[waffle] [PATCH 05/29] tests/gl_basic: use actual/expect arrays for the pixel storage

2016-01-06 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 tests/functional/gl_basic_test.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index c95ae39..55d078d 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -69,7 +69,8 @@ static const uint8_tGREEN_UB= 0x00;
 static const uint8_tBLUE_UB = 0xff;
 static const uint8_tALPHA_UB= 0xff;
 
-static uint8_t pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT];
+static uint8_t actual_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT];
+static uint8_t expect_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT];
 
 #define ASSERT_GL(statement) \
 do { \
@@ -136,7 +137,17 @@ static void (APIENTRY *glReadPixels)(GLint x, GLint y,
 static void
 testgroup_gl_basic_setup(void)
 {
-memset(pixels, 0, sizeof(pixels));
+for (int y = 0 ; y < WINDOW_HEIGHT; ++y) {
+for (int x = 0; x < WINDOW_WIDTH; ++x) {
+uint8_t *p = _pixels[4 * (y * WINDOW_WIDTH + x)];
+p[0] = RED_UB;
+p[1] = GREEN_UB;
+p[2] = BLUE_UB;
+p[3] = ALPHA_UB;
+}
+}
+
+memset(actual_pixels, 0x99, sizeof(actual_pixels));
 }
 
 static void
@@ -321,21 +332,15 @@ gl_basic_draw__(struct gl_basic_draw_args__ args)
 ASSERT_GL(glClear(GL_COLOR_BUFFER_BIT));
 ASSERT_GL(glReadPixels(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT,
GL_RGBA, GL_UNSIGNED_BYTE,
-   pixels));
+   actual_pixels));
 ASSERT_TRUE(waffle_window_swap_buffers(window));
 
 // Probe color buffer.
 //
 // Fail at first failing pixel. If the draw fails, we don't want a terminal
 // filled with error messages.
-for (int y = 0 ; y < WINDOW_HEIGHT; ++y) {
-for (int x = 0; x < WINDOW_WIDTH; ++x) {
-uint8_t *p = [4 * (y * WINDOW_WIDTH + x)];
-ASSERT_TRUE(p[0] == RED_UB);
-ASSERT_TRUE(p[1] == GREEN_UB);
-ASSERT_TRUE(p[2] == BLUE_UB);
-ASSERT_TRUE(p[3] == ALPHA_UB);
-}
+for (i = 0 ; i < sizeof(actual_pixels); ++i) {
+ASSERT_TRUE(actual_pixels[i] == expect_pixels[i]);
 }
 
 // Teardown.
-- 
2.6.2

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


[waffle] [PATCH 07/29] tests/gl_basic: add test_glXX() macro

2016-01-06 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 tests/functional/gl_basic_test.c | 192 +++
 1 file changed, 73 insertions(+), 119 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index 03c4a0b..a14ce32 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -370,56 +370,25 @@ static void test_gl_basic_##context_api##_rgba(void)  
  \
   .expect_error=WAFFLE_##error);\
 }
 
-test_XX_rgb(gl, OPENGL, NO_ERROR)
-test_XX_rgba(gl, OPENGL, NO_ERROR)
-
-TEST(gl_basic, all_gl10)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=10);
-}
-
-TEST(gl_basic, all_gl11)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=11);
-}
-
-TEST(gl_basic, all_gl12)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=12);
-}
-
-TEST(gl_basic, all_gl13)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=13);
-}
-
-TEST(gl_basic, all_gl14)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=14);
-}
-
-TEST(gl_basic, all_gl15)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=15);
+#define test_glXX(waffle_version, error)\
+static void test_gl_basic_gl##waffle_version(void)  \
+{   \
+gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,   \
+  .version=waffle_version,  \
+  .expect_error=WAFFLE_##error);\
 }
 
-TEST(gl_basic, all_gl20)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=20);
-}
+test_XX_rgb(gl, OPENGL, NO_ERROR)
+test_XX_rgba(gl, OPENGL, NO_ERROR)
 
-TEST(gl_basic, all_gl21)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=21);
-}
+test_glXX(10, NO_ERROR)
+test_glXX(11, NO_ERROR)
+test_glXX(12, NO_ERROR)
+test_glXX(13, NO_ERROR)
+test_glXX(14, NO_ERROR)
+test_glXX(15, NO_ERROR)
+test_glXX(20, NO_ERROR)
+test_glXX(21, NO_ERROR)
 
 TEST(gl_basic, all_gl21_fwdcompat_bad_attribute)
 {
@@ -447,11 +416,7 @@ TEST(gl_basic, all_but_cgl_gl_fwdcompat_bad_attribute)
   .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE);
 }
 
-TEST(gl_basic, all_but_cgl_gl30)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=30);
-}
+test_glXX(30, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gl30_fwdcompat)
 {
@@ -460,11 +425,7 @@ TEST(gl_basic, all_but_cgl_gl30_fwdcompat)
   .forward_compatible=true);
 }
 
-TEST(gl_basic, all_but_cgl_gl31)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=31);
-}
+test_glXX(31, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gl31_fwdcompat)
 {
@@ -654,18 +615,8 @@ TEST(gl_basic, cgl_gl_fwdcompat_bad_attribute)
   .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE);
 }
 
-TEST(gl_basic, cgl_gl30)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=30,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
-TEST(gl_basic, cgl_gl31)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
-  .version=31);
-}
+test_glXX(30, ERROR_UNSUPPORTED_ON_PLATFORM)
+test_glXX(31, NO_ERROR)
 
 TEST(gl_basic, cgl_gl32_core)
 {
@@ -775,17 +726,18 @@ testsuite_cgl(void)
 TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported);
 TEST_RUN(gl_basic, cgl_gl_fwdcompat_bad_attribute);
 
-TEST_RUN2(gl_basic, cgl_gl10, all_gl10);
-TEST_RUN2(gl_basic, cgl_gl11, all_gl11);
-TEST_RUN2(gl_basic, cgl_gl12, all_gl12);
-TEST_RUN2(gl_basic, cgl_gl13, all_gl13);
-TEST_RUN2(gl_basic, cgl_gl14, all_gl14);
-TEST_RUN2(gl_basic, cgl_gl15, all_gl15);
-TEST_RUN2(gl_basic, cgl_gl20, all_gl20);
-TEST_RUN2(gl_basic, cgl_gl21, all_gl21);
+TEST_RUN(gl_basic, gl10);
+TEST_RUN(gl_basic, gl11);
+TEST_RUN(gl_basic, gl12);
+TEST_RUN(gl_basic, gl13);
+TEST_RUN(gl_basic, gl14);
+TEST_RUN(gl_basic, gl15);
+TEST_RUN(gl_basic, gl20);
+TEST_RUN(gl_basic, gl21);
 TEST_RUN2(gl_basic, cgl_gl21_fwdcompat_bad_attribute, 
all_gl21_fwdcompat_bad_attribute);
-TEST_RUN(gl_basic, cgl_gl30);
-TEST_RUN(gl_basic, cgl_gl31);
+
+TEST_RUN(gl_basic, gl30);
+TEST_RUN(gl_basic, gl31);
 
 TEST_RUN(gl_basic, cgl_gl32_core);
 TEST_RUN(gl_basic, cgl_gl33_core);
@@ -819,19 +771,19 @@ testsuite_glx(void)
 TEST_RUN2(gl_basic, glx_gl_debug, all_but_cgl_gl_debug);
 TEST_RUN2(gl_basic, glx_gl_fwdcompat_bad_attribute, 
all_but_cgl_gl_fwdcompat_bad_attribute);
 
-TEST_RUN2(gl_basic, glx_gl10, all_gl10);
-TEST_RUN2(gl_basic, glx_gl11, all_gl11);
-TEST_RUN2(gl_basic, glx_gl12, all_gl12);
-TEST_RUN2(gl_basic, glx_gl13, all_gl13);
-TEST_RUN2(gl

[waffle] [PATCH 12/29] tests/gl_basic: add test_glesXX() macro

2016-01-06 Thread Emil Velikov
Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
---
 tests/functional/gl_basic_test.c | 93 
 1 file changed, 36 insertions(+), 57 deletions(-)

diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c
index f753276..10b9c71 100644
--- a/tests/functional/gl_basic_test.c
+++ b/tests/functional/gl_basic_test.c
@@ -415,6 +415,14 @@ static void 
test_gl_basic_gl##waffle_version##_compat(void) \
   .expect_error=WAFFLE_##error);\
 }
 
+#define test_glesXX(api_version, waffle_version, error) \
+static void test_gl_basic_gles##waffle_version(void)\
+{   \
+gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES##api_version,   \
+  .version=waffle_version,  \
+  .expect_error=WAFFLE_##error);\
+}
+
 test_XX_rgb(gl, OPENGL, NO_ERROR)
 test_XX_rgba(gl, OPENGL, NO_ERROR)
 
@@ -468,20 +476,8 @@ test_glXX_compat(43, NO_ERROR)
 
 test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR)
 test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR)
-
-TEST(gl_basic, all_but_cgl_gles10)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1,
-  .version=10,
-  .alpha=true);
-}
-
-TEST(gl_basic, all_but_cgl_gles11)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1,
-  .version=11,
-  .alpha=true);
-}
+test_glesXX(1, 10, NO_ERROR)
+test_glesXX(1, 11, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute)
 {
@@ -492,12 +488,7 @@ TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute)
 
 test_XX_rgb(gles2, OPENGL_ES2, NO_ERROR)
 test_XX_rgba(gles2, OPENGL_ES2, NO_ERROR)
-
-TEST(gl_basic, all_but_cgl_gles20)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2,
-  .version=20);
-}
+test_glesXX(2, 20, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute)
 {
@@ -508,12 +499,7 @@ TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute)
 
 test_XX_rgb(gles3, OPENGL_ES3, NO_ERROR)
 test_XX_rgba(gles3, OPENGL_ES3, NO_ERROR)
-
-TEST(gl_basic, all_but_cgl_gles30)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3,
-  .version=30);
-}
+test_glesXX(3, 30, NO_ERROR)
 
 TEST(gl_basic, all_but_cgl_gles3_fwdcompat_bad_attribute)
 {
@@ -529,18 +515,6 @@ TEST(gl_basic, cgl_init)
 gl_basic_init(WAFFLE_PLATFORM_CGL);
 }
 
-TEST(gl_basic, cgl_gles1_unsupported)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
-TEST(gl_basic, cgl_gles2_unsupported)
-{
-gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2,
-  .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
-}
-
 TEST(gl_basic, cgl_gl_debug_is_unsupported)
 {
 gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL,
@@ -575,14 +549,14 @@ test_glXX_compat(41, ERROR_UNSUPPORTED_ON_PLATFORM)
 test_glXX_compat(42, ERROR_UNSUPPORTED_ON_PLATFORM)
 test_glXX_compat(43, ERROR_UNSUPPORTED_ON_PLATFORM)
 
+test_glesXX(1, 10, ERROR_UNSUPPORTED_ON_PLATFORM)
+test_glesXX(2, 20, ERROR_UNSUPPORTED_ON_PLATFORM)
+
 static void
 testsuite_cgl(void)
 {
 TEST_RUN(gl_basic, cgl_init);
 
-TEST_RUN(gl_basic, cgl_gles1_unsupported);
-TEST_RUN(gl_basic, cgl_gles2_unsupported);
-
 TEST_RUN(gl_basic, gl_rgb);
 TEST_RUN(gl_basic, gl_rgba);
 TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported);
@@ -617,6 +591,9 @@ testsuite_cgl(void)
 TEST_RUN(gl_basic, gl41_compat);
 TEST_RUN(gl_basic, gl42_compat);
 TEST_RUN(gl_basic, gl43_compat);
+
+TEST_RUN(gl_basic, gles10);
+TEST_RUN(gl_basic, gles20);
 }
 #endif // WAFFLE_HAS_CGL
 
@@ -668,19 +645,19 @@ testsuite_glx(void)
 
 TEST_RUN(gl_basic, gles1_rgb);
 TEST_RUN(gl_basic, gles1_rgba);
+TEST_RUN(gl_basic, gles10);
+TEST_RUN(gl_basic, gles11);
 TEST_RUN2(gl_basic, glx_gles1_fwdcompat_bad_attribute, 
all_but_cgl_gles1_fwdcompat_bad_attribute);
-TEST_RUN2(gl_basic, glx_gles10, all_but_cgl_gles10);
-TEST_RUN2(gl_basic, glx_gles11, all_but_cgl_gles10);
 
 TEST_RUN(gl_basic, gles2_rgb);
 TEST_RUN(gl_basic, gles2_rgba);
+TEST_RUN(gl_basic, gles20);
 TEST_RUN2(gl_basic, glx_gles2_fwdcompat_bad_attribute, 
all_but_cgl_gles2_fwdcompat_bad_attribute);
-TEST_RUN2(gl_basic, glx_gles20, all_but_cgl_gles20);
 
 TEST_RUN(gl_basic, gles3_rgb);
 TEST_RUN(gl_basic, gles3_rgba);
+TEST_RUN(gl_basic, gles30);
 TEST_RUN2(gl_basic, glx_gles3_fwdcompat_bad_attribute, 
all_but_cgl_gles3_fwdcompat_bad_attribute);
-TEST_RUN2(gl_basic, glx_gles30, all_but_cgl_gles30);
 }
 #endif // WAFFLE_HAS_GLX
 
@@ -732,19 +709,19 @@ testsuite_wayland(void)
 
 TEST_RUN(gl_basic, gles1_rgb);
 TEST_RUN(gl_basic, gles1_rgba);
+TEST_RUN(gl_basic, gles10);
+TEST_RUN(gl_basic, gles11);
 TEST_RUN2(gl

  1   2   3   4   >