Live data from Hacker News

Fun with compute shaders and fluid dynamics

blog.kummerlaender.eu

11–14 of 14 posts

Re: Fun with compute shaders and fluid dynamics

#11
post #8

The idea to put input energy via the mouse is nifty. Nice work! I dont think vertex buffers are the ideal storage mechanism for lattice methods. I used Cuda to rasterize a plain buffer but I have two GPUs, the one doing the sim wasn't the one rendering. Its better this way if you are looking to run the sim 1000s of cycles per sec, but only render 60 fps. Theres a lot of extra data that could be eliminated by simply u…

(Author here) Thanks for the interesting links! I agree that there is much that could be optimized. The choice to use vertex buffers was driven by the overarching goal of implementing the whole thing in GLSL. It really is just a small playground project to generate some nice visualizations. If we wanted to actually use the results beyond displaying them the tight coupling between simulation and rendering would certai…

Well it looks awesome, we all are just fooling around with this stuff :-)

If you did want to increase performance, you could try to use OpenGL for rendering but write your actual sim in CUDA C++.

The whole interop API is listed here: https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART_...

Essentially it wouldn't involve any host/memory transfer, all would be processed on GPU.

Then you could limit your rendering thread to 60fps while running the CUDA kernel non-stop.

I haven't actually tested this out though because I had 2 GPUs for the sims above, and the beefy one running the sim was on TCC instead of WDDM mode (no attached display allowable.) [1] So I had the universe state buffer transferred to host memory, and then to the 2nd GPU for rendering to attached display.

I am not sure of the speed gains TCC vs WDDM really provides, but Nvidia says it makes "some difference."

[1] https://docs.nvidia.com/gameworks/content/developertools/des...

Re: Fun with compute shaders and fluid dynamics

#14
post #3

Here's another classic article about fluids on the GPU: http://developer.download.nvidia.com/books/HTML/gpugems/gpug... It's significantly older, but it's still good and it goes into the details for those (like me) who don't have a background in fluid dynamics. I had a lot of fun implementing it on the side a while back.

The one I remember is the last reference there:

Jos Stam, Stable Fluids [1999]

http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/...

More of his papers:

http://www.dgp.toronto.edu/people/stam/reality/Research/pub....

Post reply on HN