Closed Bug 821193 Opened 12 years ago Closed 6 years ago

Don't shadow framebuffer bindings in GLContext

Categories

(Core :: Graphics: CanvasWebGL, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jgilbert, Assigned: jgilbert)

References

(Blocks 1 open bug)

Details

(Whiteboard: [rplus] webgl-internal)

Attachments

(1 file)

We should stop shadowing framebuffer bindings in GLContext. We've been lucky so far, but lazy and/or async GL errors make this impractical to assure.

We should switch from shadow-and-emulate to emulate-by-translation. ('emulate' referring to our framebuffer zero trick for offscreen buffers)
You can also reassign this review to someone else, if you have any ideas.
Attachment #691716 - Flags: review?(bjacob)
Blocks: 811181
Can you just share a little more insights to help the reviewing. What is the conceptual difference between shadow-and-emulate and emulate-by-translation? What is specificly the problem in the old approach?
(In reply to Benoit Jacob [:bjacob] from comment #2)
> Can you just share a little more insights to help the reviewing. What is the
> conceptual difference between shadow-and-emulate and emulate-by-translation?
> What is specificly the problem in the old approach?

Sure. Right now, we intercept calls getting and setting the framebuffer binding points such that, when the user of GLContext tries to bind FB 0 (on an offscreen context), we pretend they did, but behind the scenes, we actually bind our offscreen buffers. Likewise, when they query the current binding, we 'tell them what they want to hear'. If they bound 0 before, we tell them 0 is still bound, even if we've actually bound other framebuffers instead.

This approach means that we either need to track which buffer they've requested we bind, or instead translate back and forth between GL's actual bound FB and what the user should see it as. Currently, we do the former.

The problem is that when BindFramebuffer generates an error, it usually doesn't change the currently bound buffer.[1] This means that if we're shadowing, we need to detect these errors, or we will get mispredictions. Detecting these errors means that we *must* call GetError, since we can't easily predict all errors at bind-time. (and we can't at all predict OOMs)

Instead, we should switch to translating, where we query GL to find out which FB is actually bound, and then translate that value into the value the clients of GLContext expect. (If GL tells us the offscreen FB is bound, we tell the clients that 0 is bound) Likewise, for BindFramebuffer, we intercept calls to bind FB 0, and instead bind our offscreen FB(s).

[1] OOM errors leave things undefined when they happen, unlike other errors. Since GL will often lazily allocate buffers, we can get OOM errors at BindFramebuffer, when GL decides to actually allocate the data needed.
Thanks for the explanation, that makes a lot of sense, and sorry for the reviewing delay, b2g + vacations. reviewing now.
Attachment #691716 - Flags: review?(bjacob) → review+
Whiteboard: [rplus] webgl-internal
We basically stopped doing this via GLScreenBuffer, and are in the process of deprecating that too.
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: