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

Re: [Public WebGL] WebGL bufferSubData lacks "size" parameter




On Jan 12, 2012, at 12:14 PM, James Robinson wrote:

> 
> 
> ...
> Perhaps browsers can improve, but there's no magic here and no such thing as a free lunch. Garbage collection tuning is a series of tradeoffs. A win on this use case will be a loss on other use cases.  No matter how good the GC is it can only support a finite amount of object allocations per frame without dropping them.  Requiring objects for every bufferSubData call eats into this budget.  Even if we managed to get a collector that could maintain 60fps without dropping frames on this bufferSubData benchmark on all hardware, the added garbage adds a lot of pressure to the rest of the system and removes headroom for objects needed elsewhere in the critical path.
> 
> I agree that the view-based API is much nicer, and I'm very sympathetic to the need to keep implementations and specs simple.  I think that having a view type that was a value type instead of an object would be ideal, but that's not possible in JavaScript.  I think that WebGL needs to fully embrace the fact that it's a JavaScript API and deal with the restrictions that imposes.  We expect authors to put in lots of effort avoiding unnecessary object allocation in their draw loops, shouldn't we put forth the same effort in the API?

The thing we can say for certain is that WebGL and it's good friend Typed Arrays exposes new use cases to the web. As such it exposes some weaknesses in current browsers. One of those has to do with garbage collection. Every browser needs to do a better job to better suit the needs of the real-time use cases WebGL often brings up. I have no doubt that will happen.

But another improvement has to do with the special handling that can be applied to the Typed Array classes. Most browsers are already starting to treat these classes specially, even to the point of generating optimized JIT code for them. It seems quite possible that the creation and temporary use of a View to provide a window into an ArrayBuffer can be optimized out and produce no garbage at all. I also believe this will happen over time.

My, my. You're all just so impatient :-)

-----
~Chris
cmarrin@apple.com





-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------