On 02/03/2015 08:50 PM, Chad Versace wrote:
On 01/22/2015 11:59 PM, 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 another one. This is done by introducing a worker thread that
does buffer swaps from a work queue.
Signed-off-by: Tapani Pälli <tapani.pa...@intel.com>
+// Thread takes care that we do not issue another buffer
+// swap before previous swap has completed.
+class NaclSwapThread : public pp::SimpleThread
+
+ void swap_buffers(int32_t result)
+ {
+ ctx.SwapBuffers(pp::BlockUntilComplete());
+ }
I think I discovered why you were seeing rendering artifacts despite using
BlockUntilComplete
as the callback. Quoting the NaCl API reference:
int32_t(* PPB_Graphics3D::SwapBuffers)(PP_Resource context, struct
PP_CompletionCallback callback)
[...]
SwapBuffers runs in asynchronous mode. Specify a callback function and the
argument for that
callback function. The callback function will be executed on the calling
thread ***after*** the color
buffer has been composited with rest of the html page.
The keyword is "after". If I understand this correctly, ctx.SwapBuffers()
returned immediately.
Later, after webpage composition completed, the NaCl runtime called the
BlockUntilComplete
callback, which is a no-op at that time. This is all new to me, though, so
maybe I'm completely
wrong.
According to documentation pp::BlockUntilComplete() can be used to
request blocking behavior (to implement synchronous call):
"BlockUntilComplete() is used in place of an actual completion callback
to request blocking behavior.
If specified, the calling thread will block until the function
completes. Blocking completion callbacks are only allowed from
background threads."
So, what I believe should be happening here is that swap() returns
immediately so that main app thread can continue, but swap_buffers()
blocks NaclSwapThread until SwapBuffers has happened. Meanwhile main
thread can try to queue more swaps but these will never happen as
NaclSwapThread will only consume more work when swap_buffers() returns.
I will try to further verify that this is the behaviour. This made
gl_basic to work, but then I noticed that gl_basic has sleep which hides
more artifacts and for these I came up with using the 'swap event' callback.
// Tapani
_______________________________________________
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle