UNPKG

typegpu

Version:

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

54 lines (53 loc) 1.7 kB
import type { DualFn, ShaderStage } from '../types.ts'; /** * Returns `true` when the direct callee is being transpiled for GPU, otherwise `false`. * * @example * const f = () => { * 'use gpu'; * return isBeingTranspiled() ? 1 : 0; * }; * * f(); // returns 0, but resolved WGSL looks like this: * * fn f() -> i32 { * return 1; * } * * @note * Inside `comptime`, `lazy` or `simulate`, it always returns `false`. */ export declare const isBeingTranspiled: DualFn<() => boolean>; /** * If invoked during the resolution process, it returns the name of the shader language that * is ultimately being generated (usually `wgsl`); otherwise, returns `undefined`. * * @example * function f() { * 'use gpu'; * return getTargetShaderLanguage() === 'wgsl'; * }; * * f(); // returns false, but resolved WGSL looks like this: * * fn f() -> bool { * return true; * } * * @note * Inside `simulate`, it always returns `undefined`. * * Inside `comptime`, it returns the shader language that is ultimately * being generated (usually `wgsl`) if called during the resolution process; otherwise, `undefined`. */ export declare const getTargetShaderLanguage: import("../indexNamedExports.ts").TgpuComptime<() => string | undefined>; /** * Can be used to change behavior based on which shader stage the code is being * used in. If used in a 'use gpu' function, its definition will be duplicated * for each shader stage. * * @note * When called outside of shader resolution, or when the shader stage cannot be * determined, `undefined` is returned. */ export declare const getShaderStage: import("../indexNamedExports.ts").TgpuComptime<() => ShaderStage | undefined>;