[waffle] [PATCH 1/3] cmake: drop the LINK_INTERFACE_LIBRARIES hack

2014-08-21 Thread Emil Velikov
It was added in order to silence Debian's packagin system which
detected that wflinfo has unused direct deps (is overlinked).
Properly annotate waffle's libdeps as PRIVATE this way they won't
get propagated to wflinfo and other objects that link against
libwaffle.

Signed-off-by: Emil Velikov 
---
 src/waffle/CMakeLists.txt | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 954db78..0a84e60 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -191,7 +191,7 @@ include_directories(
 )
 
 add_library(${waffle_libname} SHARED ${waffle_sources})
-target_link_libraries(${waffle_libname} ${waffle_libdeps})
+target_link_libraries(${waffle_libname} PRIVATE ${waffle_libdeps})
 
 set_target_properties(${waffle_libname}
 PROPERTIES
@@ -208,13 +208,6 @@ if(waffle_on_windows)
 )
 endif()
 
-if(NOT waffle_on_mac)
-set_target_properties(${waffle_libname}
-PROPERTIES
-LINK_INTERFACE_LIBRARIES ""
-)
-endif()
-
 install(
 TARGETS ${waffle_libname}
 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-- 
2.0.2

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


[waffle] [PATCH 2/3] cmake: remove empty LDFLAGS

2014-08-21 Thread Emil Velikov
We don't check for xcb or x11 so these two are undefined(empty).
The check for x11-xcb is independent and has nothing to do with
setting up these two.

Signed-off-by: Emil Velikov 
---
 src/waffle/CMakeLists.txt | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 0a84e60..f126fac 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -40,9 +40,7 @@ set(waffle_libdeps
 ${libudev_LDFLAGS}
 ${wayland-client_LDFLAGS}
 ${wayland-egl_LDFLAGS}
-${x11_LDFLAGS}
 ${x11-xcb_LDFLAGS}
-${xcb_LDFLAGS}
 ${THREADS_LIBRARIES}
 )
 
-- 
2.0.2

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


[waffle] [PATCH 3/3] cmake: do not over-link

2014-08-21 Thread Emil Velikov
In the cases where we have the dependencies/libs of a waffle back-end,
and wish you opt-out of it we currently link against the library.
Avoid that an honour the user selection.

Signed-off-by: Emil Velikov 
---
 src/waffle/CMakeLists.txt | 36 +---
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index f126fac..39ead01 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -34,15 +34,37 @@ include_directories(
 # 
 
 set(waffle_libdeps
-${egl_LDFLAGS}
-${gbm_LDFLAGS}
-${gl_LDFLAGS}
-${libudev_LDFLAGS}
-${wayland-client_LDFLAGS}
-${wayland-egl_LDFLAGS}
-${x11-xcb_LDFLAGS}
 ${THREADS_LIBRARIES}
 )
+if(waffle_on_linux)
+if(waffle_has_egl)
+list(APPEND waffle_libdeps
+${egl_LDFLAGS}
+)
+endif()
+if(waffle_has_glx)
+list(APPEND waffle_libdeps
+${gl_LDFLAGS}
+)
+endif()
+if(waffle_has_wayland)
+list(APPEND waffle_libdeps
+${wayland-client_LDFLAGS}
+${wayland-egl_LDFLAGS}
+)
+endif()
+if(waffle_has_x11)
+list(APPEND waffle_libdeps
+${x11-xcb_LDFLAGS}
+)
+endif()
+if(waffle_has_gbm)
+list(APPEND waffle_libdeps
+${gbm_LDFLAGS}
+${libudev_LDFLAGS}
+)
+endif()
+endif()
 
 set(waffle_sources
 api/api_priv.c
-- 
2.0.2

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


[waffle] [PATCH 0/3] Cleanup linking hacks

2014-08-21 Thread Emil Velikov
Hello list,

As promised here is another series from your truly :P

This one removes a linking hack we added a while back and prevent
over-linking when we have the library/deps but do not build that
particular waffle back-end
eg.
 wayland is present on my system but I provide -Dwaffle_use_wayland=0

With the above will end up linking against libwayland-{client,egl}
and the last patch of this series will fix this.


-Emil

P.S. I have another small series which removes our explicit linking 
against libEGL, and we dlopen it at runtime. But that for another day :)

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


Re: [waffle] Final (GSoCwise) waffle WGL release

2014-08-21 Thread Jose Fonseca

On 21/08/14 00:15, Chad Versace wrote:

On 08/20/2014 06:55 AM, Emil Velikov wrote:


waffle works like a champ with WGL, even piglit approves :P

With branches 'yet-another-round-of-msvc-fixes-1.2' [1] and 'waffle-WGL-1.2' I
can run piglit+waffle+wgl on my Windows 7 machine and even crash the drivers
on a non-concurrent run :) Below is a summary of my piglit run.

[15023/15023] crash: 24, fail: 1401, pass: 8323, skip: 5274, warn: 1


Woo!


Great job Emil!

Jose


I neglected to observe that you've spammed the Piglit list too :) I will
take a look at it.


There are still some small bits that needs picking (one of which is the final
API/ABI change which I'm trying to convince Chad is a good idea), but those
will happen in due time. Meanwhile head over to the github release page [3] if
you like to give it a try.


Emil, start sending pull requests! Except for the one patch we're still arguing
about...



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


Re: [waffle] [PATCH 4/4] wgl: attempt to fix the final test

2014-08-21 Thread Emil Velikov
On 21/08/14 00:11, Chad Versace wrote:
> On 08/19/2014 11:42 AM, Jose Fonseca wrote:
>> On 19/08/14 18:44, Emil Velikov wrote:
>>> On 19 August 2014 16:51, Jose Fonseca  wrote:
 On 19/08/14 16:41, Jose Fonseca wrote:
> 
>> I'm sure it overflows on Linux too. valgrind might complain.
>>
>> But MSVC emits code to check for stack overflow -- some sort of canary.  
>> There is no "crash" per se -- but an error dialog.
> 
> To catch bugs like this, maybe it's time that waffle gets a `make 
> check-valgrind`.
> Or maybe build with -fstack-protector by default.
Hmm adding "make check-varglind" should be too hard - I will give it a bash.

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

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


Re: [waffle] [PATCH 13/18] api: make dl_can_open() dl_sym() display dependent

2014-08-21 Thread Emil Velikov
On 20/08/14 23:11, Chad Versace wrote:
> On 08/18/2014 05:35 PM, Emil Velikov wrote:
>> On 18/08/14 22:40, Chad Versace wrote:
>>> On 08/13/2014 03:47 PM, Emil Velikov wrote:
 On 13/08/14 23:23, Chad Versace wrote:
> On 07/22/2014 08:31 PM, Emil Velikov wrote:
>> This will allow us to correctly work around waffle design which
>> allows the a library to be dl_open'ed if we support the corresponding
>> WAFFLE_CONTEXT (via waffle_display_supports_context_api).
>>
>> This is required by WGL which (as implemented in this patch) can
>> support ES contexts via EXT_create_context_es*_profile yet provides
>> all the symbols via a single library. We should check if ES context
>> can be create prior rather than blindly trying to retrieve the symbols.
>>
>> Once waffle has GL dispatch we can remove all the dl functions from
>> the waffle API, as we'll provide every function that the user needs.
>>
>> Note that this breaks the API in a non-backwards compatible way.
>>
>> TODO:
>>  - Add a note in the release notes.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>
> The only remaining patch without review...
>
> I don't agree with this patch and think it's unneeded. Perhaps I'm
> failing to see some subtelty of Windows.
>
> Here's my argument. waffle_dl_can_open($LIB_FOR_API) doesn't guarantee
> that the platform supports $API. It can't. My Linux system, the one I'm
> typing on right now, supports the following feature matrix according to 
> wflinfo.
>
> platform=gbm   | GL  GLES1  GLES2  GLES3
> ---|-
> waffle_dl_can_open |  T  T  T  T
> waffle_display_supports_context_api|  T  T  T  T
> Can really create given context type   |  T  T  T  T
>
>
> platform=glx   | GL  GLES1  GLES2  GLES3
> ---|-
> waffle_dl_can_open |  T  T  T  T
> waffle_display_supports_context_api|  T  F  T *F
> Can really create given context type   |  T  F  T *T
>
>
> On my system, GBM supports GLES1 but GLX doesn't. Therefore the ability to
> obtain functions with dlsym() should be independent of the display in use.
> This behavior intentionally differs from waffle_get_proc_address().
>
> (To make it weirder, waffle_display_supports_context_api(glx_dpy, gles3) 
> returns
> false despite that the GLX display is actually capable of creating a 
> GLES3 context.
> This is because Mesa fails to advertise 
> GLX_EXT_create_context_es_profile. This is
> a Mesa bug, and Waffle needs a workaround for it.)
>
 Ok let me put things in a different light:


The Windows issue:

 All the (GL1.0) symbols come from a single file on Windows - opengl32.dll,
 while at the same time it's the display which knows if we should provide
 symbols for the ES* APIs.


The waffle confusion:

 - waffle_dl_can_open
 Handles dlopening a library based on the API requested.

 - waffle_display_supports_context_api
 States what context API can be used but not what API is purely/directly 
 available.
>>>   ^^^
>>> I'm unsure what you mean by "directly" available.
>>>  
>> purely/directly = not via {W,}GL{,X}_compatibility_you_name_it_extension
>>
 I believe the issue here is dl_can_open is about a file to open, which may 
 not
 always map nicely to "I can get ES* context".
>>>
>>> Correct. Just because you can dlopen the OpenGL ES x.y library and get 
>>> OpenGL ES x.y
>>> symbols does not imply that you can actually create an OpenGL ES x.y 
>>> context.
>>>
 I don't mind dropping the patch although I would appreciate some hints on 
 how
 we can handle the "funny" Windows case.
>>>
>>> The Windows case *is* odd. In a perfect world, we should deprecate 
>>> waffle_dl_can_open()
>>> and waffle_get_proc_address(), and instead replace them with a generic
>>> waffle_get_the_proc_address_the_correct_way_for_this_os_and_context(). Now 
>>> that
>>> Khronos has published an XML description for the API, it shouldn't be too 
>>> hard to write
>>> such a function. That's essentially step #1 for any OpenGL dispatch library.
>>>
>> We'll get there eventually :P
>>
>>> But... we need to implement Waffle's current weird API for Windows. On 
>>> Linux, Waffle maps
>>> each API to the library that provides that API's symbols.
>>>
>>> Linux:
>>> WAFFLE_DL_OPENGL-> libGL
>>> WAFFLE_DL_OPENGL_ES1-> libGLESv1
>>> WAFFLE_DL_OPENGL_ES2-> libGLESv2
>>> WAFFLE_DL_OPENGL_ES3 

[waffle] [PULL] Waffle WGL support

2014-08-21 Thread Emil Velikov
Hello Chad,

Please consider pulling the series into origin/next.

Highlights:
 - WGL support for waffle
   - Just works (tm).
   - Only single window per config is supported.
   - Single API/ABI change - waffle_get_proc_address().
   - Waffle version is unchanged.
 - Misc clean-ups and fixes in waffle core and utils.
 - Tests are currently broken - will be fixed by the next pull request.

Cheers,
Emil

The following changes since commit 3557ab49bf125dce7401659b75fdf0daeddbc6af:

  Merge branch 'master' into next (2014-08-13 14:50:29 -0700)

are available in the git repository at:

  https://github.com/evelikov/waffle.git for-upstream-WGL+fixes-pull

for you to fetch changes up to 0d4ffa247581e7b1b1adae84f88c8b14692c2e83:

  examples/gl_basic: move variable declaration before code (2014-08-21
12:39:44 +0100)


Emil Velikov (31):
  android: misc build fixes
  pkg/archlinux: add mingw-w64-waffle package
  README: Add notes when building Waffle for Windows.
  wgl: add skeleton implementation
  wgl: fill up the dl_* hooks
  wgl: implement display management
  wgl: wire-up wgl_window and wgl_config hooks
  api: make waffle_get_proc_address() display aware
  wgl: add context hooks
  wgl: check for various WGL extensions and fetch their funcptrs
  wgl: use wglChoosePixelFormatARB when available
  wgl: fully support ARB_create_context and EXT_create_context_es_profile.
  wgl: provide static GLES* symbols (dlsym) via opengl32.dll
  cmake: set most compiler flags/defines in a single location
  cmake: drop the waffle library prefix on Windows
  wgl: restrict exported symbols via module-definition file
  wgl: avoid using container_of and DEFINE_CONTAINER_CAST_FUNC macros
  tests: do not force gcc compiler flags onto msvc
  tests/gl_basic_test: don't include posix headers when building for win32
  core: wcore_error_unittest include c99_compat.h
  examples/gl_basic: use native sleep functions
  core: use compiler specific (noreturn) attribute
  examples/gl_basic: use compiler specific (noreturn) attribute
  utils/wflinfo: use compiler specific (noreturn) attribute
  examples/simple-x11-egl: properly annotate the function pointers
  examples/gl_basic: properly annotate the function pointers
  utils/wflinfo: properly annotate the function pointers
  tests/gl_basic_test: properly annotate the function pointers
  utils/wflinfo: use define to provide buffer length
  utils/wflinfo: wrap if (glHamSandwich() != GL_NO_ERROR ||...) in curly
brackets
  examples/gl_basic: move variable declaration before code

 Android.mk |   7 +-
 README.txt | 177 +++-
 cmake/Modules/WaffleDefineCompilerFlags.cmake  | 107 ++--
 cmake/Modules/WaffleDefineOS.cmake |   2 +
 .../Modules/WafflePrintConfigurationSummary.cmake  |   6 +
 cmake/Modules/WaffleValidateOptions.cmake  |  13 +
 examples/gl_basic.c|  49 +++-
 examples/simple-x11-egl.c  |  12 +-
 include/waffle/waffle.h|   4 +-
 man/waffle_display.3.xml   |   2 +-
 man/waffle_enum.3.xml  |   1 +
 man/waffle_get_proc_address.3.xml  |  18 +-
 man/waffle_init.3.xml  |   8 +
 man/waffle_is_extension_in_string.3.xml|   2 +-
 man/wflinfo.1.xml  |   1 +
 pkg/archlinux/mingw-w64-waffle/PKGBUILD|  86 ++
 src/utils/wflinfo.c|  55 ++--
 src/waffle/CMakeLists.txt  |  39 ++-
 src/waffle/api/api_priv.h  |   3 +-
 src/waffle/api/waffle_gl_misc.c|  12 +-
 src/waffle/api/waffle_init.c   |  11 +
 src/waffle/cgl/cgl_platform.m  |   4 +-
 src/waffle/core/wcore_error.c  |   2 -
 src/waffle/core/wcore_error_unittest.c |   6 +-
 src/waffle/core/wcore_platform.h   |   1 +
 src/waffle/core/wcore_tinfo.c  |  10 +-
 src/waffle/core/wcore_util.c   |   1 +
 src/waffle/egl/wegl_util.c |   4 +-
 src/waffle/egl/wegl_util.h |   4 +-
 src/waffle/glx/glx_platform.c  |   1 +
 src/waffle/waffle.def.in   |  33 +++
 src/waffle/wgl/wgl_config.c| 300 +
 src/waffle/wgl/wgl_config.h|  61 +
 src/waffle/wgl/wgl_context.c   | 212 +++
 src/waffle/wgl/wgl_context.h   |  53 
 src/waffle/wgl/wgl_display.c   | 275 +++
 src/waffle/wgl/

[waffle] [PATCHv2 13/18] wgl: provide static GLES* symbols (dlsym) via

2014-08-21 Thread Emil Velikov
Under Windows there is a single library that provides the basic/core
symbols for OpenGL and OpenGL ES* alike. One should attempt to use the
latter only if WGL_EXT_create_context_es{2,}_profile is supported.

We check for the extension in waffle_display_supports_context_api()
and users are strongly recommended check the function's return value.

Signed-off-by: Emil Velikov 
---

With all the ranting aside a completely different approach towards
the problem, which has a negative delta :P

-Emil

 src/waffle/wgl/wgl_dl.c | 12 ++--
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/waffle/wgl/wgl_dl.c b/src/waffle/wgl/wgl_dl.c
index eb9ef46..9d05cb9 100644
--- a/src/waffle/wgl/wgl_dl.c
+++ b/src/waffle/wgl/wgl_dl.c
@@ -39,19 +39,11 @@ wgl_dl_check_enum(int32_t waffle_dl)
 {
 switch (waffle_dl) {
 case WAFFLE_DL_OPENGL:
-return true;
 case WAFFLE_DL_OPENGL_ES1:
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "WGL does not support OpenGL ES1");
-return false;
 case WAFFLE_DL_OPENGL_ES2:
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "WGL does not support OpenGL ES2");
-return false;
 case WAFFLE_DL_OPENGL_ES3:
-wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
- "WGL does not support OpenGL ES3");
-return false;
+// OPENGL32.DLL provides GL and GLES* symbols.
+return true;
 default:
 assert(false);
 return false;
-- 
2.0.2

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


Re: [waffle] Final (GSoCwise) waffle WGL release

2014-08-21 Thread Emil Velikov
On 21/08/14 00:15, Chad Versace wrote:
> On 08/20/2014 06:55 AM, Emil Velikov wrote:
> 
>> waffle works like a champ with WGL, even piglit approves :P
>>
>> With branches 'yet-another-round-of-msvc-fixes-1.2' [1] and 'waffle-WGL-1.2' 
>> I
>> can run piglit+waffle+wgl on my Windows 7 machine and even crash the drivers
>> on a non-concurrent run :) Below is a summary of my piglit run.
>>
>> [15023/15023] crash: 24, fail: 1401, pass: 8323, skip: 5274, warn: 1
> 
> Woo!
> 
> I neglected to observe that you've spammed the Piglit list too :) I will
> take a look at it.
>  
>> There are still some small bits that needs picking (one of which is the final
>> API/ABI change which I'm trying to convince Chad is a good idea), but those
>> will happen in due time. Meanwhile head over to the github release page [3] 
>> if
>> you like to give it a try.
> 
> Emil, start sending pull requests! Except for the one patch we're still 
> arguing
> about...
> 
I fear that all the outstanding series depend on that patch(series) :\

With the recent conclusion I shall compact things up into 1-2 large pull
requests. Unless you insist on keeping them separate as they have been
floating on the mailing list.

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