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

Re: [Public WebGL] Issues with sharing resources across contexts



Ken: I'd hate to see the tradeoff go so far in the way of 'just make it faster for the simple cases'. The single worker populating textures is something I'd argue doesn't need any of this work, anyway - if the browsers weren't so horrible at decoding images (so move network and decode and upload off the main thread, etc) it largely wouldn't matter. It's something much better left in native browser code and as an implementation detail to apps. If the goal was just this decoding case, I'd say ignore any user-app level API changes and fix the browser code instead. Save the API changes for the interesting bits. Those interesting bits of off-thread access are all ones where either multiple workers or main/worker in conjunction are touching resources in non-trivial (read: dynamic) ways.


On Fri, Aug 24, 2012 at 3:18 PM, Florian Bösch <pyalot@gmail.com> wrote:
Let's make an example, this is how I want to deal with the problem:

gl = createContext();

gl.bindFront(canvas1);
gl.uniform4fv(view);
gl.drawArrays(...);
gl.bindFront(null)

mat4rotatex(90, view);
gl.bindFront(canvas2);
gl.uniform4vf(view);
gl.drawArrays(...)
gl.bindFront(null)

This is how I do not want to have to deal with it:

ctx1 = canvas1.getContext()
ctx2 = canvas2.getContext()
shader = ctx1.createShader(); ...
ctx1.use(shader)
ctx1.acquire(shader)
ctx1.acquire(buffer)
ctx1.uniform4fv(mat4)
ctx1.drawArrays(...)
ctx1.unuse(shader)
release(shader)
release(buffer)

ctx2.acquire(shader)
ctx2.acquire(buffer)
ctx2.useShader(shader)
rotatex(90, view)
ctx2.drawArrays()
ctx2.unbind(buffer)
ctx2.unuse(shader)
ctx2.release(shader)
ctx2.release(buffer)