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

Re: [Public WebGL] using the same context with multiple canvases

I agree with Florian

On Sat, Jan 23, 2016 at 12:25 AM, Florian Bösch <pyalot@gmail.com> wrote:
I don't understand why we pursue this proposal: https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/OffscreenCanvas , which relies on the resize/copy-over semantic.
  • It leads to framebuffer trashing
  • To combat framebuffer trashing you need to build a framebuffer size heuristic/cache
  • If you build a framebuffer size heuristic/cache you end up with over-allocations of framebuffers (animated resizes from window, css animation, developer console, orientation change, pinch/zoom etc.)
  • It requires an unneccesary extra-copy
  • It can't manage drawing surface configurations (like stencil/depth/multiple color targets/etc.), and if you'd want to have them, you need to mirror all commits with framebuffers...
  • It runs counter established API semantics in GL that already define how to draw offscreen efficiently (both to framebuffers and as handles to frontbuffers)
  • Most frameworks (three.js, babylon.js etc.) know how to deal with framebuffers, but they do not know about this new resize/commit semantic.
I believe that we should try to emulate framebuffer semantic as closely as possible. Ideally, we could just attach a canvas as color target to a framebuffer.

// setup the binding
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, canvas, 0)

// drawing to
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);