UNPKG

typegpu

Version:

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

30 lines (29 loc) 1.44 kB
import { type ResolutionCtx } from '../../types.ts'; import type { FnExternals } from '../function/fnCore.ts'; /** * A key-value mapping where keys represent identifiers within shader code, * and values can either be another ExternalMap, or be any type that can be resolved to a code string. */ export type ExternalMap = Record<string, unknown>; /** * Merges function externals into one map. */ export declare function mergeFunctionExternals(fnExternals: FnExternals): ExternalMap; export declare function addArgTypesToExternals(implementation: string, argTypes: unknown[], core: { setExternals: (key: 'args', externals: ExternalMap) => void; }): void; export declare function addReturnTypeToExternals(implementation: string, returnType: unknown, core: { setExternals: (key: 'out', externals: ExternalMap) => void; }): void; export declare const anyIdent: RegExp; export declare const boundedPropChain: RegExp; /** * Replaces all occurrences of external names in WGSL code with their resolved values. * It adds all necessary definitions to the resolution context. * @param ctx - The resolution context. * @param externalMap - The external map. Assumes that keys don't contain dots. * @param wgsl - The WGSL code. * * @returns The WGSL code with all external names replaced with their resolved values. */ export declare function replaceExternalsInWgsl(ctx: ResolutionCtx, externalMap: ExternalMap, wgsl: string): string;