toU32
On this page

toU32()

Function in Builtins

Convert to u32: the explicit numeric cast, where u32(/api/u32/) builds a literal from a JS number.

import { toU32 } from 'typeshade'

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

Syntax

const toU32: (x: ReadonlyNode<string> | number) => Node<"u32">

Parameters

x ReadonlyNode<string> | number

Return value

Node<'u32'>

Description

Emits u32(x) on WGSL and uint(x) on GLSL. Use it over toI32 wherever the context is unsigned, such as a buffer stride.

Examples

Example

import { fn, toU32, f32T } from 'typeshade'
const idx = fn('idx', { anchorMode: f32T }, ({ anchorMode }) => toU32(anchorMode))

Targets

TargetSupportNotes
WGSL (WebGPU) Supported

u32(x).

GLSL ES 3.00 (WebGL2) Supported

uint(x).

CPU oracle Supported

Evaluated in f64 by the oracle.

See also

Source

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

Edit this page Report a problem