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

Re: [Public WebGL] Matrix objects in JavaScript






On Thu, Mar 21, 2013 at 3:27 PM, Rik Cabanier <cabanier@gmail.com> wrote:


On Thu, Mar 21, 2013 at 3:18 PM, Rik Cabanier <cabanier@gmail.com> wrote:


On Thu, Mar 21, 2013 at 2:40 PM, Florian Bösch <pyalot@gmail.com> wrote:
On Thu, Mar 21, 2013 at 10:16 PM, Rik Cabanier <cabanier@gmail.com> wrote:
Which one is faster:
element.style.transform = window.getComputedStyle(element).transformMatrix.rotateBy(45); // 1 temporary object. all calculations on c++ side
or
... make sure some js library is loaded
element.style.transform = new MyMatrix(window.getComputedStyle(element).transform).rotateBy(45).getFloatArray(); // 2 (or 3) temporary objects + 6 or 16 (12 or 32?) temporary floats + all calculations on js side

Neither, this one is faster:

mat4Rotate(window.getComputedStyle(element).transform, 45, element.style.transform)
                                                              ^ source    ^a                        ^ target

We're quite serious when we say temporaries/allocation is a serious problem, seriously, we're not joking. And lengthy discussions on the GC issue have been conducted with only one clear outcome, while things may get better, they will not get perfect.

You constructed 2 temporaries there as well as brought in at least 12 floats into the JS VM + you did all the math in js.

I take that back. There's also only 1 temporary.

Can the VM create native code for typed arrays?

AFAIK both Firefox and Chrome are working on making the VM create native code for typed arrays.
 
I though that only worked if you used objects.
 

 If 'element.style.transform' returned a live object, you could just do 'element.style.transform.rotateBy(45)' and have only 1 temporary.