Good night fellas,
As an academic exercise to test the feasibility of Unity as a research platform, I’m in the process of porting over the GPGPU Smoothed Particle Hydrodynamics sample using DirectCompute from the DirectX SDK.
In order to determine the contribution to the density and the forces exerted over a particle by it’s neighbors, I have an spatial hash structure where neighbors list are stored in a vector. Each of the elements of the vector consists of a key-value tuple with the particle id and the computed hash for the particle’s position. This part seems to work properly when comparing it by my CPU-generated results. However, in order to able to use the list and generate the offsets table that point to the beginning of each bucket, I need to sort the vector by the computed hash.
Therefore I have ported the Bitonic Sort provided in the same SDK over to Unity, but I’m having troubles making it work. Seems like it’s only sorting the values that are within the bitonic group size (currently 512 elements). As I’m not too experienced with the DX11 API, I might have screwed up translating the DX11 API calls but they seem OK to me.
I’ve spent a bunch of hours struggling with it and I’m getting close to the point of desperation. So here’s my cry for help: have any of you guys successfully ported the Bitonic sort, or has a ready-to-use implementation of a sorting algorithm for DirectCompute?
Any help is welcome, as there doesn’t seem to be many samples out there and even less properly documented. [13412-gpusort.zip|13412] It includes a simple test case MonoBehaviour, just create an empty scene and attach the test script to an empty gameobject. The results are written into the debug window.
Thanks for the help!