const WGSLLinker: {
loadModule:
(
code: string,
name?: string,
entry?: string,
compressed?: boolean,
) => ParsedModule,
loadModuleWithCache:
(
code: string,
name?: string,
entry?: string,
cache?: ParsedModuleCache | null,
) => ParsedModule,
loadStaticModule:
(
code: string,
name: string,
entry?: string,
) => {
name: string,
code: string,
hash: number,
table: any,
label: string,
},
transpileWGSL:
(
source: string,
resourcePath: string,
options?: TranspileOptions,
) => TranspileOutput,
bindEntryPoint:
<T extends ParsedModule | ParsedBundle>(
bundle: T,
entry?: string,
) => T,
bundleToAttribute:
(
shader: ShaderModule,
name?: string,
) => UniformAttribute,
bundleToAttributes: (
shader: ShaderModule,
) => UniformAttribute[],
wgsl:
(
literals: TemplateStringsArray,
...tokens: string[],
) => ParsedModule,
f32: (x: number) => string,
i32: (x: number) => string,
u32: (x: number) => string,
defineConstants: (
defs: Record<string, ShaderDefine>,
) => string,
linkBundle:
(
source: ShaderModule,
links?: Record<string,
ParsedModule<any> | ParsedBundle<any> | null | undefined>,
defines?: Record<string, ShaderDefine>,
) => string,
linkModule:
(
source: ParsedModule,
libraries?: Record<string, ShaderModule>,
links?: Record<string,
ParsedModule<any> | ParsedBundle<any> | null | undefined>,
defines?: Record<string, ShaderDefine>,
) => string,
linkCode:
(
code: string,
libraries?: Record<string, string>,
links?: Record<string, string | null>,
defines?: Record<string, ShaderDefine>,
cache?: ParsedModuleCache | null,
) => string,
bindBundle:
(
subject: ShaderModule,
links?:
| Record<string, ParsedModule<any> | ParsedBundle<any> | null | undefined>
| null,
defines?: Record<string, ShaderDefine> | null,
) => ParsedBundle,
bindModule:
(
subject: ShaderModule,
links?:
| Record<string, ParsedModule<any> | ParsedBundle<any> | null | undefined>
| null,
defines?: Record<string, ShaderDefine> | null,
) => ParsedBundle,
bindingsToLinks:
(
bindings: ({
uniform: UniformAttribute,
storage?: StorageSource,
texture?: TextureSource,
lambda?: LambdaSource<ShaderModule<SymbolTable>>,
constant?: any,
})[],
) => Record<string, ParsedBundle<SymbolTable> | ParsedModule<SymbolTable>>,
bindingToModule:
(
binding: {
uniform: UniformAttribute,
storage?: StorageSource,
texture?: TextureSource,
lambda?: LambdaSource<ShaderModule<SymbolTable>>,
constant?: any,
},
) => ParsedBundle<SymbolTable> | ParsedModule<SymbolTable>,
sourceToModule:
<T>(
source: any,
) => ParsedBundle<SymbolTable> | ParsedModule<SymbolTable> | null,
resolveBindings: any,
extractBindings:
(
stages: ((
| false
| ParsedBundle<SymbolTable>
| ParsedModule<SymbolTable>
| null
| undefined)[])[],
pass: string,
) => GPUBindGroupLayoutEntry[],
castTo:
(
source: ShaderModule,
type: string,
swizzle?: string | { basis: string, signs?: string, gain?: number } | null,
) => ParsedBundle,
chainTo: (
from: ShaderModule,
to: ShaderModule,
) => ParsedBundle,
diffBy:
(
source: ShaderModule,
offset: number | string | (string | number | null)[] | null,
size:
| ShaderModule
| (ParsedModule<any> | ParsedBundle<any> | null)[]
| null,
) => ParsedBundle,
explode:
(
struct: ShaderModule,
source: ShaderModule,
) => ParsedBundle,
instanceWith:
(
values: ShaderModule[],
indices?: ShaderModule,
) => ParsedBundle,
swizzleTo:
(
from: string,
to: string,
swizzle: string | { basis: string, signs?: string, gain?: number },
) => ParsedBundle,
structType:
(
fields: UniformAttribute[],
name?: string,
) => ParsedBundle,
makeASTParser:
(
code: string,
tree: Tree,
name?: string,
) => {
getImports:
() => ({
at: number,
symbols: string[],
name: string,
imports: ImportRef[],
})[],
getDeclarations: () => DeclarationRef[],
getSymbolTable: () => SymbolTable,
getShakeTable: (
table?: SymbolTable,
) => ShakeTable | undefined,
},
compressAST:
(
code: string,
tree: Tree,
symbols?: string[],
modules?: ({
at: number,
symbols: string[],
name: string,
imports: ImportRef[],
})[],
) => CompressedNode[],
decompressAST:
(
nodes: CompressedNode[],
symbols?: string[],
) => Tree,
rewriteUsingAST:
(
code: string,
tree: Tree,
rename: Map<string, string>,
shake?: number[],
optionals?: Set<string>,
) => string,
makeModuleCache:
(
options?: Record<string, any>,
) => LRUCache<number,
{ name: string, code: string, hash: number, table: SymbolTable, tree?: Tree, shake?: ShakeTable, virtual?: VirtualTable<SymbolTable>, entry?: string, label?: string, key?: number }>,
getBundleEntry: (
bundle: ShaderModule,
) => string | undefined,
getBundleHash: (bundle: ShaderModule) => number,
getBundleKey: (bundle: ShaderModule) => number,
getBundleLabel: (bundle: ShaderModule) => string,
decompressString:
(
symbols: string[],
) => (s: (string | number)[]) => string[]
(s: string | number) => string,
symbolDictionary: {
A: "at",
B: "bindings",
C: "vec4<f32>",
D: "vec3<f32>",
E: "exports",
F: "func",
G: "flags",
H: "inferred",
I: "identifiers",
J: "imported",
K: "imports",
L: "linkable",
M: "members",
N: "name",
O: "modules",
P: "parameters",
Q: "qual",
R: "symbol",
S: "symbols",
T: "type",
U: "struct",
V: "variable",
W: "visibles",
X: "externals",
Y: "types",
Z: "attr",
},
parser: LRParser,
}
packages / shader / src / index.ts