[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] More predictable behavior for !preserveDrawingBuffer

On Mon, Jun 4, 2012 at 6:50 PM, Kenneth Russell <kbr@google.com> wrote:
This question has been raised before; see
for example. Please check the archives, and see if there's new
information or thoughts on topic.

That's a different question.  I already know how to handle the issue of when to trigger the clear (or at least I think I do).  I'll post that in detail, but the first question is whether the triple-buffering approach itself is implementable.

On Mon, Jun 4, 2012 at 6:54 PM, James Robinson <jamesr@google.com> wrote:
When preserveDrawingBuffer is false, the buffer is cleared when it's actually composited.  Would it be possible to clear the buffer as soon as the JS code returns to the browser, rather than waiting for compositing, so the time of compositing can't affect script behavior?

These times aren't quite the same.  For instance:

I know.  I have http://zewt.org/~glenn/webgl-nondeterministic-clearing.html which demonstrates one of the problems that needs to be fixed; on my system, it alternately displays 4294902015/4294902015 and 4294902015/0, depending on when compositing happens.

The point here is that the script-visible part--the clearing of the buffer--would happen immediately, and synchronously, when you return from JS to the browser.  In principle, that would simply be a triple buffer flip, handing the buffer you just drew to the compositor and giving you an empty buffer immediately.  In practice I'm guessing it's a bit more complicated than that, since you can't flip the buffer until the drawing queue finishes, and you don't want to block the UI thread or script execution while you effectively do a glFinish().  That's the part I'm not sure about the practicality of...
On this test case, while the modal dialog is open I see a blue square in the most recent versions of Chrome and Firefox, indicating that the browser did in fact composite even though the anonymous function has not yet returned control to the browser and the task queue is suspended.  You'll have to pretty carefully define when exactly you want the clearing to happen to make this proposal well-defined.

That work is already done for us; see the "stable state" concept in HTML.

(Actually, I already have suggested text using it, but I wanted to check this underlying question first, so I don't waste people's time if it's just not implementable.)

Glenn Maynard