---
title: "textureBarrier: shader function examples and input limits"
description: "A barrier waits for the invocations of one workgroup and orders their accesses to texture memory."
url: https://typeshade.dev/reference/functions/textureBarrier/
language: en
---

# `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 assumptions**`A, B ∈ workgroup W; C ∈ workgroup V; W ≠ V`

**Example 1`W: A.write → textureBarrier() → B.read`**

**Result**

`A.write ≺ B.read`

**Example 2`W: A.write → textureBarrier() → A.read`**

**Result**

`A.write ≺ A.read`

**Example 3`W.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](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

- [`workgroupBarrier`](https://typeshade.dev/reference/functions/workgroupBarrier/)
- [`storageBarrier`](https://typeshade.dev/reference/functions/storageBarrier/)
- [`workgroupUniformLoad`](https://typeshade.dev/reference/functions/workgroupUniformLoad/)

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

```ts
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](https://typeshade.dev/reference/rules/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

- [`gallery/compute-sync/compute-sync.shade.ts`](https://typeshade.dev/guide/examples/compute-sync/)

## See also

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