-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propose WEBGL_present, allowing for early Present. #2564
base: main
Are you sure you want to change the base?
Conversation
Can the same thing effectively be accomplished with OffscreenCanvas? |
OffscreenCanvas support isn't imminent, and this is actually a subset of what OffscreenCanvas does with respect to Present. OffscreenCanvas bypasses the Present-to-compositor completely, whereas this just Presents early. |
Interesting idea for an extension, I can see how it may be useful. The concept could benefit VR. I feel like it needs some more detail around various edge cases, though:
Most of these feel like they have unsurprising answers, but it's probably worth documenting the behavior in the extension text regardless. Finally, exposing |
The intent is that present() triggers our html-Present code early:
Since we're reusing this concept of html-Present, all of your edge cases have clear answers to me. We're just Presenting to the conceptual html compositor early, so we have the same frame atomicity rules as usual, as well as the same logic around dirtying. This all (to me) falls directly out of invoking the html-Present concept.
|
I suppose what's not clear is that this call doesn't immediately invoke html-composition, but instead waits for end-of-frame like normal. |
Thanks! That does help clarify. A couple more questions: If you draw, call Finally, if this does not immediately trigger page composition then it seems you could largely get the same behavior with a |
If you draw after present(), with autoPresent=true, the second draw is composited that frame. This is a stronger statement than a flush(). In particular, we can't tell whether a flush is indicating the end of frame or not. This means that if we assume flush() indicates the end of a frame, multiple flushes in a frame would cause multiple multisample-resolve-and-fence steps. We definitely flush on present(), but it's not all we do. |
I am confused by the purpose of this extension. Is it for performance so we can trigger page composition early? If so, then this will break the existing frame rules because the WebGL frame is meant to appear as one unit with all of the other DOM manipulations you do as part of the rAF and other event handlers that fire after it. Is that by design? Similarly, what happens in the case where there are multiple WebGL contexts on the page at once? Is the browser meant to wait until all of them have had a chance to present before starting to draw the page? If we were to adopt this extension, I think we should prevent more than one present call per rAF callback. For Edge, we throttle rAF callbacks with the amount of work the GPU is able to retire in order to create a smooth experience. We skip VSyncs if there are more than 2 frames outstanding. I fear that enabling developers to draw more than one frame per rAF callback will lead to content that appears to work well on some machines but bogs down machines with limited GPU capabilities and end up triggering our hang resistance logic. |
In Present, if the backbuffer is dirty, we resolve from the multisampled backbuffer to the single-sampled compositable surface, enqueue a fence/release a KeyedMutex that will tell us when the single-sampled resource is ready, and flush the driver. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment not addressing the higher-level questions raised by others.
<code>autoPresent</code> disables (or re-enables) the default backbuffer-dirty auto-Present. | ||
When disabled, the context will not automatically Present its backbuffer to the compositor | ||
even if the backbuffer has been drawn into. | ||
In this case, <code>present()</code> is the only way trigger Presentation of the backbuffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
way trigger -> way to trigger
Per discussions in the working group: @jdashg will prototype the OffscreenCanvas's transferToImageBitmap API, which should allow this present() API to be polyfilled from JavaScript for experimentation purposes. |
I'd like to explicitly credit @toji with the transferToImageBitmap idea. |
No description provided.