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

Re: [Public WebGL] Uint8ClampedArray can not be used with WebGL

Also: the intent is that SharedArrayBuffers will be accepted everywhere that ArrayBuffer is accepted in the WebGL API, and typed arrays viewing SharedArrayBuffers will be accepted everywhere as well. In WebGL, data races during texture and buffer uploads are harmless; they might result in incorrect rendering, but won't cause program logic to change its behavior.


On Sat, Mar 5, 2016 at 11:09 AM, Kenneth Russell <kbr@google.com> wrote:
That's a bug. Uint8ClampedArray used to derive from Uint8Array but the type hierarchy was changed when typed arrays were folded into the ECMAScript spec. It should be fixed for both WebGL 1.0 and 2.0. I've filed https://github.com/KhronosGroup/WebGL/issues/1533 about this. Thanks for reporting the problem.


On Sat, Mar 5, 2016 at 9:49 AM, Gregg Tavares <khronos@greggman.com> wrote:
I forgot why but currently calls to texImage2D check based on `type` that the corresponding ArrayBuffer type.

for type `UNSIGNED_BYTE` currently `Uint8Array` is required which means I get an error if I pass in a `Uint8ClampedArray`

gl = document.createElement("canvas").getContext("webgl");
gl.bindTexture(gl.TEXTURE_2D, gl.createTexture());
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, 
         new Uint8ClampedArray(4));

WebGL: INVALID_OPERATION: texImage2D: type UNSIGNED_BYTE but ArrayBufferView not Uint8Array

Should that change? Should it change for WebGL2 if not WebGL1?

How about SharedArrays?