typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
46 lines (45 loc) • 1.82 kB
TypeScript
import { type Metadata, type RawMetadata } from './normalizeMetadata.ts';
/**
* Don't use or you WILL get fired from your job.
*
* The information that this type describes is additional
* properties that we add onto `globalThis`, used by tools
* like `unplugin-typegpu` or our test suite.
*
* @internal
*/
export type INTERNAL_GlobalExt = typeof globalThis & {
__TYPEGPU_VERSION__?: string;
__TYPEGPU_META__?: WeakMap<object, RawMetadata>;
__TYPEGPU_AUTONAME__?: <T>(exp: T, label: string) => T;
__TYPEGPU_MEASURE_PERF__?: boolean | undefined;
__TYPEGPU_PERF_RECORDS__?: Map<string, unknown[]>;
};
/**
* Can be assigned a name. Not to be confused with just having a name.
* The `$name` function should use `setName` to rename the object itself,
* even if `$getNameForward` symbol is present.
*/
export interface TgpuNamable {
$name(label: string): this;
}
export declare function isNamable(value: unknown): value is TgpuNamable;
export declare function getName(definition: unknown): string | undefined;
export declare function setName(definition: object, name: string): void;
/**
* Retrieves normalized (non-raw) function metadata.
* If `globalExt.__TYPEGPU_META__` contains raw metadata for the function,
* it is normalized, and then deleted to avoid unnecessary re-normalization.
*/
export declare function getFunctionMetadata(definition: object): Metadata | undefined;
/**
* AST's are given to functions with a 'use gpu' directive, which this function checks for.
*/
export declare function hasTinyestMetadata(value: unknown): value is (...args: never[]) => unknown;
/**
* Performance measurements are only enabled in dev & test environments for now
*/
export declare const PERF: {
readonly enabled: boolean;
record(name: string, data: unknown): void;
} | undefined;