@motion-core/motion-gpu
Version:
Framework-agnostic WebGPU runtime for fullscreen WGSL shaders with explicit Svelte, React, and Vue adapter entrypoints.
83 lines • 3.18 kB
TypeScript
/// <reference types="@webgpu/types" />
import type { StorageBufferAccess, StorageBufferType } from './types.js';
/**
* Logical material texture and its current renderer-owned physical state.
*/
export interface RuntimeTextureResource {
readonly logicalId: string;
ownedTexture: GPUTexture | null;
storageView: GPUTextureView | null;
sampledView: GPUTextureView;
publishedView: GPUTextureView;
format: GPUTextureFormat;
width: number | undefined;
height: number | undefined;
mipLevelCount: number;
sampleType: GPUTextureSampleType;
usage: GPUTextureUsageFlags;
resourceVersion: number;
}
/**
* Logical material storage buffer and its renderer-owned physical allocation.
*/
export interface RuntimeStorageBufferResource {
readonly logicalId: string;
readonly buffer: GPUBuffer;
readonly size: number;
readonly wgslType: StorageBufferType;
readonly access: StorageBufferAccess;
readonly usage: GPUBufferUsageFlags;
resourceVersion: number;
}
export interface RuntimeTextureResourceInput {
logicalId: string;
ownedTexture?: GPUTexture | null;
storageView?: GPUTextureView | null;
sampledView: GPUTextureView;
publishedView?: GPUTextureView;
format: GPUTextureFormat;
width?: number;
height?: number;
mipLevelCount: number;
sampleType: GPUTextureSampleType;
usage: GPUTextureUsageFlags;
}
export interface RuntimeTextureAllocation {
ownedTexture: GPUTexture | null;
storageView: GPUTextureView | null;
sampledView: GPUTextureView;
format: GPUTextureFormat;
width: number | undefined;
height: number | undefined;
mipLevelCount: number;
usage: GPUTextureUsageFlags;
}
/**
* Renderer-local registry of logical material resources.
*
* The registry owns metadata, not WebGPU objects. The renderer remains
* responsible for destroying allocations in its lifecycle teardown.
*/
export declare class MaterialResourceRegistry {
private readonly textures;
private readonly buffers;
registerTexture(input: RuntimeTextureResourceInput): RuntimeTextureResource;
registerStorageBuffer(input: Omit<RuntimeStorageBufferResource, 'resourceVersion'>): RuntimeStorageBufferResource;
getTexture(logicalId: string): RuntimeTextureResource | undefined;
requireTexture(logicalId: string): RuntimeTextureResource;
getStorageBuffer(logicalId: string): RuntimeStorageBufferResource | undefined;
requireStorageBuffer(logicalId: string): RuntimeStorageBufferResource;
/**
* Replaces physical texture state and publishes the sampled view atomically.
* Returns whether fragment/consumer bind groups need a new view reference.
*/
replaceTextureAllocation(logicalId: string, next: RuntimeTextureAllocation): boolean;
/**
* Publishes a renderer-produced view without changing the source allocation.
*/
publishTextureView(logicalId: string, view: GPUTextureView): boolean;
markTextureWritten(logicalId: string, publishedView?: GPUTextureView): boolean;
markStorageBufferWritten(logicalId: string): void;
clear(): void;
}
//# sourceMappingURL=resource-registry.d.ts.map