Files
webgpufundamentals/webgpu/lessons/webgpu-wgsl-function-reference.inc.html
2026-03-12 00:54:14 -07:00

1969 lines
164 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div><h2 id="bit-reinterp-builtin-functions">Bit Reinterpretation Built-in Functions</h2><table id="functions-bit-reinterp-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<T>(e : T) -> T {{/escapehtml}}</pre></td><td>T is a concrete numeric scalar or concrete numeric vector</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Identity transform.<br>
Component-wise when <code>T</code> is a vector.<br>
The result is <code>e</code>.
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<T>(e : S) -> T {{/escapehtml}}</pre></td><td>S is i32, u32, or f32
T is not S and is i32, u32, or f32</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Reinterpretation of bits as <code>T</code>.<br>
The result is the reintepretation of bits in <code>e</code> as a <code>T</code> value.
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<vecN<T>>(e : vecN<S>) -> vecN<T> {{/escapehtml}}</pre></td><td>S is i32, u32, or f32
T is not S and is i32, u32, or f32</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Component-wise reinterpretation of bits as <code>T</code>.<br>
The result is the reintepretation of bits in <code>e</code> as a <code>vecN&lt;T&gt;</code> value.
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<u32>(e : AbstractInt) -> u32 fn bitcast<vecN<u32>>(e : vecN<AbstractInt>) -> vecN<u32> {{/escapehtml}}</pre></td><td></td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>
The identity operation if <code>e</code> can be represented as u32,
otherwise it produces a shader-creation error.
That is, produces the same result as <code>u32(e)</code>.
<p>Component-wise when <code>e</code> is a vector.</p>
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<T>(e : vec2<f16>) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, or f32</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Component-wise reinterpretation of bits as <code>T</code>.<br>
The result is the reintepretation of the 32 bits in <code>e</code> as a <code>T</code> value, following the internal layout rules.
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<vec2<T>>(e : vec4<f16>) -> vec2<T> {{/escapehtml}}</pre></td><td>T is i32, u32, or f32</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Component-wise reinterpretation of bits as <code>T</code>.<br>
The result is the reintepretation of the 64 bits in <code>e</code> as a <code>T</code> value, following the internal layout rules.
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<vec2<f16>>(e : T) -> vec2<f16> {{/escapehtml}}</pre></td><td>T is i32, u32, or f32</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Component-wise reinterpretation of bits as f16.<br>
The result is the reintepretation of the 32 bits in <code>e</code> as an f16 value, following the internal layout rules.
</td></tr><tr id="builtin-bitcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn bitcast<vec4<f16>>(e : vec2<T>) -> vec4<f16> {{/escapehtml}}</pre></td><td>T is i32, u32, or f32</td><td id="bitcast-builtin"><a href="https://www.w3.org/TR/WGSL/#bitcast-builtin" target="_blank"></a>Component-wise reinterpretation of bits as <code>vec2&lt;f16&gt;</code>.<br>
The result is the reintepretation of the 64 bits in <code>e</code> as an f16 value, following the internal layout rules.
</td></tr></tbody></table><h2 id="logical-builtin-functions">Logical Built-in Functions</h2><table id="functions-logical-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-all-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn all(e: vecN<bool>) -> bool {{/escapehtml}}</pre></td><td></td><td id="all-builtin"><a href="https://www.w3.org/TR/WGSL/#all-builtin" target="_blank"></a>Returns true if each component of <code>e</code> is true.
</td></tr><tr id="builtin-all-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn all(e: bool) -> bool {{/escapehtml}}</pre></td><td></td><td id="all-builtin"><a href="https://www.w3.org/TR/WGSL/#all-builtin" target="_blank"></a>Returns <code>e</code>.
</td></tr><tr id="builtin-any-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn any(e: vecN<bool>) -> bool {{/escapehtml}}</pre></td><td></td><td id="any-builtin"><a href="https://www.w3.org/TR/WGSL/#any-builtin" target="_blank"></a>Returns true if any component of <code>e</code> is true.
</td></tr><tr id="builtin-any-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn any(e: bool) -> bool {{/escapehtml}}</pre></td><td></td><td id="any-builtin"><a href="https://www.w3.org/TR/WGSL/#any-builtin" target="_blank"></a>Returns <code>e</code>.
</td></tr><tr id="builtin-select-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn select(f: T,
t: T,
cond: bool) -> T {{/escapehtml}}</pre></td><td>T is scalar or vector</td><td id="select-builtin"><a href="https://www.w3.org/TR/WGSL/#select-builtin" target="_blank"></a>Returns <code>t</code> when <code>cond</code> is true, and <code>f</code> otherwise.
</td></tr><tr id="builtin-select-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn select(f: vecN<T>,
t: vecN<T>,
cond: vecN<bool>) -> vecN<T> {{/escapehtml}}</pre></td><td>T is scalar</td><td id="select-builtin"><a href="https://www.w3.org/TR/WGSL/#select-builtin" target="_blank"></a>Component-wise selection. Result component <code>i</code> is evaluated
as <code>select(f[i], t[i], cond[i])</code>.
</td></tr></tbody></table><h2 id="array-builtin-functions">Array Built-in Functions</h2><table id="functions-array-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-arrayLength-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn arrayLength(p: ptr<storage, array<E>, AM>) -> u32 {{/escapehtml}}</pre></td><td>E is an element type for a runtime-sized array,
access mode AM is read or read_write</td><td id="arrayLength-builtin"><a href="https://www.w3.org/TR/WGSL/#arrayLength-builtin" target="_blank"></a>
Returns NRuntime, the number of elements in the runtime-sized array.
<p>See §13.3.4 Buffer Binding Determines Runtime-Sized Array Element Count</p>
</td></tr></tbody></table><h2 id="numeric-builtin-functions">Numeric Built-in Functions</h2><table id="functions-numeric-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-abs-float-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn abs(e: T ) -> T {{/escapehtml}}</pre></td><td>S is AbstractInt, AbstractFloat, i32, u32, f32, or f16
T is S, or vecN&lt;S&gt;</td><td id="abs-float-builtin"><a href="https://www.w3.org/TR/WGSL/#abs-float-builtin" target="_blank"></a>
The absolute value of <code>e</code>.
Component-wise when <code>T</code> is a vector.
<p>If <code>e</code> is a floating-point type, then the result is <code>e</code> with a positive sign bit.
If <code>e</code> is an unsigned integer scalar type, then the result is <code>e</code>.
If <code>e</code> is a signed integer scalar type and evaluates to the largest
negative value, then the result is <code>e</code>.</p>
</td></tr><tr id="builtin-acos-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn acos(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="acos-builtin"><a href="https://www.w3.org/TR/WGSL/#acos-builtin" target="_blank"></a>
Returns the principal value, in radians, of the inverse cosine (cos<sup>-1</sup>) of <code>e</code>.<br>
That is, approximates <code>x</code> with 0 ≤ <code>x</code> ≤ π, such that <code>cos</code>(<code>x</code>) = <code>e</code>.
<p>Component-wise when <code>T</code> is a vector.</p>
Interval [1, 1]
</td></tr><tr id="builtin-acosh-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn acosh(x: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="acosh-builtin"><a href="https://www.w3.org/TR/WGSL/#acosh-builtin" target="_blank"></a>
Returns the inverse hyperbolic cosine (cosh<sup>-1</sup>) of <code>x</code>, as a hyperbolic angle.<br>
That is, approximates <code>a</code> with 0 ≤ a ≤ +∞, such that <code>cosh</code>(<code>a</code>) = <code>x</code>.
<p>Component-wise when <code>T</code> is a vector.</p>
Interval [1, +∞]
</td></tr><tr id="builtin-asin-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn asin(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="asin-builtin"><a href="https://www.w3.org/TR/WGSL/#asin-builtin" target="_blank"></a>
Returns the principal value, in radians, of the inverse sine (sin<sup>-1</sup>) of <code>e</code>.<br>
That is, approximates <code>x</code> with -π/2 ≤ <code>x</code> ≤ π/2, such that <code>sin</code>(<code>x</code>) = <code>e</code>.
<p>Component-wise when <code>T</code> is a vector.</p>
Interval [1, 1]
</td></tr><tr id="builtin-asinh-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn asinh(y: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="asinh-builtin"><a href="https://www.w3.org/TR/WGSL/#asinh-builtin" target="_blank"></a>
Returns the inverse hyperbolic sine (sinh<sup>-1</sup>) of <code>y</code>, as a hyperbolic angle.<br>
That is, approximates <code>a</code> such that <code>sinh</code>(<code>y</code>) = <code>a</code>.
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-atan-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn atan(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="atan-builtin"><a href="https://www.w3.org/TR/WGSL/#atan-builtin" target="_blank"></a>
Returns the principal value, in radians, of the inverse tangent (tan<sup>-1</sup>) of <code>e</code>.<br>
That is, approximates <code>x</code> with π/2 ≤ <code>x</code> ≤ π/2, such that <code>tan</code>(<code>x</code>) = <code>e</code>.
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-atanh-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn atanh(t: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="atanh-builtin"><a href="https://www.w3.org/TR/WGSL/#atanh-builtin" target="_blank"></a>
Returns the inverse hyperbolic tangent (tanh<sup>-1</sup>) of <code>t</code>, as a hyperbolic angle.<br>
That is, approximates <code>a</code> such that <code>tanh</code>(<code>a</code>) = <code>t</code>.
<p>Component-wise when <code>T</code> is a vector.</p>
Interval [1, 1]
</td></tr><tr id="builtin-atan2-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn atan2(y: T,
x: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="atan2-builtin"><a href="https://www.w3.org/TR/WGSL/#atan2-builtin" target="_blank"></a>
Returns an angle, in radians, in the interval [-π, π] whose tangent is <code>y</code>÷<code>x</code>.
<p>The quadrant selected by the result depends on the signs of <code>y</code> and <code>x</code>.
For example, the function may be implemented as:</p>
<ul>
<li data-md="">
<p><code>atan(y/x)</code> when <code>x</code> &gt; 0</p>
</li><li data-md="">
<p><code>atan(y/x)</code> + π when (<code>x</code> &lt; 0) and (<code>y</code> &gt; 0)</p>
</li><li data-md="">
<p><code>atan(y/x)</code> - π when (<code>x</code> &lt; 0) and (<code>y</code> &lt; 0)</p>
</li></ul>
<div class="note" role="note">
<span class="marker">Note:</span> The error in the result is unbounded:
<ul>
<li data-md="">
<p>When <code>abs(x)</code> is very small, e.g. subnormal for its type,</p>
</li><li data-md="">
<p>At the origin (<code>x</code>,<code>y</code>) = (0,0), or</p>
</li><li data-md="">
<p>When <code>y</code> is subnormal or infinite.</p>
</li></ul>
</div>
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-ceil-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn ceil(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="ceil-builtin"><a href="https://www.w3.org/TR/WGSL/#ceil-builtin" target="_blank"></a>Returns the ceiling of <code>e</code>.
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-clamp"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn clamp(e: T,
low: T,
high: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractInt, AbstractFloat, i32, u32, f32, or f16
T is S, or vecN&lt;S&gt;</td><td id="clamp"><a href="https://www.w3.org/TR/WGSL/#clamp" target="_blank"></a>
Restricts the value of <code>e</code> within a range.
<p>If <code>T</code> is an integer type, then the result is <code>min(max(e, low), high)</code>.</p>
<p>If <code>T</code> is a floating-point type, then the result is either <code>min(max(e, low), high)</code>, or the median of the three values <code>e</code>, <code>low</code>, <code>high</code>.</p>
<p>Component-wise when <code>T</code> is a vector.</p>
<p>If <code>low</code> is greater than <code>high</code>, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>low</code> and <code>high</code> are const-expressions.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>low</code> and <code>high</code> are override-expressions.</p>
</li></ul>
</td></tr><tr id="builtin-cos-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn cos(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="cos-builtin"><a href="https://www.w3.org/TR/WGSL/#cos-builtin" target="_blank"></a>Returns the cosine of <code>e</code>, where <code>e</code> is in radians.
Component-wise when <code>T</code> is a vector.
Interval (−∞, +∞)
</td></tr><tr id="builtin-cosh-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn cosh(a: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="cosh-builtin"><a href="https://www.w3.org/TR/WGSL/#cosh-builtin" target="_blank"></a>
Returns the hyperbolic cosine of <code>a</code>, where <code>a</code> is a hyperbolic angle.
Approximates the pure mathematical function (<em>e</em><sup>a</sup> + <em>e</em><sup>a</sup>)÷2,
but not necessarily computed that way.
<p>Component-wise when <code>T</code> is a vector</p>
</td></tr><tr id="builtin-countLeadingZeros-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn countLeadingZeros(e: T) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, vecN&lt;i32&gt;, or vecN&lt;u32&gt;</td><td id="countLeadingZeros-builtin"><a href="https://www.w3.org/TR/WGSL/#countLeadingZeros-builtin" target="_blank"></a>The number of consecutive 0 bits starting from the most significant bit
of <code>e</code>, when <code>T</code> is a scalar type.<br>
Component-wise when <code>T</code> is a vector.<br>
Also known as "clz" in some languages.
</td></tr><tr id="builtin-countOneBits-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn countOneBits(e: T) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, vecN&lt;i32&gt;, or vecN&lt;u32&gt;</td><td id="countOneBits-builtin"><a href="https://www.w3.org/TR/WGSL/#countOneBits-builtin" target="_blank"></a>The number of 1 bits in the representation of <code>e</code>.<br>
Also known as "population count".<br>
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-countTrailingZeros-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn countTrailingZeros(e: T) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, vecN&lt;i32&gt;, or vecN&lt;u32&gt;</td><td id="countTrailingZeros-builtin"><a href="https://www.w3.org/TR/WGSL/#countTrailingZeros-builtin" target="_blank"></a>The number of consecutive 0 bits starting from the least significant bit
of <code>e</code>, when <code>T</code> is a scalar type.<br>
Component-wise when <code>T</code> is a vector.<br>
Also known as "ctz" in some languages.
</td></tr><tr id="builtin-cross-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn cross(a: vec3<T>,
b: vec3<T>) -> vec3<T> {{/escapehtml}}</pre></td><td>T is AbstractFloat, f32, or f16</td><td id="cross-builtin"><a href="https://www.w3.org/TR/WGSL/#cross-builtin" target="_blank"></a>Returns the cross product of <code>e1</code> and <code>e2</code>.
Implied from linear terms given by a possible implementation:
<ul>
<li data-md="">
<p><var>a</var>[1] × <var>b</var>[2] <var>a</var>[2] × <var>b</var>[1]</p>
</li><li data-md="">
<p><var>a</var>[2] × <var>b</var>[0] <var>a</var>[0] × <var>b</var>[2]</p>
</li><li data-md="">
<p><var>a</var>[0] × <var>b</var>[1] <var>a</var>[1] × <var>b</var>[0]</p>
</li></ul>
</td></tr><tr id="builtin-degrees-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn degrees(e1: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="degrees-builtin"><a href="https://www.w3.org/TR/WGSL/#degrees-builtin" target="_blank"></a>Converts radians to degrees, approximating <code>e1</code>&nbsp;×&nbsp;180&nbsp;÷&nbsp;π.
Component-wise when <code>T</code> is a vector
</td></tr><tr id="builtin-determinant-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn determinant(e: matCxC<T>) -> T {{/escapehtml}}</pre></td><td>T is AbstractFloat, f32, or f16</td><td id="determinant-builtin"><a href="https://www.w3.org/TR/WGSL/#determinant-builtin" target="_blank"></a>Returns the determinant of <code>e</code>.
Implied from linear terms in a standard mathematical definition of the determinant.
</td></tr><tr id="builtin-distance-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn distance(e1: T,
e2: T) -> S {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="distance-builtin"><a href="https://www.w3.org/TR/WGSL/#distance-builtin" target="_blank"></a>
Returns the distance between <code>e1</code> and <code>e2</code> (e.g. <code>length(e1 - e2)</code>).
<p>The domain is all vectors (<var>e1</var>,<var>e2</var>) where the subtraction <var>e1</var><var>e2</var> is valid.
That is, the set of all vectors except where <code>e1[i]</code> and <code>e2[i]</code> are the same infinite value,
for some component <code>i</code>.</p>
</td></tr><tr id="builtin-dot-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dot(e1: vecN<T>,
e2: vecN<T>) -> T {{/escapehtml}}</pre></td><td>T is AbstractInt, AbstractFloat, i32, u32, f32, or f16</td><td id="dot-builtin"><a href="https://www.w3.org/TR/WGSL/#dot-builtin" target="_blank"></a>Returns the dot product of <code>e1</code> and <code>e2</code>.
Implied from linear terms of the sum over terms <var>e1</var>[i] × <var>e2</var>[i].
</td></tr><tr id="builtin-dot4U8Packed-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dot4U8Packed(e1: u32,
e2: u32) -> u32 {{/escapehtml}}</pre></td><td></td><td id="dot4U8Packed-builtin"><a href="https://www.w3.org/TR/WGSL/#dot4U8Packed-builtin" target="_blank"></a><code>e1</code> and <code>e2</code> are interpreted as vectors with four 8-bit unsigned integer components.
Return the unsigned integer dot product of these two vectors.
</td></tr><tr id="builtin-dot4I8Packed-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dot4I8Packed(e1: u32,
e2: u32) -> i32 {{/escapehtml}}</pre></td><td></td><td id="dot4I8Packed-builtin"><a href="https://www.w3.org/TR/WGSL/#dot4I8Packed-builtin" target="_blank"></a><code>e1</code> and <code>e2</code> are interpreted as vectors with four 8-bit signed integer components.
Return the signed integer dot product of these two vectors. Each component is sign-extended
to i32 before performing the multiply, and then the add operations are done in WGSL i32 (the
addition cannot overflow since the result is mathematically guaranteed to be in the range
from -65024 to 65536, which lies within the range of numbers that can be represented by
i32).
</td></tr><tr id="builtin-exp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn exp(e1: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="exp-builtin"><a href="https://www.w3.org/TR/WGSL/#exp-builtin" target="_blank"></a>Returns the natural exponentiation of <code>e1</code> (e.g. <code>e</code><sup><code>e1</code></sup>).
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-exp2-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn exp2(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="exp2-builtin"><a href="https://www.w3.org/TR/WGSL/#exp2-builtin" target="_blank"></a>Returns 2 raised to the power <code>e</code> (e.g. <code>2</code><sup><code>e</code></sup>).
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-extractBits-signed-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn extractBits(e: T,
offset: u32,
count: u32) -> T {{/escapehtml}}</pre></td><td>T is i32 or vecN&lt;i32&gt;</td><td id="extractBits-signed-builtin"><a href="https://www.w3.org/TR/WGSL/#extractBits-signed-builtin" target="_blank"></a>
Reads bits from an integer, with sign extension.
<p>When <code>T</code> is a scalar type, then:</p>
<ul>
<li><code>w</code> is the bit width of <code>T</code>
</li><li><code>o = min(offset, w)</code>
</li><li><code>c = min(count, w - o)</code>
</li><li>The result is 0 if <code>c</code> is 0.
</li><li>Otherwise, bits <code>0..c - 1</code> of the result are copied from bits
<code>o..o + c - 1</code> of <code>e</code>.
Other bits of the result are the same as bit <code>c - 1</code> of the result.
</li></ul>
Component-wise when <code>T</code> is a vector.
<p>If <code>count</code> + <code>offset</code> is greater than <code>w</code>, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>count</code> and <code>offset</code> are const-expressions.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>count</code> and <code>offset</code> are override-expressions.</p>
</li></ul>
</td></tr><tr id="builtin-extractBits-unsigned-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn extractBits(e: T,
offset: u32,
count: u32) -> T {{/escapehtml}}</pre></td><td>T is u32 or vecN&lt;u32&gt;</td><td id="extractBits-unsigned-builtin"><a href="https://www.w3.org/TR/WGSL/#extractBits-unsigned-builtin" target="_blank"></a>
Reads bits from an integer, without sign extension.
<p>When <code>T</code> is a scalar type, then:</p>
<ul>
<li><code>w</code> is the bit width of <code>T</code>
</li><li><code>o = min(offset, w)</code>
</li><li><code>c = min(count, w - o)</code>
</li><li>The result is 0 if <code>c</code> is 0.
</li><li>Otherwise, bits <code>0..c - 1</code> of the result are copied from bits
<code>o..o + c - 1</code> of <code>e</code>.
Other bits of the result are 0.
</li></ul>
Component-wise when <code>T</code> is a vector.
<p>If <code>count</code> + <code>offset</code> is greater than <code>w</code>, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>count</code> and <code>offset</code> are const-expressions.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>count</code> and <code>offset</code> are override-expressions.</p>
</li></ul>
</td></tr><tr id="builtin-faceForward-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn faceForward(e1: T,
e2: T,
e3: T) -> T {{/escapehtml}}</pre></td><td>T is vecN&lt;AbstractFloat&gt;, vecN&lt;f32&gt;, or vecN&lt;f16&gt;</td><td id="faceForward-builtin"><a href="https://www.w3.org/TR/WGSL/#faceForward-builtin" target="_blank"></a>Returns <code>e1</code> if <code>dot(e2, e3)</code> is negative, and <code>-e1</code> otherwise.
The domain restrictions arise from the <code>dot(e2,e3)</code> operation: they are implied from linear terms of the sum over terms <var>e2</var>[i] × <var>e3</var>[i].
</td></tr><tr id="builtin-firstLeadingBit-signed-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn firstLeadingBit(e: T) -> T {{/escapehtml}}</pre></td><td>T is i32 or vecN&lt;i32&gt;</td><td id="firstLeadingBit-signed-builtin"><a href="https://www.w3.org/TR/WGSL/#firstLeadingBit-signed-builtin" target="_blank"></a>
For scalar <code>T</code>, the result is:
<ul>
<li>-1 if <code>e</code> is 0 or -1.
</li><li>Otherwise the position of the most significant bit in
<code>e</code> that is different from <code>e</code>s sign bit.
</li></ul>
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-firstLeadingBit-unsigned-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn firstLeadingBit(e: T) -> T {{/escapehtml}}</pre></td><td>T is u32 or vecN&lt;u32&gt;</td><td id="firstLeadingBit-unsigned-builtin"><a href="https://www.w3.org/TR/WGSL/#firstLeadingBit-unsigned-builtin" target="_blank"></a>
For scalar <code>T</code>, the result is:
<ul>
<li><code>T(-1)</code> if <code>e</code> is zero.
</li><li>Otherwise the position of the most significant 1
bit in <code>e</code>.
</li></ul>
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-firstTrailingBit-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn firstTrailingBit(e: T) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, vecN&lt;i32&gt;, or vecN&lt;u32&gt;</td><td id="firstTrailingBit-builtin"><a href="https://www.w3.org/TR/WGSL/#firstTrailingBit-builtin" target="_blank"></a>
For scalar <code>T</code>, the result is:
<ul>
<li><code>T(-1)</code> if <code>e</code> is zero.
</li><li>Otherwise the position of the least significant 1
bit in <code>e</code>.
</li></ul>
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-floor-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn floor(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="floor-builtin"><a href="https://www.w3.org/TR/WGSL/#floor-builtin" target="_blank"></a>Returns the floor of <code>e</code>.
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-fma-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn fma(e1: T,
e2: T,
e3: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="fma-builtin"><a href="https://www.w3.org/TR/WGSL/#fma-builtin" target="_blank"></a>
Returns <code>e1 * e2 + e3</code>.
Component-wise when <code>T</code> is a vector.
<p class="note" role="note"><span class="marker">Note:</span> The name <code>fma</code> is short for "fused multiply add".</p>
<p class="note" role="note"><span class="marker">Note:</span>
The IEEE-754 <code>fusedMultiplyAdd</code> operation computes the intermediate results
as if with unbounded range and precision, and only the final result is rounded
to a value in the destination type.
However, the §15.7.4 Floating Point Accuracy rule for <code>fma</code> allows an implementation
which performs an ordinary multiply to the target type followed by an ordinary addition.
In this case the intermediate result values may overflow or lose accuracy, and the overall
operation is not "fused" at all.</p>
Implied from linear terms of the expressions <var>e2</var> × <var>e2</var> + <var>e3</var>.
</td></tr><tr id="builtin-fract-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn fract(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="fract-builtin"><a href="https://www.w3.org/TR/WGSL/#fract-builtin" target="_blank"></a>Returns the fractional part of <code>e</code>, computed as <code>e - floor(e)</code>.<br>
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-frexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn frexp(e: T) -> __frexp_result_f32 {{/escapehtml}}</pre></td><td>T is f32</td><td id="frexp-builtin"><a href="https://www.w3.org/TR/WGSL/#frexp-builtin" target="_blank"></a>
Splits <code>e</code> into a fraction and an exponent.
<ul>
<li data-md="">
<p>When <code>e</code> is zero, the fraction is zero.</p>
</li><li data-md="">
<p>When <code>e</code> is non-zero and normal, <code>e</code> = <code>fraction * 2</code><sup><code>exponent</code></sup>, where
the fraction is in the range [0.5, 1.0) or (-1.0, -0.5].</p>
</li><li data-md="">
<p>Otherwise, <code>e</code> is subnormal, NaN, or infinite. The result fraction and exponent are indeterminate values.</p>
</li></ul>
<p>Returns the <code>__frexp_result_f32</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __frexp_result_f32 {
fract : f32, // fraction part
exp : i32 // exponent part
}
</pre>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>frexp</code> is "<strong>fr</strong>action and <strong>exp</strong>onent".</p>
</td></tr><tr id="builtin-frexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn frexp(e: T) -> __frexp_result_f16 {{/escapehtml}}</pre></td><td>T is f16</td><td id="frexp-builtin"><a href="https://www.w3.org/TR/WGSL/#frexp-builtin" target="_blank"></a>
Splits <code>e</code> into a fraction and an exponent.
<ul>
<li data-md="">
<p>When <code>e</code> is zero, the fraction is zero.</p>
</li><li data-md="">
<p>When <code>e</code> is non-zero and normal, <code>e</code> = <code>fraction * 2</code><sup><code>exponent</code></sup>, where
the fraction is in the range [0.5, 1.0) or (-1.0, -0.5].</p>
</li><li data-md="">
<p>Otherwise, <code>e</code> is subnormal, NaN, or infinite. The result fraction and exponent are indeterminate values.</p>
</li></ul>
<p>Returns the <code>__frexp_result_f16</code> built-in structure, defined as if as follows:</p>
<pre class="highlight language-wgsl">struct __frexp_result_f16 {
fract : f16, // fraction part
exp : i32 // exponent part
}
</pre>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>frexp</code> is "<strong>fr</strong>action and <strong>exp</strong>onent".</p>
</td></tr><tr id="builtin-frexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn frexp(e: T) -> __frexp_result_abstract {{/escapehtml}}</pre></td><td>T is AbstractFloat</td><td id="frexp-builtin"><a href="https://www.w3.org/TR/WGSL/#frexp-builtin" target="_blank"></a>
Splits <code>e</code> into a fraction and an exponent.
<ul>
<li data-md="">
<p>When <code>e</code> is zero, the fraction is zero.</p>
</li><li data-md="">
<p>When <code>e</code> is non-zero and normal, <code>e</code> = <code>fraction * 2</code><sup><code>exponent</code></sup>, where
the fraction is in the range [0.5, 1.0) or (-1.0, -0.5].</p>
</li><li data-md="">
<p>When <code>e</code> is subnormal, the fraction and exponent are have unbounded error.
The fraction may be any AbstractFloat value, and the exponent may be any AbstractInt value.</p>
</li></ul>
<p class="note" role="note"><span class="marker">Note:</span> AbstractFloat expressions resulting in infinity or NaN cause a shader-creation error.</p>
<p>Returns the <code>__frexp_result_abstract</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __frexp_result_abstract {
fract : AbstractFloat, // fraction part
exp : AbstractInt // exponent part
}
</pre>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>frexp</code> is "<strong>fr</strong>action and <strong>exp</strong>onent".</p>
</td></tr><tr id="builtin-frexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn frexp(e: T) -> __frexp_result_vecN_f32 {{/escapehtml}}</pre></td><td>T is vecN&lt;f32&gt;</td><td id="frexp-builtin"><a href="https://www.w3.org/TR/WGSL/#frexp-builtin" target="_blank"></a>
Splits components <code>ei</code> of <code>e</code> into a fraction and an exponent.
<ul>
<li data-md="">
<p>When <code>ei</code> is zero, the fraction is zero.</p>
</li><li data-md="">
<p>When <code>ei</code> is non-zero and normal, <code>ei</code> = <code>fraction * 2</code><sup><code>exponent</code></sup>, where
the fraction is in the range [0.5, 1.0) or (-1.0, -0.5].</p>
</li><li data-md="">
<p>Otherwise, <code>ei</code> is NaN or infinite. The result fraction and exponent are indeterminate values.</p>
</li></ul>
<p>Returns the <code>__frexp_result_vecN_f32</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __frexp_result_vecN_f32 {
fract : vecN<f32>, // fraction part
exp : vecN<i32> // exponent part
}
</pre>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>frexp</code> is "<strong>fr</strong>action and <strong>exp</strong>onent".</p>
</td></tr><tr id="builtin-frexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn frexp(e: T) -> __frexp_result_vecN_f16 {{/escapehtml}}</pre></td><td>T is vecN&lt;f16&gt;</td><td id="frexp-builtin"><a href="https://www.w3.org/TR/WGSL/#frexp-builtin" target="_blank"></a>
Splits components <code>ei</code> of <code>e</code> into a fraction and an exponent.
<ul>
<li data-md="">
<p>When <code>ei</code> is zero, the fraction is zero.</p>
</li><li data-md="">
<p>When <code>ei</code> is non-zero and normal, <code>ei</code> = <code>fraction * 2</code><sup><code>exponent</code></sup>, where
the fraction is in the range [0.5, 1.0) or (-1.0, -0.5].</p>
</li><li data-md="">
<p>Otherwise, <code>ei</code> is NaN or infinite. The result fraction and exponent are indeterminate values.</p>
</li></ul>
<p>Returns the <code>__frexp_result_vecN_f16</code> built-in structure, defined as if as follows:</p>
<pre class="highlight language-wgsl">struct __frexp_result_vecN_f16 {
fract : vecN<f16>, // fraction part
exp : vecN<i32> // exponent part
}
</pre>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>frexp</code> is "<strong>fr</strong>action and <strong>exp</strong>onent".</p>
</td></tr><tr id="builtin-frexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn frexp(e: T) -> __frexp_result_vecN_abstract {{/escapehtml}}</pre></td><td>T is vecN&lt;AbstractFloat&gt;</td><td id="frexp-builtin"><a href="https://www.w3.org/TR/WGSL/#frexp-builtin" target="_blank"></a>
Splits components <code>ei</code> of <code>e</code> into a fraction and an exponent.
<ul>
<li data-md="">
<p>When <code>ei</code> is zero, the fraction is zero.</p>
</li><li data-md="">
<p>When <code>ei</code> is non-zero and normal, <code>ei</code> = <code>fraction * 2</code><sup><code>exponent</code></sup>, where
the fraction is in the range [0.5, 1.0) or (-1.0, -0.5].</p>
</li><li data-md="">
<p>When <code>ei</code> is subnormal, the fraction and exponent are have unbounded error.
The fraction may be any AbstractFloat value, and the exponent may be any AbstractInt value.</p>
</li></ul>
<p class="note" role="note"><span class="marker">Note:</span> AbstractFloat expressions resulting in infinity or NaN cause a shader-creation error.</p>
<p>Returns the <code>__frexp_result_vecN_abstract</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __frexp_result_vecN_abstract {
fract : vecN<AbstractFloat>, // fraction part
exp : vecN<AbstractInt> // exponent part
}
</pre>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>frexp</code> is "<strong>fr</strong>action and <strong>exp</strong>onent".</p>
</td></tr><tr id="builtin-insertBits-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn insertBits(e: T,
newbits: T,
offset: u32,
count: u32) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, vecN&lt;i32&gt;, or vecN&lt;u32&gt;</td><td id="insertBits-builtin"><a href="https://www.w3.org/TR/WGSL/#insertBits-builtin" target="_blank"></a>
Sets bits in an integer.
<p>When <code>T</code> is a scalar type, then:</p>
<ul>
<li><code>w</code> is the bit width of <code>T</code>
</li><li><code>o = min(offset, w)</code>
</li><li><code>c = min(count, w - o)</code>
</li><li>The result is <code>e</code> if <code>c</code> is 0.
</li><li>Otherwise,
bits <code>o..o + c - 1</code> of the result are copied from bits <code>0..c - 1</code> of <code>newbits</code>.
Other bits of the result are copied from <code>e</code>.
</li></ul>
Component-wise when <code>T</code> is a vector.
<p>If <code>count</code> + <code>offset</code> is greater than <code>w</code>, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>count</code> and <code>offset</code> are const-expressions.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>count</code> and <code>offset</code> are override-expressions.</p>
</li></ul>
</td></tr><tr id="builtin-inverseSqrt-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn inverseSqrt(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="inverseSqrt-builtin"><a href="https://www.w3.org/TR/WGSL/#inverseSqrt-builtin" target="_blank"></a>Returns the reciprocal of <code>sqrt(e)</code>.
Component-wise when <code>T</code> is a vector.
Interval [0, +∞]
</td></tr><tr id="builtin-ldexp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn ldexp(e1: T,
e2: I) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;
I is AbstractInt, i32, vecN&lt;AbstractInt&gt;, or vecN&lt;i32&gt;
I is a vector if and only if T is a vector
T can only be abstract if I is also abstract and vice versa
Note: If either parameter is concrete then the other parameter
will undergo automatic conversion to
a concrete type (if applicable) and the result will be a
concrete type.</td><td id="ldexp-builtin"><a href="https://www.w3.org/TR/WGSL/#ldexp-builtin" target="_blank"></a>
Returns <code>e1 * 2</code><sup><code>e2</code></sup>, except:
<ul>
<li data-md="">
<p>The result may be zero if <code>e2</code> + <em>bias</em> ≤ 0.</p>
</li><li data-md="">
<p>If <code>e2</code> &gt; <em>bias</em> + 1</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>e2</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>e2</code> is an override-expression.</p>
</li><li data-md="">
<p>Otherwise the result is an indeterminate value for <code>T</code>.</p>
</li></ul>
</li></ul>
<p>Here, <em>bias</em> is the exponent bias of the floating point format:</p>
<ul>
<li data-md="">
<p>15 for <code>f16</code></p>
</li><li data-md="">
<p>127 for <code>f32</code></p>
</li><li data-md="">
<p>1023 for AbstractFloat, when AbstractFloat is IEEE-754 binary64</p>
</li></ul>
<p>If <code>x</code> is zero or a finite normal value for its type, then:</p>
<blockquote>
x = ldexp(frexp(x).fract, frexp(x).exp)
</blockquote>
<p>Component-wise when <code>T</code> is a vector.</p>
<p class="note" role="note"><span class="marker">Note:</span> A mnemonic for the name <code>ldexp</code> is "load exponent".
The name may have been taken from the corresponding instruction in the floating point unit of
the PDP-11.</p>
</td></tr><tr id="builtin-length-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn length(e: T) -> S {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="length-builtin"><a href="https://www.w3.org/TR/WGSL/#length-builtin" target="_blank"></a>
Returns the length of <code>e</code>.<br>
Evaluates to the absolute value of <code>e</code> if <code>T</code> is scalar.<br>
Evaluates to <code>sqrt(e[0]</code><sup><code>2</code></sup> <code>+ e[1]</code><sup><code>2</code></sup> <code>+ ...)</code> if <code>T</code> is a vector type.
<p class="note" role="note"><span class="marker">Note:</span> The scalar case may be evaluated as <code>sqrt(e * e)</code>,
which may unnecessarily overflow or lose accuracy.</p>
</td></tr><tr id="builtin-log-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn log(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="log-builtin"><a href="https://www.w3.org/TR/WGSL/#log-builtin" target="_blank"></a>Returns the natural logarithm of <code>e</code>.
Component-wise when <code>T</code> is a vector.
Interval [0, +∞]
</td></tr><tr id="builtin-log2-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn log2(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="log2-builtin"><a href="https://www.w3.org/TR/WGSL/#log2-builtin" target="_blank"></a>Returns the base-2 logarithm of <code>e</code>.
Component-wise when <code>T</code> is a vector.
Interval [0, +∞]
</td></tr><tr id="builtin-max-float-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn max(e1: T,
e2: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractInt, AbstractFloat, i32, u32, f32, or f16
T is S, or vecN&lt;S&gt;</td><td id="max-float-builtin"><a href="https://www.w3.org/TR/WGSL/#max-float-builtin" target="_blank"></a>
Returns <code>e2</code> if <code>e1</code> is less than <code>e2</code>, and <code>e1</code> otherwise.
Component-wise when <code>T</code> is a vector.
<p>If <code>e1</code> and <code>e2</code> are floating-point values, then:</p>
<ul>
<li data-md="">
<p>If both <code>e1</code> and <code>e2</code> are subnormal, then the result may be <em>either</em> value.</p>
</li></ul>
</td></tr><tr id="builtin-min-float-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn min(e1: T,
e2: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractInt, AbstractFloat, i32, u32, f32, or f16
T is S, or vecN&lt;S&gt;</td><td id="min-float-builtin"><a href="https://www.w3.org/TR/WGSL/#min-float-builtin" target="_blank"></a>
Returns <code>e2</code> if <code>e2</code> is less than <code>e1</code>, and <code>e1</code> otherwise.
Component-wise when <code>T</code> is a vector.
<p>If <code>e1</code> and <code>e2</code> are floating-point values, then:</p>
<ul>
<li data-md="">
<p>If both <code>e1</code> and <code>e2</code> are subnormal, then the result may be <em>either</em> value.</p>
</li></ul>
</td></tr><tr id="builtin-mix-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn mix(e1: T,
e2: T,
e3: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="mix-builtin"><a href="https://www.w3.org/TR/WGSL/#mix-builtin" target="_blank"></a>Returns the linear blend of <code>e1</code> and <code>e2</code> (e.g. <code>e1 * (T(1) - e3) + e2 * e3</code>).
Component-wise when <code>T</code> is a vector.
Implied from linear terms of the expressions: <var>e1</var>[i] × (1 <var>e3</var>[i]) + <var>e2</var>[i] × <var>e3</var>[i].
<var>e2</var>[i] × <var>e2</var>[i] + <var>e3</var>[i].
</td></tr><tr id="builtin-mix-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn mix(e1: T2,
e2: T2,
e3: T) -> T2 {{/escapehtml}}</pre></td><td>T is AbstractFloat, f32, or f16
T2 is vecN&lt;T&gt;</td><td id="mix-builtin"><a href="https://www.w3.org/TR/WGSL/#mix-builtin" target="_blank"></a>Returns the component-wise linear blend of <code>e1</code> and <code>e2</code>,
using scalar blending factor <code>e3</code> for each component.<br>
Same as <code>mix(e1, e2, T2(e3))</code>.
Implied from linear terms of the expressions: <var>e1</var>[i] × (1 <var>e3</var>) + <var>e2</var>[i] × <var>e3</var>.
</td></tr><tr id="builtin-modf-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn modf(e: T) -> __modf_result_f32 {{/escapehtml}}</pre></td><td>T is f32</td><td id="modf-builtin"><a href="https://www.w3.org/TR/WGSL/#modf-builtin" target="_blank"></a>
Splits <code>e</code> into fractional and whole number parts.
<p>The whole part is trunc(<code>e</code>), and the fractional part is <code>e</code> - trunc(<code>e</code>).</p>
<p>Returns the <code>__modf_result_f32</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __modf_result_f32 {
fract : f32, // fractional part
whole : f32 // whole part
}
</pre>
</td></tr><tr id="builtin-modf-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn modf(e: T) -> __modf_result_f16 {{/escapehtml}}</pre></td><td>T is f16</td><td id="modf-builtin"><a href="https://www.w3.org/TR/WGSL/#modf-builtin" target="_blank"></a>
Splits <code>e</code> into fractional and whole number parts.
<p>The whole part is trunc(<code>e</code>), and the fractional part is <code>e</code> - trunc(<code>e</code>).</p>
<p>Returns the <code>__modf_result_f16</code> built-in structure, defined as if as follows:</p>
<pre class="highlight language-wgsl">struct __modf_result_f16 {
fract : f16, // fractional part
whole : f16 // whole part
}
</pre>
</td></tr><tr id="builtin-modf-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn modf(e: T) -> __modf_result_abstract {{/escapehtml}}</pre></td><td>T is AbstractFloat</td><td id="modf-builtin"><a href="https://www.w3.org/TR/WGSL/#modf-builtin" target="_blank"></a>
Splits <code>e</code> into fractional and whole number parts.
<p>The whole part is trunc(<code>e</code>), and the fractional part is <code>e</code> - trunc(<code>e</code>).</p>
<p>Returns the <code>__modf_result_abstract</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __modf_result_abstract {
fract : AbstractFloat, // fractional part
whole : AbstractFloat // whole part
}
</pre>
</td></tr><tr id="builtin-modf-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn modf(e: T) -> __modf_result_vecN_f32 {{/escapehtml}}</pre></td><td>T is vecN&lt;f32&gt;</td><td id="modf-builtin"><a href="https://www.w3.org/TR/WGSL/#modf-builtin" target="_blank"></a>
Splits the components of <code>e</code> into fractional and whole number parts.
<p>The <code>i</code>th component of the whole and fractional parts equal the whole and fractional parts
of <code>modf(e[i])</code>.</p>
<p>Returns the <code>__modf_result_vecN_f32</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __modf_result_vecN_f32 {
fract : vecN<f32>, // fractional part
whole : vecN<f32> // whole part
}
</pre>
</td></tr><tr id="builtin-modf-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn modf(e: T) -> __modf_result_vecN_f16 {{/escapehtml}}</pre></td><td>T is vecN&lt;f16&gt;</td><td id="modf-builtin"><a href="https://www.w3.org/TR/WGSL/#modf-builtin" target="_blank"></a>
Splits the components of <code>e</code> into fractional and whole number parts.
<p>The <code>i</code>th component of the whole and fractional parts equal the whole and fractional parts
of <code>modf(e[i])</code>.</p>
<p>Returns the <code>__modf_result_vecN_f16</code> built-in structure, defined as if as follows:</p>
<pre class="highlight language-wgsl">struct __modf_result_vecN_f16 {
fract : vecN<f16>, // fractional part
whole : vecN<f16> // whole part
}
</pre>
</td></tr><tr id="builtin-modf-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn modf(e: T) -> __modf_result_vecN_abstract {{/escapehtml}}</pre></td><td>T is vecN&lt;AbstractFloat&gt;</td><td id="modf-builtin"><a href="https://www.w3.org/TR/WGSL/#modf-builtin" target="_blank"></a>
Splits the components of <code>e</code> into fractional and whole number parts.
<p>The <code>i</code>th component of the whole and fractional parts equal the whole and fractional parts
of <code>modf(e[i])</code>.</p>
<p>Returns the <code>__modf_result_vecN_abstract</code> built-in structure, defined as follows:</p>
<pre class="highlight language-wgsl">struct __modf_result_vecN_abstract {
fract : vecN<AbstractFloat>, // fractional part
whole : vecN<AbstractFloat> // whole part
}
</pre>
</td></tr><tr id="builtin-normalize-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn normalize(e: vecN<T> ) -> vecN<T> {{/escapehtml}}</pre></td><td>T is AbstractFloat, f32, or f16</td><td id="normalize-builtin"><a href="https://www.w3.org/TR/WGSL/#normalize-builtin" target="_blank"></a>
Returns a unit vector in the same direction as <code>e</code>.
<p>The domain is all vectors except the zero vector.</p>
</td></tr><tr id="builtin-pow-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pow(e1: T,
e2: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="pow-builtin"><a href="https://www.w3.org/TR/WGSL/#pow-builtin" target="_blank"></a>Returns <code>e1</code> raised to the power <code>e2</code>.
Component-wise when <code>T</code> is a vector.
The set of all pairs of extended reals (<var>x</var>,<var>y</var>) except:
<ul>
<li data-md="">
<p><var>x</var> &lt; 0.</p>
</li><li data-md="">
<p><var>x</var> is 1 and <var>y</var> is infinite.</p>
</li><li data-md="">
<p><var>x</var> is infinite and <var>y</var> is 0.</p>
</li></ul>
<p>This rule arises from the fact the result may be computed as
<code>exp2(y * log2(x))</code>.</p>
</td></tr><tr id="builtin-quantizeToF16-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn quantizeToF16(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="quantizeToF16-builtin"><a href="https://www.w3.org/TR/WGSL/#quantizeToF16-builtin" target="_blank"></a>
Quantizes a 32-bit floating point value <code>e</code> as if <code>e</code> were converted to
a IEEE-754 binary16 value, and then converted back to a
IEEE-754 binary32 value.
<p>If <code>e</code> is outside the finite range of binary16, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>e</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>e</code> is an override-expression.</p>
</li><li data-md="">
<p>Otherwise the result is an indeterminate value for <code>T</code>.</p>
</li></ul>
<p>The intermediate binary16 value may be flushed to zero, i.e. the final
result may be zero if the intermediate binary16 value is subnormal.</p>
<p>See §15.7.6 Floating Point Conversion.</p>
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-radians-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn radians(e1: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="radians-builtin"><a href="https://www.w3.org/TR/WGSL/#radians-builtin" target="_blank"></a>Converts degrees to radians, approximating <code>e1</code>&nbsp;×&nbsp;π&nbsp;÷&nbsp;180.
Component-wise when <code>T</code> is a vector
</td></tr><tr id="builtin-reflect-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn reflect(e1: T,
e2: T) -> T {{/escapehtml}}</pre></td><td>T is vecN&lt;AbstractFloat&gt;, vecN&lt;f32&gt;, or vecN&lt;f16&gt;</td><td id="reflect-builtin"><a href="https://www.w3.org/TR/WGSL/#reflect-builtin" target="_blank"></a>For the incident vector <code>e1</code> and surface orientation <code>e2</code>, returns the reflection direction
<code>e1 - 2 * dot(e2, e1) * e2</code>.
</td></tr><tr id="builtin-refract-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn refract(e1: T,
e2: T,
e3: I) -> T {{/escapehtml}}</pre></td><td>T is vecN&lt;I&gt;
I is AbstractFloat, f32, or f16</td><td id="refract-builtin"><a href="https://www.w3.org/TR/WGSL/#refract-builtin" target="_blank"></a>For the incident vector <code>e1</code> and surface normal <code>e2</code>, and the ratio of
indices of refraction <code>e3</code>,
let <code>k = 1.0 - e3 * e3 * (1.0 - dot(e2, e1) * dot(e2, e1))</code>.
If <code>k &lt; 0.0</code>, returns the refraction vector 0.0, otherwise return the refraction vector
<code>e3 * e1 - (e3 * dot(e2, e1) + sqrt(k)) * e2</code>. The incident vector <code>e1</code> and the normal <code>e2</code>
should be normalized for desired results according to Snells Law; otherwise, the results
may not conform to expected physical behavior.
</td></tr><tr id="builtin-reverseBits-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn reverseBits(e: T) -> T {{/escapehtml}}</pre></td><td>T is i32, u32, vecN&lt;i32&gt;, or vecN&lt;u32&gt;</td><td id="reverseBits-builtin"><a href="https://www.w3.org/TR/WGSL/#reverseBits-builtin" target="_blank"></a>Reverses the bits in <code>e</code>: The bit at position <code>k</code> of the result equals the
bit at position <code>31 -k</code> of <code>e</code>.<br>
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-round-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn round(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="round-builtin"><a href="https://www.w3.org/TR/WGSL/#round-builtin" target="_blank"></a>Result is the integer <code>k</code> nearest to <code>e</code>, as a floating point value.<br>
When <code>e</code> lies halfway between integers <code>k</code> and <code>k + 1</code>,
the result is <code>k</code> when <code>k</code> is even, and <code>k + 1</code> when <code>k</code> is odd.<br>
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-saturate-float-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn saturate(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="saturate-float-builtin"><a href="https://www.w3.org/TR/WGSL/#saturate-float-builtin" target="_blank"></a>Returns <code>clamp(e, 0.0, 1.0)</code>.
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-sign-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn sign(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractInt, AbstractFloat, i32, f32, or f16
T is S, or vecN&lt;S&gt;</td><td id="sign-builtin"><a href="https://www.w3.org/TR/WGSL/#sign-builtin" target="_blank"></a>
Result is:
<ul>
<li> 1 when <code>e</code> &gt; 0
</li><li> 0 when <code>e</code> = 0
</li><li> -1 when <code>e</code> &lt; 0
</li></ul>
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-sin-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn sin(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="sin-builtin"><a href="https://www.w3.org/TR/WGSL/#sin-builtin" target="_blank"></a>Returns the sine of <code>e</code>, where <code>e</code> is in radians.
Component-wise when <code>T</code> is a vector.
Interval (−∞, +∞)
</td></tr><tr id="builtin-sinh-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn sinh(a: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="sinh-builtin"><a href="https://www.w3.org/TR/WGSL/#sinh-builtin" target="_blank"></a>
Returns the hyperbolic sine of <code>a</code>, where <code>a</code> is a hyperbolic angle.
Approximates the pure mathematical function
(<em>e</em><sup>a</sup> <em>e</em><sup>a</sup>)÷2,
but not necessarily computed that way.
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-smoothstep-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn smoothstep(edge0: T,
edge1: T,
x: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="smoothstep-builtin"><a href="https://www.w3.org/TR/WGSL/#smoothstep-builtin" target="_blank"></a>
Returns the smooth Hermite interpolation between 0 and 1.
Component-wise when <code>T</code> is a vector.
<p>For scalar <code>T</code>, the result is
<code>t * t * (3.0 - 2.0 * t)</code>,<br>
where <code>t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0)</code>.</p>
<p>Qualitatively:</p>
<ul>
<li data-md="">
<p>When <code>edge0</code> &lt; <code>edge1</code>, the function is 0 for <code>x</code> below <code>edge0</code>, then smoothly rises
until <code>x</code> reaches <code>edge1</code>, and remains at 1 afterward.</p>
</li><li data-md="">
<p>When <code>edge0</code> &gt; <code>edge1</code>, the function is 1 for <code>x</code> below <code>edge1</code>, then smoothly descends
until <code>x</code> reaches <code>edge0</code>, and remains at 0 afterward.</p>
</li></ul>
<p>If <code>edge0</code> = <code>edge1</code>:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>edge0</code> and <code>edge1</code> are const-expressions.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>edge0</code> and <code>edge1</code> are override-expressions.</p>
</li><li data-md="">
<p>Otherwise, the result is an indeterminate value for <code>T</code>.
In this case the computation performs a floating point division by zero,
and the Finite Math Assumption applies.</p>
</li></ul>
</td></tr><tr id="builtin-sqrt-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn sqrt(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="sqrt-builtin"><a href="https://www.w3.org/TR/WGSL/#sqrt-builtin" target="_blank"></a>Returns the square root of <code>e</code>.
Component-wise when <code>T</code> is a vector.
Interval [0, +∞]
</td></tr><tr id="builtin-step-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn step(edge: T,
x: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="step-builtin"><a href="https://www.w3.org/TR/WGSL/#step-builtin" target="_blank"></a>Returns 1.0 if <code>edge</code><code>x</code>, and 0.0 otherwise.
Component-wise when <code>T</code> is a vector.
</td></tr><tr id="builtin-tan-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn tan(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="tan-builtin"><a href="https://www.w3.org/TR/WGSL/#tan-builtin" target="_blank"></a>Returns the tangent of <code>e</code>, where <code>e</code> is in radians.
Component-wise when <code>T</code> is a vector.
Interval (−∞, +∞)
</td></tr><tr id="builtin-tanh-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn tanh(a: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="tanh-builtin"><a href="https://www.w3.org/TR/WGSL/#tanh-builtin" target="_blank"></a>
Returns the hyperbolic tangent of <code>a</code>, where <code>a</code> is a hyperbolic angle.
Approximates the pure mathematical function
(<em>e</em><sup>a</sup> <em>e</em><sup>a</sup>) ÷ (<em>e</em><sup>a</sup> + <em>e</em><sup>a</sup>)
but not necessarily computed that way.
<p>Component-wise when <code>T</code> is a vector.</p>
</td></tr><tr id="builtin-transpose-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn transpose(e: matRxC<T>) -> matCxR<T> {{/escapehtml}}</pre></td><td>T is AbstractFloat, f32, or f16</td><td id="transpose-builtin"><a href="https://www.w3.org/TR/WGSL/#transpose-builtin" target="_blank"></a>Returns the transpose of <code>e</code>.
</td></tr><tr id="builtin-trunc-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn trunc(e: T) -> T {{/escapehtml}}</pre></td><td>S is AbstractFloat, f32, or f16
T is S or vecN&lt;S&gt;</td><td id="trunc-builtin"><a href="https://www.w3.org/TR/WGSL/#trunc-builtin" target="_blank"></a>Returns truncate(<code>e</code>), the nearest whole number whose absolute value
is less than or equal to the absolute value of <code>e</code>.
Component-wise when <code>T</code> is a vector.
</td></tr></tbody></table><h2 id="derivative-builtin-functions">Derivative Built-in Functions</h2><table id="functions-derivative-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-dpdx-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dpdx(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="dpdx-builtin"><a href="https://www.w3.org/TR/WGSL/#dpdx-builtin" target="_blank"></a>
Partial derivative of <code>e</code> with respect to window x coordinates.
The result is the same as either <code>dpdxFine(e)</code> or <code>dpdxCoarse(e)</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-dpdxCoarse-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dpdxCoarse(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="dpdxCoarse-builtin"><a href="https://www.w3.org/TR/WGSL/#dpdxCoarse-builtin" target="_blank"></a>
Returns the partial derivative of <code>e</code> with respect to window x coordinates using local differences.
This may result in fewer unique positions than <code>dpdxFine(e)</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-dpdxFine-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dpdxFine(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="dpdxFine-builtin"><a href="https://www.w3.org/TR/WGSL/#dpdxFine-builtin" target="_blank"></a>
Returns the partial derivative of <code>e</code> with respect to window x coordinates.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-dpdy-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dpdy(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="dpdy-builtin"><a href="https://www.w3.org/TR/WGSL/#dpdy-builtin" target="_blank"></a>
Partial derivative of <code>e</code> with respect to window y coordinates.
The result is the same as either <code>dpdyFine(e)</code> or <code>dpdyCoarse(e)</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-dpdyCoarse-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dpdyCoarse(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="dpdyCoarse-builtin"><a href="https://www.w3.org/TR/WGSL/#dpdyCoarse-builtin" target="_blank"></a>
Returns the partial derivative of <code>e</code> with respect to window y coordinates using local differences.
This may result in fewer unique positions than <code>dpdyFine(e)</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-dpdyFine-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn dpdyFine(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="dpdyFine-builtin"><a href="https://www.w3.org/TR/WGSL/#dpdyFine-builtin" target="_blank"></a>
Returns the partial derivative of <code>e</code> with respect to window y coordinates.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-fwidth-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn fwidth(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="fwidth-builtin"><a href="https://www.w3.org/TR/WGSL/#fwidth-builtin" target="_blank"></a>
Returns <code>abs(dpdx(e)) + abs(dpdy(e))</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-fwidthCoarse-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn fwidthCoarse(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="fwidthCoarse-builtin"><a href="https://www.w3.org/TR/WGSL/#fwidthCoarse-builtin" target="_blank"></a>
Returns <code>abs(dpdxCoarse(e)) + abs(dpdyCoarse(e))</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr><tr id="builtin-fwidthFine-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn fwidthFine(e: T) -> T {{/escapehtml}}</pre></td><td>T is f32 or vecN&lt;f32&gt;</td><td id="fwidthFine-builtin"><a href="https://www.w3.org/TR/WGSL/#fwidthFine-builtin" target="_blank"></a>
Returns <code>abs(dpdxFine(e)) + abs(dpdyFine(e))</code>.
<p>Returns an indeterminate value if called in non-uniform control flow.</p>
</td></tr></tbody></table><h2 id="texture-builtin-functions">Texture Built-in Functions</h2><table id="functions-texture-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-texturedimensions"><td class="full-description" colspan="3" id="texturedimensions"><a href="https://www.w3.org/TR/WGSL/#texturedimensions" target="_blank"></a><code class="builtin" data-name="textureDimensions">textureDimensions</code><div><p>Returns the dimensions of a texture, or textures mip level in texels.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled,
multisampled, depth,
storage, or external texture.
</td></tr><tr>
<td><code>level</code>
</td><td>
The mip level, with level 0 containing a full size version of the texture.<br>
If omitted, the dimensions of level 0 are returned.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The coordinate dimensions of the texture.</p><p>That is, the result provides the integer bounds on the coordinates of the logical texel address,
excluding the mip level count, array size, and sample count.</p><p>For textures based on cubes, the results are the dimensions of each face of the cube.
Cube faces are square, so the x and y components of the result are equal.</p><p>If <code>level</code> is outside the range <code>[0, textureNumLevels(t))</code> then an indeterminate value
for the return type may be returned.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureDimensions(t: T) -> u32 {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
F is a texel format
A is an access mode
T is texture_1d&lt;ST&gt; or texture_storage_1d&lt;F,A&gt;</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureDimensions(t: T,
level: L) -> u32 {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
T is texture_1d&lt;ST&gt;
L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureDimensions(t: T) -> vec2<u32> {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
F is a texel format
A is an access mode
T is texture_2d&lt;ST&gt;, texture_2d_array&lt;ST&gt;, texture_cube&lt;ST&gt;,
texture_cube_array&lt;ST&gt;, texture_multisampled_2d&lt;ST&gt;,
texture_depth_2d, texture_depth_2d_array, texture_depth_cube,
texture_depth_cube_array, texture_depth_multisampled_2d,
texture_storage_2d&lt;F,A&gt;, texture_storage_2d_array&lt;F,A&gt;,
or texture_external</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureDimensions(t: T,
level: L) -> vec2<u32> {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
T is texture_2d&lt;ST&gt;, texture_2d_array&lt;ST&gt;, texture_cube&lt;ST&gt;,
texture_cube_array&lt;ST&gt;, texture_depth_2d, texture_depth_2d_array,
texture_depth_cube, or texture_depth_cube_array
L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureDimensions(t: T) -> vec3<u32> {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
F is a texel format
A is an access mode
T is texture_3d&lt;ST&gt; or texture_storage_3d&lt;F,A&gt;</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureDimensions(t: T,
level: L) -> vec3<u32> {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
T is texture_3d&lt;ST&gt;
L is i32, or u32</td><td></td></tr><tr id="builtin-texturegather"><td class="full-description" colspan="3" id="texturegather"><a href="https://www.w3.org/TR/WGSL/#texturegather" target="_blank"></a><code class="builtin" data-name="textureGather">textureGather</code><div><p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="texture-gather">texture gather</dfn> operation reads from a 2D, 2D array, cube, or cube array texture,
computing a four-component vector as follows:</p><ul>
<li data-md="">
<p>Find the four texels that would be used in a sampling operation with linear filtering,
from mip level 0:</p>
<ul>
<li data-md="">
<p>Use the specified coordinate, array index (when present), and offset (when present).</p>
</li><li data-md="">
<p>The texels are adjacent, forming a square, when considering their texture space coordinates (<em>u</em>,<em>v</em>).</p>
</li><li data-md="">
<p>Selected texels at the texture edge, cube face edge, or cube corners are handled
as in ordinary texture sampling.</p>
</li></ul>
</li><li data-md="">
<p>For each texel, read one channel and convert it into a scalar value.</p>
<ul>
<li data-md="">
<p>For non-depth textures, a zero-based <code>component</code> parameter specifies the channel to use.</p>
<ul>
<li data-md="">
<p>If the texture format supports the specified channel, i.e. has more than <code>component</code> channels:</p>
<ul>
<li data-md="">
<p>Yield scalar value <code>v[component]</code> when the texel value is <code>v</code>.</p>
</li></ul>
</li><li data-md="">
<p>Otherwise:</p>
<ul>
<li data-md="">
<p>Yield 0.0 when <code>component</code> is 1 or 2.</p>
</li><li data-md="">
<p>Yield 1.0 when <code>component</code> is 3 (the alpha channel).</p>
</li></ul>
</li></ul>
</li><li data-md="">
<p>For depth textures, yield the texel value. (Depth textures only have one channel.)</p>
</li></ul>
</li><li data-md="">
<p>Yield the four-component vector, arranging scalars produced by the previous step into components
according to the relative coordinates of the texels, as follows:</p>
<ul>
<li data-md="">
<table>
<thead class="data">
<tr>
<td>Result component
</td><td>Relative texel coordinate
</td></tr></thead><tbody>
<tr>
<td>x
</td><td>(<em>u</em><sub>min</sub>,<em>v</em><sub>max</sub>)
</td></tr><tr>
<td>y
</td><td>(<em>u</em><sub>max</sub>,<em>v</em><sub>max</sub>)
</td></tr><tr>
<td>z
</td><td>(<em>u</em><sub>max</sub>,<em>v</em><sub>min</sub>)
</td></tr><tr>
<td>w
</td><td>(<em>u</em><sub>min</sub>,<em>v</em><sub>min</sub>)
</td></tr></tbody></table>
</li></ul>
</li></ul><p>The four texels form the sampled area as described in the
WebGPU sampler descriptor.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>component</code>
</td><td>
Only applies to non-depth textures.
<br>The index of the channel to read from the selected texels.
<br>When provided, the <code>component</code> expression must be a const-expression (e.g. <code>1</code>).<br>
Its value must be at least 0 and at most 3.
Values outside of this range will result in a shader-creation error.
</td></tr><tr>
<td><code>t</code>
</td><td>
The sampled or depth texture to read from.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>A four component vector with components extracted from the specified channel from the selected texels, as described above.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(component: C,
t: texture_2d<ST>,
s: sampler,
coords: vec2<f32>) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(component: C,
t: texture_2d<ST>,
s: sampler,
coords: vec2<f32>,
offset: vec2<i32>) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(component: C,
t: texture_2d_array<ST>,
s: sampler,
coords: vec2<f32>,
array_index: A) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
A is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(component: C,
t: texture_2d_array<ST>,
s: sampler,
coords: vec2<f32>,
array_index: A,
offset: vec2<i32>) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
A is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(component: C,
t: texture_cube<ST>,
s: sampler,
coords: vec3<f32>) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(component: C,
t: texture_cube_array<ST>,
s: sampler,
coords: vec3<f32>,
array_index: A) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
A is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(t: texture_depth_2d,
s: sampler,
coords: vec2<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(t: texture_depth_2d,
s: sampler,
coords: vec2<f32>,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(t: texture_depth_cube,
s: sampler,
coords: vec3<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(t: texture_depth_2d_array,
s: sampler,
coords: vec2<f32>,
array_index: A) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(t: texture_depth_2d_array,
s: sampler,
coords: vec2<f32>,
array_index: A,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGather(t: texture_depth_cube_array,
s: sampler,
coords: vec3<f32>,
array_index: A) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-texturegathercompare"><td class="full-description" colspan="3" id="texturegathercompare"><a href="https://www.w3.org/TR/WGSL/#texturegathercompare" target="_blank"></a><code class="builtin" data-name="textureGatherCompare">textureGatherCompare</code><div><p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="texture-gather-compare">texture gather compare</dfn> operation performs a depth comparison on four texels in a depth
texture and collects the results into a single vector, as follows:</p><ul>
<li data-md="">
<p>Find the four texels that would be used in a depth sampling operation with linear filtering,
from mip level 0:</p>
<ul>
<li data-md="">
<p>Use the specified coordinate, array index (when present), and offset (when present).</p>
</li><li data-md="">
<p>The texels are adjacent, forming a square, when considering their texture space coordinates (<em>u</em>,<em>v</em>).</p>
</li><li data-md="">
<p>Selected texels at the texture edge, cube face edge, or cube corners are handled
as in ordinary texture sampling.</p>
</li></ul>
</li><li data-md="">
<p>For each texel, perform a comparison against the depth reference value,
yielding a 0.0 or 1.0 value, as controlled by the comparison sampler parameters.</p>
</li><li data-md="">
<p>Yield the four-component vector where the components are the comparison results with the texels with
relative texel coordinates as follows:</p>
<ul>
<li data-md="">
<table>
<thead class="data">
<tr>
<td>Result component
</td><td>Relative texel coordinate
</td></tr></thead><tbody>
<tr>
<td>x
</td><td>(<em>u</em><sub>min</sub>,<em>v</em><sub>max</sub>)
</td></tr><tr>
<td>y
</td><td>(<em>u</em><sub>max</sub>,<em>v</em><sub>max</sub>)
</td></tr><tr>
<td>z
</td><td>(<em>u</em><sub>max</sub>,<em>v</em><sub>min</sub>)
</td></tr><tr>
<td>w
</td><td>(<em>u</em><sub>min</sub>,<em>v</em><sub>min</sub>)
</td></tr></tbody></table>
</li></ul>
</li></ul><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The depth texture to read from.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler comparison.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>depth_ref</code>
</td><td>
The reference value to compare the sampled depth value against.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>A four component vector with comparison result for the selected texels, as described above.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGatherCompare(t: texture_depth_2d,
s: sampler_comparison,
coords: vec2<f32>,
depth_ref: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGatherCompare(t: texture_depth_2d,
s: sampler_comparison,
coords: vec2<f32>,
depth_ref: f32,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGatherCompare(t: texture_depth_2d_array,
s: sampler_comparison,
coords: vec2<f32>,
array_index: A,
depth_ref: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGatherCompare(t: texture_depth_2d_array,
s: sampler_comparison,
coords: vec2<f32>,
array_index: A,
depth_ref: f32,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGatherCompare(t: texture_depth_cube,
s: sampler_comparison,
coords: vec3<f32>,
depth_ref: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureGatherCompare(t: texture_depth_cube_array,
s: sampler_comparison,
coords: vec3<f32>,
array_index: A,
depth_ref: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-textureload"><td class="full-description" colspan="3" id="textureload"><a href="https://www.w3.org/TR/WGSL/#textureload" target="_blank"></a><code class="builtin" data-name="textureLoad">textureLoad</code><div><p>Reads a single texel from a texture without sampling or filtering.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled,
multisampled,
depth,
storage, or
external
texture
</td></tr><tr>
<td><code>coords</code>
</td><td>
The 0-based texel coordinate.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index.
</td></tr><tr>
<td><code>level</code>
</td><td>
The mip level, with level 0 containing a full size version of the texture.
</td></tr><tr>
<td><code>sample_index</code>
</td><td>
The 0-based sample index of the multisampled texture.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The unfiltered texel data.</p><p>The logical texel address is invalid if:</p><ul>
<li data-md="">
<p>any element of <code>coords</code> is outside the range <code>[0, textureDimensions(t, level))</code>
for the corresponding element, or</p>
</li><li data-md="">
<p><code>array_index</code> is outside the range <code>[0, textureNumLayers(t))</code>, or</p>
</li><li data-md="">
<p><code>level</code> is outside the range <code>[0, textureNumLevels(t))</code>, or</p>
</li><li data-md="">
<p><code>sample_index</code> is outside the range <code>[0, textureNumSamples(s))</code></p>
</li></ul><p>If the logical texel address is invalid, the built-in function returns one of:</p><ul>
<li data-md="">
<p>The data for some texel within bounds of the texture.</p>
</li><li data-md="">
<p>For non-depth textures, either:</p>
<ul>
<li data-md="">
<p>The vector (0,0,0,0) or (0,0,0,1) of the appropriate type, with the texture view swizzle applied, or</p>
</li><li data-md="">
<p>The vector (0,0,0,0) or (0,0,0,1) of the appropriate type, without the texture view swizzle applied.</p>
</li></ul>
</li><li data-md="">
<p>0.0 for depth textures.</p>
</li></ul></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_1d<ST>,
coords: C,
level: L) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
L is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_2d<ST>,
coords: vec2<C>,
level: L) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
L is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_2d_array<ST>,
coords: vec2<C>,
array_index: A,
level: L) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
A is i32, or u32
L is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_3d<ST>,
coords: vec3<C>,
level: L) -> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
L is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_multisampled_2d<ST>,
coords: vec2<C>,
sample_index: S)-> vec4<ST> {{/escapehtml}}</pre></td><td>C is i32, or u32
S is i32, or u32
ST is i32, u32, or f32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_depth_2d,
coords: vec2<C>,
level: L) -> f32 {{/escapehtml}}</pre></td><td>C is i32, or u32
L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_depth_2d_array,
coords: vec2<C>,
array_index: A,
level: L) -> f32 {{/escapehtml}}</pre></td><td>C is i32, or u32
A is i32, or u32
L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_depth_multisampled_2d,
coords: vec2<C>,
sample_index: S)-> f32 {{/escapehtml}}</pre></td><td>C is i32, or u32
S is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t: texture_external,
coords: vec2<C>) -> vec4<f32> {{/escapehtml}}</pre></td><td>C is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t : texture_storage_1d<F, AM>,
coords : C) -> vec4<CF> {{/escapehtml}}</pre></td><td>C is i32, or u32
AM is read or read_write
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t : texture_storage_2d<F, AM>,
coords : vec2<C>) -> vec4<CF> {{/escapehtml}}</pre></td><td>C is i32, or u32
AM is read or read_write
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t : texture_storage_2d_array<F, AM>,
coords : vec2<C>,
array_index : A) -> vec4<CF> {{/escapehtml}}</pre></td><td>C is i32, or u32
AM is read or read_write
A is i32 or u32
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureLoad(t : texture_storage_3d<F, AM>,
coords : vec3<C>) -> vec4<CF> {{/escapehtml}}</pre></td><td>C is i32, or u32
AM is read or read_write
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr id="builtin-texturenumlayers"><td class="full-description" colspan="3" id="texturenumlayers"><a href="https://www.w3.org/TR/WGSL/#texturenumlayers" target="_blank"></a><code class="builtin" data-name="textureNumLayers">textureNumLayers</code><div><p>Returns the number of layers (elements) of an arrayed texture.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled,
depth, or
storage texture array texture.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>If the texture is based on cubes, returns the number of cubes in the cube arrayed texture.</p><p>Otherwise returns the number of layers (homogeneous grids of texels) in the arrayed texture.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureNumLayers(t: T) -> u32 {{/escapehtml}}</pre></td><td>F is a texel format
A is an access mode
ST is i32, u32, or f32
T is texture_2d_array&lt;ST&gt;, texture_cube_array&lt;ST&gt;,
texture_depth_2d_array, texture_depth_cube_array,
or texture_storage_2d_array&lt;F,A&gt;</td><td></td></tr><tr id="builtin-texturenumlevels"><td class="full-description" colspan="3" id="texturenumlevels"><a href="https://www.w3.org/TR/WGSL/#texturenumlevels" target="_blank"></a><code class="builtin" data-name="textureNumLevels">textureNumLevels</code><div><p>Returns the number of mip levels of a texture.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled or depth texture.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The mip level count for the texture.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureNumLevels(t: T) -> u32 {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
T is texture_1d&lt;ST&gt;, texture_2d&lt;ST&gt;,
texture_2d_array&lt;ST&gt;, texture_3d&lt;ST&gt;,
texture_cube&lt;ST&gt;, texture_cube_array&lt;ST&gt;,
texture_depth_2d, texture_depth_2d_array,
texture_depth_cube, or texture_depth_cube_array</td><td></td></tr><tr id="builtin-texturenumsamples"><td class="full-description" colspan="3" id="texturenumsamples"><a href="https://www.w3.org/TR/WGSL/#texturenumsamples" target="_blank"></a><code class="builtin" data-name="textureNumSamples">textureNumSamples</code><div><p>Returns the number samples per texel in a multisampled texture.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The multisampled texture.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The sample count for the multisampled texture.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureNumSamples(t: T) -> u32 {{/escapehtml}}</pre></td><td>ST is i32, u32, or f32
T is texture_multisampled_2d&lt;ST&gt;
or texture_depth_multisampled_2d</td><td></td></tr><tr id="builtin-texturesample"><td class="full-description" colspan="3" id="texturesample"><a href="https://www.w3.org/TR/WGSL/#texturesample" target="_blank"></a><code class="builtin" data-name="textureSample">textureSample</code><div><p>Samples a texture.</p><p>Must only be used in a fragment shader stage.</p><p>If uniformity analysis cannot prove a call to this function is in uniform control flow,
then a derivative_uniformity diagnostic is triggered.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled or depth
texture to sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index to sample.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The sampled value.</p><p>An indeterminate value results if called in non-uniform control flow.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_1d<f32>,
s: sampler,
coords: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: T,
s: sampler,
coords: vec3<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>T is texture_3d&lt;f32&gt;, or texture_cube&lt;f32&gt;</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_3d<f32>,
s: sampler,
coords: vec3<f32>,
offset: vec3<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_cube_array<f32>,
s: sampler,
coords: vec3<f32>,
array_index: A) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_depth_2d,
s: sampler,
coords: vec2<f32>) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_depth_2d,
s: sampler,
coords: vec2<f32>,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_depth_2d_array,
s: sampler,
coords: vec2<f32>,
array_index: A) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_depth_2d_array,
s: sampler,
coords: vec2<f32>,
array_index: A,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_depth_cube,
s: sampler,
coords: vec3<f32>) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSample(t: texture_depth_cube_array,
s: sampler,
coords: vec3<f32>,
array_index: A) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-texturesamplebias"><td class="full-description" colspan="3" id="texturesamplebias"><a href="https://www.w3.org/TR/WGSL/#texturesamplebias" target="_blank"></a><code class="builtin" data-name="textureSampleBias">textureSampleBias</code><div><p>Samples a texture with a bias to the mip level.</p><p>Must only be used in a fragment shader stage.</p><p>If uniformity analysis cannot prove a call to this function is in uniform control flow,
then a derivative_uniformity diagnostic is triggered.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled texture to sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index to sample.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>bias</code>
</td><td>
The bias to apply to the mip level before sampling.<br>
This value will be clamped in the range <code>[-16.0, 15.99]</code>.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The sampled value.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
bias: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
bias: f32,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
bias: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
bias: f32,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: T,
s: sampler,
coords: vec3<f32>,
bias: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>T is texture_3d&lt;f32&gt;, or texture_cube&lt;f32&gt;</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: texture_3d<f32>,
s: sampler,
coords: vec3<f32>,
bias: f32,
offset: vec3<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBias(t: texture_cube_array<f32>,
s: sampler,
coords: vec3<f32>,
array_index: A,
bias: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-texturesamplecompare"><td class="full-description" colspan="3" id="texturesamplecompare"><a href="https://www.w3.org/TR/WGSL/#texturesamplecompare" target="_blank"></a><code class="builtin" data-name="textureSampleCompare">textureSampleCompare</code><div><p>Samples a depth texture and compares the sampled depth values against a reference value.</p><p>Must only be used in a fragment shader stage.</p><p>If uniformity analysis cannot prove a call to this function is in uniform control flow,
then a derivative_uniformity diagnostic is triggered.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The depth texture to sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler_comparison type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index to sample.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>depth_ref</code>
</td><td>
The reference value to compare the sampled depth value against.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>A value in the range <code>[0.0..1.0]</code>.</p><p>Each sampled texel is compared against the reference value using the comparison
operator defined by the <code>sampler_comparison</code>, resulting in either a <code>0</code> or <code>1</code>
value for each texel.</p><p>If the sampler uses bilinear filtering then the returned value is
the filtered average of these values, otherwise the comparison result of a
single texel is returned.</p><p>An indeterminate value results if called in non-uniform control flow.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompare(t: texture_depth_2d,
s: sampler_comparison,
coords: vec2<f32>,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompare(t: texture_depth_2d,
s: sampler_comparison,
coords: vec2<f32>,
depth_ref: f32,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompare(t: texture_depth_2d_array,
s: sampler_comparison,
coords: vec2<f32>,
array_index: A,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompare(t: texture_depth_2d_array,
s: sampler_comparison,
coords: vec2<f32>,
array_index: A,
depth_ref: f32,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompare(t: texture_depth_cube,
s: sampler_comparison,
coords: vec3<f32>,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompare(t: texture_depth_cube_array,
s: sampler_comparison,
coords: vec3<f32>,
array_index: A,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-texturesamplecomparelevel"><td class="full-description" colspan="3" id="texturesamplecomparelevel"><a href="https://www.w3.org/TR/WGSL/#texturesamplecomparelevel" target="_blank"></a><code class="builtin" data-name="textureSampleCompareLevel">textureSampleCompareLevel</code><div><p>Samples a depth texture and compares the sampled depth values against a reference value.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The depth texture to sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler_comparison type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index to sample.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>depth_ref</code>
</td><td>
The reference value to compare the sampled depth value against.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>A value in the range <code>[0.0..1.0]</code>.</p><p>The <code>textureSampleCompareLevel</code> function is the same as <code>textureSampleCompare</code>, except that:</p><ul>
<li data-md="">
<p><code>textureSampleCompareLevel</code> always samples texels from mip level 0.</p>
<ul>
<li data-md="">
<p>The function does not compute derivatives.</p>
</li><li data-md="">
<p>There is no requirement for <code>textureSampleCompareLevel</code> to be invoked in uniform control flow.</p>
</li></ul>
</li><li data-md="">
<p><code>textureSampleCompareLevel</code> may be invoked in any shader stage.</p>
</li></ul></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompareLevel(t: texture_depth_2d,
s: sampler_comparison,
coords: vec2<f32>,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompareLevel(t: texture_depth_2d,
s: sampler_comparison,
coords: vec2<f32>,
depth_ref: f32,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompareLevel(t: texture_depth_2d_array,
s: sampler_comparison,
coords: vec2<f32>,
array_index: A,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompareLevel(t: texture_depth_2d_array,
s: sampler_comparison,
coords: vec2<f32>,
array_index: A,
depth_ref: f32,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompareLevel(t: texture_depth_cube,
s: sampler_comparison,
coords: vec3<f32>,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleCompareLevel(t: texture_depth_cube_array,
s: sampler_comparison,
coords: vec3<f32>,
array_index: A,
depth_ref: f32) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-texturesamplegrad"><td class="full-description" colspan="3" id="texturesamplegrad"><a href="https://www.w3.org/TR/WGSL/#texturesamplegrad" target="_blank"></a><code class="builtin" data-name="textureSampleGrad">textureSampleGrad</code><div><p>Samples a texture using explicit gradients.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled texture to sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index to sample.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>ddx</code>
</td><td>
The x direction derivative vector used to compute the sampling locations.
</td></tr><tr>
<td><code>ddy</code>
</td><td>
The y direction derivative vector used to compute the sampling locations.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The sampled value.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
ddx: vec2<f32>,
ddy: vec2<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
ddx: vec2<f32>,
ddy: vec2<f32>,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
ddx: vec2<f32>,
ddy: vec2<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
ddx: vec2<f32>,
ddy: vec2<f32>,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: T,
s: sampler,
coords: vec3<f32>,
ddx: vec3<f32>,
ddy: vec3<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>T is texture_3d&lt;f32&gt;, or texture_cube&lt;f32&gt;</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: texture_3d<f32>,
s: sampler,
coords: vec3<f32>,
ddx: vec3<f32>,
ddy: vec3<f32>,
offset: vec3<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleGrad(t: texture_cube_array<f32>,
s: sampler,
coords: vec3<f32>,
array_index: A,
ddx: vec3<f32>,
ddy: vec3<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr id="builtin-texturesamplelevel"><td class="full-description" colspan="3" id="texturesamplelevel"><a href="https://www.w3.org/TR/WGSL/#texturesamplelevel" target="_blank"></a><code class="builtin" data-name="textureSampleLevel">textureSampleLevel</code><div><p>Samples a texture using an explicit mip level.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled or depth texture to
sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index to sample.<br>
This value will be clamped to the range <code>[0, textureNumLayers(t) - 1]</code>.
</td></tr><tr>
<td><code>level</code>
</td><td>
The mip level, with level 0 containing a full size version of the texture.
For the functions where <code>level</code> is a <code>f32</code>, fractional values may interpolate
between two levels if the format is filterable according to the
Texture Format Capabilities.
</td></tr><tr>
<td><code>offset</code>
</td><td>
The optional texel offset applied to the unnormalized texture coordinate
before sampling the texture. This offset is applied before applying any
texture wrapping modes.<br>
The <code>offset</code> expression must be a const-expression (e.g. <code>vec2&lt;i32&gt;(1, 2)</code>).<br>
Each <code>offset</code> component must be at least <code>-8</code> and at most <code>7</code>. Values outside
of this range will result in a shader-creation error.
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The sampled value.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_1d<f32>,
s: sampler,
coords: f32,
level: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
level: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_2d<f32>,
s: sampler,
coords: vec2<f32>,
level: f32,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
level: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_2d_array<f32>,
s: sampler,
coords: vec2<f32>,
array_index: A,
level: f32,
offset: vec2<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: T,
s: sampler,
coords: vec3<f32>,
level: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>T is texture_3d&lt;f32&gt;, or texture_cube&lt;f32&gt;</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_3d<f32>,
s: sampler,
coords: vec3<f32>,
level: f32,
offset: vec3<i32>) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_cube_array<f32>,
s: sampler,
coords: vec3<f32>,
array_index: A,
level: f32) -> vec4<f32> {{/escapehtml}}</pre></td><td>A is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_depth_2d,
s: sampler,
coords: vec2<f32>,
level: L) -> f32 {{/escapehtml}}</pre></td><td>L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_depth_2d,
s: sampler,
coords: vec2<f32>,
level: L,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td>L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_depth_2d_array,
s: sampler,
coords: vec2<f32>,
array_index: A,
level: L) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32
L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_depth_2d_array,
s: sampler,
coords: vec2<f32>,
array_index: A,
level: L,
offset: vec2<i32>) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32
L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_depth_cube,
s: sampler,
coords: vec3<f32>,
level: L) -> f32 {{/escapehtml}}</pre></td><td>L is i32, or u32</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleLevel(t: texture_depth_cube_array,
s: sampler,
coords: vec3<f32>,
array_index: A,
level: L) -> f32 {{/escapehtml}}</pre></td><td>A is i32, or u32
L is i32, or u32</td><td></td></tr><tr id="builtin-textureSampleBaseClampToEdge"><td class="full-description" colspan="3" id="textureSampleBaseClampToEdge"><a href="https://www.w3.org/TR/WGSL/#textureSampleBaseClampToEdge" target="_blank"></a><code class="builtin" data-name="textureSampleBaseClampToEdge">textureSampleBaseClampToEdge</code><div><p>Samples a texture view at its base level,
with texture coordinates clamped to the edge as described below.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The sampled or external texture to sample.
</td></tr><tr>
<td><code>s</code>
</td><td>
The sampler type.
</td></tr><tr>
<td><code>coords</code>
</td><td>
The texture coordinates used for sampling.
<p>Before sampling, the given coordinates will be clamped to the rectangle</p>
<blockquote>
<p>[ <em>half_texel</em>, 1 - <em>half_texel</em> ]</p>
</blockquote>
<p>where</p>
<blockquote>
<p><em>half_texel</em> = vec2(0.5) / vec2&lt;f32&gt;(textureDimensions(t))</p>
</blockquote>
<p class="note" role="note"><span class="marker">Note:</span> The half-texel adjustment ensures that,
independent of the samplers <code class="idl">addressing</code>
and <code class="idl">filter</code> modes,
wrapping will not occur.
That is, when sampling near an edge, the sampled texels
will be at or adjacent to that edge, and not selected from the opposite edge.</p>
</td></tr></tbody></table><p><strong>Returns:</strong></p><p>The sampled value.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureSampleBaseClampToEdge(t: T,
s: sampler,
coords: vec2<f32>) -> vec4<f32> {{/escapehtml}}</pre></td><td>T is texture_2d&lt;f32&gt; or texture_external</td><td></td></tr><tr id="builtin-texturestore"><td class="full-description" colspan="3" id="texturestore"><a href="https://www.w3.org/TR/WGSL/#texturestore" target="_blank"></a><code class="builtin" data-name="textureStore">textureStore</code><div><p>Writes a single texel to a texture.</p><p><strong>Parameters:</strong></p><table class="data">
<tbody>
<tr>
<td><code>t</code>
</td><td>
The write-only storage texture or
read-write storage texture
</td></tr><tr>
<td><code>coords</code>
</td><td>
The 0-based texel coordinate.<br>
</td></tr><tr>
<td><code>array_index</code>
</td><td>
The 0-based texture array index.
</td></tr><tr>
<td><code>value</code>
</td><td>
The new texel value.
<code>value</code> is converted using the inverse channel transfer function.
</td></tr></tbody></table><p><strong>Note:</strong></p><p>The logical texel address is invalid if:</p><ul>
<li data-md="">
<p>any element of <code>coords</code> is outside the range <code>[0, textureDimensions(t))</code>
for the corresponding element, or</p>
</li><li data-md="">
<p><code>array_index</code> is outside the range of <code>[0, textureNumLayers(t))</code></p>
</li></ul><p>If the logical texel address is invalid, the built-in function will not be executed.</p></div></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureStore(t: texture_storage_1d<F,AM>,
coords: C,
value: vec4<CF>) {{/escapehtml}}</pre></td><td>F is a texel format
C is i32, or u32
AM is write or read_write
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureStore(t: texture_storage_2d<F,AM>,
coords: vec2<C>,
value: vec4<CF>) {{/escapehtml}}</pre></td><td>F is a texel format
C is i32, or u32
AM is write or read_write
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureStore(t: texture_storage_2d_array<F,AM>,
coords: vec2<C>,
array_index: A,
value: vec4<CF>) {{/escapehtml}}</pre></td><td>F is a texel format
C is i32, or u32
AM is write or read_write
A is i32, or u32
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr><tr><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureStore(t: texture_storage_3d<F,AM>,
coords: vec3<C>,
value: vec4<CF>) {{/escapehtml}}</pre></td><td>F is a texel format
C is i32, or u32
AM is write or read_write
CF depends on the storage texel format F.
See the texel format table for the mapping of texel
format to channel format.</td><td></td></tr></tbody></table><h2 id="atomic-builtin-functions">Atomic Built-in Functions</h2><table id="functions-atomic-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-atomic-load"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicLoad(atomic_ptr: ptr<AS, atomic<T>, read_write>) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-load"><a href="https://www.w3.org/TR/WGSL/#atomic-load" target="_blank"></a><p>Returns the atomically loaded the value pointed to by <code>atomic_ptr</code>.
It does not modify the object.</p></td></tr><tr id="builtin-atomic-store"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicStore(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) {{/escapehtml}}</pre></td><td></td><td id="atomic-store"><a href="https://www.w3.org/TR/WGSL/#atomic-store" target="_blank"></a><p>Atomically stores the value <code>v</code> in the atomic object pointed to by <code>atomic_ptr</code>.</p></td></tr><tr id="builtin-atomic-add"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicAdd(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-add"><a href="https://www.w3.org/TR/WGSL/#atomic-add" target="_blank"></a><p>Atomically performs an addition operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-sub"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicSub(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-sub"><a href="https://www.w3.org/TR/WGSL/#atomic-sub" target="_blank"></a><p>Atomically performs a subtraction operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-max"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicMax(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-max"><a href="https://www.w3.org/TR/WGSL/#atomic-max" target="_blank"></a><p>Atomically performs a maximum operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-min"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicMin(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-min"><a href="https://www.w3.org/TR/WGSL/#atomic-min" target="_blank"></a><p>Atomically performs a minimum operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-and"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicAnd(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-and"><a href="https://www.w3.org/TR/WGSL/#atomic-and" target="_blank"></a><p>Atomically performs a bitwise AND operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-or"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicOr(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-or"><a href="https://www.w3.org/TR/WGSL/#atomic-or" target="_blank"></a><p>Atomically performs a bitwise OR operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-xor"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicXor(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-xor"><a href="https://www.w3.org/TR/WGSL/#atomic-xor" target="_blank"></a><p>Atomically performs a bitwise XOR operation on the atomic object pointed to by <code>atomic_ptr</code>
with the value <code>v</code>, and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-exchange"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicExchange(atomic_ptr: ptr<AS, atomic<T>, read_write>,
v: T) -> T {{/escapehtml}}</pre></td><td></td><td id="atomic-exchange"><a href="https://www.w3.org/TR/WGSL/#atomic-exchange" target="_blank"></a><p>Atomically stores the value <code>v</code> in the atomic object pointed to by
<code>atomic_ptr</code> and returns the original value stored in the atomic object before the operation.</p></td></tr><tr id="builtin-atomic-compare-exchange-weak"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}}fn atomicCompareExchangeWeak( atomic_ptr: ptr<AS, atomic<T>, read_write>,
cmp: T,
v: T) -> __atomic_compare_exchange_result<T> struct __atomic_compare_exchange_result<T> { old_value : T, // old value stored in the atomic exchanged : bool // true if the exchange was done } {{/escapehtml}}</pre></td><td></td><td id="atomic-compare-exchange-weak"><a href="https://www.w3.org/TR/WGSL/#atomic-compare-exchange-weak" target="_blank"></a><p class="note" role="note"><span class="marker">Note:</span> A value cannot be explicitly declared with the type
<code>__atomic_compare_exchange_result</code>, but a value may infer the type.</p><p>Performs the following steps atomically:</p><p>Returns a two member structure, where the first member, <code>old_value</code>, is the
original value of the atomic object before the operation and the second member, <code>exchanged</code>, is
whether or not the comparison succeeded.</p><p class="note" role="note"><span class="marker">Note:</span> The equality comparison may spuriously fail on some implementations. That
is, the second component of the result vector may be <code>false</code> even if the first
component of the result vector equals <code>cmp</code>.</p></td></tr></tbody></table><h2 id="pack-builtin-functions">Data Packing Built-in Functions</h2><table id="functions-pack-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-pack4x8snorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack4x8snorm(e: vec4<f32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack4x8snorm-builtin"><a href="https://www.w3.org/TR/WGSL/#pack4x8snorm-builtin" target="_blank"></a>
Converts four normalized floating point values to 8-bit signed integers, and then combines them
into one <code>u32</code> value.
<p>Component <code>e[i]</code> of the input is converted to an 8-bit twos complement integer value
⌊ 0.5 + 127 × min(1, max(-1, e[i])) ⌋ which is then placed in bits
8 × <code>i</code> through
8 × <code>i</code> + 7 of the result.</p>
</td></tr><tr id="builtin-pack4x8unorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack4x8unorm(e: vec4<f32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack4x8unorm-builtin"><a href="https://www.w3.org/TR/WGSL/#pack4x8unorm-builtin" target="_blank"></a>
Converts four normalized floating point values to 8-bit unsigned integers, and then combines them
into one <code>u32</code> value.
<p>Component <code>e[i]</code> of the input is converted to an 8-bit unsigned integer value
⌊ 0.5 + 255 × min(1, max(0, e[i])) ⌋ which is then placed in bits
8 × <code>i</code> through
8 × <code>i</code> + 7 of the result.</p>
</td></tr><tr id="builtin-pack4xI8-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack4xI8(e: vec4<i32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack4xI8-builtin"><a href="https://www.w3.org/TR/WGSL/#pack4xI8-builtin" target="_blank"></a>
Pack the lower 8 bits of each component of <code>e</code> into a u32 value and drop all the unused bits.
<p>Component <code>e[i]</code> of the input is mapped to bits
8 × <code>i</code> through
8 × <code>i</code> + 7 of the result.</p>
</td></tr><tr id="builtin-pack4xU8-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack4xU8(e: vec4<u32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack4xU8-builtin"><a href="https://www.w3.org/TR/WGSL/#pack4xU8-builtin" target="_blank"></a>
Pack the lower 8 bits of each component of <code>e</code> into a u32 value and drop all the unused bits.
<p>Component <code>e[i]</code> of the input is mapped to bits
8 × <code>i</code> through
8 × <code>i</code> + 7 of the result.</p>
</td></tr><tr id="builtin-pack4xI8Clamp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack4xI8Clamp(e: vec4<i32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack4xI8Clamp-builtin"><a href="https://www.w3.org/TR/WGSL/#pack4xI8Clamp-builtin" target="_blank"></a>
Clamp each component of <code>e</code> in the range [-128, 127] and then pack the lower 8 bits of each
component into a u32 value.
<p>Component <code>e[i]</code> of the input is mapped to bits
8 × <code>i</code> through
8 × <code>i</code> + 7 of the result.</p>
</td></tr><tr id="builtin-pack4xU8Clamp-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack4xU8Clamp(e: vec4<u32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack4xU8Clamp-builtin"><a href="https://www.w3.org/TR/WGSL/#pack4xU8Clamp-builtin" target="_blank"></a>
Clamp each component of <code>e</code> in the range of [0, 255] and then pack the lower 8 bits of each
component into a u32 value.
<p>Component <code>e[i]</code> of the input is mapped to bits
8 × <code>i</code> through
8 × <code>i</code> + 7 of the result.</p>
</td></tr><tr id="builtin-pack2x16snorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack2x16snorm(e: vec2<f32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack2x16snorm-builtin"><a href="https://www.w3.org/TR/WGSL/#pack2x16snorm-builtin" target="_blank"></a>Converts two normalized floating point values to 16-bit signed integers, and then combines them
into one <code>u32</code> value.<br>
Component <code>e[i]</code> of the input is converted to a 16-bit twos complement integer value
⌊ 0.5 + 32767 × min(1, max(-1, e[i])) ⌋ which is then placed in bits
16 × <code>i</code> through
16 × <code>i</code> + 15 of the result.
</td></tr><tr id="builtin-pack2x16unorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack2x16unorm(e: vec2<f32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack2x16unorm-builtin"><a href="https://www.w3.org/TR/WGSL/#pack2x16unorm-builtin" target="_blank"></a>Converts two normalized floating point values to 16-bit unsigned integers, and then combines them
into one <code>u32</code> value.<br>
Component <code>e[i]</code> of the input is converted to a 16-bit unsigned integer value
⌊ 0.5 + 65535 × min(1, max(0, e[i])) ⌋ which is then placed in bits
16 × <code>i</code> through
16 × <code>i</code> + 15 of the result.
</td></tr><tr id="builtin-pack2x16float-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn pack2x16float(e: vec2<f32>) -> u32 {{/escapehtml}}</pre></td><td></td><td id="pack2x16float-builtin"><a href="https://www.w3.org/TR/WGSL/#pack2x16float-builtin" target="_blank"></a>
Converts two floating point values to half-precision floating point numbers, and then combines
them into one <code>u32</code> value.<br>
Component <code>e[i]</code> of the input is converted to a IEEE-754 binary16 value, which is then
placed in bits
16 × <code>i</code> through
16 × <code>i</code> + 15 of the result.
See §15.7.6 Floating Point Conversion.
<p>If either <code>e[0]</code> or <code>e[1]</code> is outside the finite range of binary16 then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>e</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>e</code> is an override-expression.</p>
</li><li data-md="">
<p>Otherwise the result is an indeterminate value for u32.</p>
</li></ul>
</td></tr></tbody></table><h2 id="unpack-builtin-functions">Data Unpacking Built-in Functions</h2><table id="functions-unpack-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-unpack4x8snorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack4x8snorm(e: u32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td id="unpack4x8snorm-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack4x8snorm-builtin" target="_blank"></a>Decomposes a 32-bit value into four 8-bit chunks, then reinterprets
each chunk as a signed normalized floating point value.<br>
Component <code>i</code> of the result is max(v ÷ 127, -1), where <code>v</code> is the interpretation of
bits 8×<code>i</code> through 8×<code>i + 7</code> of <code>e</code> as a twos-complement signed integer.
</td></tr><tr id="builtin-unpack4x8unorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack4x8unorm(e: u32) -> vec4<f32> {{/escapehtml}}</pre></td><td></td><td id="unpack4x8unorm-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack4x8unorm-builtin" target="_blank"></a>Decomposes a 32-bit value into four 8-bit chunks, then reinterprets
each chunk as an unsigned normalized floating point value.<br>
Component <code>i</code> of the result is <code>v</code> ÷ 255, where <code>v</code> is the interpretation of
bits 8×<code>i</code> through 8×<code>i + 7</code> of <code>e</code> as an unsigned integer.
</td></tr><tr id="builtin-unpack4xI8-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack4xI8(e: u32) -> vec4<i32> {{/escapehtml}}</pre></td><td></td><td id="unpack4xI8-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack4xI8-builtin" target="_blank"></a><code>e</code> is interpreted as a vector with four 8-bit signed integer components. Unpack <code>e</code> into a vec4&lt;i32&gt; with sign extension.
</td></tr><tr id="builtin-unpack4xU8-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack4xU8(e: u32) -> vec4<u32> {{/escapehtml}}</pre></td><td></td><td id="unpack4xU8-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack4xU8-builtin" target="_blank"></a><code>e</code> is interpreted as a vector with four 8-bit unsigned integer components. Unpack <code>e</code> into a vec4&lt;u32&gt; with zero extension.
</td></tr><tr id="builtin-unpack2x16snorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack2x16snorm(e: u32) -> vec2<f32> {{/escapehtml}}</pre></td><td></td><td id="unpack2x16snorm-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack2x16snorm-builtin" target="_blank"></a>Decomposes a 32-bit value into two 16-bit chunks, then reinterprets
each chunk as a signed normalized floating point value.<br>
Component <code>i</code> of the result is max(v ÷ 32767, -1), where <code>v</code> is the interpretation of
bits 16×<code>i</code> through 16×<code>i + 15</code> of <code>e</code> as a twos-complement signed integer.
</td></tr><tr id="builtin-unpack2x16unorm-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack2x16unorm(e: u32) -> vec2<f32> {{/escapehtml}}</pre></td><td></td><td id="unpack2x16unorm-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack2x16unorm-builtin" target="_blank"></a>Decomposes a 32-bit value into two 16-bit chunks, then reinterprets
each chunk as an unsigned normalized floating point value.<br>
Component <code>i</code> of the result is <code>v</code> ÷ 65535, where <code>v</code> is the interpretation of
bits 16×<code>i</code> through 16×<code>i + 15</code> of <code>e</code> as an unsigned integer.
</td></tr><tr id="builtin-unpack2x16float-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn unpack2x16float(e: u32) -> vec2<f32> {{/escapehtml}}</pre></td><td></td><td id="unpack2x16float-builtin"><a href="https://www.w3.org/TR/WGSL/#unpack2x16float-builtin" target="_blank"></a>Decomposes a 32-bit value into two 16-bit chunks, and reinterpets each chunk
as a floating point value.<br>
Component <code>i</code> of the result is the f32 representation of <code>v</code>,
where <code>v</code> is the interpretation of bits 16×<code>i</code> through 16×<code>i + 15</code> of <code>e</code>
as an IEEE-754 binary16 value.
See §15.7.6 Floating Point Conversion.
</td></tr></tbody></table><h2 id="sync-builtin-functions">Synchronization Built-in Functions</h2><table id="functions-sync-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-storageBarrier-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn storageBarrier() {{/escapehtml}}</pre></td><td></td><td id="storageBarrier-builtin"><a href="https://www.w3.org/TR/WGSL/#storageBarrier-builtin" target="_blank"></a>Executes a control barrier synchronization function that affects
memory and atomic operations in the storage address
space.
</td></tr><tr id="builtin-textureBarrier-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn textureBarrier() {{/escapehtml}}</pre></td><td></td><td id="textureBarrier-builtin"><a href="https://www.w3.org/TR/WGSL/#textureBarrier-builtin" target="_blank"></a>Executes a control barrier synchronization function that affects
memory operations in the handle address space.
</td></tr><tr id="builtin-workgroupBarrier-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn workgroupBarrier() {{/escapehtml}}</pre></td><td></td><td id="workgroupBarrier-builtin"><a href="https://www.w3.org/TR/WGSL/#workgroupBarrier-builtin" target="_blank"></a>Executes a control barrier synchronization function that affects
memory and atomic operations in the workgroup address
space.
</td></tr><tr id="builtin-workgroupUniformLoad-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn workgroupUniformLoad(p : ptr<workgroup, T>) -> T {{/escapehtml}}</pre></td><td>T is a concrete constructible type.</td><td id="workgroupUniformLoad-builtin"><a href="https://www.w3.org/TR/WGSL/#workgroupUniformLoad-builtin" target="_blank"></a>
Returns the value pointed to by <code>p</code> to all invocations in the workgroup.
The return value is uniform.
<code>p</code> must be a uniform value.
<p>Executes a control barrier synchronization function that affects
memory and atomic operations in the workgroup address
space.</p>
</td></tr><tr id="builtin-workgroupUniformLoad-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn workgroupUniformLoad(p : ptr<workgroup, atomic<T>, read_write>) -> T {{/escapehtml}}</pre></td><td></td><td id="workgroupUniformLoad-builtin"><a href="https://www.w3.org/TR/WGSL/#workgroupUniformLoad-builtin" target="_blank"></a>
Atomically loads the value pointed to by <code>p</code> and returns it to all invocations in the workgroup.
The return value is uniform.
<code>p</code> must be a uniform value.
<p>Executes a control barrier synchronization function that affects
memory and atomic operations in the workgroup address
space.</p>
</td></tr></tbody></table><h2 id="subgroup-builtin-functions">Subgroup Built-in Functions</h2><table id="functions-subgroup-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-subgroupadd-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupAdd(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupadd-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupadd-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the sum of <code>e</code> among all active invocations in the subgroup.</p>
</td></tr><tr id="builtin-subgroupexclusiveadd-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupExclusiveAdd(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupexclusiveadd-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupexclusiveadd-builtin" target="_blank"></a>
Exclusive prefix scan operation.<br>
<p>Returns the sum of <code>e</code> among all active invocations in the
subgroup whose subgroup invocation IDs are less than the current
invocations id.</p>
<p>The value returned for the invocation with the lowest id among active invocations is <code>T(0)</code>.</p>
</td></tr><tr id="builtin-subgroupinclusiveadd-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupInclusiveAdd(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupinclusiveadd-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupinclusiveadd-builtin" target="_blank"></a>
Inclusive prefix scan operation.<br>
<p>Returns the sum of <code>e</code> among all active invocations in the
subgroup whose subgroup invocation IDs are less than or equal to
the current invocations id.</p>
<p class="note" role="note"><span class="marker">Note:</span> equivalent to <code>subgroupExclusiveAdd(x) + x</code>.</p>
</td></tr><tr id="builtin-subgroupall-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupAll(e : bool) -> bool {{/escapehtml}}</pre></td><td></td><td id="subgroupall-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupall-builtin" target="_blank"></a>Returns <code>true</code> if <code>e</code> is <code>true</code> for all active invocations in the subgroup.
</td></tr><tr id="builtin-subgroupand-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupAnd(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupand-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupand-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the bitwise and (<code>&amp;</code>) of <code>e</code> among all active
invocations in the subgroup.</p>
</td></tr><tr id="builtin-subgroupany-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupAny(e : bool) -> bool {{/escapehtml}}</pre></td><td></td><td id="subgroupany-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupany-builtin" target="_blank"></a>Returns <code>true</code> if <code>e</code> is <code>true</code> for any active invocations in the subgroup.
</td></tr><tr id="builtin-subgroupballot-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupBallot(pred : bool) -> vec4<u32> {{/escapehtml}}</pre></td><td></td><td id="subgroupballot-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupballot-builtin" target="_blank"></a>
Returns a bitmask of the active invocations in the
subgroup for whom <code>pred</code> is <code>true</code>.<br>
<p>The x component of the return value contains invocations 0 through 31.<br>
The y component of the return value contains invocations 32 through 63.<br>
The z component of the return value contains invocations 64 through 95.<br>
The w component of the return value contains invocations 96 through 127.<br></p>
<p>Within each component, the IDs are in ascending order by bit position
(e.g. ID 32 is at bit position 0 in the y component).</p>
</td></tr><tr id="builtin-subgroupbroadcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupBroadcast(e : T,
id : I) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupbroadcast-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupbroadcast-builtin" target="_blank"></a>
Returns the value of <code>e</code> from the invocation whose subgroup invocation ID
matches <code>id</code> in the subgroup to all active invocations in the subgroup.
<p><code>id</code> must be a const-expression in the range [0, 128).</p>
<p>It is a dynamic error if <code>id</code> does not select an active
invocation.</p>
<p class="note" role="note"><span class="marker">Note:</span> If a non-constant version of <code>id</code> is required, use
subgroupShuffle instead.</p>
</td></tr><tr id="builtin-subgroupbroadcastfirst-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupBroadcastFirst(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupbroadcastfirst-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupbroadcastfirst-builtin" target="_blank"></a>Returns the value of <code>e</code> from the invocation that has the lowest
subgroup invocation ID among active invocations in the
subgroup to all active invocations in the subgroup.
</td></tr><tr id="builtin-subgroupelect-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupElect() -> bool {{/escapehtml}}</pre></td><td></td><td id="subgroupelect-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupelect-builtin" target="_blank"></a>Returns <code>true</code> if the current invocation has the lowest subgroup invocation ID
among active invocations in the subgroup.
</td></tr><tr id="builtin-subgroupmax-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupMax(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupmax-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupmax-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the maximum value of <code>e</code> among all active invocations in the subgroup.</p>
</td></tr><tr id="builtin-subgroupmin-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupMin(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupmin-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupmin-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the minimum value of <code>e</code> among all active invocations in the subgroup.</p>
</td></tr><tr id="builtin-subgroupmul-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupMul(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupmul-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupmul-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the product of <code>e</code> among all active invocations in the subgroup.</p>
</td></tr><tr id="builtin-subgroupexclusivemul-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupExclusiveMul(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupexclusivemul-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupexclusivemul-builtin" target="_blank"></a>
Exclusive prefix scan operation.<br>
<p>Returns the product of <code>e</code> among all active invocations in
the subgroup whose subgroup invocation IDs are less than the
current invocations id.</p>
<p>The value returned for the invocation with the lowest id among active invocations is <code>T(1)</code>.</p>
</td></tr><tr id="builtin-subgroupinclusivemul-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupInclusiveMul(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupinclusivemul-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupinclusivemul-builtin" target="_blank"></a>
Inclusive prefix scan operation.<br>
<p>Returns the product of <code>e</code> among all active invocations in
the subgroup whose subgroup invocation IDs are less than or equal
to the current invocations id.</p>
<p class="note" role="note"><span class="marker">Note:</span> equivalent to <code>subgroupExclusiveMul(x) * x</code>.</p>
</td></tr><tr id="builtin-subgroupor-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupOr(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupor-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupor-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the bitwise or (<code>|</code>) of <code>e</code> among all active
invocations in the subgroup.</p>
</td></tr><tr id="builtin-subgroupshuffle-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupShuffle(e : T,
id : I) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupshuffle-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupshuffle-builtin" target="_blank"></a>
Returns <code>e</code> from the invocation whose subgroup invocation ID matches <code>id</code>.
<p>If <code>id</code> is outside the range [0, 128), then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>id</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>id</code> is an override-expression.</p>
</li></ul>
<p>An indeterminate value is returned if <code>id</code> does not select an
active invocation.</p>
</td></tr><tr id="builtin-subgroupshuffledown-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupShuffleDown(e : T,
delta : u32) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupshuffledown-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupshuffledown-builtin" target="_blank"></a>
Returns <code>e</code> from the invocation whose subgroup invocation ID
matches <code>subgroup_invocation_id + delta</code> for the current invocation.
<p>If <code>delta</code> is greater than 127, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>delta</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>delta</code> is an override-expression.</p>
</li></ul>
<p>A subgroup_uniformity diagnostic is triggered if
<code>delta</code> is not a uniform value.
An indeterminate value is returned if <code>subgroup_invocation_id + delta</code>
does not select an active invocation or if <code>delta</code> is a not a
uniform value within the subgroup.</p>
</td></tr><tr id="builtin-subgroupshuffleup-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupShuffleUp(e : T,
delta : u32) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupshuffleup-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupshuffleup-builtin" target="_blank"></a>
Returns <code>e</code> from the invocation whose subgroup invocation ID
matches <code>subgroup_invocation_id - delta</code> for the current invocation.
<p>If <code>delta</code> is greater than 127, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>delta</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>delta</code> is an override-expression.</p>
</li></ul>
<p>A subgroup_uniformity diagnostic is triggered if
<code>delta</code> is not a uniform value.
An indeterminate value is returned if <code>subgroup_invocation_id - delta</code>
does not select an active invocation or if <code>delta</code> is not a
uniform value within the subgroup.</p>
</td></tr><tr id="builtin-subgroupshufflexor-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupShuffleXor(e : T,
mask : u32) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupshufflexor-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupshufflexor-builtin" target="_blank"></a>
Returns <code>e</code> from the invocation whose subgroup invocation ID
matches <code>subgroup_invocation_id ^ mask</code> for the current invocation.
<p>If <code>mask</code> is greater than 127, then:</p>
<ul>
<li data-md="">
<p>It is a shader-creation error if <code>mask</code> is a const-expression.</p>
</li><li data-md="">
<p>It is a pipeline-creation error if <code>mask</code> is an override-expression.</p>
</li></ul>
<p>A subgroup_uniformity diagnostic is triggered if
<code>mask</code> is not a uniform value.
An indeterminate value is returned if <code>mask</code>
does not select an active invocation or if <code>mask</code> is not a
uniform value within the subgroup.</p>
</td></tr><tr id="builtin-subgroupxor-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn subgroupXor(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="subgroupxor-builtin"><a href="https://www.w3.org/TR/WGSL/#subgroupxor-builtin" target="_blank"></a>
Reduction operation.<br>
<p>Returns the bitwise xor (<code>^</code>) of <code>e</code> among all active
invocations in the subgroup.</p>
</td></tr></tbody></table><h2 id="quad-builtin-functions">Quad Operations</h2><table id="functions-quad-builtin-functions"><thead><th>Function</th><th>Parameter Types</th><th>Description</th></thead><tbody><tr id="builtin-quadbroadcast-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn quadBroadcast(e : T,
id : I) -> T {{/escapehtml}}</pre></td><td></td><td id="quadbroadcast-builtin"><a href="https://www.w3.org/TR/WGSL/#quadbroadcast-builtin" target="_blank"></a>
Returns the value of <code>e</code> from the invocation whose quad invocation ID
matches <code>id</code> in the quad to all active invocations in the quad.
<p><code>id</code> must be a const-expression in the range [0, 4).</p>
<p>An indeterminate value is returned if <code>id</code> does not select an
active invocation.</p>
<p class="note" role="note"><span class="marker">Note:</span> Unlike subgroupBroadcast, there is currently
no non-constant alternative.</p>
</td></tr><tr id="builtin-quadswapdiagonal-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn quadSwapDiagonal(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="quadswapdiagonal-builtin"><a href="https://www.w3.org/TR/WGSL/#quadswapdiagonal-builtin" target="_blank"></a>
Returns the value of <code>e</code> from the invocation in the quad with the opposite coordinates.
That is:
<ul>
<li data-md="">
<p>IDs 0 and 3 swap.</p>
</li><li data-md="">
<p>IDs 1 and 2 swap.</p>
</li></ul>
</td></tr><tr id="builtin-quadswapx-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn quadSwapX(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="quadswapx-builtin"><a href="https://www.w3.org/TR/WGSL/#quadswapx-builtin" target="_blank"></a>
Returns the value of <code>e</code> from invocation in the quad sharing the same X dimension.
That is:
<ul>
<li data-md="">
<p>IDs 0 and 1 swap.</p>
</li><li data-md="">
<p>IDs 2 and 3 swap.</p>
</li></ul>
</td></tr><tr id="builtin-quadswapy-builtin"><td><pre class="tableprettyprint lang-wgsl">{{#escapehtml}} fn quadSwapY(e : T) -> T {{/escapehtml}}</pre></td><td></td><td id="quadswapy-builtin"><a href="https://www.w3.org/TR/WGSL/#quadswapy-builtin" target="_blank"></a>
Returns the value of <code>e</code> from invocation in the quad sharing the same Y dimension.
That is:
<ul>
<li data-md="">
<p>IDs 0 and 2 swap.</p>
</li><li data-md="">
<p>IDs 1 and 3 swap.</p>
</li></ul>
</td></tr></tbody></table></div>