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

Re: [Public WebGL] Float16Array



On Sat, Nov 22, 2014 at 11:56 PM, Florian Bösch <pyalot@gmail.com> wrote:
> I've laid out my reasons for Float16Array support in es-discuss:
> https://mail.mozilla.org/pipermail/es-discuss/2014-November/040377.html

That's the right forum on which to bring up this topic.

> Sadly it seems that participating in the ecmascript standard is opaque and
> weird, and the group doesn't even seem to revision their standard/IDL in a
> public repository (or at all?).
>
> It also seems that previous discussion on typed array stalled:
> https://mail.mozilla.org/pipermail/es-discuss/2014-November/040378.html
>
> TC-39 also doesn't publish anything other than a strawman wiki page, they
> don't seem to have a typed array specification/idl at all.

That's not accurate; typed arrays are fully incorporated into the ES6
drafts which are linked from
http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts .
There's quite a lot of spec text describing their behavior, and in
particular they're integrated with the language's core array types,
which wasn't possible to express in Web IDL.


> Khronos doesn't seem to be administering the typed array specification
> anymore:
> https://github.com/KhronosGroup/WebGL/blob/master/doc/spec/TypedArray-spec.html

We stopped updating it when typed arrays were folded into the
ECMAScript 6 drafts.


> Since I see no other way to participate in TC-39 and to improve typed arrays
> with a much needed functionality, I have created a copy of the lastest copy
> of the standard found on
> https://www.khronos.org/registry/typedarray/specs/latest/ in a github
> repository: https://github.com/pyalot/typed-array-spec and submitted a new
> branch for addition of Float16Array to it:
> https://github.com/pyalot/typed-array-spec/commit/341ba739e728a8d9a9393b94474137bf343a7b24
>
> There are some issues with it:
>
> The WebIDL does not contain a half data type, does it need to be added?
> https://github.com/pyalot/typed-array-spec/issues/1
> What would be a good C equivalent type for half?
> https://github.com/pyalot/typed-array-spec/issues/2
>
> I would be happy to receive feedback on this approach, to receive pull
> requests and feedback on the issues.

I'd recommend you work with the others on the ES6 mailing list (it
looked like you got some good interest from Andrea Giammarchi) to try
to see if there's a path toward specifying this.

The best way to motivate it, I think, is to take your
half-float/main.js a little further, and put together a polyfill that
uses proxies to make a pseudo-Float16Array. I'm 99% sure you ought to
be able to use ES6 proxies to actually support the indexed getter and
setter. The following snippet, at least, works in both Firefox Nightly
and Chrome Canary, Chrome with both the "Enable Experimental
JavaScript" about:flags entry turned on, *and* the command-line
argument --js-flags=--harmony-proxies. It looks like only Firefox
supports the current "new Proxy(target, handler)" syntax, and Chrome
only the older Proxy.create()? I don't know the current status here.

  var TestArray = (function () {
    var underlying = ['1', '2', '3'];
    return Proxy.create({
      get: function(receiver, name) {
        console.log("getting property " + name);
        return underlying[name];
      },

      set: function(receiver, name, value) {
        console.log("setting property " + name + " to " + value);
        underlying[name] = value;
      }
    });
  });

  var my = new TestArray();
  my[0];
  my[0] = 2;
  my[0];

Additionally: having a fairly complete ECMAScript implementation of
the float16 / half data type should make it much easier to incorporate
this support into JS engines. In V8, at least, I'm 99% sure the best
way to implement this would actually be in JavaScript, and let the VM
compile that JavaScript down to efficient assembly. V8's typed arrays
are already implemented in JS.

-Ken

-----------------------------------------------------------
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
-----------------------------------------------------------