---
title: "atomicLoad: shader function examples, uses and input limits"
description: "An atomic load reads one shared integer without a torn read. Use it for reading a shared counter."
url: https://typeshade.dev/reference/functions/atomicLoad/
language: en
---

# `atomicLoad`

Function

An atomic load reads one shared integer without a torn read.

## Compare examples

Compare the returned value with the stored value. Each case starts from its own initial state.

**Model assumptions**`location: atomic<u32>`

**Example 1`atomicLoad(location)`**

**Stored value before**

`5`

**Returned value**

`5`

**Stored value after**

`5`

**Example 2`atomicLoad(location)`**

**Stored value before**

`0`

**Returned value**

`0`

**Stored value after**

`0`

**Example 3`atomicLoad(location)`**

**Stored value before**

`4294967295`

**Returned value**

`4294967295`

**Stored value after**

`4294967295`

The examples are calculation models and do not run GPU work. The reference below gives the complete call signatures. Decimal results are rounded for display. The stated assumptions determine each example; actual shader results follow the target precision and execution rules.

## When to use it

Use it for reading a shared counter.

## Inputs and limits

The model uses an unsigned integer and one serialized operation. Real invocation order is unspecified. Atomicity does not synchronize unrelated memory; these calls require WebGPU in this compiler.

For shader input rules and precision, consult [WGSL](https://www.w3.org/TR/WGSL/) and [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf).

## Related functions

- [`atomicStore`](https://typeshade.dev/reference/functions/atomicStore/)
- [`atomicAdd`](https://typeshade.dev/reference/functions/atomicAdd/)
- [`atomicSub`](https://typeshade.dev/reference/functions/atomicSub/)
- [`atomicMin`](https://typeshade.dev/reference/functions/atomicMin/)
- [`atomicMax`](https://typeshade.dev/reference/functions/atomicMax/)

The signature, the sentence and any message are the compiler's own text at commit af54ddad5.

Reads the value of an `atomic<u32>` or `atomic<i32>` location in a read-write storage binding (`atomicLoad(bins[i])`).

## Syntax

```ts
declare function atomicLoad<T extends u32 | i32>(location: atomic<T>): T
```

## Parameters

- `location` `atomic<T>`

## Return value

`T`

## Description

Compiles to `atomicLoad(&bins[i])` on WGSL; its GLSL lowering is not supported yet ([Rule 10.5](https://typeshade.dev/reference/rules/10-5/)), so a module using it emits WGSL alone. The CPU oracle runs invocations in order and reads the location.

## Targets

**WGSL**

`atomicLoad(&a)`

**GLSL ES 3.00**

`atomicLoad` is not supported yet in a GLSL ES 3.00 stage (Rule 10.5); a `@compute` entry that reaches no texture runs it on WebGL2 as its pass program (Rule 11.8)

## See also

- [Functions](https://typeshade.dev/reference/functions/)
- [Builtin table](https://typeshade.dev/guide/language/builtins/#atomics)
