typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
23 lines (22 loc) • 1.05 kB
TypeScript
import { type ResolvedSnippet } from '../data/snippet.ts';
import type { ResolutionCtx, SelfResolvable } from '../types.ts';
/**
* WARNING: This is an API that touches a lot of internals, and is not stable
* (can change between patches). You should probably talk to the TypeGPU team
* before using this, maybe we can provide a better public API for your use case.
*
* Defines additional properties on `value` (mutates it) that makes TypeGPU
* understand how it should handle passing this object to the `tgpu.resolve`
* API, or just how to generate shader code from it to begin with.
*
* `value` can in particular be the prototype of a class, meaning all instances
* of that class will be resolvable.
*/
export declare function makeResolvable<T extends object>(value: T, options: makeResolvable.Options<T>): T & SelfResolvable;
export declare namespace makeResolvable {
interface Options<T> {
resolve(this: T, ctx: ResolutionCtx): ResolvedSnippet;
asString(this: T): string;
}
type Resolvable = SelfResolvable;
}