@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
66 lines • 2.88 kB
TypeScript
import type { UniformLayout, UniformMap, UniformType, UniformValue } from './types.js';
/**
* Asserts that a name can be safely used as a WGSL identifier.
*
* @param name - Candidate uniform/texture name.
* @throws {Error} When the identifier is invalid.
*/
export declare function assertUniformName(name: string): void;
/**
* Infers the WGSL type tag from a runtime uniform value.
*
* @param value - Uniform input value.
* @returns Inferred uniform type.
* @throws {Error} When the value does not match any supported shape.
*/
export declare function inferUniformType(value: UniformValue): UniformType;
/**
* Validates that a uniform value matches an explicit uniform type declaration.
*
* @param type - Declared WGSL type.
* @param value - Runtime value to validate.
* @throws {Error} When the value shape is incompatible with the declared type.
*/
export declare function assertUniformValueForType(type: UniformType, value: UniformValue): void;
/**
* Resolves a deterministic packed uniform buffer layout from a uniform map.
*
* @param uniforms - Input uniform definitions.
* @returns Sorted layout with byte offsets and final buffer byte length.
*/
export declare function resolveUniformLayout(uniforms: UniformMap): UniformLayout;
/**
* Packs uniforms into a newly allocated `Float32Array`.
*
* @param uniforms - Uniform values to pack.
* @param layout - Target layout definition.
* @returns Packed float buffer sized to `layout.byteLength`.
*/
export declare function packUniforms(uniforms: UniformMap, layout: UniformLayout): Float32Array;
/**
* Packs uniforms into an existing output buffer and zeroes missing values.
*
* Values are validated against their declared types before being written.
* Uses an optimised fast-write path internally to avoid redundant type checks
* after validation has already been performed for each entry.
*
* @param uniforms - Uniform values to pack.
* @param layout - Target layout metadata.
* @param data - Destination float buffer.
* @throws {Error} When `data` size does not match the required layout size.
*/
export declare function packUniformsInto(uniforms: UniformMap, layout: UniformLayout, data: Float32Array): void;
/**
* Packs uniforms into an existing output buffer without per-entry validation.
*
* Intended for the renderer render loop where all values have already been
* validated at {@link setUniform} call time, making per-write re-validation
* redundant. Skips the size guard and validation to minimise hot-path overhead.
*
* @internal
* @param uniforms - Pre-validated uniform values to pack.
* @param layout - Target layout metadata.
* @param data - Destination float buffer (must match `layout.byteLength / 4`).
*/
export declare function packUniformsIntoFast(uniforms: UniformMap, layout: UniformLayout, data: Float32Array): void;
//# sourceMappingURL=uniforms.d.ts.map