typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
49 lines (48 loc) • 2.14 kB
TypeScript
import type { Snippet } from '../data/snippet.ts';
import type { SimulationState } from '../types.ts';
import type { makeResolvable } from './makeResolvable.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 using .$ on that object. All dereferenceable
* value must also be made resolvable (through the makeResolvable API).
*
* `value` can in particular be the prototype of a class, meaning all instances
* of that class will be dereferenceable.
*/
export declare function makeDereferenceable<T extends makeResolvable.Resolvable, TValue>(value: T, options: makeDereferenceable.Options<T, TValue>): T & {
$: TValue;
};
export declare namespace makeDereferenceable {
interface Options<T extends makeResolvable.Resolvable, TValue> {
normalMode: {
get(this: T): TValue;
set?(this: T, value: TValue): void;
};
codegenMode: {
/**
* Should return a representative value that is accessible on the GPU.
* If not provided, `codegenMode.getBaseSnippet` is used instead.
*/
get(this: T): TValue;
} | {
/**
* Used if `codegenMode.get` is not defined. The snippet returned from
* this function should represent the value that exists on .$
*
* The value of the snippet should in most cases be `trackingProxy` that
* is provided as the argument.
* @param trackingProxy
*/
getBaseSnippet(this: T, trackingProxy: TValue): Snippet;
};
/** @deprecated 'simulate' mode is planned to be removed in the future */
simulateMode?: {
get?(this: T, state: SimulationState): TValue;
set?(this: T, state: SimulationState, value: TValue): void;
};
}
}