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

*To*: Benoit Jacob <bjacob@mozilla.com>*Subject*: Re: [Public WebGL] Matrix objects in JavaScript*From*: Florian Bösch <pyalot@gmail.com>*Date*: Thu, 21 Mar 2013 17:35:06 +0100*Cc*: Steve Baker <steve@sjbaker.org>, public webgl <public_webgl@khronos.org>*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=obywLGLYF3fB4ZCS2peb+t7Nr18e0e6owvzzRBdaWlI=; b=j25fxpWGP6FVPAZ4L8EAKtM1wX0nRAcNdTuvbZYHXm0fYR3f/MlKkACYKuKteU0Ef9 MuDQfaEX/aB8FG13H9qOlvIBNlS/eu7O5ZejJjQHK0neCKbzJ9lAVawhh9Jy3EAbTsGI Z7zSyJ3WJBRtMTWlXia33IrglYEYT4qZk9GOhuScOm0uwvWYX1AuH4YfcfsSvPBdcFNS 9cUSBC/q8AREvsH79V1wc/DOjpKsWqF0vE2Xf2rASleGMTqY9j4ieaEkyZLBX7rdP62d 7t/OypYZKLdV37SdWmpk2lccSbCxA0NuotwmFkzZ3ZzIc29/H6thfLgIhDl+SS5cQMrx jMwQ==*In-reply-to*: <514B3173.4040202@mozilla.com>*List-archive*: <https://www.khronos.org/webgl/public-mailing-list/archives/>*List-id*: Public COLLADA Mailing List <public_webgl.khronos.org>*List-owner*: <mailto:owner-public_webgl@khronos.org>*List-post*: <mailto:public_webgl@khronos.org>*List-subscribe*: <mailto:majordomo@khronos.org?body=subscribe%20public_webgl>*List-unsubscribe*: <mailto:majordomo@khronos.org?body=unsubscribe%20public_webgl>*References*: <CAKZ+BNpxoiB=g0Q2WOvrdvkr-_bu3MEBLkOdrtvbiAKvjwcDUA@mail.gmail.com> <514ADEB4.1070108@jetbrains.com> <CAOK8ODim+65x0+k6LMjMg67YJ8i_mq-+O8xTsjUzSjvvL-39XQ@mail.gmail.com> <CAHh_GTHjWvVYL1Tei-5BwS7P0gCegH_jHMAwDEBsUjza=KYrWQ@mail.gmail.com> <514B202A.5080700@mozilla.com> <5c44e7fc194df1793a2dca5e977e785e.squirrel@webmail.sjbaker.org> <514B3173.4040202@mozilla.com>*Sender*: owner-public_webgl@khronos.org

I think there might be an underestimation of how expensive matrix operations like inverse and multiply are.

A 4x4 matrix multiplication involves:

32x fetching of the value from a buffer (likely float32) and converting to native JS doubles.

64x double multiplications

60x double additions

16x converting a double to the target buffer (likely float32)

So 48x double conversions and 124 double mathops.

A 4x4 inversion by gaussian elimination involves:

16x fetching of the value from a buffer, converting to native JS doubles

32x double multiplication, 14x double subtraction and 2x double addition to compute the determinant

64x double multiplication, 32x double addition and 32x double subtraction

16x store to buffer conversion

So 32x double conversion and 176 double mathops.

Those are not insignificant amounts of math in JS, it's not even insiginificant if somehow magically the compiler would convert it all to straightforward native code.

On Thu, Mar 21, 2013 at 5:12 PM, Benoit Jacob <bjacob@mozilla.com> wrote:

There are two competing technologies in development to do this sort of

thing: WebCL and RiverTrail. We'll see how it shakes out. That's not a

use case that the proposal on public-fx is concerned with.

Benoit

>>> On 21 March 2013 10:24, Florian Bösch <pyalot@gmail.com

On 13-03-21 12:10 PM, Steve Baker wrote:

> I agree that for all of the specialist math functions (inverse and such),

> we're better off letting _javascript_ handle it. There are plenty of good

> libraries out there - and if there is browser-engineer time available, I'd

> rather it was spent on making JS faster than on writing and maintaining a

> library like this.

>

> HOWEVER:

>

> The place where having some API support would be useful is in bulk

> operations.

>

> If I have 1,000 matrices that all need to be transformed in some way - or

> if I have a bunch of vertices that need to be multiplied by matrices -

> then there are massive gains to be had with machine-code that uses

> specialised CPU instruction sets and GPU OpenCL stuff that the JS

> optimizer is unlikely to be able to spot and take advantage of. WebCL may

> be able to handle that - but I doubt we'll get comprehensive support for

> it on every platform as soon as we could get a set of simple operations

> for bulk matrix/vector work.

>

> So I think there would be value in defining a very minimal matrix library

> to handle a minimal set of operations (multiply, translate, rotate maybe)

> on large arrays of vertices and matrices.

>

> -- Steve

>

>

> Benoit Jacob wrote:

>> I have been arguing on public-fx that we are better off without a

>> browser-supported matrix library because this is best done in JS both

>> from the perspective of performance (giving it a bit of time for JS

>> toolchains to solve roadblocks) and from the perspective of flexibility

>> and not blessing an arbitrary choice of matrix library over other ones

>> (and a poor one at that).

>>

>> Benoit

>>

>> On 13-03-21 07:04 AM, Si Robertson wrote:

>>> I have to say I can not think of any reason for native matrix objects

>>> to be implemented by browser vendors unless those objects (a) provide

>>> a significant performance gain over custom code, and (b) are

>>> compatible with WebGL.

>>>

>>> Matrix operations that work on typed arrays are very fast already if

>>> the code is optimised, and it is relatively easily to avoid creating

>>> new type arrays when needed.

>>>

>>>

>>>

>>> <mailto:pyalot@gmail.com>> wrote:

>>>

>>> On Thu, Mar 21, 2013 at 11:19 AM, Kirill Prazdnikov

>>> <kirill.prazdnikov@jetbrains.com

>>> <mailto:kirill.prazdnikov@jetbrains.com>> wrote:

>>>

>>> Will it be a helper library or part of WebGL API ?

>>>

>>> Neither. It would be implemented in the browser, not related to

>>> WebGL, and in my opinion, unusable for it.

>>>

>>>

>>>

>>

>

> -- Steve

>

-----------------------------------------------------------

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

-----------------------------------------------------------

**Follow-Ups**:**Re: [Public WebGL] Matrix objects in JavaScript***From:*Benoit Jacob <bjacob@mozilla.com>

**References**:**[Public WebGL] Matrix objects in JavaScript***From:*Gregg Tavares <gman@google.com>

**Re: [Public WebGL] Matrix objects in JavaScript***From:*Kirill Prazdnikov <kirill.prazdnikov@jetbrains.com>

**Re: [Public WebGL] Matrix objects in JavaScript***From:*Florian Bösch <pyalot@gmail.com>

**Re: [Public WebGL] Matrix objects in JavaScript***From:*Si Robertson <retromodular@gmail.com>

**Re: [Public WebGL] Matrix objects in JavaScript***From:*Benoit Jacob <bjacob@mozilla.com>

**Re: [Public WebGL] Matrix objects in JavaScript***From:*"Steve Baker" <steve@sjbaker.org>

**Re: [Public WebGL] Matrix objects in JavaScript***From:*Benoit Jacob <bjacob@mozilla.com>

- Prev by Date:
**Re: [Public WebGL] Matrix objects in JavaScript** - Next by Date:
**Re: [Public WebGL] Matrix objects in JavaScript** - Previous by thread:
**Re: [Public WebGL] Matrix objects in JavaScript** - Next by thread:
**Re: [Public WebGL] Matrix objects in JavaScript** - Index(es):