UNPKG

typegpu

Version:

A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.

14 lines (13 loc) 1.24 kB
import { type Decorate, type HasCustomLocation, type IsBuiltin } from '../../data/attributes.ts'; import { type BaseData, type Location, type WgslStruct } from '../../data/wgslTypes.ts'; import type { SeparatedEntryArgs } from './fnTypes.ts'; export type WithLocations<T extends Record<string, BaseData>> = { [Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key] : HasCustomLocation<T[Key]> extends true ? T[Key] : Decorate<T[Key], Location>; }; export type IOLayoutToSchema<T> = T extends BaseData ? HasCustomLocation<T> extends true ? T : Decorate<T, Location<0>> : T extends Record<string, BaseData> ? WgslStruct<WithLocations<T>> : T extends { type: 'void'; } ? void : never; export declare function withLocations<T extends BaseData>(members: Record<string, T> | undefined, locations?: Record<string, number>): Record<string, BaseData>; export declare function separateBuiltins(schema: Record<string, BaseData>, locations?: Record<string, number>): SeparatedEntryArgs; export declare function separateAllAsPositional(schema: Record<string, BaseData>): SeparatedEntryArgs; export declare function createIoSchema<T extends BaseData | Record<string, BaseData>>(layout: T, locations?: Record<string, number>): IOLayoutToSchema<T>;