workgroupUniformLoad
On this page

workgroupUniformLoad

Function

A uniform workgroup load surrounds a shared-memory read with barriers so the workgroup receives the same value.

Compare examples

Compare a write followed by the collective read with separate workgroups. The latter do not share the location.

Model assumptionsA, B ∈ workgroup W; C ∈ workgroup V; W ≠ V

Example 1W: write(value = 7) → workgroupUniformLoad(value)
Result
W: [7, 7]
Example 2W: write(value = 0) → workgroupUniformLoad(value)
Result
W: [0, 0]
Example 3W: value = 7; V: value = 3
Result
W: [7, 7]; V: [3, 3]

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 to distribute a value written cooperatively in workgroup memory.

Inputs and limits

The argument must be workgroup memory. All invocations must participate in uniform control flow. Storage memory is not accepted; this compiler emits WebGPU only.

For shader input rules and precision, consult WGSL and GLSL ES 3.00.

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

Reads one value out of workgroup memory with a barrier on each side, so every invocation of the workgroup gets the same one.

Syntax

declare function workgroupUniformLoad<T>(w: T): T

Parameters

  • w T

Return value

T

Description

Takes a place in workgroup<T> memory, not storage, and returns its type. It cuts a phase on WebGL2 as a barrier does (Rule 8.24), and it carries a barrier's placement rules: a compute entry or a function it calls, in uniform control flow.

Targets

WGSL
workgroupUniformLoad(&a)
GLSL ES 3.00
workgroupUniformLoad is not supported yet in a GLSL ES 3.00 stage (Rule 10.5)

Examples

See also

Edit this page Report a problem