[Public WebGL] Oversight in bufferData and bufferSubData specification

Gregg Tavares (wrk) [email protected]
Mon May 23 22:44:45 PDT 2011

On Mon, May 23, 2011 at 10:18 PM, Cedric Vivier <[email protected]> wrote:

> On Tue, May 24, 2011 at 03:02, Gregg Tavares (wrk) <[email protected]>
> wrote:
> >> Consider a much simpler example :
> >>
> >> readModelInto(float64ArrayThatHasBeenCreatedElsewhere); //this fills
> >> the values of any passed TypedArray from another source eg. a JSON
> >> array.
> >> gl.bufferData(gl.ARRAY_BUFFER, float64ArrayThatHasBeenCreatedElsewhere);
> >>
> >> This will result in unintended/unexpected results that the developer
> >> might have hard time to track down as there is absolutely no
> >> warning/error given to something that is semantically wrong.
> >
> > No it won't. There is no gl.DOUBLE to pass to gl.vertexAttribPointer.
> That's the problem, vertexAttribPointer will be set to gl.FLOAT
> already, the output will be garbage and there won't be any error
> reported.

And there won't be any error reported if you upload Uint8 and use gl.FLOAT
in vertexAttribPointer. Nor will there be an error if upload sets of 2 float
followed by 4 uint8s and set your size to 3. Nor will there an error if you
set your stride to 4.

> In conjunction with the fact that all numbers are double-precision
> 64-bit in Javascript, this not obey the principle of least surprise.
> > Most samples that used
> > mixed types upload all their data through a UInt8Array or Float32Array
> even
> > though their data is not uniformly gl.UNSIGNED_BYTE or gl.FLOAT
> Uniformity is not relevant here.
> If you upload an UInt8Array, you convey the intent that you will
> likely use at least one attrib of UNSIGNED_BYTE.
> If you upload an Float32Array, you convey the intent that you will
> likely use at least one attrib of FLOAT.
> As you'll never be able to use one attrib of DOUBLE, it breaks this
> "contract".

There is no such contract.

> > Disallowing Float64Array will not help the developer in any way
> As clarified above, I still think it can help the developer for simple
> typos/mistakes that would otherwise take some time to figure out.
> Not feeling strongly about inclusion in the spec though, it could be
> done out of spec by tools like WebGL Inspector.
> Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://khronos.org/pipermail/public_webgl_khronos.org/attachments/20110523/342bb8c1/attachment.html>

More information about the public_webgl mailing list