u32
On this page

u32()

Function in Values

A u32 literal node.

import { u32 } from 'typeshade'

The signature, the description and the examples come from the compiler's own source at commit 26de7be8.

Syntax

function u32(v: number): Node<'u32'>;
function u32(x: ReadonlyNode<ScalarCastSource>): Node<'u32'>;

Parameters

v number

Return value

Node<'u32'>

Exceptions

TypeError

v is neither a JS number nor a scalar node.

SD0116

SD0116 when the node operand is not a scalar.

Description

Use it over the f32 default wherever WGSL demands an unsigned scalar: buffer strides, vertex and instance indices, bit-flag masks used with .bitAnd and .bitOr.

A Node argument is a cast instead: u32(x) converts, the free-function twin of x.u32(). It builds what toU32 builds, and its operand is bounded to a scalar.

Examples

Example

import { u32 } from 'typeshade'
const flags = u32(4) // Node<'u32'>

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

u32(a).

GLSL ES 3.00 (WebGL2) Supported

uint(a).

CPU oracle Supported

Evaluated in f64 by the oracle.

In the guide

See also

Source

src/core/ir/node.ts, line 1019, at commit 26de7be8

Edit this page Report a problem