[ANNOUNCE] Waffle 1.8.1

2024-07-30 Thread Emil Velikov
The Waffle bugfix release 1.8.1 is now available.

What is new in this release:
  - Fix the meson build to avoid (over)linking against dependencies
  - Reinstate support for wayland/wayland-scanner older than 1.20
  - Run the clang-format CI stage as applicable, on the correct commits

The source is available at:

  https://waffle.freedesktop.org/files/release/waffle-1.8.1/waffle-1.8.1.tar.xz

You can also get the current source directly from the git
repository. See https://waffle.freedesktop.org for details.



Changes since 1.8.0:

Emil Velikov (11):
  release: Publish 1.8.0
  waffle: Bump post-release version to 1.8.90
  editorconfig: expand meson files, handle yml
  gitlab-ci: run clang-format only on MRs
  clang-format: correctly track the commit range in CI
  clang-format: pass correct reference to git-clang-format
  Revert "waffle: Bump post-release version to 1.8.90"
  meson: properly set the partial_dependency(es)
  clang-format: fix the post-merge commit range
  wayland: restore support for pre wayland 1.20
  waffle: Bump version to 1.8.1




signature.asc
Description: PGP signature


[waffle] [ANNOUNCE] Waffle 1.7.3

2023-09-25 Thread Emil Velikov
The Waffle bugfix release 1.7.3 is now available.

What is new in this release:
  - cgl: fix warnings and compilation issues
  - meson: drop lib prefix for waffle-1.dll

The source is available at:

  https://waffle.freedesktop.org/files/release/waffle-1.7.3/waffle-1.7.3.tar.xz

You can also get the current source directly from the git
repository. See https://waffle.freedesktop.org for details.



Changes since 1.7.2:

Emil Velikov (3):
  Use a static waffle.def
  meson: drop the libwaffle-1.dll lib prefix on windows
  waffle: Bump version to 1.7.3

Yurii Kolesnykov (2):
  Fix build on macOS by fixing a typo
  Add cflag to fix macOS build


[waffle] [ANNOUNCE] Waffle 1.8.0

2023-09-25 Thread Emil Velikov
The Waffle feature release 1.8.0 is now available.

What is new in this release:
  - meson: require meson v0.53, various wayland-scanner fixes
  - cmake: deprecate in favour of meson
  - ci: add lint stage, resolve intermittent Xvfb failures
  - nacl: remove the backend, error out if requested at build
  - cgl: fix warnings and compilation issues
  - wflinfo: add zsh completion, simplify the bash completion
  - tests: rework and de-duplicate the per-platform handling

The source is available at:

  https://waffle.freedesktop.org/files/release/waffle-1.8.0/waffle-1.8.0.tar.xz

You can also get the current source directly from the git
repository. See https://waffle.freedesktop.org for details.



Changes since 1.7.0:

Alexander Kanavin (1):
  meson.build: request native wayland-scanner

Alyssa Ross (1):
  meson: find wayland.xml from wayland-scanner.pc

David Heidelberg (1):
  www: improve layout a bit

Dylan Baker (1):
  meson: use override_dependency and override_find_program

Emil Velikov (73):
  waffle: Bump post-release version to 1.7.90
  doc: Add release notes for 1.7.0
  release: Publish Waffle 1.7.0
  release: Fixup 1.7.0 URLs
  wflinfo: doc: use space separator for longopts
  wflinfo: bash-completion: remove quirky handling
  wflinfo: add zsh completion
  gitlab-ci: use xvfb -noreset
  wayland: silence waffle 1.7 deprecation warnings
  third_party/threads: initialize abs_time
  tests/gl_basic_test: silence maybe-uninitialized warn
  waffle: consistently set WAFFLE_API_VERSION
  waffle: use same version API across programs
  core: use Wpointer-arith safe container_of
  core/tests: correct function type
  wflinfo: fixup sign-compare warnings
  tests/gl_basic_test: silence implicit-fallthrough warn
  tests/gl_basic_test: silence sign-compare warning
  meson: enable all the warnings
  gitlab-ci: flip the error on any warning
  Revert "gbm: work around mesa linkage issue"
  gbm: use libdrm instead of libudev
  clang-format: add config file
  gitlab-ci: add clang-format stage
  gitlab-ci: move the clang-format/git comment further up
  editorconfig: add initial file
  tree: update website references
  doc: update references to new git location
  tree: update maintainer Chad -> Emil
  man: meson: add all dependencies
  meson: omit bash completion, with custom prefix
  www: kill off the manpages
  www: add XDC 2012 presentation notes and videos
  doc: add notes/announce from the website branch
  www: use the in-tree release-notes, tarballs branch
  gitlab-ci: remove trailing whitespace
  gitlab-ci: correctly copy the www root files
  www: add couple more sections to acknowledgements
  editorconfig: https all the links
  README, HACKING: https all the links
  cmake: http -> https where applicable
  doc: http -> https where applicable
  waffle: https all the links
  www: https all the links
  gitlab-ci: correctly handle the release notes
  gitlab-ci: actually use the tarball branch
  gitlab-ci: trigger website updates on .gitlab-ci.yml changes
  gitlab-ci: update container to bullseye
  meson: use get_variable() update to meson 0.51
  meson: remove always true meson.version >= 0.46
  meson: generate cmake files only on Windows
  meson: produce summary(), require meson 0.53
  doc: Add release notes for 1.7.1
  release: Publish 1.7.1
  meson: don't run TLS checks on mingw
  wgl: remove unused dummy wgl_error.[ch]
  all: use format(gnu_printf), enable in mingw
  doc: Add release notes for 1.7.2
  release: Publish 1.7.2
  tests/gl_basic_test: remove #undef test* instances
  tests/gl_basic_test: shuffle expect_error further up
  tests/gl_basic_test: s/test_gl_basic_/test_/
  tests/gl_basic_test: rework rgb tests
  tests/gl_basic_test: rework the ctx flags tests
  tests/gl_basic_test: rework the version tests
  tests/gl_basic_test: print error if waffle_init() fails
  tests/gl_basic_test: rework the testsuite entrypoint
  tests/gl_basic_test: sprinkle some clang-format goodness
  Use a static waffle.def
  meson: drop the libwaffle-1.dll lib prefix on windows
  cmake: deprecate cmake in favour of meson
  Error out when nacl is requested, reinstate WAFFLE_PLATFORM_NACL
  waffle: Bump version to 1.8.0

Fabrice Fontaine (2):
  cmake: drop C++ dependency
  meson: drop C++ dependency

Gert Wollny (2):
  formatting: add add some annotations to not reformat macros
  waffle: Add support for create a context with reset notification

Jason Ekstrand (1):
  wgbm: Don't destroy a surface if init fails

Jose Fonseca (1):
  gitlab-ci: Build and package with MinGW cross-compilers.

Matt Turner (1):
  surfa

[waffle] [ANNOUNCE] Waffle 1.7.2

2023-03-05 Thread Emil Velikov
The Waffle bugfix release 1.7.2 is now available.

What is new in this release:
  - all: use format(gnu_printf), enable in mingw
  - meson: don't run TLS checks on mingw
  - wgl: remove unused dummy wgl_error.[ch]

The source is available at:

  https://waffle.freedesktop.org/files/release/waffle-1.7.2/waffle-1.7.2.tar.xz

You can also get the current source directly from the git
repository. See https://waffle.freedesktop.org for details.



Changes since 1.7.1:

Emil Velikov (4):
  meson: don't run TLS checks on mingw
  wgl: remove unused dummy wgl_error.[ch]
  all: use format(gnu_printf), enable in mingw
  waffle: Bump version to 1.7.2


[waffle] [ANNOUNCE] Waffle 1.7.1

2023-03-02 Thread Emil Velikov
The Waffle bugfix release 1.7.1 is now available.

What is new in this release:
  - cmake: pass deps' cflags to the build
  - gbm: fix crash when platform lacks modifier support
  - gitlab-ci: stabilise CI runs under X
  - gitlab-ci: add more warnings, make all warnings fatal
  - gitlab-ci: update to bullseye
  - meson: add override_* support, when using waffle as submodule
  - meson: skip installing bash completion when custom prefix is used
  - meson: silence deprecation warnings
  - meson: generate cmake files only on Windows
  - meson: find wayland.xml from wayland-scanner.pc
  - misc: zsh completion
  - misc: fix dozens of compiler warnings
  - misc: update website references
  - wayland: fix build against wayland 1.20

The source is available at:

  https://waffle.freedesktop.org/files/release/waffle-1.7.1/waffle-1.7.1.tar.xz

You can also get the current source directly from the git
repository. See https://waffle.freedesktop.org for details.



Changes since 1.7.0:

Alyssa Ross (1):
  meson: find wayland.xml from wayland-scanner.pc

Dylan Baker (1):
  meson: use override_dependency and override_find_program

Emil Velikov (25):
  doc: Add release notes for 1.7.0
  wflinfo: add zsh completion
  gitlab-ci: use xvfb -noreset
  wayland: silence waffle 1.7 deprecation warnings
  third_party/threads: initialize abs_time
  tests/gl_basic_test: silence maybe-uninitialized warn
  waffle: consistently set WAFFLE_API_VERSION
  waffle: use same version API across programs
  core: use Wpointer-arith safe container_of
  core/tests: correct function type
  wflinfo: fixup sign-compare warnings
  tests/gl_basic_test: silence implicit-fallthrough warn
  tests/gl_basic_test: silence sign-compare warning
  meson: enable all the warnings
  gitlab-ci: flip the error on any warning
  tree: update website references
  doc: update references to new git location
  tree: update maintainer Chad -> Emil
  man: meson: add all dependencies
  meson: omit bash completion, with custom prefix
  gitlab-ci: update container to bullseye
  meson: use get_variable() update to meson 0.51
  meson: remove always true meson.version >= 0.46
  meson: generate cmake files only on Windows
  waffle: Bump version to 1.7.1

Jason Ekstrand (1):
  wgbm: Don't destroy a surface if init fails

Jose Fonseca (1):
  gitlab-ci: Build and package with MinGW cross-compilers.

Philipp Zabel (1):
  wayland: fix build against version 1.20

Romain Naour (1):
  cmake: forward cflags from *.pc files to waffle cflags

Simon McVittie (9):
  waffle_dl: Fix missing format string parameter
  waffle_window_create2: Fix mismatch between format string and parameter
  Mark printf-like functions with the appropriate gcc attribute
  meson: Enable format-string-related compiler warnings
  wflinfo: Print absence of GL context flags correctly
  wflinfo: Make context_flags more const-correct
  meson: Detect non-const-correct uses of string constants
  wflinfo: Move context_flags array into constant data section
  examples, wflinfo: Add missing NORETURN attributes


[waffle] [ANNOUNCE] waffle 1.7.0

2021-03-07 Thread Emil Velikov
Hi all,

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

Notable changes since 1.6.0:
 - wayland: Support for the xdg-shell protocol.
 - surfaceless: Implement window resize
 - GLX/WGL: Behave correctly in the presence of ARB_create_context
 - tests: Rework and extend test suite
 - cmake: Bump requirement to 2.8.12
 - man: Spelling and associated fixes.
 - GBM: Pass valid arguments to gbm_surface_create_with_modifiers
 - apple: Build fixes

https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.7.0/waffle-1.7.0.tar.xz
https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.7.0/waffle-1.7.0.tar.xz.asc
https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.7.0/waffle-1.7.0.sha256sums
https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.7.0/waffle-1.7.0.sha256sums.asc
___
waffle mailing list
waffle@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] waffle 1.6.3

2021-02-24 Thread Emil Velikov
Hi all,

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

Fixes since 1.6.2
 - Recreate release tarballs from tag

https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.6.3/waffle-1.6.3.tar.xz
https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.6.3/waffle-1.6.3.tar.xz.asc
https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.6.3/waffle-1.6.3.sha256sums
https://mesa.pages.freedesktop.org/waffle/files/release/waffle-1.6.3/waffle-1.6.3.sha256sums.asc

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


[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] waffle: add waffle_get_current_*() functions to waffle.def.in

2016-11-11 Thread Emil Velikov
On 11 November 2016 at 14:29, Brian Paul  wrote:
> On 11/11/2016 06:17 AM, Emil Velikov wrote:
>>
>> On 10 November 2016 at 21:46, Brian Paul  wrote:
>>>
>>> This fixes the MinGW build.
>>> ---
>>>   src/waffle/waffle.def.in | 5 -
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/waffle/waffle.def.in b/src/waffle/waffle.def.in
>>> index 75a56c0..5803398 100644
>>> --- a/src/waffle/waffle.def.in
>>> +++ b/src/waffle/waffle.def.in
>>> @@ -32,4 +32,7 @@ EXPORTS
>>>   waffle_attrib_list_length
>>>   waffle_attrib_list_get
>>>   waffle_attrib_list_get_with_default
>>> -waffle_attrib_list_update
>>> \ No newline at end of file
>>> +waffle_attrib_list_update
>>> +waffle_get_current_display
>>> +waffle_get_current_window
>>> +waffle_get_current_context
>>
>> Reviewed-by: Emil Velikov 
>
>
> Can you (or Chad?) commit this for me?
>
Done. Had no idea I can push stuff - seems to be a recent thing ;-)

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


Re: [waffle] [PATCH] waffle: add waffle_get_current_*() functions to waffle.def.in

2016-11-11 Thread Emil Velikov
On 10 November 2016 at 21:46, Brian Paul  wrote:
> This fixes the MinGW build.
> ---
>  src/waffle/waffle.def.in | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/waffle/waffle.def.in b/src/waffle/waffle.def.in
> index 75a56c0..5803398 100644
> --- a/src/waffle/waffle.def.in
> +++ b/src/waffle/waffle.def.in
> @@ -32,4 +32,7 @@ EXPORTS
>  waffle_attrib_list_length
>  waffle_attrib_list_get
>  waffle_attrib_list_get_with_default
> -waffle_attrib_list_update
> \ No newline at end of file
> +waffle_attrib_list_update
> +waffle_get_current_display
> +waffle_get_current_window
> +waffle_get_current_context
Reviewed-by: Emil Velikov 

-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  wrote:
> On Wed 19 Oct 2016, Emil Velikov wrote:
>> On 18 October 2016 at 18:33, Chad Versace  wrote:
>> > Now waffle_init() supports WAFFLE_PLATFORM_SURFACELESS_EGL.
>> >
>> > Cc: Gurchetan Singh 
>> > Cc: Haixia Shi 
>> > ---
>> >  include/waffle/waffle.h  |   1 +
>> >  man/waffle_init.3.xml|   9 ++
>> >  src/waffle/CMakeLists.txt|   9 ++
>> >  src/waffle/api/waffle_init.c |  12 +++
>> >  src/waffle/egl/wegl_platform.c   |   6 ++
>> >  src/waffle/surfaceless_egl/sl_display.c  |  70 +++
>> >  src/waffle/surfaceless_egl/sl_display.h  |  45 ++
>> >  src/waffle/surfaceless_egl/sl_platform.c | 144 
>> > +++
>> >  src/waffle/surfaceless_egl/sl_platform.h |  49 +++
>> >  src/waffle/surfaceless_egl/sl_window.c   |  92 
>> >  src/waffle/surfaceless_egl/sl_window.h   |  53 
>> >  11 files changed, 490 insertions(+)
>> >  create mode 100644 src/waffle/surfaceless_egl/sl_display.c
>> >  create mode 100644 src/waffle/surfaceless_egl/sl_display.h
>> >  create mode 100644 src/waffle/surfaceless_egl/sl_platform.c
>> >  create mode 100644 src/waffle/surfaceless_egl/sl_platform.h
>> >  create mode 100644 src/waffle/surfaceless_egl/sl_window.c
>> >  create mode 100644 src/waffle/surfaceless_egl/sl_window.h
>> >
>
>> Should there be an extra case in src/waffle/core/wcore_util.c's
>> wcore_enum_to_string() ?
>
> Oops. I squashed the fix into this patch.
>
>> > +// [chadv] I regret the design of the get_native interface, and wish to
>> > +// deprecate and replace it with the interface that Ian Romanick orignally
>> > +// recommended: waffle_display_get_egl_display(),
>> > +// waffle_display_get_gbm_device(), waffle_display_get_xlib_display(), 
>> > etc.  As
>> > +// a first step towards that goal, I choose to not support the interface 
>> > on new
>> > +// platforms.
>
>> Silly question: what's wrong with the current [generic] get_native_{foo,bar} 
>> ?
>
> Each get_native function returns a non-extensible struct. The problem is
> the non-extensibility.
>
> Example 1:
>
> On Wayland, waffle_window_get_window() returns
>
> struct waffle_wayland_window {
> struct waffle_wayland_display display; // Definition below
> struct wl_surface *wl_surface;
> struct wl_shell_surface *wl_shell_surface;
> struct wl_egl_window *wl_window;
> EGLSurface egl_surface;
> };
>
> struct waffle_wayland_display {
> struct wl_display *wl_display;
> struct wl_compositor *wl_compositor;
> struct wl_shell *wl_shell;
> EGLDisplay egl_display;
> };
>
> If in the future we need to add more members to that struct, or even 
> remove
> members, due to changes in Wayland, then there is no good way to do 
> that.
>
> Example 2:
>
> I want to add the ability to do KMS with waffle_window/waffle_display 
> on
> the gbm and surfaceless platforms. Again, because the get_native 
> structs
> are non-extensible, there is no good way for
> waffle_window_get_native()/waffle_display_get_native() to return 
> things
> such as the CRTC.
>
> So I see two solutions:
>
> Solution 1: Change the get_native APIs to return "extensible" structs. If
> someone is going to go through all that trouble, though, they might as
> well go with solution 2, which is cleaner and less work.
>
> Solution 2: For each possible native resourse of each Waffle resource, add
> a specific getter that returns null-or-whatever if it doesn't exist.  For 
> example,
>
> EGLSurface waffle_window_get_egl_surface(...);
> struct gbm_surface *waffle_window_get_gbm_surface(...);

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

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 18:33, Chad Versace  wrote:
> Run with `bin/gl_basic_test --platform=surfaceless_egl`.
>
> All the tests fail! The rgba pixels returned by glReadPixels are
> black (0x0, 0x0, 0x0, 0xff), but the test expects magenta (0xff, 0x0,
> 0xff, 0xff). I don't know why.
>
> Cc: Gurchetan Singh 
> Cc: Haixia Shi 
> ---
>  tests/functional/gl_basic_test.c | 17 +
>  1 file changed, 17 insertions(+)
>
> diff --git a/tests/functional/gl_basic_test.c 
> b/tests/functional/gl_basic_test.c
> index 4a90dfd..c3c7774 100644
> --- a/tests/functional/gl_basic_test.c
> +++ b/tests/functional/gl_basic_test.c
> @@ -703,6 +703,17 @@ CREATE_TESTSUITE(WAFFLE_PLATFORM_GLX, glx)
>
>  #endif // WAFFLE_HAS_GLX
>
> +#ifdef WAFFLE_HAS_SURFACELESS_EGL
> +
> +#define unit_test_make(name)\
> +cmocka_unit_test_setup_teardown(name, setup_surfaceless_egl, 
> gl_basic_fini)
> +
> +CREATE_TESTSUITE(WAFFLE_PLATFORM_SURFACELESS_EGL, surfaceless_egl)
> +
> +#undef unit_test_make
> +
Which reminds me that we might want to add support for testsuite(s)
where each test, uses the same setup/teardown [to cmocka] and drop the
above define/undef foo is related (rather nasty) macros.

Either way, with the small fixes in 4 and 5 the series is
Reviewed-by: Emil Velikov 

Separating surfaceless/null and "platform FOO does not display
anything" wss a great move, imho.

Nicely done !
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 supported on Darwin: 
> waffle_has_x11_egl.")
>  endif()
> +if(waffle_h

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

2016-10-18 Thread Emil Velikov
On 18 October 2016 at 18:33, Chad Versace  wrote:
> Add function wegl_pbuffer_init(), which initializes a struct
> wegl_surface with eglCreatePbufferSurface().
>
> Not yet used, but will be used later by the new surfaceless platform.
>
> Cc: Gurchetan Singh 
> Cc: Haixia Shi 
> ---
>  src/waffle/egl/wegl_platform.c |  1 +
>  src/waffle/egl/wegl_platform.h |  2 ++
>  src/waffle/egl/wegl_surface.c  | 42 
> ++
>  src/waffle/egl/wegl_surface.h  |  5 +
>  4 files changed, 50 insertions(+)
>
> diff --git a/src/waffle/egl/wegl_platform.c b/src/waffle/egl/wegl_platform.c
> index 71eb29e..331cc89 100644
> --- a/src/waffle/egl/wegl_platform.c
> +++ b/src/waffle/egl/wegl_platform.c
> @@ -139,6 +139,7 @@ wegl_platform_init(struct wegl_platform *self, EGLenum 
> egl_platform)
>  // window
>  RETRIEVE_EGL_SYMBOL(eglGetConfigAttrib);
>  RETRIEVE_EGL_SYMBOL(eglCreateWindowSurface);
> +RETRIEVE_EGL_SYMBOL(eglCreatePbufferSurface);
>  RETRIEVE_EGL_SYMBOL(eglDestroySurface);
>  RETRIEVE_EGL_SYMBOL(eglSwapBuffers);
>
> diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h
> index d6788eb..a5092a5 100644
> --- a/src/waffle/egl/wegl_platform.h
> +++ b/src/waffle/egl/wegl_platform.h
> @@ -89,6 +89,8 @@ struct wegl_platform {
>  EGLSurface (*eglCreateWindowSurface)(EGLDisplay dpy, EGLConfig config,
>   EGLNativeWindowType win,
>   const EGLint *attrib_list);
> +EGLSurface (*eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
> +  const EGLint *attrib_list);
>  EGLBoolean (*eglDestroySurface)(EGLDisplay dpy, EGLSurface surface);
>  EGLBoolean (*eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
>  };
> diff --git a/src/waffle/egl/wegl_surface.c b/src/waffle/egl/wegl_surface.c
> index ccd0799..0bd0857 100644
> --- a/src/waffle/egl/wegl_surface.c
> +++ b/src/waffle/egl/wegl_surface.c
> @@ -74,6 +74,48 @@ fail:
>  }
>
>  bool
> +wegl_pbuffer_init(struct wegl_surface *surf,
> +  struct wcore_config *wc_config,
> +  int32_t width, int32_t height)
> +{
> +struct wegl_config *config = wegl_config(wc_config);
> +struct wegl_display *dpy = wegl_display(wc_config->display);
> +struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
> +bool ok;
> +
> +ok = wcore_window_init(&surf->wcore, wc_config);
> +if (!ok)
> +goto fail;
> +
This hunk (and most of the series really) will clash with a fair bit
of cleanups I have on the list.
In this particular case - the wcore_window_init API has 'lost' it's
[always return true] return type.

Re-basing either way will be fun, so let's get the new platform in
first and then consider the cleanups.
Please ?

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


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

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

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

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


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

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

-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  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 
>> Cc: Chad Versace 
>> ---
>> Hi all, this is weird a reminder about getting null/surfaceless updated.
>
> I started working on this recently. There's also a pile of *new* patches
> in the CrOS tree that need upstreaming.
>
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 00/13] Core waffle cleanups

2016-08-23 Thread Emil Velikov
On 23 August 2016 at 12:26, Tapani Pälli  wrote:
>
> On 08/23/2016 12:52 PM, Tapani Pälli wrote:
>>
>> On 08/18/2016 01:28 PM, Emil Velikov wrote:
>>>
>>> On 21 June 2016 at 11:33, Emil Velikov  wrote:
>>>>
>>>> On 16 May 2016 at 11:57, Emil Velikov  wrote:
>>>>>
>>>>> On 16 May 2016 at 11:54, Emil Velikov  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.
>>
>>
>>
>> Patches 1 (cleanup) and 3-7 (do not check null since api_check_entry did
>> it already):
>>
>> Reviewed-by: Tapani Pälli 
>>
>> (I will check the rest from the repo)
>
>
> Also R-B to 12 and 13.
>
Thanks Tapani. Hope we can find someone with commit access to push these.

> Question about "core: remove wcore_*_teardown()" patch:
>
> Is it possible that core classes will have allocations or some other stuff
> in their constructor that then needs cleanup in dtor in the future? If it
> happens then all of this infrastructure needs to be put back .. I'm just
> thinking if this is OK from that perspective?
>
I cannot think of any case that would require us to bring these back since:
 - waffle itself is meant to have/store little to no state (only some
*_platform can take more than 100 bytes) with the memory allocation
done in the platform rather than wcore.
I.e. wcore does not and should not [mc]alloc anything that needs to be freed.
 - the wcore api only 'links' the primitives initially thus there is
nothing that could/should be teardown.

One day as we add MT support we might need to rethink things, but we
would need a serious work either way, imho.
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  wrote:
> On 16 May 2016 at 11:48, Emil Velikov  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  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  wrote:
> On 16 May 2016 at 11:57, Emil Velikov  wrote:
>> On 16 May 2016 at 11:54, Emil Velikov  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  wrote:
> In some cases (like building on Android) the headers might not have the
> 1.5 definitions, leading to a build failures like the one in github
> issue #41.
>
> Since the ABI is baked in stone, add a local define to resolve that.
>
> Cc: Chad Versace 
> Fixes: f8a485e7cc7 ("egl: Improve support for robust GLES contexts on
> EGL 1.5")
> Issue: https://github.com/waffle-gl/waffle/issues/41
> Signed-off-by: Emil Velikov 
> ---
>  src/waffle/egl/wegl_context.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
> index 0e59231..97931fc 100644
> --- a/src/waffle/egl/wegl_context.c
> +++ b/src/waffle/egl/wegl_context.c
> @@ -34,6 +34,11 @@
>  #include "wegl_platform.h"
>  #include "wegl_util.h"
>
> +// Pre EGL 1.5 headers lack the definition.
> +#ifndef EGL_CONTEXT_OPENGL_ROBUST_ACCESS
> +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS  0x31B2
> +#endif
> +
Humble poke ?

-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 
---
 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 &self->wegl.wcore;
-
-wgbm_platform_destroy(&self->wegl.wcore);
-return NULL;
+if (!wgbm_platform_init(self)) {
+wgbm_platform_destroy(&self->wegl.wcore);
+return NULL;
+}
+return &self->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


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

2016-07-20 Thread Emil Velikov
In some cases (like building on Android) the headers might not have the
1.5 definitions, leading to a build failures like the one in github
issue #41.

Since the ABI is baked in stone, add a local define to resolve that.

Cc: Chad Versace 
Fixes: f8a485e7cc7 ("egl: Improve support for robust GLES contexts on
EGL 1.5")
Issue: https://github.com/waffle-gl/waffle/issues/41
Signed-off-by: Emil Velikov 
---
 src/waffle/egl/wegl_context.c | 5 +
 1 file changed, 5 insertions(+)

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

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

2016-06-21 Thread Emil Velikov
On 16 May 2016 at 11:57, Emil Velikov  wrote:
> On 16 May 2016 at 11:54, Emil Velikov  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  wrote:
> On 06/17/2016 07:59 PM, Emil Velikov wrote:
>>
>> 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 differen

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 largest, a combination

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

2016-06-14 Thread Emil Velikov
On 14 June 2016 at 22:17, Chad Versace  wrote:
> On Tue 14 Jun 2016, Emil Velikov wrote:
>> On 14 June 2016 at 18:10, Chad Versace  wrote:
>> > On Tue 26 Apr 2016, Emil Velikov wrote:
>> >> Humble ping ?
>> >
>> > And an embarassedly late merge.
>> >
>> > Thanks for all the cleanups. All the patches in the series, except patch
>> > 1, are merged. I skipped patch 1 because it introduced a single symbol,
>> > but that symbol was never used.
>>
>> I'm slightly leaning towards having that symbol, as with it (and a gbm
>> cleanup) one should be able to run the waffle tests on Travis CI
>> (which has old wayland). I won't insist on it though.
>> Alternatively we should really bump the minimum required wayland version to 
>> 1.4.
>>
>> Which one would you prefer ?
>
> If adding that symbol will allow Waffle to use Travis, then please add
> the symbol.
It's been a while since I've tried it, so I'm not 100% sure. I'll
respin my local "try travis ci" patches and see how it goes.

It might take a couple a week or so.

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


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

2016-06-14 Thread Emil Velikov
On 14 June 2016 at 22:22, Chad Versace  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 

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  wrote:
> From: Emil Velikov 
>
> 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 
> ---
>  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  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  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 

All the callers already ensure this never happens.

Signed-off-by: Emil Velikov 
---
 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 

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

Signed-off-by: Emil Velikov 
---
 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 

Analogous to previous commit.

Signed-off-by: Emil Velikov 
---
 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 

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 
---
 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 03/13] all: remove 'self' NULL check from *_platform_destroy()

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

The upper layer (API) already guarantees that one cannot send NULL down
the backends, plus our ctors never call the function with NULL ptr.

Signed-off-by: Emil Velikov 
---
 src/waffle/android/droid_platform.c   | 3 ---
 src/waffle/cgl/cgl_platform.m | 3 ---
 src/waffle/gbm/wgbm_platform.c| 3 ---
 src/waffle/glx/glx_platform.c | 3 ---
 src/waffle/nacl/nacl_platform.c   | 3 ---
 src/waffle/wayland/wayland_platform.c | 3 ---
 src/waffle/wgl/wgl_platform.c | 3 ---
 src/waffle/xegl/xegl_platform.c   | 3 ---
 8 files changed, 24 deletions(-)

diff --git a/src/waffle/android/droid_platform.c 
b/src/waffle/android/droid_platform.c
index bbf2b14..da7a8d3 100644
--- a/src/waffle/android/droid_platform.c
+++ b/src/waffle/android/droid_platform.c
@@ -46,9 +46,6 @@ droid_platform_destroy(struct wcore_platform *wc_self)
 struct droid_platform *self = droid_platform(wc_self);
 bool ok = true;
 
-if (!self)
-return true;
-
 if (self->linux)
 ok &= linux_platform_destroy(self->linux);
 
diff --git a/src/waffle/cgl/cgl_platform.m b/src/waffle/cgl/cgl_platform.m
index 2da0b40..e87e6cf 100644
--- a/src/waffle/cgl/cgl_platform.m
+++ b/src/waffle/cgl/cgl_platform.m
@@ -42,9 +42,6 @@ cgl_platform_destroy(struct wcore_platform *wc_self)
 struct cgl_platform *self = cgl_platform(wc_self);
 bool ok = true;
 
-if (!self)
-return ok;
-
 if (self->dl_gl)
 ok &= cgl_dl_close(&self->wcore);
 
diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c
index 0fc0352..40f5fd1 100644
--- a/src/waffle/gbm/wgbm_platform.c
+++ b/src/waffle/gbm/wgbm_platform.c
@@ -79,9 +79,6 @@ wgbm_platform_destroy(struct wcore_platform *wc_self)
 {
 struct wgbm_platform *self = wgbm_platform(wegl_platform(wc_self));
 
-if (!self)
-return true;
-
 bool ok = wgbm_platform_teardown(self);
 free(self);
 return ok;
diff --git a/src/waffle/glx/glx_platform.c b/src/waffle/glx/glx_platform.c
index 4fb2eed..1f4e3fb 100644
--- a/src/waffle/glx/glx_platform.c
+++ b/src/waffle/glx/glx_platform.c
@@ -48,9 +48,6 @@ glx_platform_destroy(struct wcore_platform *wc_self)
 bool ok = true;
 int error = 0;
 
-if (!self)
-return true;
-
 if (self->linux)
 ok &= linux_platform_destroy(self->linux);
 
diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c
index a3d7625..b4b326c 100644
--- a/src/waffle/nacl/nacl_platform.c
+++ b/src/waffle/nacl/nacl_platform.c
@@ -42,9 +42,6 @@ nacl_platform_destroy(struct wcore_platform *wc_self)
 struct nacl_platform *self = nacl_platform(wc_self);
 bool ok = true;
 
-if (!self)
-return true;
-
 ok &= wcore_platform_teardown(wc_self);
 
 nacl_container_teardown(self->nacl);
diff --git a/src/waffle/wayland/wayland_platform.c 
b/src/waffle/wayland/wayland_platform.c
index 2746ca1..4603643 100644
--- a/src/waffle/wayland/wayland_platform.c
+++ b/src/waffle/wayland/wayland_platform.c
@@ -56,9 +56,6 @@ wayland_platform_destroy(struct wcore_platform *wc_self)
 bool ok = true;
 int error;
 
-if (!self)
-return true;
-
 unsetenv("EGL_PLATFORM");
 
 if (self->linux)
diff --git a/src/waffle/wgl/wgl_platform.c b/src/waffle/wgl/wgl_platform.c
index f4649b4..cdbfd89 100644
--- a/src/waffle/wgl/wgl_platform.c
+++ b/src/waffle/wgl/wgl_platform.c
@@ -45,9 +45,6 @@ wgl_platform_destroy(struct wcore_platform *wc_self)
 struct wgl_platform *self = wgl_platform(wc_self);
 bool ok = true;
 
-if (!self)
-return true;
-
 if (self->dl_gl)
 ok &= wgl_dl_close(wc_self);
 
diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c
index e36a41b..a2e7cd2 100644
--- a/src/waffle/xegl/xegl_platform.c
+++ b/src/waffle/xegl/xegl_platform.c
@@ -48,9 +48,6 @@ xegl_platform_destroy(struct wcore_platform *wc_self)
 struct xegl_platform *self = xegl_platform(wegl_platform(wc_self));
 bool ok = true;
 
-if (!self)
-return true;
-
 unsetenv("EGL_PLATFORM");
 
 if (self->linux)
-- 
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 

Analogous to previous commit

Signed-off-by: Emil Velikov 
---
 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(&self->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(&self->wegl);
+ok = wegl_display_teardown(&self->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(&self->x11);
+ok = x11_display_teardown(&self->x11);
 ok &= wcore_display_teardown(&self->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(&self->wcore);
+ok = wcore_display_teardown(&self->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(&self->wegl);
+ok = wegl_display_teardown(&self->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_di

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

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

Analogous to previous commit

Signed-off-by: Emil Velikov 
---
 src/waffle/cgl/cgl_context.m   |  7 ++-
 src/waffle/egl/wegl_context.c  | 23 ++-
 src/waffle/glx/glx_context.c   | 17 +
 src/waffle/nacl/nacl_context.c | 11 +++
 src/waffle/wgl/wgl_context.c   |  7 ++-
 5 files changed, 22 insertions(+), 43 deletions(-)

diff --git a/src/waffle/cgl/cgl_context.m b/src/waffle/cgl/cgl_context.m
index 7786113..5d3f575 100644
--- a/src/waffle/cgl/cgl_context.m
+++ b/src/waffle/cgl/cgl_context.m
@@ -36,13 +36,10 @@ bool
 cgl_context_destroy(struct wcore_context *wc_self)
 {
 struct cgl_context *self = cgl_context(wc_self);
-bool ok = true;
-
-if (!self)
-return ok;
+bool ok;
 
 [self->ns release];
-ok &= wcore_context_teardown(wc_self);
+ok = wcore_context_teardown(wc_self);
 free(self);
 return ok;
 }
diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 41334eb..7f12b3a 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -214,23 +214,20 @@ fail:
 bool
 wegl_context_destroy(struct wcore_context *wc_ctx)
 {
+struct wegl_context *ctx = wegl_context(wc_ctx);
 bool result = true;
 
-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(&ctx->wcore);
-free(ctx);
 }
+
+result &= wcore_context_teardown(&ctx->wcore);
+free(ctx);
 return result;
 }
diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c
index a553a6b..87adc28 100644
--- a/src/waffle/glx/glx_context.c
+++ b/src/waffle/glx/glx_context.c
@@ -51,22 +51,15 @@
 bool
 glx_context_destroy(struct wcore_context *wc_self)
 {
-struct glx_context *self;
-struct glx_display *dpy;
-struct glx_platform *platform;
-bool ok = true;
-
-if (!wc_self)
-return ok;
-
-self = glx_context(wc_self);
-dpy = glx_display(wc_self->display);
-platform = glx_platform(wc_self->display->platform);
+struct glx_context *self = glx_context(wc_self);
+struct glx_display *dpy = glx_display(wc_self->display);
+struct glx_platform *platform = glx_platform(wc_self->display->platform);
+bool ok;
 
 if (self->glx)
 wrapped_glXDestroyContext(platform, dpy->x11.xlib, self->glx);
 
-ok &= wcore_context_teardown(wc_self);
+ok = wcore_context_teardown(wc_self);
 free(self);
 return ok;
 }
diff --git a/src/waffle/nacl/nacl_context.c b/src/waffle/nacl/nacl_context.c
index 52015c2..eba3213 100644
--- a/src/waffle/nacl/nacl_context.c
+++ b/src/waffle/nacl/nacl_context.c
@@ -32,17 +32,12 @@ bool
 nacl_context_destroy(struct wcore_context *wc_self)
 {
 struct nacl_context *self = nacl_context(wc_self);
-struct nacl_platform *plat;
-bool ok = true;
-
-if (!wc_self)
-return ok;
-
-plat = nacl_platform(wc_self->display->platform);
+struct nacl_platform *plat = nacl_platform(wc_self->display->platform);
+bool ok;
 
 nacl_container_context_fini(plat->nacl);
 
-ok &= wcore_context_teardown(wc_self);
+ok = wcore_context_teardown(wc_self);
 free(self);
 return ok;
 }
diff --git a/src/waffle/wgl/wgl_context.c b/src/waffle/wgl/wgl_context.c
index 9b732ab..c1ac7d8 100644
--- a/src/waffle/wgl/wgl_context.c
+++ b/src/waffle/wgl/wgl_context.c
@@ -39,15 +39,12 @@ bool
 wgl_context_destroy(struct wcore_context *wc_self)
 {
 struct wgl_context *self = wgl_context(wc_self);
-bool ok = true;
-
-if (!self)
-return true;
+bool ok;
 
 if (self->hglrc)
 ok &= wglDeleteContext(self->hglrc);
 
-ok &= wcore_context_teardown(wc_self);
+ok = wcore_context_teardown(wc_self);
 free(self);
 return ok;
 }
-- 
2.6.2

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


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

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

Analogous to previous commit

Signed-off-by: Emil Velikov 
---
 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(&self->wegl);
+ok = wegl_window_teardown(&self->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(&self->wcore);
+ok = wcore_window_teardown(&self->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(&self->wegl);
+ok = wegl_window_teardown(&self->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(&self->x11);
+ok = x11_window_teardown(&self->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(&self->wegl);
+ok = wegl_window_teardown(&self->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-&g

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

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

Analogous to previous commit

Signed-off-by: Emil Velikov 
---
 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(&self->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 

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

Signed-off-by: Emil Velikov 
---
 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(&ctx->wcore, &config->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 &ctx->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(&ctx->wcore);
-return NULL;
-}
-
-return &ctx->wcore;
+wegl_context_destroy(&ctx->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(&ctx->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(&ctx->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 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 01/13] x11: straighten code flow

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

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

Signed-off-by: Emil Velikov 
---
 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 1/4] egl: fix build against old headers

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

Namely add the EGL_CONTEXT_OPENGL_ROBUST_ACCESS define, if missing.

Signed-off-by: Emil Velikov 
---
 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 
---
 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, &config->visual);
+
+if (!ok)
+goto fail;
+
 return &config->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,
-   &gbm_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(wegl_pla

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

2016-05-16 Thread Emil Velikov
From: Emil Velikov 

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

Signed-off-by: Emil Velikov 
---
 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(&self->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(&self->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(&self->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(&self->wegl.wcore);
+return NULL;
 }
 
-ok = wegl_window_init(&self->wegl, wc_config,
-  (intptr_t) self->gbm_surface);
-if (!ok)
-goto error;
-
 return &self->wegl.wcore;
-
-error:
-wgbm_window_destroy(&self->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 

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 
---
 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(&backup_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


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

2016-05-14 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.
v3: Keep get_apis() and get_extensions() separate. Use mask for the API.

Signed-off-by: Emil Velikov 
---
 src/waffle/egl/wegl_config.c  | 43 +++-
 src/waffle/egl/wegl_display.c | 58 ---
 src/waffle/egl/wegl_display.h |  6 +
 3 files changed, 63 insertions(+), 44 deletions(-)

diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index 08e06fb..37fbe65 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));
@@ -76,6 +74,14 @@ check_context_attrs(struct wegl_display *dpy,
 
 switch (attrs->context_api) {
 case WAFFLE_CONTEXT_OPENGL:
+if (!(dpy->api_mask & WEGL_OPENGL_API)) {
+wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ "EGL 1.4 and eglQueryString(EGL_CLIENT_APIS) "
+ "advertising \"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 "
@@ -96,46 +102,25 @@ 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)) {
+case WAFFLE_CONTEXT_OPENGL_ES3:
+if (!(dpy->api_mask & WEGL_OPENGL_ES_API)) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "failed to open the OpenGL ES2 library");
+ "eglQueryString(EGL_CLIENT_APIS) does not"
+ "advertise OpenGL_ES.");
 return false;
 }
-
-return true;
-
-case WAFFLE_CONTEXT_OPENGL_ES3:
-if (!dpy->KHR_create_context) {
+if (attrs->context_api == WAFFLE_CONTEXT_OPENGL_ES3 &&
+!dpy->KHR_create_context) {
 wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
  "EGL_KHR_create_context is required to request "
  "an OpenGL ES3 context");
 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 c7be0a5..d5f6deb 100644
--- a/src/waffle/egl/wegl_display.c
+++ b/src/waffle/egl/wegl_display.c
@@ -34,6 +34,41 @@
 #include "wegl_platform.h"
 
 static bool
+get_apis(struct wegl_display *dpy)
+{
+struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
+const char *apis = plat->eglQueryString(dpy->egl, EGL_CLIENT_APIS);
+
+// Our minimum requirement - EGL 1.2 ...
+if (dpy->major_version != 1 || dpy->minor_version < 2) {
+wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
+ 

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

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

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

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

Thanks
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  wrote:
> On Sun, Apr 24, 2016 at 6:42 AM, Emil Velikov  
> wrote:
>> On 21 April 2016 at 21:25, Frank Henigman  wrote:
>>> On Fri, Jan 8, 2016 at 7:40 AM, Emil Velikov  
>>> wrote:
>>>> 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
>>

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  wrote:
> On Sat, Apr 23, 2016 at 2:51 PM, Emil Velikov  
> wrote:
>> On 21 April 2016 at 21:27, Frank Henigman  wrote:
>>> On Fri, Jan 8, 2016 at 7:50 AM, Emil Velikov 
>>> wrote:
>>>> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>>>>> Implement the platform hook of waffle_display_info_json() so it can
>>>>> pick up egl-specific information.
>>>>>
>>>>> Signed-off-by: Frank Henigman 
>>>>> ---
>>>>>  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(&dpy->wcore, wc_plat);
>>>>>  if (!ok)
>>>>> @@ -75,7 +76,7 @@ wegl_display_init(struct wegl_display *dpy,
>>>>>  goto fail;
>>>>>  }
>>>>>
>>>>> -ok = plat->eglInitialize(dpy->egl, &major, &minor);
>>>>> +ok = plat->eglInitialize(dpy->egl, &plat->major, &plat->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  wrote:
> On Fri, Jan 8, 2016 at 7:40 AM, Emil Velikov  wrote:
>> 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 GLi

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  wrote:
> On Fri, Jan 8, 2016 at 7:44 AM, Emil Velikov  wrote:
>> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>>> Add a platform hook so platform-specific information can be included
>>> by waffle_display_info_json().
>>>
>>> Signed-off-by: Frank Henigman 
>>> ---
>>>  src/waffle/api/waffle_display.c  | 10 +-
>>>  src/waffle/core/wcore_platform.h |  4 
>>>  2 files changed, 13 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/waffle/api/waffle_display.c 
>>> b/src/waffle/api/waffle_display.c
>>> index 7abe2ef..d6988ac 100644
>>> --- a/src/waffle/api/waffle_display.c
>>> +++ b/src/waffle/api/waffle_display.c
>>> @@ -367,8 +367,16 @@ waffle_display_info_json(struct waffle_display *self, 
>>> bool platform_too)
>>>
>>>  json_appendv(jj, "{", "generic", "{", "");
>>>  add_generic_info(jj, wc_self->current_context);
>>> -json_appendv(jj, "}", "}", "");
>>> +json_append(jj, "}");
>>>
>>> +if (platform_too) {
>>> +json_appendv(jj, "platform", "{", "");
>>> +if (api_platform->vtbl->display.info_json)
>>> +api_platform->vtbl->display.info_json(wc_self, jj);
>> The rest of waffle tends to set UNSUPPORTED_ON_PLATFORM if the backend
>> is missing the vfunc.
>
> I'm reluctant to set an error for something that isn't clearly an
> error (it might just be that a backend doesn't have platform-specific
> details) because it could add a burden to the user to distinguish this
> case from definite errors.
With all respect I have to disagree. Error checking/handling is not a
'burden'. Even if some choose to ignore it that doesn't make it less
relevant ;-)

Obviously things would be way easier/cleaner if things were split -
generic info vs platform specific (or even finer). As-is, with all of
them in one piece, no error-checking or UNSUPPORTED_ON_PLATFORM one
gets badly formatted/corrupted json. Thus the user has no way of
knowing if things failed for reason some, or the setup simply lacks
the information Y that they need.


>  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  wrote:
> On Fri, Apr 8, 2016 at 7:38 PM, Chad Versace  wrote:
>> On 01/08/2016 04:17 AM, Emil Velikov wrote:
>>> On 6 January 2016 at 21:56, Frank Henigman  wrote:
>>>> A small library for building JSON strings.
>>>>
>>>> Signed-off-by: Frank Henigman 
>>>> ---
>>>>  src/waffle/CMakeLists.txt |   1 +
>>>>  src/waffle/core/json.c| 235 
>>>> ++
>>>>  src/waffle/core/json.h|  93 ++
>>
>>> Is the library is copied/derived from another project or written from
>>> scratch ? If the former should we move it to third_party/  ?
>>
>> I have the same question. Was this code copied from a public Google project?
>> If so, the we should place in third_party/ with a note explaining its origin
>> and explaining how to update it in the future. If not, the the current 
>> location
>> in src/waffle/core/ is appropriate.
>
> 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 > wrote:
> On Fri, Jan 8, 2016 at 7:50 AM, Emil Velikov > wrote:
>> On 6 January 2016 at 21:56, Frank Henigman > wrote:
>>> Implement the platform hook of waffle_display_info_json() so it can
>>> pick up egl-specific information.
>>>
>>> Signed-off-by: Frank Henigman >
>>> ---
>>>  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(&dpy->wcore, wc_plat);
>>>  if (!ok)
>>> @@ -75,7 +76,7 @@ wegl_display_init(struct wegl_display *dpy,
>>>  goto fail;
>>>  }
>>>
>>> -ok = plat->eglInitialize(dpy->egl, &major, &minor);
>>> +ok = plat->eglInitialize(dpy->egl, &plat->major, &plat->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  wrote:
> On Sat, Apr 16, 2016 at 4:12 PM, Emil Velikov 
> wrote:
>>
>> On 16 April 2016 at 22:06, Jason Ekstrand  wrote:
>>
>> >> Then again importing bits from other projects tend to be quite a nasty
>> >> solution. The place where I borrowed the idea from (libSDL) does/did
>> >> not imports the protocol.
>> >
>> >
>> > I don't think this is as bad an idea as you seem to think.  I'll explain
>> > a
>> > bit further down.
>> >
>>  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 the same name) and 

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

2016-04-16 Thread Emil Velikov
On 16 April 2016 at 22:06, Jason Ekstrand  wrote:

>> Then again importing bits from other projects tend to be quite a nasty
>> solution. The place where I borrowed the idea from (libSDL) does/did
>> not imports the protocol.
>
>
> I don't think this is as bad an idea as you seem to think.  I'll explain a
> bit further down.
>
 If it's a good idea why aren't others doing it ?
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 ?

> The problem is waffle's usage of libwayland and its generated headers.
> Because waffle inserts its own shim layer in between, there are two versions
> of the libwayland API in play: the one provided by libwayland-client.so and
> the one provided by waffle's shim layer.  Even though the libwayland-client
> API is progressing in a backwards-compatable manner, waffle doesn't get new
> entrypoints until it plumbs them through its shim layer so it's always a bit
> behind.  The problem with waffle's useage of the headers is that the
> functions in the wayland-client-protocol.h header are calling into waffle's
> shim layer and libwayland-client.so directly.  This means that the
> "automatic upgrade" process that normal wayland apps get won't work for
> waffle.
Double checking - "automatic upgrade" refers to the regenerated
headers correct ?

>  Instead, waffle can't upgrade to a new version of the protocol
> header until it updates its shim layer.
Not quite. There is an issue only when new libwayland API gets
unconditionally used, which (as I call it) breaks the ABI.

Furthermore if one resolves a wayland issue without adding new API by
tweaking the headers, this leaves waffle with imported headers
'vulnerable' (completely wrong terminology but you get the point).

Afaict we have two options:

A: 3-4 lines of shim layer every so often - afaics this is the second
case twice wayland 1.0
B: Recheck-in the updated header and update the libwayland version on
regular intervals. If we want to use old wayland versions (as you
point out below) - one also has to add stubs.

> This means that it can't trust the
> system-installed one and needs to use its own.
>
I'm afraid I don't see how you made this deduction based on the
previous statements.

> Is it safe to check a copy in?  Absolutely.  Like I said above,
> wayland-client-protocol-core.h is very careful to only provide static inline
> wrappers around the actual set of symbols exported from libwayland-client.so
> and those are kept backwards-compatable.  You can compile against as old a
> copy of wayland-client-protocol.h as you want and it should work fine.
>
Modulo the bugs that have bee

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  wrote:
> EGL 1.5 also supports the EGL_CONTEXT_OPENGL_ROBUST_ACCESS
> attribute without any extensions for both ES and non-ES.
>
> Signed-off-by: Bas Nieuwenhuizen 
> ---
>  src/waffle/egl/wegl_config.c  | 9 ++---
>  src/waffle/egl/wegl_context.c | 9 +++--
>  src/waffle/egl/wegl_display.c | 3 +--
>  src/waffle/egl/wegl_display.h | 2 ++
>  4 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/src/waffle/egl/wegl_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(&dpy->wcore, wc_plat);
>  if (!ok)
> @@ -76,7 +75,7 @@ wegl_display_init(struct wegl_display *dpy,
>  goto fail;
>  }
>
> -ok = plat->eglInitialize(dpy->egl, &major, &minor);
> +ok = plat->eglInitialize(dpy->egl, &dpy->major_version, 
> &dpy->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
___
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  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] egl: correctly set the attrib/bits for robust contexts

2016-04-15 Thread Emil Velikov
The EXT_create_context_robustness extension covers only GLES contexts,
while the latter EGL_KHR_create_context works for both GL and GLES ones.

Cc: Bas Nieuwenhuizen 
Signed-off-by: Emil Velikov 
---

Seems like these lovely extensions managed to confused most of us.
Although in all honestly, chances are pretty small that one will 
implement the KHR extension and no the EXT one and vice-versa.

Emil

 src/waffle/egl/wegl_config.c  | 12 +++-
 src/waffle/egl/wegl_context.c | 11 +--
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c
index 1c3f416..9e0bc2e 100644
--- a/src/waffle/egl/wegl_config.c
+++ b/src/waffle/egl/wegl_config.c
@@ -56,18 +56,12 @@ check_context_attrs(struct wegl_display *dpy,
 }
 
 if (attrs->context_robust && !dpy->EXT_create_context_robustness &&
-attrs->context_api != WAFFLE_CONTEXT_OPENGL) {
+attrs->context_api != WAFFLE_CONTEXT_OPENGL && 
!dpy->KHR_create_context) {
 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,
+ "request a robust access context for OpenGL ES."
  "EGL_KHR_create_context is required in order to "
- "request a robust access context for OpenGL");
+ "request a robust access context for OpenGL or OpenGL 
ES");
 return false;
 }
 
diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 67cbc04..027ed97 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -77,6 +77,10 @@ create_real_context(struct wegl_config *config,
 context_flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
 }
 
+if (attrs->context_robust && dpy->KHR_create_context) {
+context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
+}
+
 switch (waffle_context_api) {
 case WAFFLE_CONTEXT_OPENGL:
 if (dpy->KHR_create_context) {
@@ -95,11 +99,6 @@ create_real_context(struct wegl_config *config,
 context_flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
 }
 
-if (attrs->context_robust) {
-assert(dpy->KHR_create_context);
-context_flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
-}
-
 if (wcore_config_attrs_version_ge(attrs, 32))  {
 assert(dpy->KHR_create_context);
 switch (attrs->context_profile) {
@@ -133,7 +132,7 @@ create_real_context(struct wegl_config *config,
 assert(attrs->context_minor_version == 0);
 }
 
-if (attrs->context_robust) {
+if (attrs->context_robust && EXT_create_context_robustness) {
 attrib_list[i++] = EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT;
 attrib_list[i++] = EGL_TRUE;
 }
-- 
2.8.0

___
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 
Cc: Ilia Mirkin 
Signed-off-by: Emil Velikov 
---
 src/waffle/wgl/wgl_config.c  |  7 ---
 src/waffle/wgl/wgl_context.c | 12 +++-
 src/waffle/wgl/wgl_context.h | 15 +++
 3 files changed, 30 insertions(+), 4 deletions(-)

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(&config->wcore.attrs, 10) ||
+ wgl_context_needs_arb_create_context(&config->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 
Reviewed-by: Jose Fonseca  (v1)
Signed-off-by: Emil Velikov 
---
 src/waffle/glx/glx_config.c  |  7 ---
 src/waffle/glx/glx_context.c | 12 +++-
 src/waffle/glx/glx_context.h | 16 
 3 files changed, 31 insertions(+), 4 deletions(-)

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

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  wrote:
> On 04/15/2016 09:36 AM, Jason Ekstrand wrote:
>> On Fri, Apr 15, 2016 at 3:03 AM, Emil Velikov > <mailto:emil.l.veli...@gmail.com>> wrote:
>>
>> On 15 April 2016 at 03:32, Michel Dänzer > <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 > <mailto:mic...@daenzer.net>> wrote:
>> >>>> From: Michel Dänzer > <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 > <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 makes the wayland-protocol.h file effectively internal to waffle but
>> still updatable by the distro.  This is a layering violation.  To keep t

[waffle] [PATCH] wayland: Wrap wl_proxy_marshal_constructor_versioned v2

2016-04-15 Thread Emil Velikov
From: Michel Dänzer 

Fixes build failure due to wl_proxy_marshal_constructor_versioned being
unresolved when building against current wayland.

This API was introduced in wayland 1.9.91 by commit 557032e3 ("Track
protocol object versions inside wl_proxy."). The waffle code doesn't
reference wl_proxy_marshal_constructor_versioned directly but
indirectly via wayland-scanner.

v2:
* Add paragraph about how wl_proxy_marshal_constructor_versioned was
  introduced. (Emil Velikov)
* Only resolve wl_proxy_marshal_constructor_versioned with wayland >=
  1.9.91.

Signed-off-by: Michel Dänzer 

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

Cc: Jason Ekstrand 
Cc: Chad Versace 
Signed-off-by: Emil Velikov 
---

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

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

The series is:
Reviewed-by: Emil Velikov 

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  wrote:
> On 6 January 2016 at 21:27, Emil Velikov  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 
>> ---
>>  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


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

2016-04-06 Thread Emil Velikov
On 6 January 2016 at 21:27, Emil Velikov  wrote:
> 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 
> ---
>  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


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


[waffle] [PATCH 6/8] android: plug memory leak in droid_window_create()

2016-04-05 Thread Emil Velikov
Prior to last few commits, leaking self might have been required. With
droid_create_surface() in proper shape we can correctly tear it down.

This effectively reverts commit 0009b5d0d2f "android: Improve name of
'error' goto label" with the commit message of which sharing no
information why this is needed.

Cc: Arun Sl 
Signed-off-by: Emil Velikov 
---
 src/waffle/android/droid_window.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/waffle/android/droid_window.c 
b/src/waffle/android/droid_window.c
index 048a2bb..dcfd31b 100644
--- a/src/waffle/android/droid_window.c
+++ b/src/waffle/android/droid_window.c
@@ -66,7 +66,7 @@ droid_window_create(struct wcore_platform *wc_plat,
 self->pANWContainer = droid_create_surface(width, height,
dpy->pSFContainer);
 if (!self->pANWContainer)
-goto error_droid_create_surface;
+goto error;
 
 ok = wegl_window_init(&self->wegl, wc_config,
   (intptr_t) *((intptr_t*)(self->pANWContainer)));
@@ -77,7 +77,6 @@ droid_window_create(struct wcore_platform *wc_plat,
 
 error:
 droid_window_destroy(&self->wegl.wcore);
-error_droid_create_surface:
 return NULL;
 }
 
-- 
2.8.0

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


[waffle] [PATCH 7/8] android: teardown things in the correct order

2016-04-05 Thread Emil Velikov
Signed-off-by: Emil Velikov 
---
 src/waffle/android/droid_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/waffle/android/droid_display.c 
b/src/waffle/android/droid_display.c
index 3f39739..6e66d17 100644
--- a/src/waffle/android/droid_display.c
+++ b/src/waffle/android/droid_display.c
@@ -72,10 +72,10 @@ droid_display_disconnect(struct wcore_display *wc_self)
 if (!self)
 return true;
 
+ok &= wegl_display_teardown(&self->wegl);
 if (self->pSFContainer)
 droid_deinit_gl(self->pSFContainer);
 
-ok &= wegl_display_teardown(&self->wegl);
 free(self);
 return ok;
 }
-- 
2.8.0

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


[waffle] [PATCH 8/8] android: coding style fixes

2016-04-05 Thread Emil Velikov
Follow waffle's coding style by re-indent and adding space between the
type and *.

Signed-off-by: Emil Velikov 
---
 src/waffle/android/droid_display.c  |  2 +-
 src/waffle/android/droid_platform.c | 12 +++---
 src/waffle/android/droid_surfaceflingerlink.cpp | 55 ++---
 src/waffle/android/droid_surfaceflingerlink.h   | 26 +---
 4 files changed, 38 insertions(+), 57 deletions(-)

diff --git a/src/waffle/android/droid_display.c 
b/src/waffle/android/droid_display.c
index 6e66d17..306b5f7 100644
--- a/src/waffle/android/droid_display.c
+++ b/src/waffle/android/droid_display.c
@@ -35,7 +35,7 @@
 
 struct wcore_display*
 droid_display_connect(struct wcore_platform *wc_plat,
-const char *name)
+  const char *name)
 {
 bool ok = true;
 struct droid_display *self;
diff --git a/src/waffle/android/droid_platform.c 
b/src/waffle/android/droid_platform.c
index bbf2b14..bf5f34f 100644
--- a/src/waffle/android/droid_platform.c
+++ b/src/waffle/android/droid_platform.c
@@ -84,19 +84,17 @@ error:
 }
 
 static bool
-droid_dl_can_open(
-struct wcore_platform *wc_self,
-int32_t waffle_dl)
+droid_dl_can_open(struct wcore_platform *wc_self,
+  int32_t waffle_dl)
 {
 return linux_platform_dl_can_open(droid_platform(wc_self)->linux,
   waffle_dl);
 }
 
 static void*
-droid_dl_sym(
-struct wcore_platform *wc_self,
-int32_t waffle_dl,
-const char *name)
+droid_dl_sym(struct wcore_platform *wc_self,
+ int32_t waffle_dl,
+ const char *name)
 {
 return linux_platform_dl_sym(droid_platform(wc_self)->linux,
  waffle_dl, name);
diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp 
b/src/waffle/android/droid_surfaceflingerlink.cpp
index c3e2fc8..d8422a1 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -50,7 +50,7 @@ struct droid_surfaceflinger_container {
 
 struct droid_ANativeWindow_container {
 // it is important ANativeWindow* is the first element in this structure
-ANativeWindow* native_window;
+ANativeWindow *native_window;
 sp surface_control;
 sp window;
 };
@@ -61,7 +61,7 @@ const int32_t  droid_magic_surface_z = 0x7FFF;
 
 static void
 droid_tear_down_surfaceflinger_link(
-waffle::droid_surfaceflinger_container* pSFContainer)
+waffle::droid_surfaceflinger_container *pSFContainer)
 {
 delete pSFContainer->composer_client;
 delete pSFContainer;
@@ -70,9 +70,9 @@ droid_tear_down_surfaceflinger_link(
 static droid_surfaceflinger_container*
 droid_setup_surfaceflinger_link()
 {
-bool bRVal;
+droid_surfaceflinger_container *pSFContainer;
 EGLint iRVal;
-droid_surfaceflinger_container* pSFContainer;
+bool bRVal;
 
 pSFContainer = new droid_surfaceflinger_container;
 pSFContainer->composer_client = new SurfaceComposerClient;
@@ -90,9 +90,8 @@ error:
 }
 
 static void
-droid_destroy_surface(
-droid_surfaceflinger_container* pSFContainer,
-droid_ANativeWindow_container* pANWContainer)
+droid_destroy_surface(droid_surfaceflinger_container *pSFContainer,
+  droid_ANativeWindow_container *pANWContainer)
 {
 delete pANWContainer->window;
 pSFContainer->composer_client->openGlobalTransaction();
@@ -104,15 +103,12 @@ droid_destroy_surface(
 }
 
 static droid_ANativeWindow_container*
-droid_setup_surface(
-int width,
-int height,
-droid_surfaceflinger_container* pSFContainer)
+droid_setup_surface(int width, int height,
+droid_surfaceflinger_container *pSFContainer)
 {
-bool bRVal;
+droid_ANativeWindow_container *pANWContainer;
 EGLint iRVal;
-
-droid_ANativeWindow_container* pANWContainer;
+bool bRVal;
 
 pANWContainer = new droid_ANativeWindow_container;
 
@@ -179,9 +175,8 @@ error:
 }
 
 static bool
-droid_show_surface(
-droid_surfaceflinger_container* pSFContainer,
-droid_ANativeWindow_container* pANWContainer)
+droid_show_surface(droid_surfaceflinger_container *pSFContainer,
+   droid_ANativeWindow_container *pANWContainer)
 {
 int iRVal;
 
@@ -198,11 +193,9 @@ droid_show_surface(
 }
 
 static bool
-droid_resize_surface(
-droid_surfaceflinger_container* pSFContainer,
-droid_ANativeWindow_container* pANWContainer,
-int width,
-int height)
+droid_resize_surface(droid_surfaceflinger_container *pSFContainer,
+ droid_ANativeWindow_container* pANWContainer,
+ int width, int height)
 {
 int iRVal;
 
@@ -249,9 +242,8 @@ droid_create_surface(
 }
 
 extern "C" bool
-droid_show_surface(
-droid_surfaceflinger_container* pSFContainer,
-droid_ANativeWindow_container* pANWContainer)
+droid_show_surface(droid_su

[waffle] [PATCH 5/8] android: straighten droid_setup_surface error paths

2016-04-05 Thread Emil Velikov
Similar to previous commit drop the unneeded NULL check (left over from
commit c42522c76a94e82907b218c7670c89a8f92f952c (Android: Fix surface
setup segfault) and teardown things in the inverse order of creating
them (by using droid_destroy_surface).

Add a comment about the seemingly strange clear() in
droid_destroy_surface(), and don't forget to teardown the actual surface
object.

XXX: the comment does not cover the question if we should still delete
the object.

Cc: Juha-Pekka Heikkila 
Cc: Chad Versace 
Signed-off-by: Emil Velikov 
---
 src/waffle/android/droid_surfaceflingerlink.cpp | 21 +++--
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp 
b/src/waffle/android/droid_surfaceflingerlink.cpp
index e8c31ab..c3e2fc8 100644
--- a/src/waffle/android/droid_surfaceflingerlink.cpp
+++ b/src/waffle/android/droid_surfaceflingerlink.cpp
@@ -94,7 +94,10 @@ droid_destroy_surface(
 droid_surfaceflinger_container* pSFContainer,
 droid_ANativeWindow_container* pANWContainer)
 {
+delete pANWContainer->window;
 pSFContainer->composer_client->openGlobalTransaction();
+// Admire the lengthy comment in the implementation of clear() why we
+// need it over the normal dtor.
 pANWContainer->surface_control->clear();
 pSFContainer->composer_client->closeGlobalTransaction();
 delete pANWContainer;
@@ -113,9 +116,6 @@ droid_setup_surface(
 
 pANWContainer = new droid_ANativeWindow_container;
 
-if (pANWContainer == NULL)
-goto error;
-
 // The signature of SurfaceComposerClient::createSurface() differs across
 // Android versions.
 #if WAFFLE_ANDROID_MAJOR_VERSION == 4 &&\
@@ -137,7 +137,6 @@ droid_setup_surface(
 if (pANWContainer->surface_control == NULL) {
 wcore_errorf(WAFFLE_ERROR_UNKNOWN,
  "Unable to get android::SurfaceControl");
-delete pANWContainer;
 goto error;
 }
 
@@ -145,21 +144,19 @@ droid_setup_surface(
 if (bRVal != true) {
 wcore_errorf(WAFFLE_ERROR_UNKNOWN,
  "Acquired android::SurfaceControl is invalid");
-delete pANWContainer;
 goto error;
 }
 
 pSFContainer->composer_client->openGlobalTransaction();
 iRVal = pANWContainer->surface_control->setLayer(droid_magic_surface_z);
+pSFContainer->composer_client->closeGlobalTransaction();
+
 if (iRVal != NO_ERROR) {
 wcore_errorf(WAFFLE_ERROR_UNKNOWN,
  "Error in android::SurfaceControl->setLayer");
-delete pANWContainer;
-goto error_closeTransaction;
+goto error;
 }
 
-pSFContainer->composer_client->closeGlobalTransaction();
-
 pANWContainer->window = pANWContainer->surface_control->getSurface();
 
 pSFContainer->composer_client->openGlobalTransaction();
@@ -169,7 +166,6 @@ droid_setup_surface(
 if (iRVal != NO_ERROR) {
 wcore_errorf(WAFFLE_ERROR_UNKNOWN,
  "error in android::SurfaceControl->setSize");
-delete pANWContainer;
 goto error;
 }
 
@@ -177,11 +173,8 @@ droid_setup_surface(
 
 return pANWContainer;
 
-error_closeTransaction:
-pSFContainer->composer_client->closeGlobalTransaction();
-
 error:
-droid_tear_down_surfaceflinger_link(pSFContainer);
+droid_destroy_surface(pSFContainer, pANWContainer)
 return NULL;
 }
 
-- 
2.8.0

___
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 
---
 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 
---
 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 
---
 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] [RFC PATCH 0/8] Android: plus memory leaks

2016-04-05 Thread Emil Velikov
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


  1   2   3   4   5   6   >