Sign in to follow this  
jerome

SPS experiments

Recommended Posts

thanks for the feedback... I'm no shader expert, it's my first one ever. The message seems to tell us that Edge doesn't like my float array declaration : float[11] rotMatrix

not sure... I'll ask to the shader gods.

In order to better understand the comparisons between all these versions, the GPU one ( http://jerome.bousquie.fr/BJS/test/SPSGpu/spsShader.html ) is actually exactly the same than the monothreaded typed array based one ( http://jerome.bousquie.fr/BJS/test/spsBuffer.html ), except that the transformations are computed GPU side instead of CPU side.

This means that, without any worker, the gain is really important.

Compared to the worker versions, on my not-that-strong laptop, the GPU version is a bit faster than the worker version.

Should I add workers now to the GPU version ? not sure actually, because all the heaviest computation part is deported to the GPU and the CPU only does now simple array element assignements. Splitting the array among different workers won't bring anything more because the memory shared between these workers can't be also shared with the GPU, meaning that we have to loop over the whole worker shared array, once updated, to copy it into the GPU buffer anyway.. so the same loop size in final, once more, to fill the vertex buffer.

Share this post


Link to post
Share on other sites

I honestly have no idea. I'm still trying to wrap my head around shared arrays and atomics, to see whether, and how much, these are usable for running physics in workers. Why not give it a try. At least you'll gain some knowledge. It's just a matter of time before it's as compatible as WebGL. I'll be interesting in your findings and experiments..

Share this post


Link to post
Share on other sites

Let's go on now with the WASM SPS.

First remember the former tests on a 40 K solid particle SPS and the perfs I get in my Chrome :

Legacy SPS : http://jerome.bousquie.fr/BJS/test/spsReference.html     (8 fps)

Lighter Buffer SPS : http://jerome.bousquie.fr/BJS/test/spsBuffer.html   (7 fps)

Two worker SPS : http://jerome.bousquie.fr/BJS/test/SPSWorker/twoWorkers/spsProtoWorker.html (37-42 fps)

and now the WASM SPS : http://jerome.bousquie.fr/BJS/test/SPSWasm/spsWasm.html  (31 fps)

This last version has done with AssemblyScript like explained here :

It's the Buffer SPS version ported to AssemblyScript, then compiled in WASM. It brings a gain of 4.4 more speed

You can get the AS source here : http://jerome.bousquie.fr/BJS/test/SPSWasm/index.ts

Please let me know how this behaves in your browser.

Note that WASM is compatible with workers and that a double-worker-wasm SPS could be implemented... not sure I'll do it because it's quite complex.

[EDIT] : a test with 20K particles runs at 60 fps here. So I guess that a two-worker implementation, each computing 20K in wasm, could also run at 60 fps for a total of 40K particles.

Share this post


Link to post
Share on other sites

let's also recap what dimensions we are talking about :

20 K boxes, each having 24 vertices = 480K vertices

+ 20K tetrahedrons, each having 12 vertices = 240K vertices

A total of 720 K vertices, knowing each has 3 floats (x,y,z)  for the positions and 3 floats for the normals, so 4.320 millions floats just for the coordinates.

Each particle stores a shape length, an integer, so 40K integers more.

Each particle is set a transformation (a position, a rotation and a scaling) so 9 floats per particle, so 360 K floats.

In total 4.680 millions floats and 40K integers as input data.

From these  input data, 4.320 millions floats, the transformed vertex positions and normals, are computed and stored in the same buffer... in 18 ms

[EDIT] and meanwhile 40K quaternions and 40K rotation matrices, one per particle, are also computed !

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.