Did you already look at Alon's work to proxy WebGL calls from WebWorkers here https://blog.mozilla.org/research/2014/07/22/webgl-in-web-workers-today-and-faster-than-expected/?).
I haven't tried this yet, and I didn't continue with a similar approach I used earlier, since the code was simply too complex, but may be it simplifies things for your engine port. For context initialization I have switched to the emscripten_webgl_xxx functions a while ago after first using the glut and then EGL wrappers, the emscripten_webgl functions simplified some code where the webpage and the emscripten code needs to interact (e.g. getting notified of switching to fullscreen and back). Here's my code to setup WebGL using the emscripten functions: https://github.com/floooh/oryol/blob/master/code/Modules/Gfx/emsc/emscDisplayMgr.cc#L33 And here using EGL (which I'm now only using for Android): https://github.com/floooh/oryol/blob/master/code/Modules/Gfx/egl/eglDisplayMgr.cc#L48 Cheers, -Floh. Am Freitag, 4. September 2015 21:58:13 UTC+2 schrieb Robert Goulet: > > Thanks for the answer. > > Right now the real blocker for us is GL in main thread with SAB. The only > way I've found to work-around this bug is to completely disable pthread in > our Emscripten game engine build, which is a huge hack and not well > supported/maintainable. Unless there's a way to hack it in Emscripten? I'm > guessing, changes proposed in > https://bugzilla.mozilla.org/show_bug.cgi?id=1176214 > <https://www.google.com/url?q=https%3A%2F%2Fbugzilla.mozilla.org%2Fshow_bug.cgi%3Fid%3D1176214&sa=D&sntz=1&usg=AFQjCNGu15DgRdwgRwBhPqesbXgWwKU20Q> > will > have an impact on Emscripten implementation of pthreads? > > We decided to use GLFW3 for our rendering window/context management. Does > EGL have better Emscripten support? > > As for rendering from any thread... not really a blocker as long as I can > keep pthread enabled for other tasks. I don't even know how much > performance we would really get from moving GL rendering calls into a > thread. > > Thank you! > > > On Friday, September 4, 2015 at 3:16:52 PM UTC-4, jj wrote: >> >> Hi Robert, >> >> my patch hinges on this change to occur: >> https://bugzilla.mozilla.org/show_bug.cgi?id=1176214 , that will make my >> current patch obsolete, and I've been waiting for that to land so that I'd >> know how to make the correct new patch. >> >> Also, unfortunately that patch won't let one render from any thread :( >> There is this work going on: >> https://bugzilla.mozilla.org/show_bug.cgi?id=709490 , which will enable >> rendering from a single worker thread, but that worker will have to >> explicitly be passed the GL worker to render with (in C, likely the thread >> that creates the GL context is able to render in it). Things like >> eglMakeCurrent() are still not possible after that patch. >> >> Eventually, we could try to proxy all GL commands synchronously via the >> SharedArrayBuffer. That would allow eglMakeCurrent() to function as well, >> but it's still a question of how much performance that will impact. >> >> I'll poke Lars to ask the schedule of 1176214, perhaps I could just land >> my patch as a temporary one, and that would get swapped out when it's no >> longer needed. That could unblock at least GL in main thread with SAB to >> work. >> >> >> 2015-09-04 18:36 GMT+03:00 Robert Goulet <[email protected]>: >> >>> Hi Jukka, >>> >>> I saw you had a similar issue some time ago : >>> >>> >>> https://groups.google.com/d/msg/emscripten-discuss/gQQRjajQ6iY/s7etdAjXthUJ >>> https://bugzilla.mozilla.org/show_bug.cgi?id=1147441 >>> >>> Any idea where the patch landed since then? I'm afraid this is blocking >>> me, since we'd like to be able to render from any thread. >>> Do you know if there's a build available with your patch? Or perhaps I >>> could make one myself? >>> >>> Thanks! >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "emscripten-discuss" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
