Home

ComputeShaders

Compute shaders are shader programs designed for general-purpose GPU computation (GPGPU). They run on the GPU outside of the traditional graphics pipeline and typically write to memory buffers or images rather than producing a rendered frame. They are invoked by a dispatch that specifies a two- or three-dimensional grid of work groups, each containing multiple threads or invocations.

In the execution model, each thread executes the same shader code with a unique index identifying its

Compute shaders are implemented in several graphics APIs, including OpenGL with GLSL, DirectX with HLSL, Vulkan,

Applications cover data-parallel tasks such as physics and fluid simulations, image and video processing, numerical computations,

data
element.
Threads
within
a
work
group
may
share
memory
and
synchronize
via
barriers;
synchronization
across
work
groups
generally
requires
separate
dispatches
or
atomic
operations.
Programs
can
read
and
write
to
buffers
and
textures,
using
memory
types
such
as
global,
shared
(group),
and
constant
memory.
and
Metal.
They
are
compiled
to
an
appropriate
intermediate
representation
and
bound
via
a
compute
pipeline.
The
local
work
group
size
is
defined
by
the
shader,
and
the
total
number
of
threads
is
the
product
of
the
local
size
and
the
number
of
work
groups.
Monte
Carlo
methods,
and
other
GPU-accelerated
workloads.
Performance
depends
on
data
locality,
memory
access
patterns,
occupancy,
and
minimizing
CPU-GPU
data
transfers.
Debugging
and
portability
require
careful
API-specific
considerations.