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

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

Admittedly I am not familiar with drawing offscreen in standard openGL.  But I have been eagerly awaiting the OffscreenCanvas API to be implemented.  I don't see how your proposal would solve the problems OffscreenCanvas API was designed to solve ie. allow a WebWorker to render to a canvas without proxying webGL API calls back to the main thread.  Can you provide pseudo code examples showing how your proposal would handle that?

see 'Use Case Description' at https://wiki.whatwg.org/wiki/OffscreenCanvas

Ryan Patterson

On Fri, Jan 22, 2016 at 6:25 PM, 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);