textureBarrier
On this page

textureBarrier

Function

A barrier waits for the invocations of one workgroup and orders their accesses to texture memory.

Compare examples

Compare the shared workgroup case with independent workgroups. Only invocations in the same workgroup rendezvous.

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

Example 1W: A.write → textureBarrier() → B.read
Result
A.write ≺ B.read
Example 2W: A.write → textureBarrier() → A.read
Result
A.write ≺ A.read
Example 3W.textureBarrier(); V.textureBarrier()
Result
scope(W) ≠ scope(V)

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 between a cooperative write phase and a read phase involving texture memory.

Inputs and limits

Every invocation of the workgroup must reach the barrier in uniform control flow. It is not a device-wide barrier. These compiler calls are compute-only and 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.

Holds every invocation of the workgroup until all have arrived, ordering their writes to the TEXTURE address space.

Syntax

declare function textureBarrier(): void

Return value

void

Description

A statement, in a compute entry or a function it calls, in uniform control flow; not supported yet on the WebGL2 tier, where an entry that reaches a texture does not run as the pass program (Rule 8.24). Part of the readonly_and_readwrite_storage_textures WGSL language feature that reflect().requiredLanguageFeatures reports.

Targets

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

Examples

See also

Edit this page Report a problem