@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
72 lines • 2.88 kB
TypeScript
import type { MaterialLineMap, MaterialSourceLocation } from './material-preprocess.js';
import type { StorageBufferType, UniformLayout } from './types.js';
type ComputeShaderSourceLocation = {
kind: 'compute';
line: number;
};
/**
* 1-based map from generated WGSL lines to original material source lines.
*/
export type ShaderLineMap = Array<(MaterialSourceLocation | ComputeShaderSourceLocation) | null>;
/**
* Result of shader source generation with line mapping metadata.
*/
export interface BuiltShaderSource {
/**
* Full WGSL source code.
*/
code: string;
/**
* 1-based generated-line map to material source locations.
*/
lineMap: ShaderLineMap;
}
/**
* Assembles complete WGSL shader source used by the fullscreen renderer pipeline.
*
* @param fragmentWgsl - User fragment shader code containing `frag(uv: vec2f) -> vec4f`.
* @param uniformLayout - Resolved uniform layout.
* @param textureKeys - Sorted texture keys.
* @param options - Shader build options.
* @returns Complete WGSL source for vertex + fragment stages.
*/
export declare function buildShaderSource(fragmentWgsl: string, uniformLayout: UniformLayout, textureKeys?: string[], options?: {
convertLinearToSrgb?: boolean;
premultiplyOutputAlpha?: boolean;
storageBufferKeys?: string[];
storageBufferDefinitions?: Record<string, {
type: StorageBufferType;
}>;
}): string;
/**
* Assembles complete WGSL shader source with material-source line mapping metadata.
*/
export declare function buildShaderSourceWithMap(fragmentWgsl: string, uniformLayout: UniformLayout, textureKeys?: string[], options?: {
convertLinearToSrgb?: boolean;
premultiplyOutputAlpha?: boolean;
fragmentLineMap?: MaterialLineMap;
storageBufferKeys?: string[];
storageBufferDefinitions?: Record<string, {
type: StorageBufferType;
}>;
}): BuiltShaderSource;
/**
* Assembles WGSL shader source used by renderer-managed fragment ping-pong passes.
*
* The shader exposes the same group(0) frame/uniform/texture bindings as the
* material fragment shader and adds group(1) bindings for the previous
* ping-pong texture.
*/
export declare function buildPingPongShaderSource(fragmentWgsl: string, uniformLayout: UniformLayout, textureKeys?: string[]): string;
/**
* Assembles ping-pong fragment WGSL with material-source line mapping metadata.
*/
export declare function buildPingPongShaderSourceWithMap(fragmentWgsl: string, uniformLayout: UniformLayout, textureKeys?: string[], options?: {
fragmentLineMap?: MaterialLineMap;
}): BuiltShaderSource;
/**
* Converts source location metadata to user-facing diagnostics label.
*/
export declare function formatShaderSourceLocation(location: (MaterialSourceLocation | ComputeShaderSourceLocation) | null): string | null;
export {};
//# sourceMappingURL=shader.d.ts.map