[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Typed Array spec nitpicks
----- "Cedric Vivier" <email@example.com> wrote:
On Tue, Apr 13, 2010 at 03:09, Oliver Hunt <firstname.lastname@example.org>
I suspect this is a byproduct of the typed arrays originally being specified inline in the WebGL spec which does specify that everything is initialized.
Speaking of Section 4.1 "WebGLArrayBuffer and Uninitialized Data", is there any drawback specifying one and only one behavior only?
Hardware issues -- DirectX 10 compatible hardware will generate 0 when a VBO is accessed outside of its valid bounds, but if that feature isn't available in hardware then 0 access is much more expensive to implement than nearest-index or accessing index 0. This mainly comes up when rendering with glDrawElements, because the index buffer can have arbitrary indices in it and thus if the hardware doesn't support "safe" access, then the WebGL implementation must check every index. If an out-of-range index is found, it has to do something and can't mimic the hardware approach (because to do so, it would have to change the index value to something whose value is 0 in the invalid array).
However, this is really an issue for DrawElements (and other webgl methods that cause an access to an ArrayBuffer), and not for WebGLArrayBuffer specifically. It's not possible to index an ArrayBuffer directly, and individual typed arrays have defined out of range semantics (though those will likely change from what's in the spec now to be more consistent with ES Arrays -- so NaN/0, same as reading a "hole" from a normal array and converting to a number -- instead of throwing an exception).
Currently it is worded like this :
"Additionally, the WebGL implementation must ensure that no data outside of the valid byte range for a WebGLArrayBuffer can be accessed. If a caller attempts to access any data outside of that range, an implementation may choose to raise an exception, use the closest valid index, use 0, or any other approach that prevents it from providing access to uninitialized data."
then in 126.96.36.199 :
"get(index) Return the element at the given index. If the index is out of range, an exception is raised."
I think the current wording is inconsistent, which makes the behavior of "array[array.length+1]" ambiguous/undefined and could cause problems with apps "mysteriously" working on one WebGL implementation but not on another (difference between using closest valid index and using zero might be subtle and difficult to debug/detect).