Re: [waffle] [PATCH 00/13] Core waffle cleanups
On 08/23/2016 05:40 PM, Emil Velikov wrote: On 23 August 2016 at 12:26, Tapani Pälli <tapani.pa...@intel.com> 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 <emil.l.veli...@gmail.com> wrote: On 16 May 2016 at 11:57, Emil Velikov <emil.l.veli...@gmail.com> wrote: On 16 May 2016 at 11:54, Emil Velikov <emil.l.veli...@gmail.com> wrote: Hi all, While looking at the gbm/egl I've noticed a few interesting bits. - We do NULL checking for values that are guaranteed by API to be non-NULL. - wcore_*_init does not need a return type, plus in some places we were not calling it in the correct time. - wcore_*_teardown is a simple wrapper around assert, which (at the time the function should be called) is too late/not needed. So this series simplifies these, giving us a nice -350 line count ;-) The whole thing can be found in https://github.com/evelikov/waffle/tree/for-upstream/core-cleanups For some reason git send-email seems to be choking on patches 08/13 and 09/13. Please check those out via the above repo or let me know if you'd prefer them in other format. I might have gone overboard (too much) folding the error label(s) in 09/13 "core: remove wcore_*_init() return type". I can split those up if people prefer. Humble poke. Patches 1 (cleanup) and 3-7 (do not check null since api_check_entry did it already): Reviewed-by: Tapani Pälli <tapani.pa...@intel.com> (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. Yeah, I cannot really come up with such case either .. maybe only some debugging/tracing could be hooked there but yeah .. just wanted to check if there is possible 'futureproofing' in place there. R-B also to following patches: egl: tweak wegl_platform_init() wayland: tweak wayland_wrapper_init() // Tapani ___ waffle mailing list waffle@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 6/6] nacl: Add an error when trying to use a robust access context.
This looks correct to me; Reviewed-by: Tapani Pälli <tapani.pa...@intel.com> Note that following patch is required to build waffle nacl support on any recent nacl sdk versions: https://lists.freedesktop.org/archives/waffle/2015-October/001266.html On 04/06/2016 06:59 PM, Bas Nieuwenhuizen wrote: Signed-off-by: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl> --- src/waffle/nacl/nacl_config.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c index 9017775..668657b 100644 --- a/src/waffle/nacl/nacl_config.c +++ b/src/waffle/nacl/nacl_config.c @@ -63,6 +63,12 @@ nacl_config_choose(struct wcore_platform *wc_plat, goto error; } +if (attrs->context_robust) { +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + "NaCl does not support robust contexts."); +goto error; +} + unsigned attr = 0; // Max amount of attribs is hardcoded in nacl_config.h (64) ___ waffle mailing list waffle@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH] nacl: fix gl_basic example compilation issue with new nacl SDKs
For pepper_43 ppapi_simple was moved from C++ to C. We need C++ entrypoints so link with ppapi_simple_cpp instead of ppapi_simple. Patch also changes default SDK version in Options.cmake to latest stable NaCl SDK (that is tested to be compatible with the change). Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> --- Options.cmake | 2 +- examples/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Options.cmake b/Options.cmake index 4f097a0..3339ac1 100644 --- a/Options.cmake +++ b/Options.cmake @@ -32,7 +32,7 @@ if(waffle_on_linux) # NaCl specific settings. set(nacl_sdk_path "" CACHE STRING "Set nacl_sdk path here") -set(nacl_version "pepper_39" CACHE STRING "Set NaCl bundle here") +set(nacl_version "pepper_44" CACHE STRING "Set NaCl bundle here") endif() option(waffle_build_tests "Build tests" ON) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 31a909b..1102ad4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -36,7 +36,7 @@ if (waffle_has_nacl) target_link_libraries(gl_basic_nacl.nexe ${waffle_libname} ${nacl_LDFLAGS} --lppapi_simple +-lppapi_simple_cpp -lnacl_io ) -- 2.4.3 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 04/10] nacl: rework nacl_dl functions
On 03/25/2015 04:07 PM, Emil Velikov wrote: On 25 March 2015 at 06:10, Tapani tapani.pa...@intel.com wrote: 2 small things below .. On 03/24/2015 05:56 PM, Emil Velikov wrote: [...] +static bool +nacl_dl_check_enum(int32_t waffle_dl) +{ +switch (waffle_dl) { +case WAFFLE_DL_OPENGL: +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + NACL does not support OpenGL); +return false; +case WAFFLE_DL_OPENGL_ES1: +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + NACL does not support OpenGL ES1); +return false; +case WAFFLE_DL_OPENGL_ES2: +return true; +case WAFFLE_DL_OPENGL_ES3: +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + NACL does not support OpenGL ES3); I don't see much value in in these messages, we only have 1 api that returns true. If really wanted then just have default that prints the error using wcore_enum_to_string() for the waffle_dl. As mentioned above this is what waffle's cgl already does. If others are ok with nuking/reworking the similar hunk in cgl then I'm ok with it. I think it's worth the trouble, if nothing else it is more readable. +return false; +default: +assert(false); +return false; + } +} + +static bool +nacl_dl_open(struct nacl_platform *plat) +{ +plat-dl_gl = dlopen(NACL_GLES2_LIBRARY, RTLD_LAZY); + +if (!plat-dl_gl) { +wcore_errorf(WAFFLE_ERROR_UNKNOWN, + dlopen(\%s\) failed, NACL_GLES2_LIBRARY); Would be cool to have the dlerror() message here. Any objections if I keep this as a follow up change which updates both cgl and nacl ? This is fine! // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 05/10] nacl: emit errors when things fail
On 03/25/2015 03:59 PM, Emil Velikov wrote: On 25 March 2015 at 06:21, Tapani tapani.pa...@intel.com wrote: I don't quite agree with this change, IMO the behavior is fine as it matches how other backends work. The 'gl' prefix is internal detail, user should not be trying to dlopen some other functions anyway? I'm not 100% sure about your concern here - are you suggesting a change from WAFFLE_ERROR_UNKNOWN to WAFFLE_ERROR_INTERNAL, or that the user does not deserve to get any message on failure ? One could think about pushing the gl check further up to the waffle internal api but considering this is the only place waffle cares it's ok as is. OK, I'm fine adding the error. It just first felt a bit strange case, this shouldn't really ever happen and error exposes details that might some day change. Purpose of the call is to query for functions only for the given API so anything else is out of scope and the poor (but maybe also evil) user knows it. For the patch; Reviewed-by: Tapani Palli tapani.pa...@intel.com // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH v2 04/10] nacl: rework nacl_dl functions
On 03/25/2015 04:22 PM, Emil Velikov wrote: This is a direct copy from cgl with the following tweaks - s/cgl/nacl/ - s/cgl_dl_gl_path/NACL_GLES2_LIBRARY/ - Add move the nacl_prefix function from nacl_platform.c Doing this allows us to have more consistent codebase and additional error messages for the user. As a bonus it squashes a bug where waffle_dl_can_open() was setting an error when it shouldn't have. v2: - s/gl_dl/dl_gl/ nacl_platform.* : the latter is used throughout waffle - s/cgl_dl_gl_path/NACL_GLES2_LIBRARY/ - missed a couple of references - add missing includes - stdio.h, string.h, nacl_container.h Cc: Tapani Pälli tapani.pa...@intel.com Signed-off-by: Emil Velikov emil.l.veli...@gmail.com --- Tapani, this update addresses only the compilation goofups. This way people can give it a test if interested. v3 will be comming after the input of my follow up questions. How did you structure the files for your test [1] ? All the requirements (SOs, etc.) are next to the nexe,nmf,html and Chromium is running with --enable-nacl, yet nothing pops up. Your test runs like a charm though :-) I have all the dependencies in same directory as the test, this is because we use '--no-arch-prefix' when creating nmf file (see CMakeLists.txt for the reason ..) I should probably file a bug/change request for create_nmf tool because it would be nice to have each arch in their own path like it is designed even when using '-x' flag. For nmf file issues, easy way to check what is missing is to turn on developer tools from chrome's 'More tools' menu and from there check the Network tab. You should also see some errors on console there, maybe some of the dependencies is not found or has wrong file permissions. Thanks Emil [1] http://koti.kapsi.fi/~tpalli/nacl/ src/waffle/CMakeLists.txt | 1 + src/waffle/nacl/nacl_dl.c | 191 src/waffle/nacl/nacl_dl.h | 43 + src/waffle/nacl/nacl_platform.c | 86 ++ src/waffle/nacl/nacl_platform.h | 2 +- 5 files changed, 241 insertions(+), 82 deletions(-) create mode 100644 src/waffle/nacl/nacl_dl.c create mode 100644 src/waffle/nacl/nacl_dl.h diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt index ac9b415..758039c 100644 --- a/src/waffle/CMakeLists.txt +++ b/src/waffle/CMakeLists.txt @@ -186,6 +186,7 @@ if(waffle_has_nacl) nacl/nacl_config.c nacl/nacl_context.c nacl/nacl_display.c +nacl/nacl_dl.c nacl/nacl_platform.c nacl/nacl_window.c ) diff --git a/src/waffle/nacl/nacl_dl.c b/src/waffle/nacl/nacl_dl.c new file mode 100644 index 000..7337122 --- /dev/null +++ b/src/waffle/nacl/nacl_dl.c @@ -0,0 +1,191 @@ +// Copyright 2012-2015 Intel Corporation +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include assert.h +#include dlfcn.h +#include stdio.h +#include string.h + +#include wcore_error.h + +#include nacl_container.h +#include nacl_dl.h +#include nacl_platform.h + + +static bool +nacl_dl_check_enum(int32_t waffle_dl) +{ +switch (waffle_dl) { +case WAFFLE_DL_OPENGL: +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + NACL does not support OpenGL); +return false; +case WAFFLE_DL_OPENGL_ES1: +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + NACL does not support OpenGL ES1); +return false; +case WAFFLE_DL_OPENGL_ES2: +return true; +case WAFFLE_DL_OPENGL_ES3: +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM
Re: [waffle] [PATCH v2 0/8] nacl backend implementation
On 02/12/2015 03:45 AM, Chad Versace wrote: On 02/09/2015 05:24 AM, Tapani Pälli wrote: Here's v2 of the nacl backend implementation patches. I've gone through review comments and hopefully did not forget anything. I changed the way how swapbuffers is implemented and now it blocks (so no event required). All patches are in tree here: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=nacl Alternative tree with extra patch to have naclgears testcase: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=naclgears Thanks; Tapani Pälli (8): nacl: add attrib_list parameter to create_window nacl: add supports_context_api implementation nacl: add implementation for waffle_config_choose nacl: add implementation for waffle_context_create nacl: add implementation for window create and resize nacl: add implementation for waffle_make_current nacl: add implementation for waffle_window_swap_buffers nacl: add implementation for waffle_dl_sym Tapani, This entire series, including v3 of the swap buffers patch, is Reviewed-by: Chad Versace chad.vers...@intel.com I don't fully understand the NaCl APIs in the swap buffers patch, but I'll just have to live with that. Should I pull from your 'nacl' branch or collect the patches off the list? Thanks, they match so you are free to do whichever is easier to go with! You can forward any bugs reported on this backend for me, I'll also be testing this with new nacl SDK's and adding gles3 support whenever it happens. // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH v3] nacl: add implementation for waffle_window_swap_buffers
On 02/12/2015 03:47 AM, Chad Versace wrote: On 02/09/2015 06:22 AM, Tapani Pälli wrote: Implementation for nacl is somewhat different as for other platforms, platform needs to ensure that the previous swap has finished before issuing GL commands or more swaps. This is done by introducing a worker thread that does buffer swaps from a work queue and uses a semaphore to lock main thread until swap is finished. v2: add error messaging if pp::Graphics3D::SwapBuffers fails add semaphore to implement blocking swap() remove extra nacl_swapbuffers() c++ function (Chad, Emil) v3: destroy semaphore when thread dies Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 12 + src/waffle/nacl/nacl_container.h | 2 +- src/waffle/nacl/nacl_swap_thread.h | 94 ++ src/waffle/nacl/nacl_window.c | 3 +- 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/waffle/nacl/nacl_swap_thread.h diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index fe907ff..84ab1da 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -28,11 +28,13 @@ #include ppapi/cpp/module.h #include ppapi/c/pp_errors.h #include nacl_container.h +#include nacl_swap_thread.h namespace waffle { struct nacl_container { pp::Graphics3D *ctx; +NaclSwapThread *swapper; void *glapi; bool (*glInitializePPAPI) (PPB_GetInterface); @@ -49,6 +51,7 @@ nacl_container_dtor(waffle::nacl_container *nc) if (nc-glapi) dlclose(nc-glapi); +delete nc-swapper; delete nc; } @@ -119,6 +122,7 @@ nacl_context_init(waffle::nacl_container *nc, struct nacl_config *cfg) return false; } +nc-swapper = new NaclSwapThread(pp_instance, nc-ctx); return true; } @@ -194,3 +198,11 @@ nacl_makecurrent(nacl_container *nc, bool release) return true; } + +extern C bool +nacl_swapbuffers(nacl_container *nc) +{ +waffle::nacl_container *cpp_nc = +reinterpret_castwaffle::nacl_container*(nc); +return cpp_nc-swapper-swap(); +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index ca26a1f..579856d 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -43,7 +43,7 @@ bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); bool nacl_makecurrent(struct nacl_container *nc, bool release); void nacl_context_fini(struct nacl_container *nc); - +bool nacl_swapbuffers(struct nacl_container *nc); #ifdef __cplusplus }; #endif diff --git a/src/waffle/nacl/nacl_swap_thread.h b/src/waffle/nacl/nacl_swap_thread.h new file mode 100644 index 000..8e8687b --- /dev/null +++ b/src/waffle/nacl/nacl_swap_thread.h @@ -0,0 +1,94 @@ +// Copyright 2014 Intel Corporation +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include ppapi/cpp/graphics_3d.h +#include ppapi/cpp/instance.h +#include ppapi/utility/completion_callback_factory.h +#include ppapi/utility/threading/simple_thread.h +#include wcore_error.h +#include semaphore.h + +// Thread takes care that we do not issue another buffer +// swap before previous swap has completed. +class NaclSwapThread : public pp::SimpleThread +{ +public: +explicit NaclSwapThread(const pp::InstanceHandle instance, +pp::Graphics3D *_ctx) : +pp::SimpleThread(instance), +ctx(_ctx), +cbf(this) +{ +Start(); +sem_init(sem, 0, 0
Re: [waffle] [PATCH v2 8/8] nacl: add implementation for waffle_dl_sym
On 02/12/2015 01:02 PM, Emil Velikov wrote: On 9 February 2015 at 13:24, Tapani Pälli tapani.pa...@intel.com wrote: v2: use wcore_calloc, code cleanup (Emil Velikov) open dll only once in can_open (Chad Versace) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_platform.c | 69 +++-- src/waffle/nacl/nacl_platform.h | 1 + 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c index c4fefe5..22169da 100644 --- a/src/waffle/nacl/nacl_platform.c +++ b/src/waffle/nacl/nacl_platform.c @@ -43,6 +43,11 @@ nacl_platform_destroy(struct wcore_platform *wc_self) nacl_teardown(self-nacl); +if (self-gl_dl) +if (dlclose(self-gl_dl) != 0) +wcore_errorf(WAFFLE_ERROR_UNKNOWN, dlclose failed: %s, + dlerror()); + free(self); return ok; } @@ -51,7 +56,41 @@ static bool nacl_platform_dl_can_open(struct wcore_platform *wc_self, int32_t waffle_dl) { -return false; +struct nacl_platform *self = nacl_platform(wc_self); + +switch (waffle_dl) { +case WAFFLE_DL_OPENGL_ES2: +if (!self-gl_dl) +self-gl_dl = dlopen(NACL_GLES2_LIBRARY, RTLD_LAZY); +break; +// API not supported +default: +return false; +} + +if (!self-gl_dl) +wcore_errorf(WAFFLE_ERROR_UNKNOWN, dlopen failed: %s, dlerror()); + +return self-gl_dl ? true : false; +} + +// Construct a string that maps GL function to NaCl function +// by concating given prefix and function name tail from 'src'. +static char * +nacl_prefix(const char *src, const char *prefix) +{ +if (strncmp(src, gl, 2) != 0) +return NULL; + +uint32_t len = strlen(src) + strlen(prefix); + +char *dst = wcore_calloc(len); +if (!dst) +return NULL; + +snprintf(dst, len, %s%s, prefix, src + 2); + +return dst; } static void* @@ -59,7 +98,33 @@ nacl_platform_dl_sym(struct wcore_platform *wc_self, int32_t waffle_dl, const char *name) { -return NULL; +struct nacl_platform *self = nacl_platform(wc_self); +char *nacl_name = NULL; +void *func = NULL; + +if (!self-gl_dl) +if (!nacl_platform_dl_can_open(wc_self, waffle_dl)) I'm sorry boring this again but - doing this will not set the correct error on WAFFLE_DL_OPENGL_ES3. Thanks for pointing this out. I've been now busy with some bugs but I'll promise to fix this. +return false; return NULL; Cheers, Emil // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v3] nacl: add implementation for waffle_window_swap_buffers
Implementation for nacl is somewhat different as for other platforms, platform needs to ensure that the previous swap has finished before issuing GL commands or more swaps. This is done by introducing a worker thread that does buffer swaps from a work queue and uses a semaphore to lock main thread until swap is finished. v2: add error messaging if pp::Graphics3D::SwapBuffers fails add semaphore to implement blocking swap() remove extra nacl_swapbuffers() c++ function (Chad, Emil) v3: destroy semaphore when thread dies Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 12 + src/waffle/nacl/nacl_container.h | 2 +- src/waffle/nacl/nacl_swap_thread.h | 94 ++ src/waffle/nacl/nacl_window.c | 3 +- 4 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/waffle/nacl/nacl_swap_thread.h diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index fe907ff..84ab1da 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -28,11 +28,13 @@ #include ppapi/cpp/module.h #include ppapi/c/pp_errors.h #include nacl_container.h +#include nacl_swap_thread.h namespace waffle { struct nacl_container { pp::Graphics3D *ctx; +NaclSwapThread *swapper; void *glapi; bool (*glInitializePPAPI) (PPB_GetInterface); @@ -49,6 +51,7 @@ nacl_container_dtor(waffle::nacl_container *nc) if (nc-glapi) dlclose(nc-glapi); +delete nc-swapper; delete nc; } @@ -119,6 +122,7 @@ nacl_context_init(waffle::nacl_container *nc, struct nacl_config *cfg) return false; } +nc-swapper = new NaclSwapThread(pp_instance, nc-ctx); return true; } @@ -194,3 +198,11 @@ nacl_makecurrent(nacl_container *nc, bool release) return true; } + +extern C bool +nacl_swapbuffers(nacl_container *nc) +{ +waffle::nacl_container *cpp_nc = +reinterpret_castwaffle::nacl_container*(nc); +return cpp_nc-swapper-swap(); +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index ca26a1f..579856d 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -43,7 +43,7 @@ bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); bool nacl_makecurrent(struct nacl_container *nc, bool release); void nacl_context_fini(struct nacl_container *nc); - +bool nacl_swapbuffers(struct nacl_container *nc); #ifdef __cplusplus }; #endif diff --git a/src/waffle/nacl/nacl_swap_thread.h b/src/waffle/nacl/nacl_swap_thread.h new file mode 100644 index 000..8e8687b --- /dev/null +++ b/src/waffle/nacl/nacl_swap_thread.h @@ -0,0 +1,94 @@ +// Copyright 2014 Intel Corporation +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include ppapi/cpp/graphics_3d.h +#include ppapi/cpp/instance.h +#include ppapi/utility/completion_callback_factory.h +#include ppapi/utility/threading/simple_thread.h +#include wcore_error.h +#include semaphore.h + +// Thread takes care that we do not issue another buffer +// swap before previous swap has completed. +class NaclSwapThread : public pp::SimpleThread +{ +public: +explicit NaclSwapThread(const pp::InstanceHandle instance, +pp::Graphics3D *_ctx) : +pp::SimpleThread(instance), +ctx(_ctx), +cbf(this) +{ +Start(); +sem_init(sem, 0, 0); +} + +~NaclSwapThread() +{ +sem_destroy(sem); +message_loop().PostQuit(true); +} + +bool swap
[waffle] [PATCH v2 0/8] nacl backend implementation
Here's v2 of the nacl backend implementation patches. I've gone through review comments and hopefully did not forget anything. I changed the way how swapbuffers is implemented and now it blocks (so no event required). All patches are in tree here: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=nacl Alternative tree with extra patch to have naclgears testcase: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=naclgears Thanks; Tapani Pälli (8): nacl: add attrib_list parameter to create_window nacl: add supports_context_api implementation nacl: add implementation for waffle_config_choose nacl: add implementation for waffle_context_create nacl: add implementation for window create and resize nacl: add implementation for waffle_make_current nacl: add implementation for waffle_window_swap_buffers nacl: add implementation for waffle_dl_sym src/waffle/nacl/nacl_config.c | 37 ++ src/waffle/nacl/nacl_config.h | 1 + src/waffle/nacl/nacl_container.cpp | 144 - src/waffle/nacl/nacl_container.h | 13 +++- src/waffle/nacl/nacl_context.c | 12 src/waffle/nacl/nacl_display.c | 13 +++- src/waffle/nacl/nacl_platform.c| 73 ++- src/waffle/nacl/nacl_platform.h| 1 + src/waffle/nacl/nacl_swap_thread.h | 93 src/waffle/nacl/nacl_window.c | 22 -- src/waffle/nacl/nacl_window.h | 4 +- 11 files changed, 401 insertions(+), 12 deletions(-) create mode 100644 src/waffle/nacl/nacl_swap_thread.h -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2 5/8] nacl: add implementation for window create and resize
v2: cleanup + throw error if resize fails (Chad Versace) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 27 +++ src/waffle/nacl/nacl_container.h | 1 + src/waffle/nacl/nacl_window.c | 9 ++--- src/waffle/nacl/nacl_window.h | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index e4bf07a..5dd44a8 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -26,6 +26,7 @@ #include ppapi/cpp/graphics_3d.h #include ppapi/cpp/instance.h #include ppapi/cpp/module.h +#include ppapi/c/pp_errors.h #include nacl_container.h namespace waffle { @@ -154,3 +155,29 @@ nacl_context_fini(struct nacl_container *nc) cpp_nc-glSetCurrentContextPPAPI(0); cpp_nc-glTerminatePPAPI(); } + +extern C bool +nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) +{ +waffle::nacl_container *cpp_nc = +reinterpret_castwaffle::nacl_container*(nc); + +int32_t error = cpp_nc-ctx-ResizeBuffers(width, height); + +if (error == PP_OK) + return true; + +switch (error) { +case PP_ERROR_BADRESOURCE: +wcore_errorf(WAFFLE_ERROR_FATAL, Invalid NaCl 3D context.); +break; +case PP_ERROR_BADARGUMENT: +wcore_errorf(WAFFLE_ERROR_BAD_PARAMETER, + Invalid values given for resize (w %d h %d), + width, height); +break; +default: +wcore_errorf(WAFFLE_ERROR_UNKNOWN, NaCl resize failed.); +} +return false; +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index af08116..d1cb11d 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -40,6 +40,7 @@ struct nacl_container; struct nacl_container *nacl_init(); void nacl_teardown(struct nacl_container *nc); bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); +bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); void nacl_context_fini(struct nacl_container *nc); #ifdef __cplusplus diff --git a/src/waffle/nacl/nacl_window.c b/src/waffle/nacl/nacl_window.c index 3596327..7b7121f 100644 --- a/src/waffle/nacl/nacl_window.c +++ b/src/waffle/nacl/nacl_window.c @@ -53,6 +53,7 @@ nacl_window_create(struct wcore_platform *wc_plat, { struct nacl_window *self; +struct nacl_platform *nplat = nacl_platform(wc_plat); bool ok = true; if (wcore_attrib_list_length(attrib_list) 0) { @@ -68,8 +69,9 @@ nacl_window_create(struct wcore_platform *wc_plat, if (!ok) goto error; -if (!ok) -goto error; +// Set requested dimensions for the backing surface. +if (!nacl_resize(nplat-nacl, width, height)) + goto error; return self-wcore; @@ -88,7 +90,8 @@ bool nacl_window_resize(struct wcore_window *wc_self, int32_t width, int32_t height) { -return false; +struct nacl_platform *plat = nacl_platform(wc_self-display-platform); +return nacl_resize(plat-nacl, width, height); } bool diff --git a/src/waffle/nacl/nacl_window.h b/src/waffle/nacl/nacl_window.h index 48567b1..d3465f3 100644 --- a/src/waffle/nacl/nacl_window.h +++ b/src/waffle/nacl/nacl_window.h @@ -27,6 +27,7 @@ #include wcore_window.h #include wcore_util.h +#include nacl_container.h #include nacl_platform.h struct wcore_platform; -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2 7/8] nacl: add implementation for waffle_window_swap_buffers
Implementation for nacl is somewhat different as for other platforms, platform needs to ensure that the previous swap has finished before issuing GL commands or more swaps. This is done by introducing a worker thread that does buffer swaps from a work queue and uses a semaphore to lock main thread until swap is finished. v2: add error messaging if pp::Graphics3D::SwapBuffers fails add semaphore to implement blocking swap() remove extra nacl_swapbuffers() c++ function (Chad, Emil) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 12 + src/waffle/nacl/nacl_container.h | 2 +- src/waffle/nacl/nacl_swap_thread.h | 93 ++ src/waffle/nacl/nacl_window.c | 3 +- 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 src/waffle/nacl/nacl_swap_thread.h diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index fe907ff..84ab1da 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -28,11 +28,13 @@ #include ppapi/cpp/module.h #include ppapi/c/pp_errors.h #include nacl_container.h +#include nacl_swap_thread.h namespace waffle { struct nacl_container { pp::Graphics3D *ctx; +NaclSwapThread *swapper; void *glapi; bool (*glInitializePPAPI) (PPB_GetInterface); @@ -49,6 +51,7 @@ nacl_container_dtor(waffle::nacl_container *nc) if (nc-glapi) dlclose(nc-glapi); +delete nc-swapper; delete nc; } @@ -119,6 +122,7 @@ nacl_context_init(waffle::nacl_container *nc, struct nacl_config *cfg) return false; } +nc-swapper = new NaclSwapThread(pp_instance, nc-ctx); return true; } @@ -194,3 +198,11 @@ nacl_makecurrent(nacl_container *nc, bool release) return true; } + +extern C bool +nacl_swapbuffers(nacl_container *nc) +{ +waffle::nacl_container *cpp_nc = +reinterpret_castwaffle::nacl_container*(nc); +return cpp_nc-swapper-swap(); +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index ca26a1f..579856d 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -43,7 +43,7 @@ bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); bool nacl_makecurrent(struct nacl_container *nc, bool release); void nacl_context_fini(struct nacl_container *nc); - +bool nacl_swapbuffers(struct nacl_container *nc); #ifdef __cplusplus }; #endif diff --git a/src/waffle/nacl/nacl_swap_thread.h b/src/waffle/nacl/nacl_swap_thread.h new file mode 100644 index 000..98d4630 --- /dev/null +++ b/src/waffle/nacl/nacl_swap_thread.h @@ -0,0 +1,93 @@ +// Copyright 2014 Intel Corporation +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include ppapi/cpp/graphics_3d.h +#include ppapi/cpp/instance.h +#include ppapi/utility/completion_callback_factory.h +#include ppapi/utility/threading/simple_thread.h +#include wcore_error.h +#include semaphore.h + +// Thread takes care that we do not issue another buffer +// swap before previous swap has completed. +class NaclSwapThread : public pp::SimpleThread +{ +public: +explicit NaclSwapThread(const pp::InstanceHandle instance, +pp::Graphics3D *_ctx) : +pp::SimpleThread(instance), +ctx(_ctx), +cbf(this) +{ +Start(); +sem_init(sem, 0, 0); +} + +~NaclSwapThread() +{ +message_loop().PostQuit(true); +} + +bool swap() +{ +pp::CompletionCallback cb = +cbf.NewCallback
[waffle] [PATCH v2 4/8] nacl: add implementation for waffle_context_create
Patch creates and initializes pp::Graphics3D context for OpenGL ES 2.0. v2: fix error messages and context object initialization (Chad Versace) dlclose on teardown, free the context properly (Emil Velikov) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 92 +- src/waffle/nacl/nacl_container.h | 9 src/waffle/nacl/nacl_context.c | 12 + 3 files changed, 112 insertions(+), 1 deletion(-) diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index 3e8073c..e4bf07a 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -24,12 +24,19 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include ppapi/cpp/graphics_3d.h +#include ppapi/cpp/instance.h +#include ppapi/cpp/module.h #include nacl_container.h namespace waffle { struct nacl_container { -pp::Graphics3D ctx; +pp::Graphics3D *ctx; + +void *glapi; +bool (*glInitializePPAPI) (PPB_GetInterface); +void (*glSetCurrentContextPPAPI) (PP_Resource); +bool (*glTerminatePPAPI) (void); }; static void @@ -37,6 +44,10 @@ nacl_container_dtor(waffle::nacl_container *nc) { if (!nc) return; + +if (nc-glapi) +dlclose(nc-glapi); + delete nc; } @@ -51,6 +62,65 @@ nacl_container_ctor() return nc; } +static bool +nacl_context_init(waffle::nacl_container *nc, struct nacl_config *cfg) +{ +// There is no way currently to pass a pp::Instance for Waffle, so +// we fetch a map of all instances and if there's only one we select +// that one, otherwise we fail. +const pp::Module::InstanceMap instances = +pp::Module::Get()-current_instances(); + +if (instances.size() != 1) { +wcore_errorf(WAFFLE_ERROR_FATAL, +Could not find a pp::Instance for Waffle to use.); +return false; +} + +pp::Instance *pp_instance = instances.begin()-second; +nc-ctx = new pp::Graphics3D(pp_instance, pp::Graphics3D(), cfg-attribs); + +if (nc-ctx-is_null()) { +wcore_errorf(WAFFLE_ERROR_FATAL, Unable to create NaCl 3D context.); +return false; +} + +// We need to fetch NaCl specific init, makecurrent and terminate +// functions that communicate with the browser interface. As nacl_config +// currently supports only ES2, this is hardcoded for ES2. +nc-glapi = dlopen(NACL_GLES2_LIBRARY, RTLD_LAZY); +if (!nc-glapi) { +wcore_errorf(WAFFLE_ERROR_FATAL, dlopen failed: %s, dlerror()); +return false; +} + +#define RESOLVE(func) \ +nc-func = (typeof(nc-func)) dlsym(nc-glapi, (#func)); \ +if (!nc-func) { \ +wcore_errorf(WAFFLE_ERROR_FATAL, failed to resolve %s, #func); \ +return false; \ +} + +RESOLVE(glInitializePPAPI); +RESOLVE(glSetCurrentContextPPAPI); +RESOLVE(glTerminatePPAPI); + +#undef RESOLVE + +if (!nc-glInitializePPAPI(pp::Module::Get()-get_browser_interface())) { +wcore_errorf(WAFFLE_ERROR_FATAL, +Unable to initialize GL PPAPI!); +return false; +} + +if (!pp_instance-BindGraphics(*nc-ctx)) { +wcore_errorf(WAFFLE_ERROR_FATAL, Unable to bind NaCl 3D context.); +return false; +} + +return true; +} + }; // namespace waffle ends extern C struct nacl_container* @@ -64,3 +134,23 @@ nacl_teardown(nacl_container *nc) { waffle::nacl_container_dtor(reinterpret_castwaffle::nacl_container*(nc)); } + +extern C bool +nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg) +{ +return waffle::nacl_context_init( + reinterpret_castwaffle::nacl_container*(nc), cfg); +} + +extern C void +nacl_context_fini(struct nacl_container *nc) +{ +waffle::nacl_container *cpp_nc = +reinterpret_castwaffle::nacl_container*(nc); + +delete cpp_nc-ctx; +cpp_nc-ctx = NULL; + +cpp_nc-glSetCurrentContextPPAPI(0); +cpp_nc-glTerminatePPAPI(); +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index 61d935c..af08116 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -25,13 +25,22 @@ #ifdef __cplusplus +#include dlfcn.h + extern C { #endif +#include nacl_config.h +#include wcore_error.h + +#define NACL_GLES2_LIBRARY libppapi_gles2.so + struct nacl_container; struct nacl_container *nacl_init(); void nacl_teardown(struct nacl_container *nc); +bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); +void nacl_context_fini(struct nacl_container *nc); #ifdef __cplusplus }; diff --git a/src/waffle/nacl/nacl_context.c b/src/waffle/nacl/nacl_context.c index 2e68a64..962c4d9 100644 --- a/src/waffle/nacl/nacl_context.c +++ b/src/waffle/nacl/nacl_context.c @@ -24,6 +24,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include nacl_context.h
[waffle] [PATCH v2 3/8] nacl: add implementation for waffle_config_choose
Patch fills attributes table suitable for Pepper API from wcore_config_attrs passed by the application. v2: throw error on unsupported context type (Chad Versace) code cleanup, comment for max attribs (Emil Velikov) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_config.c | 37 + src/waffle/nacl/nacl_config.h | 1 + 2 files changed, 38 insertions(+) diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c index 27a75e1..7478493 100644 --- a/src/waffle/nacl/nacl_config.c +++ b/src/waffle/nacl/nacl_config.c @@ -23,7 +23,9 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include ppapi/c/pp_graphics_3d.h #include nacl_config.h +#include wcore_error.h bool nacl_config_destroy(struct wcore_config *wc_self) @@ -50,6 +52,41 @@ nacl_config_choose(struct wcore_platform *wc_plat, if (self == NULL) return NULL; +// Currently only OpenGL ES 2.0 is supported. +if (attrs-context_api != WAFFLE_CONTEXT_OPENGL_ES2) { +wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, + NaCl does no support context type %s., + wcore_enum_to_string(attrs-context_api)); +return NULL; +} + +unsigned attr = 0; + +// Max amount of attribs is hardcoded in nacl_config.h (64) +#define PUSH_ATTRIB(a, val) \ +if (val != WAFFLE_DONT_CARE) {\ +self-attribs[attr++] = a; \ +self-attribs[attr++] = val;\ +} + +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_ALPHA_SIZE, attrs-alpha_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_BLUE_SIZE, attrs-blue_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_GREEN_SIZE, attrs-green_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_RED_SIZE, attrs-red_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_DEPTH_SIZE, attrs-depth_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_STENCIL_SIZE, attrs-stencil_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_SAMPLES,attrs-samples); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, attrs-sample_buffers); + +// Note, we have to have at least 1x1 size so that initial context +// backing surface creation will succeed without errors. Later on +// it is resized by window creation/resize. +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_WIDTH, 1); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_HEIGHT, 1); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_NONE, 0); + +#undef PUSH_ATTRIB + ok = wcore_config_init(self-wcore, wc_dpy, attrs); if (!ok) goto error; diff --git a/src/waffle/nacl/nacl_config.h b/src/waffle/nacl/nacl_config.h index 3270179..47fa252 100644 --- a/src/waffle/nacl/nacl_config.h +++ b/src/waffle/nacl/nacl_config.h @@ -33,6 +33,7 @@ struct wcore_platform; struct nacl_config { struct wcore_config wcore; +int32_t attribs[64]; }; DEFINE_CONTAINER_CAST_FUNC(nacl_config, -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2 8/8] nacl: add implementation for waffle_dl_sym
v2: use wcore_calloc, code cleanup (Emil Velikov) open dll only once in can_open (Chad Versace) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_platform.c | 69 +++-- src/waffle/nacl/nacl_platform.h | 1 + 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c index c4fefe5..22169da 100644 --- a/src/waffle/nacl/nacl_platform.c +++ b/src/waffle/nacl/nacl_platform.c @@ -43,6 +43,11 @@ nacl_platform_destroy(struct wcore_platform *wc_self) nacl_teardown(self-nacl); +if (self-gl_dl) +if (dlclose(self-gl_dl) != 0) +wcore_errorf(WAFFLE_ERROR_UNKNOWN, dlclose failed: %s, + dlerror()); + free(self); return ok; } @@ -51,7 +56,41 @@ static bool nacl_platform_dl_can_open(struct wcore_platform *wc_self, int32_t waffle_dl) { -return false; +struct nacl_platform *self = nacl_platform(wc_self); + +switch (waffle_dl) { +case WAFFLE_DL_OPENGL_ES2: +if (!self-gl_dl) +self-gl_dl = dlopen(NACL_GLES2_LIBRARY, RTLD_LAZY); +break; +// API not supported +default: +return false; +} + +if (!self-gl_dl) +wcore_errorf(WAFFLE_ERROR_UNKNOWN, dlopen failed: %s, dlerror()); + +return self-gl_dl ? true : false; +} + +// Construct a string that maps GL function to NaCl function +// by concating given prefix and function name tail from 'src'. +static char * +nacl_prefix(const char *src, const char *prefix) +{ +if (strncmp(src, gl, 2) != 0) +return NULL; + +uint32_t len = strlen(src) + strlen(prefix); + +char *dst = wcore_calloc(len); +if (!dst) +return NULL; + +snprintf(dst, len, %s%s, prefix, src + 2); + +return dst; } static void* @@ -59,7 +98,33 @@ nacl_platform_dl_sym(struct wcore_platform *wc_self, int32_t waffle_dl, const char *name) { -return NULL; +struct nacl_platform *self = nacl_platform(wc_self); +char *nacl_name = NULL; +void *func = NULL; + +if (!self-gl_dl) +if (!nacl_platform_dl_can_open(wc_self, waffle_dl)) +return false; + +nacl_name = nacl_prefix(name, GLES2); + +if (!nacl_name) +return NULL; + +func = dlsym(self-gl_dl, nacl_name); + +if (!func) { +const char *error = dlerror(); +if (error) { +wcore_errorf(WAFFLE_ERROR_UNKNOWN, + dlsym(libname=\%s\, symbol=\%s\) failed: %s, + NACL_GLES2_LIBRARY, nacl_name, error); +} +} + +free(nacl_name); + +return func; } static bool diff --git a/src/waffle/nacl/nacl_platform.h b/src/waffle/nacl/nacl_platform.h index ba58de5..fa2d364 100644 --- a/src/waffle/nacl/nacl_platform.h +++ b/src/waffle/nacl/nacl_platform.h @@ -38,6 +38,7 @@ struct nacl_platform { struct wcore_platform wcore; struct nacl_container *nacl; +void *gl_dl; }; DEFINE_CONTAINER_CAST_FUNC(nacl_platform, -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2 2/8] nacl: add supports_context_api implementation
Currently only OpenGL ES 2.0 is supported. v2: throw error only on erroneous input (Chad Versace) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_display.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/waffle/nacl/nacl_display.c b/src/waffle/nacl/nacl_display.c index 2d1162e..d1906fe 100644 --- a/src/waffle/nacl/nacl_display.c +++ b/src/waffle/nacl/nacl_display.c @@ -66,5 +66,16 @@ bool nacl_display_supports_context_api(struct wcore_display *wc_self, int32_t context_api) { -return false; +switch (context_api) { +case WAFFLE_CONTEXT_OPENGL_ES2: +return true; +case WAFFLE_CONTEXT_OPENGL: +case WAFFLE_CONTEXT_OPENGL_ES1: +case WAFFLE_CONTEXT_OPENGL_ES3: +return false; +default: +wcore_error_internal(waffle_context_api has bad value %#x, + context_api); +return false; +} } -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2 6/8] nacl: add implementation for waffle_make_current
v2: cleanup code, no need for separate c++ function (Chad Versace) release context when ctx and window are NULL (Emil Velikov) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 13 + src/waffle/nacl/nacl_container.h | 1 + src/waffle/nacl/nacl_platform.c| 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index 5dd44a8..fe907ff 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -181,3 +181,16 @@ nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) } return false; } + +extern C bool +nacl_makecurrent(nacl_container *nc, bool release) +{ +waffle::nacl_container *cpp_nc = +reinterpret_castwaffle::nacl_container*(nc); + +PP_Resource ctx = release ? 0 : cpp_nc-ctx-pp_resource(); + +cpp_nc-glSetCurrentContextPPAPI(ctx); + +return true; +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index d1cb11d..ca26a1f 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -41,6 +41,7 @@ struct nacl_container *nacl_init(); void nacl_teardown(struct nacl_container *nc); bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); +bool nacl_makecurrent(struct nacl_container *nc, bool release); void nacl_context_fini(struct nacl_container *nc); #ifdef __cplusplus diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c index b4df9d9..c4fefe5 100644 --- a/src/waffle/nacl/nacl_platform.c +++ b/src/waffle/nacl/nacl_platform.c @@ -68,7 +68,9 @@ nacl_platform_make_current(struct wcore_platform *wc_self, struct wcore_window *wc_window, struct wcore_context *wc_ctx) { -return false; +bool release = (!wc_window !wc_ctx); +return nacl_makecurrent(nacl_platform(wc_self)-nacl, +release); } struct wcore_platform* -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2 1/8] nacl: add attrib_list parameter to create_window
Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_window.c | 10 +- src/waffle/nacl/nacl_window.h | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/waffle/nacl/nacl_window.c b/src/waffle/nacl/nacl_window.c index c5ba4e0..3596327 100644 --- a/src/waffle/nacl/nacl_window.c +++ b/src/waffle/nacl/nacl_window.c @@ -24,6 +24,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include wcore_error.h +#include wcore_attrib_list.h #include nacl_config.h #include nacl_display.h #include nacl_window.h @@ -47,11 +48,18 @@ struct wcore_window* nacl_window_create(struct wcore_platform *wc_plat, struct wcore_config *wc_config, int width, - int height) + int height, + const intptr_t attrib_list[]) + { struct nacl_window *self; bool ok = true; +if (wcore_attrib_list_length(attrib_list) 0) { +wcore_error_bad_attribute(attrib_list[0]); +return NULL; +} + self = wcore_calloc(sizeof(*self)); if (self == NULL) return NULL; diff --git a/src/waffle/nacl/nacl_window.h b/src/waffle/nacl/nacl_window.h index 5f0906d..48567b1 100644 --- a/src/waffle/nacl/nacl_window.h +++ b/src/waffle/nacl/nacl_window.h @@ -43,7 +43,8 @@ struct wcore_window* nacl_window_create(struct wcore_platform *wc_plat, struct wcore_config *wc_config, int width, - int height); + int height, + const intptr_t attrib_list[]); bool nacl_window_destroy(struct wcore_window *wc_self); -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 0/7] nacl backend implementation
On 02/06/2015 11:58 PM, Chad Versace wrote: On 02/05/2015 04:45 AM, Tapani wrote: On 02/05/2015 09:47 AM, Tapani Pälli wrote: On 02/03/2015 10:07 PM, Chad Versace wrote: It seems that two solutions are available: S1. Provide waffle_set_swap_buffers_callback(). S2. On Waffle's NaCl backend, implement waffle_swap_buffers() to block until the back buffer has been composited onto the web page. (I believe this is possible to implement without a worker thread). I guess it is possible but not without introducing extra latency/slowness for the application thread which I was trying to avoid. Ideally app could continue doing something else while swap goes on. I also don't want Waffle to force latency onto the app. I originally though that Solution2 (a blocking swapbuffers on NaCl) did not force any latency, as long as the application created a separate presentation thread that performed the swap buffer calls. But I no longer have that opinion. Maintaining a seprate presentation thread that does swapbuffer calls and a rendering thread that does the real rendering is difficult to do safely in OpenGL, because OpenGL is inherently a single-threaded API. And I've heard that some drivers are fundamentally broken with respect to multi-threading. So, I agree with you now. If waffle_window_swap_buffers() blocks, that *will* force latency onto the NaCl app unless Waffle also provides some alternative non-blocking way to swap buffers, because we can't reasonably expect applications to avoid the latency by creating a separate presentation thread and suffering through the inevitable OpenGL headaches. Right, it can be rather painful. Maybe some non-blocking option can be planned as the future API, if not with traditional GL then perhaps with glNext. One of the design goals I have in Waffle is that the application's use of Waffle should vary as little as possible across platforms. If, to obtain correct rendering behavior, Waffle requires users on NaCl to use a swapbuffer callback but on non-NaCl platforms the callback is unneeded, then then I feel such a callback violates the design goal. That's the main reason I'm opposed to the callback. Yes, I agree on this point and respect this decision. Portability and ease of use should be the main driver here, it feels bad to introduce additional API for just one backend. I'd like the default behavior of waffle_window_swap_buffers() on NaCl to be blocking behavior due the design goal above. The default behavior should give correct rendering like it does on all other platforms. Then, in follow-up patches, we can start working on providing non-blocking solutions, either with a callback or cookie mechanism. I don't want to lightly add a callback mechanism as part of this series, because implementing it correctly, in a way compatible with non-NaCl usage, will require adding callback queue and dispatch to Waffle, a non-trivial task. Once the NaCl patches landed, with blocking swapbuffers, then let's have a realtime conversation on how to implement the non-blocking alternative. OK, I'll try to get blocking behaviour to work. I'm a bit surprised that there seems no way to 'flush pending events' or something like this in NaCl which would make this much easier to implement. Having experimented this for some time with this I don't think this is possible to implement. Problem is that I can't wait in the main thread for the callback to be called (blocking somewhere within waffle_swap_buffers), the event dispatcher never gets run and there is no API to 'flush event queue' or 'run single iteration of event dispatcher'. There is way to get pp::MessageLoop of the main thread but you can just post more work to it. I vote for the thread, I don't find problems with it :) Thanks for explaining that. I understand now why the helper thread is needed to implement a blocking swap buffers. I have two more experiments that may be worth doing: - If you pass PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR=PP_GRAPHICS3DATTRIB_BUFFER_DESTROYED to PPB_Graphics3D::Create, then does PPB_Graphics3D::SwapBuffers behave more traditionally? That is, if you begin rendering immediately after it returns, do you get correct rendering? I ask this because I hope NaCl implements BUFFER_DESTROYED with double- or triple-buffering. - The same question, but passing the attribute to PPB_Graphics3D::SetAttribs instead. Thanks, I'll try these out! // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 0/7] nacl backend implementation
On 02/03/2015 10:07 PM, Chad Versace wrote: On 01/30/2015 02:33 AM, Tapani Pälli wrote: Hi; As a Finn I interpret silence as 'yes' :) A safe assumption in many open source cultures :) So I started to hack on swap completion event support. I believe it can be useful for other backends also since then application can throttle rendering and receive information on swaps. I made early hacky prototype that fixes the issues I've seen with nacl backend: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=hacky I have a few questions on implementation details for the 'waffle_swap_complete'. This is my proposal for the API: typedef void (*waffle_swapbuffers_cb) (struct waffle_window *); bool waffle_set_swap_complete_handler(waffle_swapbuffers_cb func); (would fail if backend does not support this) Optionally we could put timestamp there also as callback data but I'm not sure what format is preferred for that. Any ideas here would be good. I'm not sure the OML triple (ust, msc, sbc) like in GLX_INTEL_swap_event make sense or should it be something simpler? We shouldn't return timestamp information. Some Waffle platforms do not provide that information. And for some that do, like GLX_INTEL_swap_event, the OML triple is often lie. For example, NVidia hardware doesn't monitor usr, msc, sbc because it requires an interrupt to detect. I think the same is true for recent Intel GPUs too, but I'm not sure. For Waffle to return an accurate OML triple, the compositor must provide that information to Waffle. But, this opens up a can of worms. What exactly indicates swap buffer completion? When the compositor client's GL command stream has completed execution? When the compositor's GL command stream for compositing the client buffer has completed execution? When the compositor has scheduled a post to display that will present the client's back buffer? When the display hardware has completed the requested presentation? Argh!!! How do you choose?!?! Right, it seems quite a problematic api as a whole. The sad state of the world is, if you choose one of the above to mean completion of swap buffers, Waffle will be able to query the chosen completion timestamps on only a proper subset, possibly empty, of Waffle's supported platforms. No choice is supported on all display systems. I agree and simple callback is enough for nacl which seems the only user for now. Then, whenever waffle_wndow_swap_buffers(window) gets called, backend will call callback if it is set. It should be noted that it can happen from a separate thread. How does this sound? It seems that two solutions are available: S1. Provide waffle_set_swap_buffers_callback(). S2. On Waffle's NaCl backend, implement waffle_swap_buffers() to block until the back buffer has been composited onto the web page. (I believe this is possible to implement without a worker thread). I guess it is possible but not without introducing extra latency/slowness for the application thread which I was trying to avoid. Ideally app could continue doing something else while swap goes on. Let's analyze both solutions, keeping in mind two obstacles: O1. In NaCl, it is illegal to render to the default framebuffer until PPB_Graphics3D::SwapBuffers invokes its callback. O2. If a NaCl app blocks on the main thread, the UI becomes unresponsive. Waffle's API must protect against O1. Corrupt rendering is unacceptable. Case !O2 = Suppose that we don't care about O2. Let the UI hang. Then the simplest solution is S2. Let waffle_window_swap_buffers() block. Then we don't have to worry about the semantics of a waffle_window_swap_buffers_callback on the different platforms. I will spend some time prototyping this blocking case to have a stronger opinion. Case O2 === Suppose now that we do care about O2. Perhaps we care because we want to write an interactive GL testcase. Then Waffle's API must provide enough machinery to allow the application to avoid blocking on the main thread, and that machinery should be as simple as possible. Subcase O2 + S2 --- If we choose solution 2, then the testcase/app will need to delegate waffle_window_swap_buffers() to a child presentation thread. The app will need to implement its own cross-thread synchronization between the main thread and the presentation thread. For a small testcase of demo app, requiring the user to implement this synchronization feels like overkill. Real NaCl games must use a separate rendering and presentation threads anyway if they do non-trivial rendering. However, I don't believe real games are not Waffle's concern. Waffle is for little apps and testcases. However, S2 keeps the Waffle API simple and is easy to implement. I agree simple sounds good. IMO Waffle has a good chance to be a porting layer for a bigger application too, overall porting effort feels quite small. Subcase O2 + S1 --- If we choose solution 1
Re: [waffle] [PATCH 5/7] nacl: add implementation for waffle_make_current
On 02/03/2015 05:48 PM, Emil Velikov wrote: On 23 January 2015 at 07:59, Tapani Pälli tapani.pa...@intel.com wrote: Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 17 + src/waffle/nacl/nacl_container.h | 1 + src/waffle/nacl/nacl_platform.c| 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index bca39eb..abd64fd 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -135,6 +135,16 @@ nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) return true; } +static bool +nacl_makecurrent(waffle::nacl_container *nc) +{ +if (!nc) +return false; + +nc-glSetCurrentContextPPAPI(nc-ctx.pp_resource()); +return true; +} + [...] diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c index b4df9d9..20a9739 100644 --- a/src/waffle/nacl/nacl_platform.c +++ b/src/waffle/nacl/nacl_platform.c @@ -68,7 +68,7 @@ nacl_platform_make_current(struct wcore_platform *wc_self, struct wcore_window *wc_window, struct wcore_context *wc_ctx) { -return false; +return nacl_makecurrent(nacl_platform(wc_self)-nacl); If I understood you correctly - in order to drop the current ctx one needs nc-glSetCurrentContextPPAPI(0); On the other hand, as wc_window/wc_ctx are NULL you'll still try to bind the ctx in nc-ctx. Is this some platform limitation ? Nope, I forgot the NULL case! Thanks! -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] [RFC] waffle: support for swap completion callback
On 02/03/2015 07:32 PM, Emil Velikov wrote: On 2 February 2015 at 13:08, Tapani Pälli tapani.pa...@intel.com wrote: Patch introduces a new API that enables application to register a callback to be called when swapbuffers has finished. This can be used to throttle rendering loop. [...] @@ -173,6 +174,9 @@ bool waffle_is_extension_in_string(const char *extension_string, const char *extension_name); +bool +waffle_register_swap_callback(waffle_swapbuffers_cb func); + Perhaps inlining the typedef in there, and wrapping it in WAFFLE_API_VERSION (alongside the function prototype) ? I put it in separate header so that wcore_platform.h would not need to include whole waffle.h but if that feels ok then typedef can be moved here. Fwiw changing the func prototype to something like the following will be more consistent, and less likely to abuse. bool waffle_window_register_swap_callback(struct waffle_window *window, waffle_swapbuffers_cb func); This means that callback would be window specific. I think this is ok, although then user needs to register callback for each window separately and window argument could be removed from the actual callback. On the topic of the OML triple (ust, msc, sbc), I cannot really comment as I've never had the pleasure. diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c index 138974d..ac155c0 100644 --- a/src/waffle/api/waffle_gl_misc.c +++ b/src/waffle/api/waffle_gl_misc.c @@ -108,3 +108,20 @@ waffle_get_proc_address(const char *name) return api_platform-vtbl-get_proc_address(api_platform, name); } + +WAFFLE_API bool +waffle_register_swap_callback(waffle_swapbuffers_cb func) +{ +const struct api_object *obj_list[] = { +(void*) func, +}; + +if (!api_check_entry(obj_list, 1)) +return false; + With the struct waffle_window * in you can use it so that one does not abuse the API too much :) I'm now sure what would be the abuse case? +if (api_platform-vtbl-register_swap_callback) +return api_platform-vtbl-register_swap_callback(api_platform, func); + +wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); I'm not sure if we should error in here, considering that one of all platforms is likely to have a callback func. Cheers, 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 3/7] nacl: add implementation for waffle_context_create
On 02/03/2015 08:26 PM, Chad Versace wrote: On 02/03/2015 07:37 AM, Emil Velikov wrote: On 23 January 2015 at 07:59, Tapani Pälli tapani.pa...@intel.com wrote: Patch creates and initializes pp::Graphics3D context for OpenGL ES 2.0. Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- [...] @@ -37,6 +43,10 @@ nacl_container_dtor(waffle::nacl_container *nc) { if (!nc) return; + + nc-ctx = pp::Graphics3D(); I would guess that you want to nuke the Graphics3D ctx first ? +nc-glSetCurrentContextPPAPI(0); +nc-glTerminatePPAPI(); + Imho the teardown should be symmetrical to the setup - i.e. create a new function nacl_context_fini (or similar) which has the above three calls, and gets executed in nacl_context_destroy. I just want to echo Emil here. Writing teardown to be symmteric to setup is generally a good idea. OK, will do. +static bool +nacl_context_init(waffle::nacl_container *nc, struct nacl_config *cfg) +{ [...] + +dlclose(glapi); + Calling the function pointers after closing the handle causes segfaults on my Archlinux machine. Am I the only one or does nacl has something special in this regard ? Hmmm... This seems wrong to me too. Huh yes, this is wrong. I believe it works currently only because the functions resolved do not allocate memory ... maybe. I will move dlclose to happen when teardown happens. // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [RFC] waffle: support for swap completion callback
Patch introduces a new API that enables application to register a callback to be called when swapbuffers has finished. This can be used to throttle rendering loop. Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- (This is a API proposal for swap event callback.) include/CMakeLists.txt | 1 + include/waffle/waffle.h | 4 include/waffle/waffle_typedefs.h | 38 ++ src/waffle/api/waffle_gl_misc.c | 17 + src/waffle/core/wcore_platform.h | 9 + src/waffle/waffle.def.in | 3 ++- 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 include/waffle/waffle_typedefs.h diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index e190a76..ba84e95 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -7,6 +7,7 @@ install( waffle/waffle.h waffle/waffle_gbm.h waffle/waffle_glx.h +waffle/waffle_typedefs.h waffle/waffle_version.h waffle/waffle_wayland.h waffle/waffle_x11_egl.h diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h index 77885a4..e421375 100644 --- a/include/waffle/waffle.h +++ b/include/waffle/waffle.h @@ -31,6 +31,7 @@ #include stdlib.h #include waffle_version.h +#include waffle_typedefs.h #ifdef __cplusplus extern C { @@ -173,6 +174,9 @@ bool waffle_is_extension_in_string(const char *extension_string, const char *extension_name); +bool +waffle_register_swap_callback(waffle_swapbuffers_cb func); + // --- // waffle_display // --- diff --git a/include/waffle/waffle_typedefs.h b/include/waffle/waffle_typedefs.h new file mode 100644 index 000..6532de4 --- /dev/null +++ b/include/waffle/waffle_typedefs.h @@ -0,0 +1,38 @@ +// Copyright 2015 Intel Corporation +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#pragma once + +#ifdef __cplusplus +extern C { +#endif + +struct waffle_window; + +typedef void (*waffle_swapbuffers_cb) (const struct waffle_window *window); + +#ifdef __cplusplus +} // end extern C +#endif diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c index 138974d..ac155c0 100644 --- a/src/waffle/api/waffle_gl_misc.c +++ b/src/waffle/api/waffle_gl_misc.c @@ -108,3 +108,20 @@ waffle_get_proc_address(const char *name) return api_platform-vtbl-get_proc_address(api_platform, name); } + +WAFFLE_API bool +waffle_register_swap_callback(waffle_swapbuffers_cb func) +{ +const struct api_object *obj_list[] = { +(void*) func, +}; + +if (!api_check_entry(obj_list, 1)) +return false; + +if (api_platform-vtbl-register_swap_callback) +return api_platform-vtbl-register_swap_callback(api_platform, func); + +wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); +return NULL; +} diff --git a/src/waffle/core/wcore_platform.h b/src/waffle/core/wcore_platform.h index 77943e4..5f53ab8 100644 --- a/src/waffle/core/wcore_platform.h +++ b/src/waffle/core/wcore_platform.h @@ -30,6 +30,8 @@ #include stdint.h #include c99_compat.h +#include waffle_typedefs.h + struct wcore_config; struct wcore_config_attrs; struct wcore_context; @@ -64,6 +66,12 @@ struct wcore_platform_vtbl { int32_t waffle_dl, const char *symbol); +/// May be null. +bool +(*register_swap_callback)( +struct wcore_platform *self, +waffle_swapbuffers_cb callback); + struct wcore_display_vtbl { struct wcore_display
Re: [waffle] [PATCH 1/7] nacl: add supports_context_api implementation
On 02/03/2015 12:59 AM, Chad Versace wrote: On 01/22/2015 11:59 PM, Tapani Pälli wrote: Currently only OpenGL ES 2.0 is supported. Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_display.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/waffle/nacl/nacl_display.c b/src/waffle/nacl/nacl_display.c index 2d1162e..514d644 100644 --- a/src/waffle/nacl/nacl_display.c +++ b/src/waffle/nacl/nacl_display.c @@ -66,5 +66,12 @@ bool nacl_display_supports_context_api(struct wcore_display *wc_self, int32_t context_api) { -return false; +switch (context_api) { +case WAFFLE_CONTEXT_OPENGL_ES2: +return true; +default: +wcore_error_internal(api %#x not supported by nacl platform., + context_api); +return false; +} } Almost. The return values are correct. But waffle_display_supports_context_api() should emit an error only if an error happens or if user supplies erroneous input. See cgl_display_supports_context_api() for a good example. thanks, will fix ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 2/7] nacl: add implementation for waffle_config_choose
On 02/03/2015 01:06 AM, Chad Versace wrote: On 01/22/2015 11:59 PM, Tapani Pälli wrote: Patch fills attributes table suitable for Pepper API from wcore_config_attrs passed by the application. Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_config.c | 30 ++ src/waffle/nacl/nacl_config.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c index 27a75e1..d31bf97 100644 --- a/src/waffle/nacl/nacl_config.c +++ b/src/waffle/nacl/nacl_config.c @@ -50,6 +50,36 @@ nacl_config_choose(struct wcore_platform *wc_plat, if (self == NULL) return NULL; +// Currently only OpenGL ES 2.0 is supported. +if (attrs-context_api != WAFFLE_CONTEXT_OPENGL_ES2) +return NULL; When config creation fails, Waffle needs to emit an error to tell the user why. This check should look like this: if (attrs-context_api != WAFFLE_CONTEXT_OPENGL_ES2) { wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, CGL does not support debug contexts); return false; } will fix + +unsigned attr = 0; + +#define PUSH_ATTRIB(a, val) \ +if (val != WAFFLE_DONT_CARE) {\ +self-attribs[attr++] = a; \ +self-attribs[attr++] = val;\ +} + +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_ALPHA_SIZE, attrs-alpha_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_BLUE_SIZE, attrs-blue_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_GREEN_SIZE, attrs-green_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_RED_SIZE, attrs-red_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_DEPTH_SIZE, attrs-depth_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_STENCIL_SIZE, attrs-stencil_size); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_SAMPLES,attrs-samples); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, attrs-sample_buffers); + +// Note, we have to have at least 1x1 size initially so that initial +// context backing surface creation will succeed without errors. Later +// on it is resized by window creation/resize. +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_WIDTH, 1); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_HEIGHT, 1); +PUSH_ATTRIB(PP_GRAPHICS3DATTRIB_NONE, 0); Interesting. I didn't know that NaCl bound the render dimensions into the config. Yep, it goes and creates a backing surface (fbo) immediatly and if width and height are not set, there's a (harmless but annoying) error on console about 0x0 size. // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 4/7] nacl: add implementation for window create and resize
On 02/03/2015 01:28 AM, Chad Versace wrote: On 01/22/2015 11:59 PM, Tapani Pälli wrote: Signed-off-by: Tapani Pälli tapani.pa...@intel.com 8 + +extern C bool +nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) +{ +return waffle::nacl_resize( + reinterpret_castwaffle::nacl_container*(nc), + width, height); +} It's legal to make C++ calls inside `extern C` fuctions. So, I think you can remove waffle::nacl_resize() and just do everything inside the C nacl_resize(). This should probably work: extern C bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) { waffle::nacl_container *cpp_nc = reinterpreet_castwaffle::nacl_container*(nc); if (!cpp_nc || cpp_nc-ctx.ResizeBuffers(width, height) != PP_OK) return false; return true; } Yep, works fine. I will change this and the other functions. I think the check for cpp_nc can be also be removed as the container will always be there and cast result would be undefined behaviour if it would fail. diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index 81472cc..f3ede41 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -40,6 +40,7 @@ struct nacl_container; struct nacl_container *nacl_init(); void nacl_teardown(struct nacl_container *nc); bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); +bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); #ifdef __cplusplus }; diff --git a/src/waffle/nacl/nacl_window.c b/src/waffle/nacl/nacl_window.c index c5ba4e0..eef1d1d 100644 --- a/src/waffle/nacl/nacl_window.c +++ b/src/waffle/nacl/nacl_window.c @@ -50,12 +50,16 @@ nacl_window_create(struct wcore_platform *wc_plat, int height) { struct nacl_window *self; +struct nacl_platform *nplat = nacl_platform(wc_plat); bool ok = true; self = wcore_calloc(sizeof(*self)); if (self == NULL) return NULL; +// Set requested dimensions for the backing surface. +nacl_resize(nplat-nacl, width, height); + ok = wcore_window_init(self-wcore, wc_config); if (!ok) goto error; @@ -80,7 +84,8 @@ bool nacl_window_resize(struct wcore_window *wc_self, int32_t width, int32_t height) { -return false; +struct nacl_platform *plat = nacl_platform(wc_self-display-platform); +return nacl_resize(plat-nacl, width, height); When this function returns false, it needs to emit an error explaining why. If it's difficult to discover why, then it's always acceptable to emit the error like this wcore_error(WAFFLE_ERROR_UNKNOWN) or like this wcore_errorf(WAFFLE_ERROR_UNKNOWN, pp::Graphics3D::ResizeBuffers failed) } OK, I will add errors codes here. bool diff --git a/src/waffle/nacl/nacl_window.h b/src/waffle/nacl/nacl_window.h index 5f0906d..929 100644 --- a/src/waffle/nacl/nacl_window.h +++ b/src/waffle/nacl/nacl_window.h @@ -27,6 +27,7 @@ #include wcore_window.h #include wcore_util.h +#include nacl_container.h #include nacl_platform.h struct wcore_platform; ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 0/7] nacl backend implementation
Hi; As a Finn I interpret silence as 'yes' :) So I started to hack on swap completion event support. I believe it can be useful for other backends also since then application can throttle rendering and receive information on swaps. I made early hacky prototype that fixes the issues I've seen with nacl backend: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=hacky I have a few questions on implementation details for the 'waffle_swap_complete'. This is my proposal for the API: typedef void (*waffle_swapbuffers_cb) (struct waffle_window *); bool waffle_set_swap_complete_handler(waffle_swapbuffers_cb func); (would fail if backend does not support this) Optionally we could put timestamp there also as callback data but I'm not sure what format is preferred for that. Any ideas here would be good. I'm not sure the OML triple (ust, msc, sbc) like in GLX_INTEL_swap_event make sense or should it be something simpler? Then, whenever waffle_wndow_swap_buffers(window) gets called, backend will call callback if it is set. It should be noted that it can happen from a separate thread. How does this sound? On 01/27/2015 03:03 PM, Tapani Pälli wrote: Hello; Unfortunately I've noticed a problem with the implementation. Native client expects 3D API to be used so that caller passes a callback that gets called when swapbuffers finishes. I haven't found explicit documentation of this to be *mandatory* but all the examples work this way and lots of comments on different forums suggest to use it like this. Now what follows is that while current nacl backend takes care that user cannot 'bomb' swapbuffers callback, it cannot take care that user would not go and call GL API (for example glClear) before swapbuffers finishes. For this to happen there would need to be callback mechanism or a new API to call on start of each frame. I'm not yet 100% sure but I believe this would fix the issues I'm seeing ATM. I ported es2gears to Waffle to experiment this, here is a version that shows the problem, the artifacts on top of gears seem to relate to calling glClear 'too early' as if I remove glClear call it looks good, just not cleared: http://koti.kapsi.fi/~tpalli/naclgears-bug/ Here's a hacked version where I sleep (just a tiny bit) between frames and tadaa it works: http://koti.kapsi.fi/~tpalli/naclgears/ I'm not yet sure what to do with this, one option would be to offer a callback mechanism in Waffle (swap finished) but there are no existing callbacks like this in waffle. Would it be ok and create something like this? Thanks; On 01/23/2015 09:59 AM, Tapani Pälli wrote: Hi; Here are patches for the NaCl backend implementation. While testing I noticed that there is a general issue with Chrome and DRI3 which is well described here: http://keithp.com/blogs/chromium-dri3/ . So for testing on DRI3 you'll need to use '--disable-gpu-sandbox' for this to work. Otherwise you will see : libGL error: DRI3 Fence object allocation failure Operation not permitted which results in everything else failing, like creation of graphics context and so on. I haven't checked what's the status of fixing this but it is good to know when testing. This happened to me on Fedora 21. The whole series is in a branch here: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=nacl and a 'demo' of gl_basic available here: http://koti.kapsi.fi/~tpalli/nacl/ Note, I will be extending this to support OpenGL ES 3.0 later/soon. I'm also investigating how to make this work for portable native client, pnacl-clang. Thanks; Tapani Pälli (7): nacl: add supports_context_api implementation nacl: add implementation for waffle_config_choose nacl: add implementation for waffle_context_create nacl: add implementation for window create and resize nacl: add implementation for waffle_make_current nacl: add implementation for waffle_window_swap_buffers nacl: add implementation for waffle_dl_sym src/waffle/nacl/nacl_config.c | 30 src/waffle/nacl/nacl_config.h | 2 + src/waffle/nacl/nacl_container.cpp | 136 + src/waffle/nacl/nacl_container.h | 11 +++ src/waffle/nacl/nacl_context.c | 6 ++ src/waffle/nacl/nacl_display.c | 9 ++- src/waffle/nacl/nacl_platform.c| 65 +- src/waffle/nacl/nacl_platform.h| 1 + src/waffle/nacl/nacl_swap_thread.h | 72 src/waffle/nacl/nacl_window.c | 10 ++- src/waffle/nacl/nacl_window.h | 1 + 11 files changed, 337 insertions(+), 6 deletions(-) create mode 100644 src/waffle/nacl/nacl_swap_thread.h ___ 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 0/7] nacl backend implementation
Hello; Unfortunately I've noticed a problem with the implementation. Native client expects 3D API to be used so that caller passes a callback that gets called when swapbuffers finishes. I haven't found explicit documentation of this to be *mandatory* but all the examples work this way and lots of comments on different forums suggest to use it like this. Now what follows is that while current nacl backend takes care that user cannot 'bomb' swapbuffers callback, it cannot take care that user would not go and call GL API (for example glClear) before swapbuffers finishes. For this to happen there would need to be callback mechanism or a new API to call on start of each frame. I'm not yet 100% sure but I believe this would fix the issues I'm seeing ATM. I ported es2gears to Waffle to experiment this, here is a version that shows the problem, the artifacts on top of gears seem to relate to calling glClear 'too early' as if I remove glClear call it looks good, just not cleared: http://koti.kapsi.fi/~tpalli/naclgears-bug/ Here's a hacked version where I sleep (just a tiny bit) between frames and tadaa it works: http://koti.kapsi.fi/~tpalli/naclgears/ I'm not yet sure what to do with this, one option would be to offer a callback mechanism in Waffle (swap finished) but there are no existing callbacks like this in waffle. Would it be ok and create something like this? Thanks; On 01/23/2015 09:59 AM, Tapani Pälli wrote: Hi; Here are patches for the NaCl backend implementation. While testing I noticed that there is a general issue with Chrome and DRI3 which is well described here: http://keithp.com/blogs/chromium-dri3/ . So for testing on DRI3 you'll need to use '--disable-gpu-sandbox' for this to work. Otherwise you will see : libGL error: DRI3 Fence object allocation failure Operation not permitted which results in everything else failing, like creation of graphics context and so on. I haven't checked what's the status of fixing this but it is good to know when testing. This happened to me on Fedora 21. The whole series is in a branch here: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=nacl and a 'demo' of gl_basic available here: http://koti.kapsi.fi/~tpalli/nacl/ Note, I will be extending this to support OpenGL ES 3.0 later/soon. I'm also investigating how to make this work for portable native client, pnacl-clang. Thanks; Tapani Pälli (7): nacl: add supports_context_api implementation nacl: add implementation for waffle_config_choose nacl: add implementation for waffle_context_create nacl: add implementation for window create and resize nacl: add implementation for waffle_make_current nacl: add implementation for waffle_window_swap_buffers nacl: add implementation for waffle_dl_sym src/waffle/nacl/nacl_config.c | 30 src/waffle/nacl/nacl_config.h | 2 + src/waffle/nacl/nacl_container.cpp | 136 + src/waffle/nacl/nacl_container.h | 11 +++ src/waffle/nacl/nacl_context.c | 6 ++ src/waffle/nacl/nacl_display.c | 9 ++- src/waffle/nacl/nacl_platform.c| 65 +- src/waffle/nacl/nacl_platform.h| 1 + src/waffle/nacl/nacl_swap_thread.h | 72 src/waffle/nacl/nacl_window.c | 10 ++- src/waffle/nacl/nacl_window.h | 1 + 11 files changed, 337 insertions(+), 6 deletions(-) create mode 100644 src/waffle/nacl/nacl_swap_thread.h ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 5/7] nacl: add implementation for waffle_make_current
Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- src/waffle/nacl/nacl_container.cpp | 17 + src/waffle/nacl/nacl_container.h | 1 + src/waffle/nacl/nacl_platform.c| 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp index bca39eb..abd64fd 100644 --- a/src/waffle/nacl/nacl_container.cpp +++ b/src/waffle/nacl/nacl_container.cpp @@ -135,6 +135,16 @@ nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) return true; } +static bool +nacl_makecurrent(waffle::nacl_container *nc) +{ +if (!nc) +return false; + +nc-glSetCurrentContextPPAPI(nc-ctx.pp_resource()); +return true; +} + }; // namespace waffle ends extern C struct nacl_container* @@ -163,3 +173,10 @@ nacl_resize(struct nacl_container *nc, int32_t width, int32_t height) reinterpret_castwaffle::nacl_container*(nc), width, height); } + +extern C bool +nacl_makecurrent(nacl_container *nc) +{ +return waffle::nacl_makecurrent( + reinterpret_castwaffle::nacl_container*(nc)); +} diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h index f3ede41..5341141 100644 --- a/src/waffle/nacl/nacl_container.h +++ b/src/waffle/nacl/nacl_container.h @@ -41,6 +41,7 @@ struct nacl_container *nacl_init(); void nacl_teardown(struct nacl_container *nc); bool nacl_context_init(struct nacl_container *nc, struct nacl_config *cfg); bool nacl_resize(struct nacl_container *nc, int32_t width, int32_t height); +bool nacl_makecurrent(struct nacl_container *nc); #ifdef __cplusplus }; diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c index b4df9d9..20a9739 100644 --- a/src/waffle/nacl/nacl_platform.c +++ b/src/waffle/nacl/nacl_platform.c @@ -68,7 +68,7 @@ nacl_platform_make_current(struct wcore_platform *wc_self, struct wcore_window *wc_window, struct wcore_context *wc_ctx) { -return false; +return nacl_makecurrent(nacl_platform(wc_self)-nacl); } struct wcore_platform* -- 2.1.0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v2] waffle: make gl_basic to work with nacl
v2: fixes in cmake (Emil Velikov, Chad Versace) Changed also nmf file content and generation, moved nacl example content to separate output path. Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- .gitignore| 1 + cmake/Modules/WaffleDefineCompilerFlags.cmake | 10 -- examples/CMakeLists.txt | 46 +++ examples/gl_basic.c | 21 examples/index.html | 43 + 5 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 examples/index.html diff --git a/.gitignore b/.gitignore index 6981cd7..99b8e09 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ Makefile /doc/html/man/wflinfo.1.html /examples/gl_basic /examples/simple-x11-egl +/html/ /lib/ /libcmocka.a /src/waffle/libwaffle_static.a diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake b/cmake/Modules/WaffleDefineCompilerFlags.cmake index 7532a91..679d09c 100644 --- a/cmake/Modules/WaffleDefineCompilerFlags.cmake +++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake @@ -45,12 +45,16 @@ if (NOT MSVC) # enough for single-stepping. set(CMAKE_C_FLAGS_RELEASE -g1 -O2 -DNDEBUG) -waffle_add_c_flag(-Werror=implicit-function-declaration WERROR_IMPLICIT_FUNCTION_DECLARATION) +# These are disabled for NaCl because compilation against ppapi_simple would fail. +if(NOT waffle_has_nacl) +waffle_add_c_flag(-Werror=implicit-function-declaration WERROR_IMPLICIT_FUNCTION_DECLARATION) +waffle_add_c_flag(-fvisibility=hidden WITH_VISIBILITY_HIDDEN) +endif() + waffle_add_c_flag(-Werror=incompatible-pointer-types WERROR_INCOMPATIBLE_POINTER_TYPES) waffle_add_c_flag(-Werror=int-conversion WERROR_INT_CONVERSION) -waffle_add_c_flag(-fvisibility=hidden WITH_VISIBILITY_HIDDEN) -if(waffle_on_linux) +if(waffle_on_linux AND NOT waffle_has_nacl) # On MacOS, the SSE2 headers trigger this error. waffle_add_c_flag(-Werror=missing-prototypes WERROR_MISSING_PROTOTYPES) endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index fc0bda2..31a909b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,6 +17,52 @@ if(waffle_on_linux AND waffle_has_x11_egl) endif() # +# Target: gl_basic_nacl (executable + JSON manifest file) +# +if (waffle_has_nacl) +add_executable(gl_basic_nacl.nexe gl_basic.c) +include_directories(${nacl_INCLUDE_DIRS}) + +# Set path where to create and copy required files. +set(nacl_example_path ${PROJECT_SOURCE_DIR}/html/gl_basic_nacl) + +file(MAKE_DIRECTORY ${nacl_example_path}) + +set_target_properties(gl_basic_nacl.nexe +PROPERTIES +RUNTIME_OUTPUT_DIRECTORY ${nacl_example_path} +) + +target_link_libraries(gl_basic_nacl.nexe +${waffle_libname} +${nacl_LDFLAGS} +-lppapi_simple +-lnacl_io +) + +# Create .nmf file that contains JSON manifest for the .nexe required by NaCl +# NOTE, this serves as example only and user might need to recreate nmf file +# suitable for the used environment. Extra entry for libppapi_gles2.so is added +# because we are not linking with it but require its presence during execution. +# --no-arch-prefix is used because '-x' has no option to set architecture for +# the extra entry. +add_custom_command( +OUTPUT gl_basic_nacl.nmf +COMMAND ${nacl_root}/tools/create_nmf.py --no-arch-prefix -x libppapi_gles2.so:libppapi_gles2.so -L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${nacl_example_path}/gl_basic_nacl.nexe -o ${nacl_example_path}/gl_basic_nacl.nmf +DEPENDS gl_basic_nacl.nexe +COMMENT Create JSON manifest +VERBATIM +) + +add_custom_target(gl_basic_create_json_manifest ALL + DEPENDS gl_basic_nacl.nmf) + +# install index.html that loads gl_basic_nacl.nmf +file(INSTALL index.html DESTINATION ${nacl_example_path}) + +endif() + +# # Target: gl_basic (executable) # diff --git a/examples/gl_basic.c b/examples/gl_basic.c index 69418c8..311593a 100644 --- a/examples/gl_basic.c +++ b/examples/gl_basic.c @@ -520,8 +520,20 @@ removeXcodeArgs(int *argc, char **argv) #endif // __APPLE__ +#ifdef __native_client__ +#include ppapi_simple/ps_main.h +// +// We need to rename main() for native client +// because ppapi_simple already defines main(). +// +int basic_test_main(int argc, char **argv); +PPAPI_SIMPLE_REGISTER_MAIN(basic_test_main) +int +basic_test_main(int argc, char **argv) +#else int main(int argc, char **argv) +#endif
[waffle] [PATCH v3 4/4] waffle: update man pages with nacl changes
Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- man/waffle_enum.3.xml | 1 + man/waffle_init.3.xml | 8 2 files changed, 9 insertions(+) diff --git a/man/waffle_enum.3.xml b/man/waffle_enum.3.xml index a96bd20..07edd6c 100644 --- a/man/waffle_enum.3.xml +++ b/man/waffle_enum.3.xml @@ -101,6 +101,7 @@ enum waffle_enum { WAFFLE_PLATFORM_X11_EGL = 0x0015, WAFFLE_PLATFORM_GBM = 0x0016, WAFFLE_PLATFORM_WGL = 0x0017, +WAFFLE_PLATFORM_NACL= 0x0018, // -- // For waffle_config_choose() diff --git a/man/waffle_init.3.xml b/man/waffle_init.3.xml index a22723d..d74601a 100644 --- a/man/waffle_init.3.xml +++ b/man/waffle_init.3.xml @@ -121,6 +121,14 @@ /listitem /varlistentry varlistentry +termconstantWAFFLE_PLATFORM_NACL/constant/term +listitem + para +[Linux only, other systems not yet supported] + /para +/listitem + /varlistentry + varlistentry termconstantWAFFLE_PLATFORM_WAYLAND/constant/term listitem para -- 1.9.3 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH v3 2/4] waffle: add support for building Waffle using NaCl toolchain
Patch adds changes required to use NaCl compiler and libraries to build Waffle. Build can be configured to use specific version of the NaCl SDK, toolchain for the build needs to be selected with cmake variable CMAKE_TOOLCHAIN_FILE. Example command line to configure a build: cmake -Dwaffle_has_nacl=ON \ -Dnacl_sdk_path=/home/tpalli/nacl/nacl_sdk \ -Dnacl_version=pepper_39 \ -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-nacl-x86_64-glibc.cmake \ -DCMAKE_BUILD_TYPE=Release \ . v2: cmake fixes, create toolchain files for nacl (Emil Velikov) v3: rename toolchain files, cmake fixes (Chad Versace, Emil Velikov) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- Options.cmake | 5 cmake/Modules/WaffleDefineCompilerFlags.cmake | 4 +++ cmake/Modules/WaffleValidateOptions.cmake | 31 ++-- cmake/toolchain-nacl-x86_32-glibc.cmake | 41 +++ cmake/toolchain-nacl-x86_64-glibc.cmake | 41 +++ examples/CMakeLists.txt | 4 +++ src/utils/CMakeLists.txt | 4 +++ src/waffle/CMakeLists.txt | 7 + 8 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 cmake/toolchain-nacl-x86_32-glibc.cmake create mode 100644 cmake/toolchain-nacl-x86_64-glibc.cmake diff --git a/Options.cmake b/Options.cmake index c316070..4f097a0 100644 --- a/Options.cmake +++ b/Options.cmake @@ -28,6 +28,11 @@ if(waffle_on_linux) 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_nacl Build support for NaCl OFF) + +# NaCl specific settings. +set(nacl_sdk_path CACHE STRING Set nacl_sdk path here) +set(nacl_version pepper_39 CACHE STRING Set NaCl bundle here) endif() option(waffle_build_tests Build tests ON) diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake b/cmake/Modules/WaffleDefineCompilerFlags.cmake index 710b7e0..7532a91 100644 --- a/cmake/Modules/WaffleDefineCompilerFlags.cmake +++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake @@ -125,6 +125,10 @@ if(waffle_on_linux) add_definitions(-D_XOPEN_SOURCE=600) endif() +if(waffle_has_nacl) +add_definitions(-DWAFFLE_HAS_NACL) +endif() + if(waffle_on_windows) add_definitions(-DWAFFLE_HAS_WGL) endif() diff --git a/cmake/Modules/WaffleValidateOptions.cmake b/cmake/Modules/WaffleValidateOptions.cmake index ea60b0e..1275463 100644 --- a/cmake/Modules/WaffleValidateOptions.cmake +++ b/cmake/Modules/WaffleValidateOptions.cmake @@ -46,11 +46,38 @@ 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) + NOT waffle_has_x11_egl AND NOT waffle_has_gbm 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_x11_egl, waffle_has_gbm, +waffle_has_nacl.) +endif() +if(waffle_has_nacl) +if(NOT EXISTS ${nacl_sdk_path}) +message(FATAL_ERROR NaCl SDK path not found : ${nacl_sdk_path}) +endif() + +if(NOT EXISTS ${CMAKE_TOOLCHAIN_FILE}) +message(FATAL_ERROR Toolchain for Nacl not found. This must be +configured using CMAKE_TOOLCHAIN_FILE.) +endif() + +# Warn the user that building tests is disabled. +if(waffle_build_tests) +message(WARNING Building the tests with the NaCl backend +is not supported, skipping tests.) +set(waffle_build_tests OFF) +endif() + +# When building for NaCl, disable incompatible backends. +set(waffle_has_gbm OFF) +set(waffle_has_egl OFF) +set(waffle_has_glx OFF) +set(waffle_has_x11 OFF) +set(waffle_has_x11_egl OFF) +set(waffle_has_wayland OFF) endif() if(waffle_has_gbm) if(NOT gbm_FOUND) diff --git a/cmake/toolchain-nacl-x86_32-glibc.cmake b/cmake/toolchain-nacl-x86_32-glibc.cmake new file mode 100644 index 000..ec5779f --- /dev/null +++ b/cmake/toolchain-nacl-x86_32-glibc.cmake @@ -0,0 +1,41 @@ +# +# NaCl toolchain file for 32bit x86 using glibc C library +# + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) +set(CMAKE_SYSTEM_NAME Linux) +set(nacl_host_os linux) +else() +message(FATAL_ERROR TODO: NaCl support on ${CMAKE_HOST_SYSTEM_NAME}) +endif() + +set(nacl_target_arch i686) +set(nacl_ports glibc_x86_32) +set(nacl_toolchain ${nacl_host_os}_x86_glibc) + +# setup paths for nacl +set(nacl_root ${nacl_sdk_path}/${nacl_version}) +set(nacl_toolpath ${nacl_root}/toolchain/${nacl_toolchain}/bin
[waffle] [PATCH v3 0/4] Initial NaCl patches v3
Hello; Here is v3 of nacl support patches with many changes and fixes here and there! Thanks for Emil and Chad for review, I think it looks a lot cleaner now. In case you want to try on Chrome, I also put 'demo' of gl_basic here: http://koti.kapsi.fi/~tpalli/nacl/ Note that you'll need to enable native client for apps that are not from Chrome Web Store to run this, instructions available here: https://developer.chrome.com/native-client/devguide/devcycle/running Also, since this is not a packaged app at first time it will load quite some time, reloads are fast since you have all dependencies cached. Any comments appreciated! Tapani Pälli (4): examples: add waffle_has_x11_egl check for simple-x11-egl waffle: add support for building Waffle using NaCl toolchain waffle: initial empty implementation of nacl backend waffle: update man pages with nacl changes CMakeLists.txt| 2 +- Options.cmake | 5 + cmake/Modules/WaffleDefineCompilerFlags.cmake | 4 + cmake/Modules/WaffleValidateOptions.cmake | 31 +- cmake/toolchain-nacl-x86_32-glibc.cmake | 41 cmake/toolchain-nacl-x86_64-glibc.cmake | 41 examples/CMakeLists.txt | 6 +- include/waffle/waffle.h | 1 + man/waffle_enum.3.xml | 1 + man/waffle_init.3.xml | 8 ++ src/utils/CMakeLists.txt | 4 + src/waffle/CMakeLists.txt | 23 - src/waffle/api/waffle_init.c | 11 +++ src/waffle/core/wcore_util.c | 1 + src/waffle/nacl/nacl_config.c | 63 src/waffle/nacl/nacl_config.h | 49 ++ src/waffle/nacl/nacl_container.cpp| 66 + src/waffle/nacl/nacl_container.h | 38 src/waffle/nacl/nacl_context.c| 65 + src/waffle/nacl/nacl_context.h| 52 ++ src/waffle/nacl/nacl_display.c| 70 ++ src/waffle/nacl/nacl_display.h| 52 ++ src/waffle/nacl/nacl_platform.c | 134 ++ src/waffle/nacl/nacl_platform.h | 49 ++ src/waffle/nacl/nacl_window.c | 90 + src/waffle/nacl/nacl_window.h | 59 26 files changed, 961 insertions(+), 5 deletions(-) create mode 100644 cmake/toolchain-nacl-x86_32-glibc.cmake create mode 100644 cmake/toolchain-nacl-x86_64-glibc.cmake create mode 100644 src/waffle/nacl/nacl_config.c create mode 100644 src/waffle/nacl/nacl_config.h create mode 100644 src/waffle/nacl/nacl_container.cpp create mode 100644 src/waffle/nacl/nacl_container.h create mode 100644 src/waffle/nacl/nacl_context.c create mode 100644 src/waffle/nacl/nacl_context.h create mode 100644 src/waffle/nacl/nacl_display.c create mode 100644 src/waffle/nacl/nacl_display.h create mode 100644 src/waffle/nacl/nacl_platform.c create mode 100644 src/waffle/nacl/nacl_platform.h create mode 100644 src/waffle/nacl/nacl_window.c create mode 100644 src/waffle/nacl/nacl_window.h -- 1.9.3 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH v2 2/4] waffle: add support for building Waffle using NaCl toolchain
On 12/30/2014 12:53 AM, Emil Velikov wrote: On 22/12/14 22:28, Chad Versace wrote: On 12/21/2014 07:53 AM, Emil Velikov wrote: On 17 December 2014 at 10:17, Tapani Pälli tapani.pa...@intel.com wrote: Patch adds changes required to use NaCl compiler and libraries to build Waffle. Build can be configured to use specific version of the NaCl SDK, toolchain for the build needs to be selected with cmake variable CMAKE_TOOLCHAIN_FILE. Example command line to configure a build: cmake -Dwaffle_has_nacl=ON \ -Dnacl_sdk_path=/home/tpalli/nacl/nacl_sdk \ -Dnacl_version=pepper_39 \ Tbh I'm not a huge fan of having those piped via the top cmake into the toolchain file. Quick look indicates that nacl_sdk as of Dec 2011 has/is defining NACL_SDL_ROOT. Perhaps we can reuse that one and error out if it's missing. Considering we can use (have tested only) a single version we could just hardcode it into the toolchain file ? Emil, I don't understand. What do you mean that nacl_sdk defines NACL_SDK_ROOT? I see that some GNU Makefiles in the SDK define NACL_SDK_ROOT, but I failed to find any CMake files in the SDK. Admittedly I've not fetched/tried the SDK, but I would assume that this commits [1] sets the env var. On the plus side it seems that it works for some (again guesswork) [2]. And the bugreport about the missing way to autodetect the SDK [3]. This sure looks like a 'development shell' which would set it, I don't know if this is used though because I cannot find it in the SDK or referenced by the 'Getting started' tutorials, I'm using the SDK from here: https://developer.chrome.com/native-client/sdk/download Maybe they had it but it was removed or optional to have (?) Current instructions suggest that building is done in the users environment (regular shell). I also think that the CMake configure line can be improved and the toolchain files simplified. I'll suggest those changes in a different subthread, though. Fully agreed. My last(i.e. this) round of nitpicking on the series is mostly as jfyi/nice to have, rather than anything else. -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-nacl-linux-glibc-x86_64.cmake \ -DCMAKE_BUILD_TYPE=Release \ . diff --git a/cmake/Modules/WaffleValidateOptions.cmake b/cmake/Modules/WaffleValidateOptions.cmake index ea60b0e..1275463 100644 --- a/cmake/Modules/WaffleValidateOptions.cmake +++ b/cmake/Modules/WaffleValidateOptions.cmake @@ -46,11 +46,38 @@ 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) + NOT waffle_has_x11_egl AND NOT waffle_has_gbm 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_x11_egl, waffle_has_gbm, +waffle_has_nacl.) +endif() +if(waffle_has_nacl) +if(NOT EXISTS ${nacl_sdk_path}) +message(FATAL_ERROR NaCl SDK path not found : ${nacl_sdk_path}) +endif() + In the future as we add a proper build check, we can add it into the auto-detection. Can you add a single line of comment ? I don't see a way for Waffle's CMake to autodetect the nacl_sdk_path, because the NaCl SDK is usually (I think) installed by the user into his home directory in a custom location. For example: Tapani: ~/nacl/nacl_sdk Chad: ~/opt/nacl_sdk Emil: I admit that I'm a complete NaCl newbie, though. Emil, do you have some plan on how to perform autodetection? If we can set/use NACL_SDK_ROOT, just check for a header/library that is required and unlikely to be present on the host (to prevent false positives). I.e. I'm thinking about find_path/find_library. Cheers, Emil [1] https://code.google.com/p/nativeclient-sdk/source/detail?r=1385 [2] https://github.com/seichter/CMake-Toolchain-Collection/blob/master/toolchain-nacl.cmake [3] https://code.google.com/p/nativeclient-sdk/issues/detail?id=128 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH v2 2/4] waffle: add support for building Waffle using NaCl toolchain
On 12/29/2014 09:28 AM, Tapani Pälli wrote: On 12/23/2014 02:06 AM, Chad Versace wrote: On 12/17/2014 04:17 AM, Tapani Pälli wrote: Patch adds changes required to use NaCl compiler and libraries to build Waffle. Build can be configured to use specific version of the NaCl SDK, toolchain for the build needs to be selected with cmake variable CMAKE_TOOLCHAIN_FILE. Example command line to configure a build: cmake -Dwaffle_has_nacl=ON \ -Dnacl_sdk_path=/home/tpalli/nacl/nacl_sdk \ -Dnacl_version=pepper_39 \ -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-nacl-linux-glibc-x86_64.cmake \ -DCMAKE_BUILD_TYPE=Release \ I tried really hard to simplify the CMake cmdline, but I failed. I'm convinced that this is simple as it gets. v2: cmake fixes, create toolchain files for nacl (Emil Velikov) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- Options.cmake | 5 + cmake/Modules/WaffleDefineCompilerFlags.cmake | 4 cmake/Modules/WaffleValidateOptions.cmake | 31 +-- cmake/toolchain-nacl-linux-glibc-x86_32.cmake | 29 + cmake/toolchain-nacl-linux-glibc-x86_64.cmake | 29 + examples/CMakeLists.txt | 4 src/utils/CMakeLists.txt | 4 src/waffle/CMakeLists.txt | 6 ++ 8 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 cmake/toolchain-nacl-linux-glibc-x86_32.cmake create mode 100644 cmake/toolchain-nacl-linux-glibc-x86_64.cmake diff --git a/cmake/toolchain-nacl-linux-glibc-x86_32.cmake b/cmake/toolchain-nacl-linux-glibc-x86_32.cmake If you rename this file toolchain-nacl.cmake, and make a few changes, then I think the same file can be used for every host OS (Linux, Mac, Windows) and target architecture. OK, this sounds ideal. I'm not able to test all these though so not sure if everything would work. new file mode 100644 index 000..3c13bb6 --- /dev/null +++ b/cmake/toolchain-nacl-linux-glibc-x86_32.cmake Nothing about this file is specific to Linux. I think you can rename this file to toolchain-nacl-glibc-x86_32.cmake and, with a small change, have it work on Mac (and possibly Windows) too. Also, I think the architecture is more significant, and should therefore precede, the C library variant. That is, toolchain-nacl-{NACL_ARCH}[-{NACL_C_LIBRARY}].cmake instead of toolchain-nacl-{NACL_C_LIBRARY}-{NACL_ARCH}.cmake Otherwise, for PNaCl you end up with the weird name toolchain-nacl-newlibc-pnacl.cmake instead of the simple name toolchain-nacl-pnacl.cmake (The first is weird because newlibc is the only option for PNaCl. PNaCl doesn't support glibc). Yes, this makes sense. I will change the naming scheme. @@ -0,0 +1,29 @@ +# +# NaCl toolchain file for 32bit x86 using glibc C library +# + +set(CMAKE_SYSTEM_NAME Linux) Why did you choose to set CMAKE_SYSTEM_NAME to Linux? I expected it to be set to NaCl or left at its default value. Also, does setting it to Linux risk breaking NaCl builds done on Mac? Leaving it to default (not setting it) produces 'Error running link command: No such file or directory'. I think it leaves many needed cmake variables undefined so it needs to be there. Using 'unknown' system such as 'nacl' produces lots of warnings to console that I should consult with cm...@www.cmake.org to add 'nacl' as one of the options, it works though (with little addition to WaffleDefineOS.cmake) so it can be used. I can make this change if such warnings are ok. Notably this also means that waffle_on_linux would be false when building for nacl (on linux too since CMAKE_SYSTEM_NAME is changed), I have a fear it will create some strange build problems but I will anyway take a try and see what comes out. +set(nacl_target_arch i686) +set(nacl_ports glibc_x86_32) You can make this file generic for Linux, Mac, and Windows by replacing +set(nacl_toolchain linux_x86_glibc) with if(CMAKE_HOST_SYSTEM_NAME STREQUAL Linux) set(nacl_host_os linux) else() message(FATAL_ERROR TODO: NaCl support on ${CMAKE_HOST_SYSTEM_NAME}) endif() set(nacl_toolchain ${nacl_host_os}_x86_glibc) +# setup paths for nacl +set(nacl_root ${nacl_sdk_path}/${nacl_version}) +set(nacl_toolpath ${nacl_root}/toolchain/${nacl_toolchain}/bin) + +# setup compilers from toolchain +set(CMAKE_C_COMPILER ${nacl_toolpath}/${nacl_target_arch}-nacl-gcc) +set(CMAKE_CXX_COMPILER ${nacl_toolpath}/${nacl_target_arch}-nacl-g++) + +set(CMAKE_FIND_ROOT_PATH ${nacl_root}) + +# for FIND_PROGRAM|LIBRARY|INCLUDE use ${nacl_root} only +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) I think you should set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to NEVER and update the comment. For precedent, see the Piglit ebuild [1] in Chromium OS
[waffle] [PATCH v2 3/4] waffle: initial empty implementation of nacl backend
Patch adds nacl platform skeleton. Only thing it does is that it creates a container that holds the 3D context object which is responsible for any communication required with browser. v2: cleanups, remove unnecessary casts, use c99 initializer (Emil Velikov) Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- CMakeLists.txt | 2 +- include/waffle/waffle.h| 1 + src/waffle/CMakeLists.txt | 16 - src/waffle/api/waffle_init.c | 11 +++ src/waffle/core/wcore_util.c | 1 + src/waffle/nacl/nacl_config.c | 63 + src/waffle/nacl/nacl_config.h | 49 ++ src/waffle/nacl/nacl_container.cpp | 65 ++ src/waffle/nacl/nacl_container.h | 40 +++ src/waffle/nacl/nacl_context.c | 69 +++ src/waffle/nacl/nacl_context.h | 52 ++ src/waffle/nacl/nacl_display.c | 70 +++ src/waffle/nacl/nacl_display.h | 52 ++ src/waffle/nacl/nacl_platform.c| 134 + src/waffle/nacl/nacl_platform.h| 49 ++ src/waffle/nacl/nacl_window.c | 90 + src/waffle/nacl/nacl_window.h | 59 17 files changed, 821 insertions(+), 2 deletions(-) create mode 100644 src/waffle/nacl/nacl_config.c create mode 100644 src/waffle/nacl/nacl_config.h create mode 100644 src/waffle/nacl/nacl_container.cpp create mode 100644 src/waffle/nacl/nacl_container.h create mode 100644 src/waffle/nacl/nacl_context.c create mode 100644 src/waffle/nacl/nacl_context.h create mode 100644 src/waffle/nacl/nacl_display.c create mode 100644 src/waffle/nacl/nacl_display.h create mode 100644 src/waffle/nacl/nacl_platform.c create mode 100644 src/waffle/nacl/nacl_platform.h create mode 100644 src/waffle/nacl/nacl_window.c create mode 100644 src/waffle/nacl/nacl_window.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bde8096..fbf71df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ # 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. -project(waffle1 C) +project(waffle1 C CXX) cmake_minimum_required(VERSION 2.8.11) diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h index e04b23f..77885a4 100644 --- a/include/waffle/waffle.h +++ b/include/waffle/waffle.h @@ -104,6 +104,7 @@ enum waffle_enum { WAFFLE_PLATFORM_X11_EGL = 0x0015, WAFFLE_PLATFORM_GBM = 0x0016, WAFFLE_PLATFORM_WGL = 0x0017, +WAFFLE_PLATFORM_NACL= 0x0018, // -- // For waffle_config_choose() diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt index c88bb66..3a38ad6 100644 --- a/src/waffle/CMakeLists.txt +++ b/src/waffle/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories( egl glx linux +nacl wayland wgl x11 @@ -179,6 +180,19 @@ if(waffle_on_windows) ) endif() +if(waffle_has_nacl) +list(APPEND waffle_sources +nacl/nacl_config.c +nacl/nacl_context.c +nacl/nacl_display.c +nacl/nacl_platform.c +nacl/nacl_window.c +) +list(APPEND waffle_cxx_sources +nacl/nacl_container.cpp +) +endif() + # CMake will pass to the C compiler only C sources. CMake does not recognize the # .m extension and ignores any such files in the source lists. To coerce CMake # to pass .m files to the compiler, we must lie and claim that they are @@ -208,7 +222,7 @@ include_directories( ${XCB_INCLUDE_DIRS} ) -add_library(${waffle_libname} SHARED ${waffle_sources}) +add_library(${waffle_libname} SHARED ${waffle_sources} ${waffle_cxx_sources}) # Debian's packaging system emits warnings if wflinfo directly links to any # library that it doesn't directly use. Silence the warnings by annotating diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c index ebc6cd5..fcf8456 100644 --- a/src/waffle/api/waffle_init.c +++ b/src/waffle/api/waffle_init.c @@ -35,6 +35,7 @@ struct wcore_platform* wayland_platform_create(void); struct wcore_platform* xegl_platform_create(void); struct wcore_platform* wgbm_platform_create(void); struct wcore_platform* wgl_platform_create(void); +struct wcore_platform* nacl_platform_create(void); static bool waffle_init_parse_attrib_list( @@ -104,6 +105,12 @@ waffle_init_parse_attrib_list( CASE_UNDEFINED_PLATFORM(WGL) #endif +#ifdef WAFFLE_HAS_NACL +CASE_DEFINED_PLATFORM(NACL) +#else +CASE_UNDEFINED_PLATFORM(NACL) +#endif + default: wcore_errorf
[waffle] [PATCH v2 1/4] examples: add waffle_has_x11_egl check for simple-x11-egl
Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 281ef47..df66f60 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ install( # Target: simple-x11-egl (executable) # -if(waffle_on_linux) +if((waffle_on_linux) AND (waffle_has_x11_egl)) add_executable(simple-x11-egl simple-x11-egl.c) target_link_libraries(simple-x11-egl ${waffle_libname}) endif() -- 1.9.3 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH] RFC: gl_basic changes to work with nacl
Here's minimal changes to run existing gl_basic with nacl backend. I wanted to ask if such #ifdefs are wanted approach or should I rather have an example of its own? Thanks; Tapani Pälli (1): waffle: make gl_basic to work with nacl .gitignore | 2 ++ examples/CMakeLists.txt | 30 ++ examples/gl_basic.c | 17 + examples/index.html | 39 +++ 4 files changed, 88 insertions(+) create mode 100644 examples/index.html -- 1.9.3 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 2/2] waffle: initial empty implementation of nacl backend
Patch adds nacl platform skeleton. Only thing is does is that it creates a container that holds the 3D context object and is responsible for any communication required with browser. Signed-off-by: Tapani Pälli tapani.pa...@intel.com --- CMakeLists.txt | 2 +- include/waffle/waffle.h| 1 + src/waffle/CMakeLists.txt | 16 - src/waffle/api/waffle_init.c | 11 src/waffle/nacl/nacl_config.c | 63 +++ src/waffle/nacl/nacl_config.h | 49 +++ src/waffle/nacl/nacl_container.cpp | 65 src/waffle/nacl/nacl_container.h | 41 + src/waffle/nacl/nacl_context.c | 70 + src/waffle/nacl/nacl_context.h | 52 src/waffle/nacl/nacl_display.c | 70 + src/waffle/nacl/nacl_display.h | 52 src/waffle/nacl/nacl_platform.c| 121 + src/waffle/nacl/nacl_platform.h| 51 src/waffle/nacl/nacl_window.c | 90 +++ src/waffle/nacl/nacl_window.h | 61 +++ 16 files changed, 813 insertions(+), 2 deletions(-) create mode 100644 src/waffle/nacl/nacl_config.c create mode 100644 src/waffle/nacl/nacl_config.h create mode 100644 src/waffle/nacl/nacl_container.cpp create mode 100644 src/waffle/nacl/nacl_container.h create mode 100644 src/waffle/nacl/nacl_context.c create mode 100644 src/waffle/nacl/nacl_context.h create mode 100644 src/waffle/nacl/nacl_display.c create mode 100644 src/waffle/nacl/nacl_display.h create mode 100644 src/waffle/nacl/nacl_platform.c create mode 100644 src/waffle/nacl/nacl_platform.h create mode 100644 src/waffle/nacl/nacl_window.c create mode 100644 src/waffle/nacl/nacl_window.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bde8096..fbf71df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ # 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. -project(waffle1 C) +project(waffle1 C CXX) cmake_minimum_required(VERSION 2.8.11) diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h index e04b23f..77885a4 100644 --- a/include/waffle/waffle.h +++ b/include/waffle/waffle.h @@ -104,6 +104,7 @@ enum waffle_enum { WAFFLE_PLATFORM_X11_EGL = 0x0015, WAFFLE_PLATFORM_GBM = 0x0016, WAFFLE_PLATFORM_WGL = 0x0017, +WAFFLE_PLATFORM_NACL= 0x0018, // -- // For waffle_config_choose() diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt index b4dd63f..0d3ff72 100644 --- a/src/waffle/CMakeLists.txt +++ b/src/waffle/CMakeLists.txt @@ -15,6 +15,7 @@ include_directories( egl glx linux +nacl wayland wgl x11 @@ -179,6 +180,19 @@ if(waffle_on_windows) ) endif() +if(waffle_has_nacl) +list(APPEND waffle_sources +nacl/nacl_config.c +nacl/nacl_context.c +nacl/nacl_display.c +nacl/nacl_platform.c +nacl/nacl_window.c +) +list(APPEND waffle_cxx_sources +nacl/nacl_container.cpp +) +endif() + # CMake will pass to the C compiler only C sources. CMake does not recognize the # .m extension and ignores any such files in the source lists. To coerce CMake # to pass .m files to the compiler, we must lie and claim that they are @@ -208,7 +222,7 @@ include_directories( ${XCB_INCLUDE_DIRS} ) -add_library(${waffle_libname} SHARED ${waffle_sources}) +add_library(${waffle_libname} SHARED ${waffle_sources} ${waffle_cxx_sources}) # Debian's packaging system emits warnings if wflinfo directly links to any # library that it doesn't directly use. Silence the warnings by annotating diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c index ebc6cd5..fcf8456 100644 --- a/src/waffle/api/waffle_init.c +++ b/src/waffle/api/waffle_init.c @@ -35,6 +35,7 @@ struct wcore_platform* wayland_platform_create(void); struct wcore_platform* xegl_platform_create(void); struct wcore_platform* wgbm_platform_create(void); struct wcore_platform* wgl_platform_create(void); +struct wcore_platform* nacl_platform_create(void); static bool waffle_init_parse_attrib_list( @@ -104,6 +105,12 @@ waffle_init_parse_attrib_list( CASE_UNDEFINED_PLATFORM(WGL) #endif +#ifdef WAFFLE_HAS_NACL +CASE_DEFINED_PLATFORM(NACL) +#else +CASE_UNDEFINED_PLATFORM(NACL) +#endif + default: wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, WAFFLE_PLATFORM has bad value 0x%x, @@ -164,6
Re: [waffle] nacl backend
On 12/10/2014 09:24 AM, Tapani wrote: On 12/10/2014 07:39 AM, Chad Versace wrote: On 12/09/2014 04:15 AM, Tapani Pälli wrote: The problem I have with swapbuffers is that I cannot guarantee if the swap finished before waffle app submits a new one, This is what the swap_thread tries to deal with. I get bad results (even unresponsive FYI, this issue is now fixed (and pushed to snapshot branch). Will start to clean up things now. // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] nacl backend
Hi; I'm currently working on a NaCl backend for Waffle, I wanted to ask for opinions or comments on my current approach. First of all I'm using some c++ in the nacl backend code but AFAIK everything of this can be converted to c if c++ is absolutely not wanted. The work can be divided in to 2 main objectives. First is building waffle itself with nacl toolchain and second is to provide a NaCl backend so that we can render in to browser. 1. Building User needs to provide path to nacl_sdk and nacl_version (for example pepper_38). Maybe will need further additions like the target architecture selection (which is currently just hardcoded). For toolchain I've selected 'glibc' as waffle requires dlopen() and c99 support which were not possible when using 'pnacl-clang'. Almost everything builds fine, only failures happen for examples and unit-tests for different reasons (for example fork() or usleep() are not supported + some other symbols caused problems). I've just disabled these for now in cmakefiles when nacl is selected and made my own gl_basic_nacl example which copies the gl_basic test behavior. I'm slowly migrating it to be just like gl_basic but with some minimal changes. (Known issue: currently waffle nacl links against 'libppapi_gles2.so' but this is only because currently glInitializePPAPI() and glSetCurrentContextPPAPI() happen before context creation, I'll be fixing this soon) 2. Backend Waffle using application is responsible for creating a pp::Instance, either by creating a class or via PPAPI_SIMPLE_REGISTER_MAIN(main) type of wrapper where it gets created behind the scenes. Currently there is no interface to pass this instance to waffle so the backend seeks it out by inspecting a pp::Module::InstanceMap that lists all current instances. In the typical case of running waffle app there is only one (?) and that is selected. Then Waffle creates a pp::Graphics3D context. When app queries gl functions via waffle_dl_sym, nacl backend dlopens 'libppapi_gles2.so' and searches for GL functions, function names are automatically prefixed by the backend because nacl GLES2 library naming scheme is prefixed with 'GLES2', for example 'glClear' is 'GLES2Clear'. Swapbuffers is somewhat complicated as it is asynchronous and app might go and queue another swap before first one finished. When I have a solid solution for this I'm planning to post a set of 'WIP patches', maybe just the build system changes at first. Any comments appreciated; If you feel like testing this, I've pushed a snapshot here: http://cgit.freedesktop.org/~tpalli/waffle/log/?h=snapshot Thanks; // Tapani ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle