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

Re: [Public WebGL] Feature proposal for TypedArrays

On May 12, 2010, at 12:50 PM, Gregg Tavares wrote:

On Wed, May 12, 2010 at 10:34 AM, Chris Marrin <cmarrin@apple.com> wrote:

On May 11, 2010, at 6:37 AM, tomi.aarnio@nokia.com wrote:

> Hi all,
> Thanks for the feedback! To clarify, my proposal is aimed at TypedArrays, not the WebGL core spec. As I see it, having the necessary datatypes in place right from the start will reduce fragmentation of the TypedArray API in the future.
> Granted -- fp16 is not yet a first-class citizen on most C compilers, so it will have to be emulated using fp32 or plain integers. Luckily there are several open-source libraries available for that, see for instance www.openexr.com. Besides, we don’t need a full-blown math library here, just the conversion functions to/from fp32, which are almost trivial to write.
> I don’t quite understand the alleged problems with doing math in fp16. From the _javascript_ perspective, fp16 is no different from fp32, because neither one is supported natively. If you do myArray[i]*myArray[j], the multiplication happens in double-precision regardless of the source operand precision, right?

But on all major hardware, converting to and from fp32 and fp64 is a simple cast. No such operation exists for fp16. As I mentioned before, we can support passing fp16 to WebGL by using the unsigned short array.

I also agree with Ken that we should eventually support this, just not in 1.0.

If you've already got code converting from JS Number to/from float and JS Number to from byte and JS Number to/from short etc then adding 1 more JS Number to/from half seems like an hour or two of work a the most.

Why not put it in 1.0?  Because once it's in TypedArray, separate from WebGL, it's possibly going to take a lot more work to get it added since it's a different standards group that will be responsible for it.

I think it would be incredibly hard to get a proposal including fp16 through a standards organizartion like ECMA at any time. All the other data types are standard in virtually every computing language. FP16 is a very specific data type used by GL-ES. I think it would be a mistake to move forward with this until we have a good TypedArray spec in ES. 

I have to say I have many misgivings about putting TypedArrays in ECMA at all. WebGL is not supposed to be dependent on JS or any language, just like every other W3C spec. Moving TypedArrays to ES, makes us fully dependent on ECMAScript. With the pushback we're getting on TC-39, we may want to rethink that strategy