---
title: "Builtin functions and their WGSL and GLSL ES 3.00 forms"
description: "Every builtin the compiler can spell, 190 in all, beside the WGSL and the GLSL ES 3.00 text it writes for each one, grouped by family."
url: https://typeshade.dev/guide/language/builtins/
language: en
---

# Builtin functions

A builtin is a function the GPU already has. A call carries one neutral name through the compiler, and each backend writes its own spelling for that name, so the call is written once and emitted twice. The registry holds 190 names.

## How to read a row

The first column is the name the call carries, with a placeholder argument in each position it takes. The next two are the text the WGSL backend and the GLSL ES 3.00 backend write for that call, run from the compiler's own spelling table at the pinned commit. 44 of the names are spelled the same way on both targets, and 64 have no GLSL ES 3.00 form of their own, where the cell carries the compiler's own message: the writer has none, or a pass rewrites the call before the writer runs (the subgroup functions, which GLSL runs as one invocation). 27 answer to a `Math.` name as well, which the last column of the maths and cast tables shows. [WGSL vs GLSL ES 3.00](https://typeshade.dev/guide/concepts/wgsl-and-glsl/) compiles one shader to both targets and lists where they differ.

A few of these names are chosen by the compiler and never written by hand. A layered texture read, a depth comparison, a storage fetch and a texel read at an unsigned coordinate each take a name of their own, so the argument order of a call never depends on the texture it landed on. An `abs` of an unsigned value and an integer `dot` take one too, because GLSL ES 3.00 has no overload for either.

## A name the file declares

A function the file declares wins over a builtin of the same name. Such a name meant the author's own function before it was a builtin, and an addition does not change what a program already means.

## Maths

TypeShade WGSL GLSL ES 3.00 Math name

[`abs(a)`](https://typeshade.dev/reference/functions/abs/)

```wgsl
abs(a)
```

```glsl
abs(a)
```

`Math.abs`

`absU(a)`

```wgsl
abs(a)
```

```glsl
a
```

[`acos(a)`](https://typeshade.dev/reference/functions/acos/)

```wgsl
acos(a)
```

```glsl
acos(a)
```

`Math.acos`

[`acosh(a)`](https://typeshade.dev/reference/functions/acosh/)

```wgsl
acosh(a)
```

```glsl
acosh(a)
```

`Math.acosh`

[`all(a)`](https://typeshade.dev/reference/functions/all/)

```wgsl
all(a)
```

```glsl
all(a)
```

[`any(a)`](https://typeshade.dev/reference/functions/any/)

```wgsl
any(a)
```

```glsl
any(a)
```

[`asin(a)`](https://typeshade.dev/reference/functions/asin/)

```wgsl
asin(a)
```

```glsl
asin(a)
```

`Math.asin`

[`asinh(a)`](https://typeshade.dev/reference/functions/asinh/)

```wgsl
asinh(a)
```

```glsl
asinh(a)
```

`Math.asinh`

[`atan(a)`](https://typeshade.dev/reference/functions/atan/)

```wgsl
atan(a)
```

```glsl
atan(a)
```

`Math.atan`

[`atan2(a, b)`](https://typeshade.dev/reference/functions/atan2/)

```wgsl
atan2(a, b)
```

```glsl
atan(a, b)
```

`Math.atan2`

[`atanh(a)`](https://typeshade.dev/reference/functions/atanh/)

```wgsl
atanh(a)
```

```glsl
atanh(a)
```

`Math.atanh`

[`ceil(a)`](https://typeshade.dev/reference/functions/ceil/)

```wgsl
ceil(a)
```

```glsl
ceil(a)
```

`Math.ceil`

[`clamp(a, b, c)`](https://typeshade.dev/reference/functions/clamp/)

```wgsl
clamp(a, b, c)
```

```glsl
clamp(a, b, c)
```

[`cos(a)`](https://typeshade.dev/reference/functions/cos/)

```wgsl
cos(a)
```

```glsl
cos(a)
```

`Math.cos`

[`cosh(a)`](https://typeshade.dev/reference/functions/cosh/)

```wgsl
cosh(a)
```

```glsl
cosh(a)
```

`Math.cosh`

[`degrees(a)`](https://typeshade.dev/reference/functions/degrees/)

```wgsl
degrees(a)
```

```glsl
degrees(a)
```

[`exp(a)`](https://typeshade.dev/reference/functions/exp/)

```wgsl
exp(a)
```

```glsl
exp(a)
```

`Math.exp`

[`exp2(a)`](https://typeshade.dev/reference/functions/exp2/)

```wgsl
exp2(a)
```

```glsl
exp2(a)
```

[`floor(a)`](https://typeshade.dev/reference/functions/floor/)

```wgsl
floor(a)
```

```glsl
floor(a)
```

`Math.floor`

[`fma(a, b, c)`](https://typeshade.dev/reference/functions/fma/)

```wgsl
fma(a, b, c)
```

```glsl
((a) * (b) + (c))
```

[`fract(a)`](https://typeshade.dev/reference/functions/fract/)

```wgsl
fract(a)
```

```glsl
fract(a)
```

[`inverseSqrt(a)`](https://typeshade.dev/reference/functions/inverseSqrt/)

```wgsl
inverseSqrt(a)
```

```glsl
inversesqrt(a)
```

[`ldexp(a, b)`](https://typeshade.dev/reference/functions/ldexp/)

```wgsl
ldexp(a, b)
```

```glsl
(a * intBitsToFloat(((b >> 1) + 127) << 23) * intBitsToFloat(((b - (b >> 1)) + 127) << 23))
```

[`log(a)`](https://typeshade.dev/reference/functions/log/)

```wgsl
log(a)
```

```glsl
log(a)
```

`Math.log`

[`log2(a)`](https://typeshade.dev/reference/functions/log2/)

```wgsl
log2(a)
```

```glsl
log2(a)
```

`Math.log2`

[`max(a, b)`](https://typeshade.dev/reference/functions/max/)

```wgsl
max(a, b)
```

```glsl
max(a, b)
```

`Math.max`

[`min(a, b)`](https://typeshade.dev/reference/functions/min/)

```wgsl
min(a, b)
```

```glsl
min(a, b)
```

`Math.min`

[`mix(a, b, c)`](https://typeshade.dev/reference/functions/mix/)

```wgsl
mix(a, b, c)
```

```glsl
mix(a, b, c)
```

[`mod(a, b)`](https://typeshade.dev/reference/functions/mod/)

```wgsl
(a - b * floor(a / b))
```

```glsl
mod(a, b)
```

[`pow(a, b)`](https://typeshade.dev/api/pow/)

```wgsl
pow(a, b)
```

```glsl
pow(a, b)
```

`Math.pow`

[`quantizeToF16(a)`](https://typeshade.dev/reference/functions/quantizeToF16/)

```wgsl
quantizeToF16(a)
```

```glsl
unpackHalf2x16(packHalf2x16(vec2(a, 0.0))).x
```

`quantizeToF16Vec2(a)`

```wgsl
quantizeToF16(a)
```

```glsl
vec2(unpackHalf2x16(packHalf2x16(vec2(a.x, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.y, 0.0))).x)
```

`quantizeToF16Vec3(a)`

```wgsl
quantizeToF16(a)
```

```glsl
vec3(unpackHalf2x16(packHalf2x16(vec2(a.x, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.y, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.z, 0.0))).x)
```

`quantizeToF16Vec4(a)`

```wgsl
quantizeToF16(a)
```

```glsl
vec4(unpackHalf2x16(packHalf2x16(vec2(a.x, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.y, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.z, 0.0))).x, unpackHalf2x16(packHalf2x16(vec2(a.w, 0.0))).x)
```

[`radians(a)`](https://typeshade.dev/reference/functions/radians/)

```wgsl
radians(a)
```

```glsl
radians(a)
```

[`round(a)`](https://typeshade.dev/reference/functions/round/)

```wgsl
round(a)
```

```glsl
roundEven(a)
```

`Math.round`

[`saturate(a)`](https://typeshade.dev/reference/functions/saturate/)

```wgsl
saturate(a)
```

```glsl
clamp(a, 0.0, 1.0)
```

[`select(a, b, c)`](https://typeshade.dev/reference/functions/select/)

```wgsl
select(a, b, c)
```

```glsl
(c ? b : a)
```

[`sign(a)`](https://typeshade.dev/reference/functions/sign/)

```wgsl
sign(a)
```

```glsl
sign(a)
```

`Math.sign`

[`sin(a)`](https://typeshade.dev/reference/functions/sin/)

```wgsl
sin(a)
```

```glsl
sin(a)
```

`Math.sin`

[`sinh(a)`](https://typeshade.dev/reference/functions/sinh/)

```wgsl
sinh(a)
```

```glsl
sinh(a)
```

`Math.sinh`

[`smoothstep(a, b, c)`](https://typeshade.dev/reference/functions/smoothstep/)

```wgsl
smoothstep(a, b, c)
```

```glsl
smoothstep(a, b, c)
```

[`sqrt(a)`](https://typeshade.dev/reference/functions/sqrt/)

```wgsl
sqrt(a)
```

```glsl
sqrt(a)
```

`Math.sqrt`

[`step(a, b)`](https://typeshade.dev/reference/functions/step/)

```wgsl
step(a, b)
```

```glsl
step(a, b)
```

[`tan(a)`](https://typeshade.dev/reference/functions/tan/)

```wgsl
tan(a)
```

```glsl
tan(a)
```

`Math.tan`

[`tanh(a)`](https://typeshade.dev/reference/functions/tanh/)

```wgsl
tanh(a)
```

```glsl
tanh(a)
```

`Math.tanh`

[`trunc(a)`](https://typeshade.dev/reference/functions/trunc/)

```wgsl
trunc(a)
```

```glsl
trunc(a)
```

`Math.trunc`

## Geometry

TypeShade WGSL GLSL ES 3.00

[`cross(a, b)`](https://typeshade.dev/reference/functions/cross/)

```wgsl
cross(a, b)
```

```glsl
cross(a, b)
```

[`determinant(a)`](https://typeshade.dev/reference/functions/determinant/)

```wgsl
determinant(a)
```

```glsl
determinant(a)
```

[`distance(a, b)`](https://typeshade.dev/reference/functions/distance/)

```wgsl
distance(a, b)
```

```glsl
distance(a, b)
```

[`dot(a, b)`](https://typeshade.dev/reference/functions/dot/)

```wgsl
dot(a, b)
```

```glsl
dot(a, b)
```

`dotI(a, b)`

```wgsl
dot(a, b)
```

```glsl
_idot(a, b)
```

`dotU(a, b)`

```wgsl
dot(a, b)
```

```glsl
_idot(a, b)
```

[`faceForward(a, b, c)`](https://typeshade.dev/reference/functions/faceForward/)

```wgsl
faceForward(a, b, c)
```

```glsl
faceforward(a, b, c)
```

[`length(a)`](https://typeshade.dev/reference/functions/length/)

```wgsl
length(a)
```

```glsl
length(a)
```

[`normalize(a)`](https://typeshade.dev/reference/functions/normalize/)

```wgsl
normalize(a)
```

```glsl
normalize(a)
```

[`reflect(a, b)`](https://typeshade.dev/reference/functions/reflect/)

```wgsl
reflect(a, b)
```

```glsl
reflect(a, b)
```

[`refract(a, b, c)`](https://typeshade.dev/reference/functions/refract/)

```wgsl
refract(a, b, c)
```

```glsl
refract(a, b, c)
```

[`transpose(a)`](https://typeshade.dev/reference/functions/transpose/)

```wgsl
transpose(a)
```

```glsl
transpose(a)
```

## Derivatives

TypeShade WGSL GLSL ES 3.00

[`dpdx(a)`](https://typeshade.dev/reference/functions/dpdx/)

```wgsl
dpdx(a)
```

```glsl
dFdx(a)
```

[`dpdxCoarse(a)`](https://typeshade.dev/reference/functions/dpdxCoarse/)

```wgsl
dpdxCoarse(a)
```

```glsl
dFdx(a)
```

[`dpdxFine(a)`](https://typeshade.dev/reference/functions/dpdxFine/)

```wgsl
dpdxFine(a)
```

```glsl
dFdx(a)
```

[`dpdy(a)`](https://typeshade.dev/reference/functions/dpdy/)

```wgsl
dpdy(a)
```

```glsl
dFdy(a)
```

[`dpdyCoarse(a)`](https://typeshade.dev/reference/functions/dpdyCoarse/)

```wgsl
dpdyCoarse(a)
```

```glsl
dFdy(a)
```

[`dpdyFine(a)`](https://typeshade.dev/reference/functions/dpdyFine/)

```wgsl
dpdyFine(a)
```

```glsl
dFdy(a)
```

[`fwidth(a)`](https://typeshade.dev/reference/functions/fwidth/)

```wgsl
fwidth(a)
```

```glsl
fwidth(a)
```

[`fwidthCoarse(a)`](https://typeshade.dev/reference/functions/fwidthCoarse/)

```wgsl
fwidthCoarse(a)
```

```glsl
fwidth(a)
```

[`fwidthFine(a)`](https://typeshade.dev/reference/functions/fwidthFine/)

```wgsl
fwidthFine(a)
```

```glsl
fwidth(a)
```

## Bit operations

TypeShade WGSL GLSL ES 3.00

[`countLeadingZeros(a)`](https://typeshade.dev/reference/functions/countLeadingZeros/)

```wgsl
countLeadingZeros(a)
```

```glsl
_clz(a)
```

[`countOneBits(a)`](https://typeshade.dev/reference/functions/countOneBits/)

```wgsl
countOneBits(a)
```

```glsl
_popcnt(a)
```

[`countTrailingZeros(a)`](https://typeshade.dev/reference/functions/countTrailingZeros/)

```wgsl
countTrailingZeros(a)
```

```glsl
_ctz(a)
```

[`dot4I8Packed(a, b)`](https://typeshade.dev/reference/functions/dot4I8Packed/)

```wgsl
dot4I8Packed(a, b)
```

`dot4I8Packed` is not supported yet on the WebGL2 tier

[`dot4U8Packed(a, b)`](https://typeshade.dev/reference/functions/dot4U8Packed/)

```wgsl
dot4U8Packed(a, b)
```

`dot4U8Packed` is not supported yet on the WebGL2 tier

[`extractBits(a, b, c)`](https://typeshade.dev/reference/functions/extractBits/)

```wgsl
extractBits(a, b, c)
```

```glsl
_xbits(a, b, c)
```

[`firstLeadingBit(a)`](https://typeshade.dev/reference/functions/firstLeadingBit/)

```wgsl
firstLeadingBit(a)
```

```glsl
_msb(a)
```

[`firstTrailingBit(a)`](https://typeshade.dev/reference/functions/firstTrailingBit/)

```wgsl
firstTrailingBit(a)
```

```glsl
_lsb(a)
```

[`insertBits(a, b, c, d)`](https://typeshade.dev/reference/functions/insertBits/)

```wgsl
insertBits(a, b, c, d)
```

```glsl
_ibits(a, b, c, d)
```

[`reverseBits(a)`](https://typeshade.dev/reference/functions/reverseBits/)

```wgsl
reverseBits(a)
```

```glsl
_brev(a)
```

GLSL ES 3.00 has none of the bit builtins, so the column above names a small function the GLSL writer defines over the shifts, masks and comparisons that target does have. A module that calls none of them carries none of the definitions.

## Packing

TypeShade WGSL GLSL ES 3.00

[`pack2x16float(a)`](https://typeshade.dev/reference/functions/pack2x16float/)

```wgsl
pack2x16float(a)
```

```glsl
packHalf2x16(a)
```

[`pack2x16snorm(a)`](https://typeshade.dev/reference/functions/pack2x16snorm/)

```wgsl
pack2x16snorm(a)
```

```glsl
packSnorm2x16(a)
```

[`pack2x16unorm(a)`](https://typeshade.dev/reference/functions/pack2x16unorm/)

```wgsl
pack2x16unorm(a)
```

```glsl
packUnorm2x16(a)
```

[`pack4x8snorm(a)`](https://typeshade.dev/reference/functions/pack4x8snorm/)

```wgsl
pack4x8snorm(a)
```

```glsl
(uint(int(floor(0.5 + clamp(a.x, -1.0, 1.0) * 127.0)) & 0xFF) | (uint(int(floor(0.5 + clamp(a.y, -1.0, 1.0) * 127.0)) & 0xFF) << 8) | (uint(int(floor(0.5 + clamp(a.z, -1.0, 1.0) * 127.0)) & 0xFF) << 16) | (uint(int(floor(0.5 + clamp(a.w, -1.0, 1.0) * 127.0)) & 0xFF) << 24))
```

[`pack4x8unorm(a)`](https://typeshade.dev/reference/functions/pack4x8unorm/)

```wgsl
pack4x8unorm(a)
```

```glsl
(uint(floor(0.5 + clamp(a.x, 0.0, 1.0) * 255.0)) | (uint(floor(0.5 + clamp(a.y, 0.0, 1.0) * 255.0)) << 8) | (uint(floor(0.5 + clamp(a.z, 0.0, 1.0) * 255.0)) << 16) | (uint(floor(0.5 + clamp(a.w, 0.0, 1.0) * 255.0)) << 24))
```

[`pack4xI8(a)`](https://typeshade.dev/reference/functions/pack4xI8/)

```wgsl
pack4xI8(a)
```

`pack4xI8` is not supported yet on the WebGL2 tier

[`pack4xI8Clamp(a)`](https://typeshade.dev/reference/functions/pack4xI8Clamp/)

```wgsl
pack4xI8Clamp(a)
```

`pack4xI8Clamp` is not supported yet on the WebGL2 tier

[`pack4xU8(a)`](https://typeshade.dev/reference/functions/pack4xU8/)

```wgsl
pack4xU8(a)
```

`pack4xU8` is not supported yet on the WebGL2 tier

[`pack4xU8Clamp(a)`](https://typeshade.dev/reference/functions/pack4xU8Clamp/)

```wgsl
pack4xU8Clamp(a)
```

`pack4xU8Clamp` is not supported yet on the WebGL2 tier

[`unpack2x16float(a)`](https://typeshade.dev/reference/functions/unpack2x16float/)

```wgsl
unpack2x16float(a)
```

```glsl
unpackHalf2x16(a)
```

[`unpack2x16snorm(a)`](https://typeshade.dev/reference/functions/unpack2x16snorm/)

```wgsl
unpack2x16snorm(a)
```

```glsl
unpackSnorm2x16(a)
```

[`unpack2x16unorm(a)`](https://typeshade.dev/reference/functions/unpack2x16unorm/)

```wgsl
unpack2x16unorm(a)
```

```glsl
unpackUnorm2x16(a)
```

[`unpack4x8snorm(a)`](https://typeshade.dev/reference/functions/unpack4x8snorm/)

```wgsl
unpack4x8snorm(a)
```

```glsl
max(vec4(ivec4(uvec4(a, a >> 8, a >> 16, a >> 24) << 24) >> 24) / 127.0, vec4(-1.0))
```

[`unpack4x8unorm(a)`](https://typeshade.dev/reference/functions/unpack4x8unorm/)

```wgsl
unpack4x8unorm(a)
```

```glsl
(vec4(uvec4(a, a >> 8, a >> 16, a >> 24) & 0xFFu) / 255.0)
```

[`unpack4xI8(a)`](https://typeshade.dev/reference/functions/unpack4xI8/)

```wgsl
unpack4xI8(a)
```

`unpack4xI8` is not supported yet on the WebGL2 tier

[`unpack4xU8(a)`](https://typeshade.dev/reference/functions/unpack4xU8/)

```wgsl
unpack4xU8(a)
```

`unpack4xU8` is not supported yet on the WebGL2 tier

## Casts

TypeShade WGSL GLSL ES 3.00 Math name

[`bitcastF32(a)`](https://typeshade.dev/api/bitcastf32/)

```wgsl
bitcast<f32>(a)
```

```glsl
uintBitsToFloat(a)
```

[`bitcastU32(a)`](https://typeshade.dev/api/bitcastu32/)

```wgsl
bitcast<u32>(a)
```

```glsl
floatBitsToUint(a)
```

`bitcastVec2F32(a)`

```wgsl
bitcast<vec2<f32>>(a)
```

```glsl
uintBitsToFloat(a)
```

`bitcastVec2U32(a)`

```wgsl
bitcast<vec2<u32>>(a)
```

```glsl
floatBitsToUint(a)
```

`bitcastVec3F32(a)`

```wgsl
bitcast<vec3<f32>>(a)
```

```glsl
uintBitsToFloat(a)
```

`bitcastVec3U32(a)`

```wgsl
bitcast<vec3<u32>>(a)
```

```glsl
floatBitsToUint(a)
```

`bitcastVec4F32(a)`

```wgsl
bitcast<vec4<f32>>(a)
```

```glsl
uintBitsToFloat(a)
```

`bitcastVec4U32(a)`

```wgsl
bitcast<vec4<u32>>(a)
```

```glsl
floatBitsToUint(a)
```

[`f32(a)`](https://typeshade.dev/reference/functions/f32/)

```wgsl
f32(a)
```

```glsl
float(a)
```

`Math.fround`

[`i32(a)`](https://typeshade.dev/reference/functions/i32/)

```wgsl
i32(a)
```

```glsl
int(a)
```

[`u32(a)`](https://typeshade.dev/reference/functions/u32/)

```wgsl
u32(a)
```

```glsl
uint(a)
```

## Textures and storage

TypeShade WGSL GLSL ES 3.00

`arrayLength(a)`

```wgsl
arrayLength(&a)
```

arrayLength is not supported yet on the WebGL2 tier ([Rule 10.5](https://typeshade.dev/reference/rules/10-5/))

`storageFetchF32(a, b)`

```wgsl
storageFetchF32(a, b)
```

```glsl
_sfetch(a, int(b))
```

`storageFetchI32(a, b)`

```wgsl
storageFetchI32(a, b)
```

```glsl
_sfetchI(a, int(b))
```

`storageFetchU32(a, b)`

```wgsl
storageFetchU32(a, b)
```

```glsl
_sfetchU(a, int(b))
```

[`textureDimensions(a)`](https://typeshade.dev/reference/functions/textureDimensions/)

```wgsl
textureDimensions(a)
```

```glsl
uvec2(textureSize(a, 0))
```

`textureDimensions1d(a)`

```wgsl
textureDimensions(a)
```

`textureDimensions` on a `texture_1d` is not supported yet on the WebGL2 tier (Rule 10.5)

`textureDimensions3d(a)`

```wgsl
textureDimensions(a)
```

```glsl
uvec3(textureSize(a, 0))
```

`textureDimensionsMs(a)`

```wgsl
textureDimensions(a)
```

`textureDimensions` on a multisampled texture is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureGather(a, b, c, d)`](https://typeshade.dev/reference/functions/textureGather/)

```wgsl
textureGather(a, b, c, d)
```

`textureGather` is not supported yet on the WebGL2 tier (Rule 10.5)

`textureGatherArray(a, b, c, d, e)`

```wgsl
textureGather(a, b, c, d, e)
```

`textureGather` is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureGatherCompare(a, b, c, d)`](https://typeshade.dev/reference/functions/textureGatherCompare/)

```wgsl
textureGatherCompare(a, b, c, d)
```

`textureGatherCompare` is not supported yet on the WebGL2 tier (Rule 10.5)

`textureGatherCompareArray(a, b, c, d, e)`

```wgsl
textureGatherCompare(a, b, c, d, e)
```

`textureGatherCompare` is not supported yet on the WebGL2 tier (Rule 10.5)

`textureGatherDepth(a, b, c)`

```wgsl
textureGather(a, b, c)
```

`textureGather` is not supported yet on the WebGL2 tier (Rule 10.5)

`textureGatherDepthArray(a, b, c, d)`

```wgsl
textureGather(a, b, c, d)
```

`textureGather` is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureLoad(a, b, c)`](https://typeshade.dev/reference/functions/textureLoad/)

```wgsl
textureLoad(a, b, c)
```

```glsl
texelFetch(a, b, int(c))
```

`textureLoad3dU(a, b, c)`

```wgsl
textureLoad(a, b, c)
```

```glsl
texelFetch(a, ivec3(b), int(c))
```

`textureLoadArray(a, b, c, d)`

```wgsl
textureLoad(a, b, c, d)
```

```glsl
texelFetch(a, ivec3(b, int(c)), int(d))
```

`textureLoadArrayU(a, b, c, d)`

```wgsl
textureLoad(a, b, c, d)
```

```glsl
texelFetch(a, ivec3(ivec2(b), int(c)), int(d))
```

`textureLoadDepthMs(a, b, c)`

```wgsl
textureLoad(a, b, c)
```

a multisampled depth load is not supported yet on the WebGL2 tier (Rule 10.5)

`textureLoadMs(a, b, c)`

```wgsl
textureLoad(a, b, c)
```

a multisampled load is not supported yet on the WebGL2 tier (Rule 10.5)

`textureLoadU(a, b, c)`

```wgsl
textureLoad(a, b, c)
```

```glsl
texelFetch(a, ivec2(b), int(c))
```

[`textureNumLayers(a)`](https://typeshade.dev/reference/functions/textureNumLayers/)

```wgsl
textureNumLayers(a)
```

```glsl
uint(textureSize(a, 0).z)
```

`textureNumLayersStorage(a)`

```wgsl
textureNumLayers(a)
```

a storage texture is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureNumSamples(a)`](https://typeshade.dev/reference/functions/textureNumSamples/)

```wgsl
textureNumSamples(a)
```

`textureNumSamples` is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureSample(a, b, c)`](https://typeshade.dev/reference/functions/textureSample/)

```wgsl
textureSample(a, b, c)
```

```glsl
texture(a, c)
```

`textureSampleArray(a, b, c, d)`

```wgsl
textureSample(a, b, c, d)
```

```glsl
texture(a, vec3(c, float(d)))
```

[`textureSampleBias(a, b, c, d)`](https://typeshade.dev/reference/functions/textureSampleBias/)

```wgsl
textureSampleBias(a, b, c, d)
```

```glsl
texture(a, c, d)
```

`textureSampleBiasArray(a, b, c, d, e)`

```wgsl
textureSampleBias(a, b, c, d, e)
```

```glsl
texture(a, vec3(c, float(d)), e)
```

`textureSampleBiasCubeArray(a, b, c, d, e)`

```wgsl
textureSampleBias(a, b, c, d, e)
```

`textureSampleBias` on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureSampleCompare(a, b, c, d)`](https://typeshade.dev/reference/functions/textureSampleCompare/)

```wgsl
textureSampleCompare(a, b, c, d)
```

```glsl
texture(a, vec3(c, d))
```

`textureSampleCompareArray(a, b, c, d, e)`

```wgsl
textureSampleCompare(a, b, c, d, e)
```

```glsl
texture(a, vec4(c, float(d), e))
```

`textureSampleCompareCube(a, b, c, d)`

```wgsl
textureSampleCompare(a, b, c, d)
```

```glsl
texture(a, vec4(c, d))
```

`textureSampleCompareCubeArray(a, b, c, d, e)`

```wgsl
textureSampleCompare(a, b, c, d, e)
```

`textureSampleCompare` on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureSampleCompareLevel(a, b, c, d)`](https://typeshade.dev/reference/functions/textureSampleCompareLevel/)

```wgsl
textureSampleCompareLevel(a, b, c, d)
```

```glsl
textureLod(a, vec3(c, d), 0.0)
```

`textureSampleCompareLevelArray(a, b, c, d, e)`

```wgsl
textureSampleCompareLevel(a, b, c, d, e)
```

```glsl
textureGrad(a, vec4(c, float(d), e), vec2(0.0), vec2(0.0))
```

`textureSampleCompareLevelCube(a, b, c, d)`

```wgsl
textureSampleCompareLevel(a, b, c, d)
```

```glsl
textureGrad(a, vec4(c, d), vec3(0.0), vec3(0.0))
```

`textureSampleCompareLevelCubeArray(a, b, c, d, e)`

```wgsl
textureSampleCompareLevel(a, b, c, d, e)
```

`textureSampleCompareLevel` on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)

`textureSampleCubeArray(a, b, c, d)`

```wgsl
textureSample(a, b, c, d)
```

`textureSample` on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureSampleGrad(a, b, c, d, e)`](https://typeshade.dev/reference/functions/textureSampleGrad/)

```wgsl
textureSampleGrad(a, b, c, d, e)
```

```glsl
textureGrad(a, c, d, e)
```

`textureSampleGradArray(a, b, c, d, e, f)`

```wgsl
textureSampleGrad(a, b, c, d, e, f)
```

```glsl
textureGrad(a, vec3(c, float(d)), e, f)
```

`textureSampleGradCubeArray(a, b, c, d, e, f)`

```wgsl
textureSampleGrad(a, b, c, d, e, f)
```

`textureSampleGrad` on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureSampleLevel(a, b, c, d)`](https://typeshade.dev/reference/functions/textureSampleLevel/)

```wgsl
textureSampleLevel(a, b, c, d)
```

```glsl
textureLod(a, c, d)
```

`textureSampleLevelArray(a, b, c, d, e)`

```wgsl
textureSampleLevel(a, b, c, d, e)
```

```glsl
textureLod(a, vec3(c, float(d)), e)
```

`textureSampleLevelCubeArray(a, b, c, d, e)`

```wgsl
textureSampleLevel(a, b, c, d, e)
```

`textureSampleLevel` on a cube array is not supported yet on the WebGL2 tier (Rule 10.5)

[`textureStore(a, b, c)`](https://typeshade.dev/reference/functions/textureStore/)

```wgsl
textureStore(a, b, c)
```

`textureStore` is not supported yet on the WebGL2 tier (Rule 10.5)

## Atomics

TypeShade WGSL GLSL ES 3.00

[`atomicAdd(a, b)`](https://typeshade.dev/reference/functions/atomicAdd/)

```wgsl
atomicAdd(&a, b)
```

`atomicAdd` 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](https://typeshade.dev/reference/rules/11-8/))

[`atomicAnd(a, b)`](https://typeshade.dev/reference/functions/atomicAnd/)

```wgsl
atomicAnd(&a, b)
```

`atomicAnd` 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)

[`atomicCompareExchangeWeak(a, b, c)`](https://typeshade.dev/reference/functions/atomicCompareExchangeWeak/)

```wgsl
atomicCompareExchangeWeak(&a, b, c)
```

`atomicCompareExchangeWeak` is not supported yet in a GLSL ES 3.00 stage (Rule 10.5)

[`atomicExchange(a, b)`](https://typeshade.dev/reference/functions/atomicExchange/)

```wgsl
atomicExchange(&a, b)
```

No form on this target.

[`atomicLoad(a)`](https://typeshade.dev/reference/functions/atomicLoad/)

```wgsl
atomicLoad(&a)
```

`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)

[`atomicMax(a, b)`](https://typeshade.dev/reference/functions/atomicMax/)

```wgsl
atomicMax(&a, b)
```

`atomicMax` 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)

[`atomicMin(a, b)`](https://typeshade.dev/reference/functions/atomicMin/)

```wgsl
atomicMin(&a, b)
```

`atomicMin` 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)

[`atomicOr(a, b)`](https://typeshade.dev/reference/functions/atomicOr/)

```wgsl
atomicOr(&a, b)
```

`atomicOr` 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)

[`atomicStore(a, b)`](https://typeshade.dev/reference/functions/atomicStore/)

```wgsl
atomicStore(&a, b)
```

`atomicStore` 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)

[`atomicSub(a, b)`](https://typeshade.dev/reference/functions/atomicSub/)

```wgsl
atomicSub(&a, b)
```

`atomicSub` 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)

[`atomicXor(a, b)`](https://typeshade.dev/reference/functions/atomicXor/)

```wgsl
atomicXor(&a, b)
```

`atomicXor` 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)

## Barriers

TypeShade WGSL GLSL ES 3.00

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

```wgsl
storageBarrier()
```

No form on this target.

[`textureBarrier()`](https://typeshade.dev/reference/functions/textureBarrier/)

```wgsl
textureBarrier()
```

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

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

```wgsl
workgroupBarrier()
```

No form on this target.

[`workgroupUniformLoad(a)`](https://typeshade.dev/reference/functions/workgroupUniformLoad/)

```wgsl
workgroupUniformLoad(&a)
```

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

## Subgroups

TypeShade WGSL GLSL ES 3.00

[`subgroupAdd(a)`](https://typeshade.dev/reference/functions/subgroupAdd/)

```wgsl
subgroupAdd(a)
```

`subgroupAdd` is lowered to one lane before the GLSL writer runs ([Rule 11.21](https://typeshade.dev/reference/rules/11-21/))

[`subgroupAll(a)`](https://typeshade.dev/reference/functions/subgroupAll/)

```wgsl
subgroupAll(a)
```

`subgroupAll` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupAnd(a)`](https://typeshade.dev/reference/functions/subgroupAnd/)

```wgsl
subgroupAnd(a)
```

`subgroupAnd` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupAny(a)`](https://typeshade.dev/reference/functions/subgroupAny/)

```wgsl
subgroupAny(a)
```

`subgroupAny` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupBallot(a)`](https://typeshade.dev/reference/functions/subgroupBallot/)

```wgsl
subgroupBallot(a)
```

`subgroupBallot` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupBroadcast(a, b)`](https://typeshade.dev/reference/functions/subgroupBroadcast/)

```wgsl
subgroupBroadcast(a, b)
```

`subgroupBroadcast` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupBroadcastFirst(a)`](https://typeshade.dev/reference/functions/subgroupBroadcastFirst/)

```wgsl
subgroupBroadcastFirst(a)
```

`subgroupBroadcastFirst` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupElect()`](https://typeshade.dev/reference/functions/subgroupElect/)

```wgsl
subgroupElect()
```

`subgroupElect` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupExclusiveAdd(a)`](https://typeshade.dev/reference/functions/subgroupExclusiveAdd/)

```wgsl
subgroupExclusiveAdd(a)
```

`subgroupExclusiveAdd` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupExclusiveMul(a)`](https://typeshade.dev/reference/functions/subgroupExclusiveMul/)

```wgsl
subgroupExclusiveMul(a)
```

`subgroupExclusiveMul` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupInclusiveAdd(a)`](https://typeshade.dev/reference/functions/subgroupInclusiveAdd/)

```wgsl
subgroupInclusiveAdd(a)
```

`subgroupInclusiveAdd` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupInclusiveMul(a)`](https://typeshade.dev/reference/functions/subgroupInclusiveMul/)

```wgsl
subgroupInclusiveMul(a)
```

`subgroupInclusiveMul` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupMax(a)`](https://typeshade.dev/reference/functions/subgroupMax/)

```wgsl
subgroupMax(a)
```

`subgroupMax` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupMin(a)`](https://typeshade.dev/reference/functions/subgroupMin/)

```wgsl
subgroupMin(a)
```

`subgroupMin` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupMul(a)`](https://typeshade.dev/reference/functions/subgroupMul/)

```wgsl
subgroupMul(a)
```

`subgroupMul` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupOr(a)`](https://typeshade.dev/reference/functions/subgroupOr/)

```wgsl
subgroupOr(a)
```

`subgroupOr` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupShuffle(a, b)`](https://typeshade.dev/reference/functions/subgroupShuffle/)

```wgsl
subgroupShuffle(a, b)
```

`subgroupShuffle` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupShuffleDown(a, b)`](https://typeshade.dev/reference/functions/subgroupShuffleDown/)

```wgsl
subgroupShuffleDown(a, b)
```

`subgroupShuffleDown` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupShuffleUp(a, b)`](https://typeshade.dev/reference/functions/subgroupShuffleUp/)

```wgsl
subgroupShuffleUp(a, b)
```

`subgroupShuffleUp` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupShuffleXor(a, b)`](https://typeshade.dev/reference/functions/subgroupShuffleXor/)

```wgsl
subgroupShuffleXor(a, b)
```

`subgroupShuffleXor` is lowered to one lane before the GLSL writer runs (Rule 11.21)

[`subgroupXor(a)`](https://typeshade.dev/reference/functions/subgroupXor/)

```wgsl
subgroupXor(a)
```

`subgroupXor` is lowered to one lane before the GLSL writer runs (Rule 11.21)

## Emulated double

TypeShade WGSL GLSL ES 3.00

[`f64(a)`](https://typeshade.dev/reference/functions/f64/)

Rewritten into a pair of `f32` lanes before either backend runs.

Rewritten into a pair of `f32` lanes before either backend runs.

[`f64FromParts(a, b)`](https://typeshade.dev/api/f64fromparts/)

Rewritten into a pair of `f32` lanes before either backend runs.

Rewritten into a pair of `f32` lanes before either backend runs.

`f64Guard()`

```wgsl
textureLoad(_fp64, vec2<i32>(0, 0), 0).x
```

```glsl
texelFetch(_fp64, ivec2(0, 0), 0).x
```

[`f64Parts(a)`](https://typeshade.dev/api/f64parts/)

Rewritten into a pair of `f32` lanes before either backend runs.

Rewritten into a pair of `f32` lanes before either backend runs.

## GLSL helper functions

A storage buffer has no GLSL ES 3.00 form, so a read of one is rewritten into a read from a data texture. These are the functions that read stands for, and the GLSL writer emits the definition of each one a module calls.

Builtin GLSL function

`storageFetchF32`

`_sfetch`

`storageFetchU32`

`_sfetchU`

`storageFetchI32`

`_sfetchI`

Every row on this page is read from [the spelling registry](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/intrinsics.ts) at the pinned commit, and none of it is typed here.
