64-Bit Atomics with GL_EXT_shader_atomic_int64
The OpenGL and Vulkan shading language extension
GL_EXT_shader_atomic_int64 allows compute and graphics
shaders to perform atomic operations directly on 64-bit signed and
unsigned integers. This article provides a technical overview of the
extension's role in GLSL, detailing how it lifts historical 32-bit
constraints, the specific atomic functions it introduces, the memory
models it affects, and its practical applications in modern GPU
computing.
Overcoming 32-Bit Limitations
Standard GLSL natively restricts atomic memory operations—such as
atomicAdd and atomicCompSwap—to 32-bit integer
types (int and uint). In high-performance
rendering and GPGPU tasks, 32-bit integers frequently fall short due to
range limitations or alignment needs. The
GL_EXT_shader_atomic_int64 extension eliminates this
bottleneck by integrating native hardware support for 64-bit atomic
operations, removing the need for complex, software-emulated multi-word
locking mechanisms that degrade GPU performance.
Key Capabilities and Functions
When enabled in a shader via
#extension GL_EXT_shader_atomic_int64 : require, the
extension overloads standard GLSL built-in atomic functions to accept
int64_t and uint64_t data types. These
operations apply to both buffer variables (such as Shader Storage Buffer
Objects) and compute shader shared memory variables.
The extension enables the following 64-bit atomic functions:
- Arithmetic Operations:
atomicAdd,atomicMin, andatomicMax - Bitwise Operations:
atomicAnd,atomicOr, andatomicXor - Exchange and Compare:
atomicExchangeandatomicCompSwap
Each operation guarantees atomic read-modify-write behavior across concurrently executing invocations within a workgroup or across the entire GPU.
Critical Use Cases
The introduction of 64-bit atomic operations enables advanced GPU algorithms that require wide data tracking:
- Large-Scale Global Counters: Applications that process billions of primitives or samples can easily overflow a 32-bit counter (capped at ~4.29 billion). A 64-bit atomic counter prevents overflow in persistent GPU workloads.
- Packing Data with Handles: Developers can pack
multiple values—such as a 32-bit depth value alongside a 32-bit
primitive ID or material index—into a single 64-bit integer. Using
atomicMinoratomicMaxon these packed values allows algorithms like Order-Independent Transparency (OIT) or software rasterization to perform atomic depth-testing and payload updates simultaneously. - 64-Bit Pointers and Addressing: In advanced GPU
compute pipelines employing GPU virtual addressing or bindless resource
management, memory pointers are typically 64 bits wide.
GL_EXT_shader_atomic_int64allows the atomic insertion and traversal of nodes in lock-free GPU data structures, such as linked lists, hash tables, and spatial acceleration hierarchies.
Dependencies and Requirements
GL_EXT_shader_atomic_int64 requires foundational support
for 64-bit integer arithmetic, typically provided by extensions such as
GL_ARB_gpu_shader_int64 or
GL_EXT_shader_explicit_arithmetic_types_int64. On the
hardware level, it depends on underlying GPU architecture support for
native 64-bit atomic instructions, making it standard on modern discrete
GPUs and supported mobile architectures.