HostExport
On this page

HostExport

Type in Editor

One export of a shader module, as the host sees it.

import type { HostExport } from 'typeshade/language-service'

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

Syntax

type HostExport =
| {
readonly kind: 'function';
readonly name: string;
/** The IR function the call runs. */
readonly fn: string;
readonly params: readonly { readonly name: string; readonly type: HostType }[];
readonly result: HostType;
}
| {
readonly kind: 'const';
readonly name: string;
readonly const: string;
readonly type: HostType;
}
| {
readonly kind: 'enum';
readonly name: string;
readonly members: readonly (readonly [string, number])[];
}
| { readonly kind: 'struct'; readonly name: string; readonly type: HostType & { k: 'struct' } }
| {
/** A `@compute` entry a host can call (Rule 8.24): everything the call needs but the WGSL,
* which the module shares, and the TypeScript type of its bindings object. */
readonly kind: 'compute';
readonly name: string;
readonly entry: Omit<ComputeEntry, 'wgsl' | 'log'>;
readonly bindingsType: string;
/** The bindings object of a call on a resource, which does not block, when every binding
* the entry writes is a storage array with no size, which a `Buffer` may stand for (change
* 0138, R2; Amendment A10, Q-I). */
readonly queuedType?: string;
/** The bindings object of a call on a resource that writes a plain array, which waits
* (Amendment A11, Q7); present with {@link queuedType}. */
readonly waitingType?: string;
}
| {
/** A full-screen `@fragment` entry a host can draw into a canvas (Rule 8.24): everything
* the draw needs but the WGSL, and the TypeScript type of its bindings object. */
readonly kind: 'fragment';
readonly name: string;
readonly entry: Omit<FragmentEntry, 'wgsl' | 'log'>;
readonly bindingsType: string;
}
| {
/** A kernel function (Rule 8.22), whose call is asynchronous and dispatches its loops
* (Rule 8.21). `ranges` are the CPU-tier functions its call runs beside the GPU: its
* ranges first, then the tail and the stores after the loops (change 0094). */
readonly kind: 'kernel';
readonly name: string;
readonly face: KernelFace;
readonly ranges: readonly FuncDecl[];
}
| {
/** A binding the module exports that is a host resource (change 0138, R10; Rule 6.1;
* Amendment A5, D6): a `uniform<T>` of an exported class is a `Uniform<T>`, and a
* `storage<array<T, N>>` or `storage<array<T>>` of one a `Buffer<T>`, which the generated
* module makes once. The view types it without `dispose()` (D7). */
readonly kind: 'resource';
readonly name: string;
/** The exported class whose layouts it reads, by the name the host imports. */
readonly cls: string;
/** A storage array's element count, `null` for one with no size, whose length the host
* sets (Amendment A3); absent for a uniform. */
readonly length?: number | null;
}
| {
readonly kind: 'never';
readonly name: string;
/** Why the host cannot use it, and which later work adds it when one is planned. */
readonly reason: string;
/** A type-only export (an interface, a type alias), which has no value to refuse. */
readonly typeOnly?: true;
};

Source

src/compiler/ts/host-face-contracts.ts, line 11, at commit af54ddad5

Edit this page Report a problem