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
[email protected]
http://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to