Physics calculations on CPU vs on GPU

Hi everyone,

Apart from rendering engine, physics calculations are what I am interested to learn. Been foraying on google on this topic. There are several sub topics in this like rigid body dynamics, soft body dynamics, fluid dynamics and collision detection etc. I am not sure whether to perform these calculations on GPU ( if so how) or CPU ( using C++). Btw, I find it difficult to believe that such complex calculations are bieng done on CPU and yet those AAA games achieve 40-60 fps.

Maybe GPU is better… NVidia PhysX by exemple…

NVidia PhysX calculations, in their entirety, are not done on GPU. Besides I have AMD card.

Even supposing that some part of library is executed on GPU, do they use compute shaders and geometry shaders? In Opengl SuperBible, authors use vertex and geometry shaders to perform some calculations on vertices and bring them back to entry stage by streaming the data out for simulating a cloth. Which brings me back to my question. What portions of physics simulations can be done on today’s GPUs and what portions are, by necessity, to be done on CPU?

I can’t find the sample code for this, but i’d make a wild guess that they use Transform Feedback instead of compute shaders, as they only have to change some attributes on the same set of vertices. Compute shaders lets you input and output any data you want, with the exact number of work groups you want.

Anything that can be parallelized will have a huge performance boost when done on the GPU, like physics calculations, Z sorting for transparency/optimal early depth testing, or LOD calculations. Anything that can’t will have to run on the CPU since its single core performance is always better.