Discovering compute shaders and compute buffers
Compute shaders are quite a unique tool that has many applications, such as the rendering of procedurally generated shapes (see Figure 7.1, a screenshot taken from https://www.youtube.com/watch?v=WWI07UQbJ9E) or the large calculations in a complex system.
Figure 7.1 – Render of the Mandelbrot Set using compute shaders
In the following sections, we will see what compute shaders are exactly, why they can be useful, how they work hand in hand with compute buffers to properly share data between the CPU and the GPU, and how they are structured.
What are compute shaders?
In a nutshell, compute shaders are a specific type of shader script that are meant to offload processing from the CPU to the GPU.
The main idea is that because the GPU runs code in parallel, it can achieve better performance for computationally intensive tasks and large amounts of data – typically, heavy rendering algorithms...