---
title: "Functions, the TypeShade language reference for shaders"
description: "The 188 functions a shader calls, by family, each with its signature and with the WGSL and GLSL ES 3.00 text the compiler writes for it."
url: https://typeshade.dev/reference/functions/
language: en
---

# Functions

188 names

The functions a shader calls, by family, with the text each backend writes.

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

## Maths

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

Returns `2` raised to the power of `x`, componentwise over vectors.

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

Clamps `x` to the range \[0, 1\], componentwise over vectors.

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

Returns `x * 2^e`: an `f32` or float vector `x` with an `i32` or integer vector exponent `e` of the same shape.

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

Rounds `e` to what an IEEE-754 binary16 can hold and returns it as an `f32`, so a shader can see the precision an f16 pipeline would give it without the `shader-f16` extension.

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

Returns `a * b + c`, componentwise over vectors.

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

Whether any component of a vector of bools is true: `any(a < b)`.

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

Whether every component of a vector of bools is true: `all(a === b)`.

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

A fixed-size array built from two of one length, element by element: `zip(xs, ys, (a, b) => a * b)`.

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

Returns `trueValue` where `cond` is true and `falseValue` where it is false, in WGSL's argument order: the condition comes last.

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

Returns the sine of `x` (in radians), componentwise over vectors.

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

Returns the cosine of `x` (in radians), componentwise over vectors.

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

Returns the tangent of `x` (in radians), componentwise over vectors.

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

Returns the arcsine of `x` (in radians), componentwise over vectors.

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

Returns the arccosine of `x` (in radians), componentwise over vectors.

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

Returns the arctangent of `x` (in radians), componentwise over vectors.

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

Returns the arctangent of `y/x` (in radians), using the signs of both arguments to determine the quadrant, taking arguments in the order `(y, x)`.

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

Returns the hyperbolic sine of `x`, componentwise over vectors.

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

Returns the hyperbolic cosine of `x`, componentwise over vectors.

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

Returns the hyperbolic tangent of `x`, componentwise over vectors.

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

Returns the inverse hyperbolic sine of `x`, componentwise over vectors.

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

Returns the inverse hyperbolic cosine of `x`, componentwise over vectors.

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

Returns the inverse hyperbolic tangent of `x`, componentwise over vectors.

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

Returns the exponential function (e raised to the power of `x`), componentwise over vectors.

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

Returns the natural logarithm of `x`, componentwise over vectors.

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

Returns the base-2 logarithm of `x`, componentwise over vectors.

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

Returns the square root of `x`, componentwise over vectors.

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

Returns the reciprocal of the square root of `x` (1/`sqrt(x)`), componentwise over vectors.

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

Returns the absolute value of `x`, componentwise over vectors.

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

Returns -1 if `x` is negative, 1 if positive, and 0 if zero, componentwise over vectors.

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

Returns the largest integer not greater than `x`, componentwise over vectors.

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

Returns the smallest integer not less than `x`, componentwise over vectors.

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

Rounds `x` to the nearest integer, with halfway cases rounding to the nearest even integer, componentwise over vectors.

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

Returns `x` truncated toward zero, componentwise over vectors.

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

Returns the fractional part of `x` as `x` minus `floor(x)`, in the range \[0, 1), componentwise over vectors.

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

Returns the floor-modulo remainder of `x` divided by `y`, with the sign of `y`, componentwise over vectors.

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

Returns the lesser of `a` and `b`, componentwise over vectors.

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

Returns the greater of `a` and `b`, componentwise over vectors.

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

Clamps `x` to the range \[low, high\], computed as `min(max(x, low), high)`, componentwise over vectors.

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

Returns `a * (1 - t) + b * t`.

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

Returns 0 when `x` is less than `edge`, and 1 otherwise.

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

Applies Hermite interpolation between `edge0` and `edge1`, clamped to `[0, 1]`.

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

Converts `x` from radians to degrees, multiplying by 180/π.

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

Converts `x` from degrees to radians, multiplying by π/180.

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

Returns an `f32` in the range \[0, 1) hashed from an `f32`, `vec2` or `vec3` seed, emitted as `fract(sin(dot(seed, k)) * 43758.5453123)`.

## Geometry

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

Reflects the incident vector `i` about the normal `n`: `i - 2 * dot(n, i) * n`.

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

Refracts the incident vector `i` through a surface with normal `n` and ratio of indices `eta`; returns the zero vector on total internal reflection.

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

Returns `n` if `dot(nref, i)` is negative, else `-n`: the normal that faces the incident vector.

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

Returns the transpose of a `mat4`.

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

Returns the determinant of a `mat4` as an `f32`.

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

Returns the length (magnitude) of a vector, computed as the square root of the sum of squared components.

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

Returns the Euclidean distance between `a` and `b`, computed as `length(a - b)`.

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

Returns the dot product of two vectors: the sum of products of corresponding components.

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

Computes the cross product of two `vec3` values, returning a `vec3`.

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

Returns a unit vector in the same direction as the input, computed by dividing each component by the vector's length.

## Derivatives

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

Returns the sum of the absolute screen-space derivatives of `x` in both directions, `abs(dpdx(x)) + abs(dpdy(x))`, componentwise over vectors.

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

The partial derivative of `x` with respect to the window x coordinate, computed at the coarser granularity.

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

The partial derivative of `x` with respect to the window x coordinate, computed at the finer granularity.

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

The partial derivative of `x` with respect to the window y coordinate, computed at the coarser granularity.

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

The partial derivative of `x` with respect to the window y coordinate, computed at the finer granularity.

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

`abs(dpdxCoarse(x)) + abs(dpdyCoarse(x))`.

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

`abs(dpdxFine(x)) + abs(dpdyFine(x))`.

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

Returns the partial derivative of `x` with respect to the window x coordinate, componentwise over vectors.

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

Returns the partial derivative of `x` with respect to the window y coordinate, componentwise over vectors.

## Bit operations

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

Reads both `u32` arguments as four UNSIGNED bytes and sums the four products into a `u32`.

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

Reads both `u32` arguments as four SIGNED bytes and sums the four products into an `i32`, wrapping at 32 bits.

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

The number of 1 bits in each component of a `u32` or `i32` (or vector of them).

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

Reverses the 32 bits of each component of a `u32` or `i32` (or vector of them).

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

The number of leading 0 bits in each component of a `u32` or `i32` (32 for zero).

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

The number of trailing 0 bits in each component of a `u32` or `i32` (32 for zero).

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

The position of the most significant 1 bit of a `u32` (0xffffffff for zero), or of the most significant bit that differs from the sign bit of an `i32` (-1 for 0 and -1).

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

The position of the least significant 1 bit of a `u32` or `i32`, or all ones (0xffffffff / -1) for zero.

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

Extracts `count` bits of `e` starting at bit `offset`, sign-extended for an `i32`; the offset and count are clamped to the 32 bits as WGSL specifies.

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

Inserts the low `count` bits of `newbits` into `e` at bit `offset`; the offset and count are clamped to the 32 bits as WGSL specifies.

## Packing

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

Packs a `vec4` of values in \[0, 1\] into the four bytes of a `u32`, component 0 in the low byte.

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

Packs the low byte of each component of a `vec4u` into a `u32`, component 0 in the low byte.

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

Packs the low byte of each component of a `vec4i` into a `u32`, four bytes in a word.

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

Packs a `vec4u` into a `u32` as four bytes, clamping each component into \[0, 255\] first.

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

Packs a `vec4i` into a `u32` as four bytes, clamping each component into \[-128, 127\] first.

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

Unpacks the four bytes of a `u32` into a `vec4u`, the low byte into component 0.

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

Unpacks the four bytes of a `u32` into a `vec4i`, sign-extending each byte, the low byte into component 0.

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

Packs a `vec4` of values in \[-1, 1\] into the four bytes of a `u32` as signed bytes, component 0 in the low byte.

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

Unpacks the four bytes of a `u32` into a `vec4` of values in \[0, 1\], the low byte into component 0.

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

Unpacks the four bytes of a `u32` into a `vec4` of values in \[-1, 1\], reading each as a signed byte, the low byte into component 0.

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

Packs a `vec2` into two IEEE-754 binary16 halves of a `u32`, component 0 in the low 16 bits.

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

Packs a `vec2` of values in \[0, 1\] into two 16-bit halves of a `u32`, component 0 in the low 16 bits.

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

Packs a `vec2` of values in \[-1, 1\] into two signed 16-bit halves of a `u32`, component 0 in the low 16 bits.

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

Unpacks the two binary16 halves of a `u32` into a `vec2`, the low 16 bits into component 0.

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

Unpacks the two 16-bit halves of a `u32` into a `vec2` of values in \[0, 1\], the low 16 bits into component 0.

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

Unpacks the two signed 16-bit halves of a `u32` into a `vec2` of values in \[-1, 1\], the low 16 bits into component 0.

## Casts

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

Reads the same 32 bits as another type, each component of a vector the same way: `bitcast<u32>(x)` on an `f32`, `bitcast<f32>(x)` on a `u32`, `bitcast<vec4u>(v)` on a `vec4` and `bitcast<vec4>(w)` on a `vec4u`, `floatBitsToUint` / `uintBitsToFloat` on GLSL ES 3.00.

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

Converts a numeric scalar to `bool`: true where `x` is not zero, spelled as the compare `x != 0`.

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

Casts a number to `f32` single-precision floating-point by inlining a literal value rounded to 32-bit precision.

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

Casts a number to `i32` signed 32-bit integer by truncating toward zero.

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

Casts a number to `u32` unsigned 32-bit integer by truncating toward zero.

## Textures and storage

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

Samples a float texture through the sampler `smp` with the implicit level of detail, in the fragment stage only: at `uv` on a `texture_2d`, by a `vec3` direction on a `texture_cube`, by a `vec3` coordinate on a `texture_3d`, by one `f32` on a `texture_1d`, and on an array texture the argument after the coordinate picks the layer.

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

Reads one channel from the four texels a linear filter would blend at the coordinate on mip level 0, through the sampler `smp`, and returns them as a `vec4` in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage.

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

Compares the reference depth `ref` against the four texels a linear filter would blend at the coordinate on mip level 0, through the comparison sampler `smp`, and returns the four results (0 or 1 each) as a `vec4` in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage.

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

Samples a float texture through the sampler `smp` at an explicit mip `level`, in any stage; the coordinate is a `vec2` on a `texture_2d` and a `vec3` on a `texture_cube` or a `texture_3d`.

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

Samples a float texture through the sampler `smp` with the implicit level of detail shifted by `bias`, in the fragment stage only; the coordinate is a `vec2` on a `texture_2d` and a `vec3` on a `texture_cube` or a `texture_3d`.

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

Samples a float texture through the sampler `smp` with the explicit gradients `ddx` and `ddy`, which have the width of the coordinate, in any stage.

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

Reads one texel at the integer `coord` and mip `level` without filtering, by a `vec2i` on a `texture_2d`, a `vec3i` on a `texture_3d` and one integer on a `texture_1d`; a cube texture has no texel fetch on either target.

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

Returns the number of samples per texel of a `texture_multisampled_2d` or a `texture_depth_multisampled_2d` as a `u32`.

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

Compares the reference depth `ref` against the shadow map at `uv` through the comparison sampler `smp`, with the implicit level of detail, in the fragment stage only; returns an `f32`, how much of the filter footprint passed.

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

Compares the reference depth `ref` against the shadow map at `uv` through the comparison sampler `smp` at mip level 0, in any stage; returns an `f32`, how much of the filter footprint passed.

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

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

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

Returns the size of the texture's base mip level: width and height as a `vec2u`, width, height and depth as a `vec3u` on a `texture_3d`, or the width alone as a `u32` on a `texture_1d`.

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

Returns the number of layers of a `texture_2d_array` or a `texture_cube_array` as a `u32`.

## Atomics

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

Stores the third argument into the atomic location only when it holds the second, as one indivisible step.

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

Reads the value of an `atomic<u32>` or `atomic<i32>` location in a read-write storage binding (`atomicLoad(bins[i])`).

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

Writes `value` to an atomic location in a read-write storage binding (`atomicStore(bins[i], 0)`); returns nothing.

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

Adds `value` to the atomic location as one indivisible step and returns the value it held before (`atomicAdd(bins[i], 1)`).

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

Subtracts `value` from the atomic location as one indivisible step and returns the value it held before.

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

Stores the smaller of the atomic location and `value` as one indivisible step and returns the value it held before.

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

Stores the larger of the atomic location and `value` as one indivisible step and returns the value it held before.

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

Stores the bitwise AND of the atomic location and `value` as one indivisible step and returns the value it held before.

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

Stores the bitwise OR of the atomic location and `value` as one indivisible step and returns the value it held before.

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

Stores the bitwise XOR of the atomic location and `value` as one indivisible step and returns the value it held before.

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

Stores `value` in the atomic location as one indivisible step and returns the value it held before.

## Barriers

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

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

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

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

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

Waits until every invocation of the workgroup has reached this line, and makes every write to workgroup memory before it visible to every invocation after it.

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

Waits until every invocation of the workgroup has reached this line, and makes every write to storage before it visible to every invocation after it.

## Subgroups

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

Returns the sum of `value` over the lanes of the subgroup, in every lane.

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

Returns the product of `value` over the lanes of the subgroup, in every lane.

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

Returns the least `value` over the lanes of the subgroup, in every lane.

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

Returns the greatest `value` over the lanes of the subgroup, in every lane.

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

Returns the bitwise AND of `value` over the lanes of the subgroup, in every lane.

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

Returns the bitwise OR of `value` over the lanes of the subgroup, in every lane.

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

Returns the bitwise XOR of `value` over the lanes of the subgroup, in every lane.

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

Returns the sum of `value` over the lanes before this one in the subgroup, 0 in the first lane.

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

Returns the sum of `value` over the lanes up to and including this one in the subgroup.

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

Returns the product of `value` over the lanes before this one in the subgroup, 1 in the first lane.

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

Returns the product of `value` over the lanes up to and including this one in the subgroup.

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

Returns true when `e` is true in every lane of the subgroup.

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

Returns true when `e` is true in any lane of the subgroup.

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

Returns a `vec4u` bitmask with one bit per lane of the subgroup, set where `pred` is true.

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

Returns true in the lowest active lane of the subgroup and false in every other.

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

Returns `e` from the lane `id` of the subgroup, in every lane; `id` must be a number written in the call.

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

Returns `e` from the lowest active lane of the subgroup, in every lane.

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

Returns `e` from the lane `id` of the subgroup.

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

Returns `e` from the lane `delta` above this one in the subgroup.

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

Returns `e` from the lane `delta` below this one in the subgroup.

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

Returns `e` from the lane whose index is this lane's XOR `mask`.

## Emulated double

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

Widens an `f32` to the emulated double `f64`.

## Constructors

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

A deep copy of a value, as in JavaScript: `const b = structuredClone(a)` gives a struct or an array whose fields and elements are its own, so a write to `b` does not change `a`.

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

Builds a `mat2x2`, 2 columns of 2 components in column-major order, from 2 `vec2` columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat2x2`, 2 columns of 2 components in column-major order, from 2 `vec2` columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat2x3`, 2 columns of 3 components in column-major order, from 2 `vec3` columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat2x4`, 2 columns of 4 components in column-major order, from 2 `vec4` columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x2`, 3 columns of 2 components in column-major order, from 3 `vec2` columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x3`, 3 columns of 3 components in column-major order, from 3 `vec3` columns, from 9 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x3`, 3 columns of 3 components in column-major order, from 3 `vec3` columns, from 9 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x4`, 3 columns of 4 components in column-major order, from 3 `vec4` columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x2`, 4 columns of 2 components in column-major order, from 4 `vec2` columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x3`, 4 columns of 3 components in column-major order, from 4 `vec3` columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x4`, 4 columns of 4 components in column-major order, from 4 `vec4` columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x4`, 4 columns of 4 components in column-major order, from 4 `vec4` columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat2x2f`, the same type as `mat2x2` under WGSL's predeclared alias, in the same four ways: from 2 `vec2` columns, from 4 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat2x3f`, the same type as `mat2x3` under WGSL's predeclared alias, in the same four ways: from 2 `vec3` columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat2x4f`, the same type as `mat2x4` under WGSL's predeclared alias, in the same four ways: from 2 `vec4` columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x2f`, the same type as `mat3x2` under WGSL's predeclared alias, in the same four ways: from 3 `vec2` columns, from 6 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x3f`, the same type as `mat3x3` under WGSL's predeclared alias, in the same four ways: from 3 `vec3` columns, from 9 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat3x4f`, the same type as `mat3x4` under WGSL's predeclared alias, in the same four ways: from 3 `vec4` columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x2f`, the same type as `mat4x2` under WGSL's predeclared alias, in the same four ways: from 4 `vec2` columns, from 8 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x3f`, the same type as `mat4x3` under WGSL's predeclared alias, in the same four ways: from 4 `vec3` columns, from 12 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `mat4x4f`, the same type as `mat4x4` under WGSL's predeclared alias, in the same four ways: from 4 `vec4` columns, from 16 components column by column, from a larger matrix by truncation, or with no arguments for the zero matrix (§40).

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

Builds a `vec2` from two scalars or broadcasts a single scalar to both components.

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

Builds a `vec3` from three scalars, a `vec2` and a scalar, or broadcasts a single scalar to all three components.

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

Builds a `vec4` from four scalars, a `vec3` and a scalar, a `vec2` and two scalars, or broadcasts a single scalar to all four components.

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

A two-component vector of `f32`, same type as `vec2`.

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

A three-component vector of `f32`, same type as `vec3`.

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

A four-component vector of `f32`, same type as `vec4`.

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

Builds a `vec2i` from two `i32` scalars, broadcasts a single `i32` scalar, or converts from a `vec2` of a different element kind.

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

Builds a `vec3i` from three `i32` scalars, a `vec2i` and a scalar, broadcasts a single `i32` scalar, or converts from a `vec3` of a different element kind.

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

Builds a `vec4i` from four `i32` scalars, a `vec3i` and a scalar, a `vec2i` and two scalars, broadcasts a single `i32` scalar, or converts from a `vec4` of a different element kind.

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

Builds a `vec2u` from two `u32` scalars, broadcasts a single `u32` scalar, or converts from a `vec2` of a different element kind.

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

Builds a `vec3u` from three `u32` scalars, a `vec2u` and a scalar, broadcasts a single `u32` scalar, or converts from a `vec3` of a different element kind.

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

Builds a `vec4u` from four `u32` scalars, a `vec3u` and a scalar, a `vec2u` and two scalars, broadcasts a single `u32` scalar, or converts from a `vec4` of a different element kind.

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

Builds a `vec2b` from two `bool` scalars, broadcasts a single `bool`, or converts from a `vec2` of a different element kind (nonzero is true).

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

Builds a `vec3b` from three `bool` scalars, a `vec2b` and a scalar, broadcasts a single `bool`, or converts from a `vec3` of a different element kind.

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

Builds a `vec4b` from four `bool` scalars, a `vec3b` and a scalar, a `vec2b` and two scalars, broadcasts a single `bool`, or converts from a `vec4` of a different element kind.

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

Builds a `vec2f64` from two `f64` scalars or broadcasts a single `f64` scalar to both components; emulated in software on both GPU targets.

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

Builds a `vec3f64` from three `f64` scalars, a `vec2f64` and a scalar, or broadcasts a single `f64` scalar; emulated in software on both GPU targets.

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

Builds a `vec4f64` from four `f64` scalars, a `vec3f64` and a scalar, a `vec2f64` and two scalars, or broadcasts a single `f64` scalar; emulated in software on both GPU targets.

## Arrays and bindings

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

Builds an `array<T, N>` from exactly N values of type T.

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

Creates an `array<T, N>` where every element is the given value; requires type arguments `fill<T, N>(value)`.

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

Declares a uniform binding of type T; use `declare const name: uniform<T>` or `const name = uniform<T>()`.

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

Declares a storage binding of type T; use `declare const name: storage<T>` for read-only or `declare const name: storage<T, "read_write">` for read-write access.

Names, declarations and descriptions come from the compiler language-service tables at the pinned commit. Builtin output spellings and stage rules are read from compiler code. The site supplies the groupings and explanations around these entries.
