W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

Re: API for matrix manipulation

From: Chris Marrin <cmarrin@apple.com>
Date: Tue, 15 Mar 2011 17:06:02 -0700
Cc: Lars Knudsen <larsgk@gmail.com>, Joćo Eiras <joao.eiras@gmail.com>, public-webapps <public-webapps@w3.org>
Message-id: <0BD51B59-E712-44DB-88D0-9B4B18725125@apple.com>
To: Gregg Tavares <gman@google.com> (wrk)

On Mar 15, 2011, at 2:49 PM, Gregg Tavares (wrk) wrote:

> 
> 
> On Mon, Mar 14, 2011 at 4:27 PM, Chris Marrin <cmarrin@apple.com> wrote:
> 
> On Mar 14, 2011, at 12:19 PM, Lars Knudsen wrote:
> 
> > Hi,
> >
> > related to this:  Is there any work ongoing to tie these (or more generic vector / matrix) classes to OpenCL / WebCL for faster computation across CPUs and GPUs?
> 
> On WebKit I've experimented with an API to copy a CSSMatrix to an Float32Array, which can be directly uploaded to the GPU. It's surprising how much more efficient this was than copying the 16 floating point values out of the CSSMatrix using JS. But I've hesitated proposing such an API while WebGL and Typed Arrays were still in draft. Now that they're not, maybe it's time to discuss it.
> 
> I've also experimented with API in CSSMatrix to do in-place operations, rather than creating a new CSSMatrix to hold the results. This too was a big win, mostly I think because you get rid of all the churn of creating and collecting CSSMatrix objects.
> 
> 
> Would it be an even bigger win if CSSMatrix took a destination? That way you can avoid all allocations where as if they do it in place then you always need to make at least some copies to temps to get anything done.

When you say "destination" are you talking about operating on a Typed Array buffer directly? I suppose that would be possible, but that would really just be like having 3D matrix operations on the Float32Array object. I think it would be a mistake to make yet another set of matrix functions! And one way or the other you need to copy data between types. You might be doing a CSS animation and you want to get the current matrix, put it in a Float32Array and send it to WebGL (I've done this, works great!). The cost of copying a matrix from a CSSMatrix to a Float32Array is so low relative to all the other call overhead that I don't think eliding that copy would buy much. But I might be wrong.

-----
~Chris
cmarrin@apple.com
Received on Wednesday, 16 March 2011 00:07:09 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:43 GMT