Getting memory from the GPU back to your CPU takes time, and will likely be your bottleneck when working with compute shaders. The larger the set of calculations, the more you’ll reap the rewards of doing things on your GPU.Ĭonditional branching really kills your performance because GPUs aren’t optimized to do that, but this is no different from writing vertex and fragment shaders so if you have some experience with them this will be old hat.
Any problem which involves applying the same (no conditional branching) set of calculations to every element in a data set is perfect.
What are they good for? (and what do they suck at?) So if you don’t have access to a windows machine, the rest of this probably won’t be helpful. This means that this will be my first ever WINDOWS ONLY tutorial.
#Compute shader example opengl 4.3 mac#
Right now Unity only supports DirectX11 compute shaders, but once everyone catches up to OpenGL 4.3, hopefully us mac lovers will get them too :D Simply put, a compute shader is a is a program executed on the GPU that doesn’t need to operate on mesh or texture data, works inside the OpenGL or DirectX memory space (unlike OpenCL which has its own memory space), and can output buffers of data or textures and share memory across threads of execution. Compute shaders can be used to control the positions of particles