UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

92 lines (91 loc) 2.69 kB
import { type AbstractFloat, type AbstractInt, type Bool, type F16, type F32, type I32, type U16, type U32 } from './wgslTypes.ts'; /** * A schema that represents a boolean value. (equivalent to `bool` in WGSL) * * Can also be called to cast a value to a bool in accordance with WGSL casting rules. * * @example * const value = bool(); // false * @example * const value = bool(0); // false * @example * const value = bool(-0); // false * @example * const value = bool(21.37); // true */ export declare const bool: Bool; /** * A schema that represents an unsigned 32-bit integer value. (equivalent to `u32` in WGSL) * * Can also be called to cast a value to an u32 in accordance with WGSL casting rules. * * @example * const value = u32(); // 0 * @example * const value = u32(7); // 7 * @example * const value = u32(3.14); // 3 * @example * const value = u32(-1); // 4294967295 * @example * const value = u32(-3.1); // 0 */ export declare const u32: U32; export declare const u16: U16; /** * A schema that represents a signed 32-bit integer value. (equivalent to `i32` in WGSL) * * Can also be called to cast a value to an i32 in accordance with WGSL casting rules. * * @example * const value = i32(); // 0 * @example * const value = i32(3.14); // 3 * @example * const value = i32(-3.9); // -3 * @example * const value = i32(10000000000) // 1410065408 */ export declare const i32: I32; /** * A schema that represents a 32-bit float value. (equivalent to `f32` in WGSL) * * Can also be called to cast a value to an f32. * * @example * const value = f32(); // 0 * @example * const value = f32(1.23); // 1.23 * @example * const value = f32(true); // 1 */ export declare const f32: F32; /** * Convert a JavaScript number (treated as float32) to **binary16** bit pattern. * @param x 32-bit floating-point value * @returns 16-bit half-precision encoding (stored in a JS number) */ export declare function toHalfBits(x: number): number; /** * Convert a **binary16** encoded bit pattern back to JavaScript number. * @param h 16-bit half-precision bits * @returns JavaScript number (64-bit float) with same numerical value */ export declare function fromHalfBits(h: number): number; /** * A schema that represents a 16-bit float value. (equivalent to `f16` in WGSL) * * Can also be called to cast a value to an f16. * * @example * const value = f16(); // 0 * @example * const value = f32(1.23); // 1.23 * @example * const value = f16(true); // 1 * @example * const value = f16(21877.5); // 21872 */ export declare const f16: F16; export declare const abstractInt: AbstractInt; export declare const abstractFloat: AbstractFloat;