textureStore
On this page

textureStore

Function

Writes one texel to a storage texture at the integer coord, on a binding declared "write" or "read_write"; returns nothing.

The signature and the sentence under each name are the compiler's own text at commit 26de7be8.

Syntax

declare function textureStore<F extends StorageFormat, A extends 'write' | 'read_write'>(
tex: texture_storage_2d<F, A>,
coord: TexelCoord2,
value: StorageTexel<F>,
): void
declare function textureStore<F extends StorageFormat, A extends 'write' | 'read_write'>(
tex: texture_storage_2d_array<F, A>,
coord: TexelCoord2,
layer: number,
value: StorageTexel<F>,
): void

A number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.

type f32 = number & { readonly [f32Tag]?: true }

A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.

A signature may name a type the ambient file declares for its own use. These are those declarations.

TexelCoord2
type TexelCoord2 = vec2i | vec2u
StorageFormat
type StorageFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm'
StorageTexel
type StorageTexel<F extends StorageFormat> = F extends `${string}uint` ? vec4u : F extends `${string}sint` ? vec4i : vec4

Parameters

Return value

void

Description

The value is the texel the format decides: a "…uint" format stores a vec4u, a "…sint" one a vec4i, and every other one a vec4. Compiles to textureStore on WGSL; GLSL ES 3.00 has no image load/store, so a module using it emits WGSL alone and the CPU oracle, which has no texture memory, drops the write.

Targets

WGSL
textureStore(a, b, c)
GLSL ES 3.00
textureStore has no GLSL ES 3.00 spelling (image load/store is ES 3.10)

Examples

See also

Edit this page Report a problem