r/GraphicsProgramming 5d ago

Question Any good compute shaders optimization guides?

Hi,

for the past 2-3 years I have developed a 3d sculpting app that is almost entirely compute shader based acting on a mesh (dynamic topology + brush actions). The mesh is essentially a vertex buffer (position color normal) and an index buffer (triangle indices). I do stuff like adjacency tables and topology changes and neighborhood / local brush operations.

I am using Unity with HLSL compute shaders.

I would like to know if there are guides you recommend regarding optimization (books or websites with code samples ideally but videos can be ok too)

I have successfully brought some optimizations in this final phase of development, with better compute buffer allocation management (lazy allocation on expand, trim when needed), reducing reads and write to UAVs, struct optimization, some experiment with cache friendly layouts, caching of some data between frames (that was the biggest win).

I would like to go deeper, but I lack a structured understanding to know where to look and what is worth digging in beyond better algorithms / caching from frame to frame.

Thank you in advance for your recs

8 Upvotes

4 comments sorted by

View all comments

3

u/waramped 4d ago

Optimization for Compute is a tricky thing. Bottlenecks can be pretty unintuitive sometimes.

Your best bet is to profile your code and see what the bottlenecks are, and then address those case by case.

If you're using DX12 on Windows, try PIX. https://devblogs.microsoft.com/pix/download/

NSight if using nvidia: https://developer.nvidia.com/nsight-systems

AMD Radeon if using AMD: https://gpuopen.com/rgp/

Edit: I missed the Unity part, I'm not sure what GPU profiling tools work with Unity. Pix should?

2

u/etdeagle 4d ago

Thanks that sounds like a good direction, the target device is MetaQuest3 (Snapdragon) I think Qualcomm has some tools for profiling.