HostExport
타입, 편집기 분류
호스트가 보는 셰이더 모듈의 export 하나입니다.
import type { HostExport } from 'typeshade/language-service'
설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.
구문
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; };소스
src/compiler/ts/host-face-contracts.ts, 11행, 커밋 af54ddad5 기준