-
Notifications
You must be signed in to change notification settings - Fork 2
Compute Shaders
This is when you tell a shader very sternly to use a calculator.
Compute shaders are general purpose programs run on the GPU, in contrast to geometry, vertex and pixel shaders that all serve a fixed and precise role in the GPU pipeline.
They are usually used to compute massive amount of mathematical and especially linear operations on the GPU rather than the CPU. The main motivation being that the GPU is more efficient at those operations than a general purpose CPU.
Typical uses include:
- Liquid simulation
- Collision detection
- Noise generation
- Scene culling
- Offline computations
- Particle system
Compute shaders allows moving compute tasks from an overloaded CPU to a less loaded GPU giving more task scheduling flexibility.
They are also essential if general processing is required within a render frame. Sending information back from the GPU to the CPU is a long and asynchronous operation that can span several frames, making it impossible to process frame dependent computation on the CPU. One solution is to use compute shaders to keep all computation and data within the GPU at all time, preventing CPU stalls.
Compute shaders were initially vertex and pixel shaders that used textures and render target as inputs and outputs. Modern GPU architectures now offer better memory access with structured, unordered and read/write buffers.