import type { CompositeShaderType } from "../shadertypes/shader-types/shader-types.js"; import type { CompositeUniformValue } from "../adapter/types/uniforms.js"; import type { Device } from "../adapter/device.js"; import { Buffer } from "../adapter/resources/buffer.js"; import { type ShaderBlockLayout } from "../shadertypes/shader-types/shader-block-layout.js"; import { UniformBlock } from "./uniform-block.js"; import { ShaderBlockWriter } from "./shader-block-writer.js"; /** Definition of a single managed uniform block. */ export type UniformStoreBlockDefinition = { /** Declared shader types for the block's uniforms. */ uniformTypes?: Record; /** Reserved for future prop-level defaults. */ defaultProps?: Record; /** Initial uniform values written into the backing block. */ defaultUniforms?: Record; /** Explicit shader-block layout override. */ layout?: 'std140' | 'wgsl-uniform' | 'wgsl-storage'; }; /** Uniform block definitions keyed by block name. */ export type UniformStoreBlocks>> = Record; /** * A uniform store holds a uniform values for one or more uniform blocks, * - It can generate binary data for any uniform buffer * - It can manage a uniform buffer for each block * - It can update managed uniform buffers with a single call * - It performs some book keeping on what has changed to minimize unnecessary writes to uniform buffers. */ export declare class UniformStore> = Record>> { /** Device used to infer layout and allocate buffers. */ readonly device: Device; /** Stores the uniform values for each uniform block */ uniformBlocks: Map>>; /** Flattened layout metadata for each block. */ shaderBlockLayouts: Map; /** Serializers for block-backed uniform data. */ shaderBlockWriters: Map; /** Actual buffer for the blocks */ uniformBuffers: Map; /** * Creates a new {@link UniformStore} for the supplied device and block definitions. */ constructor(device: Device, blocks: UniformStoreBlocks); /** Destroy any managed uniform buffers */ destroy(): void; /** * Set uniforms * * Makes all group properties partial and eagerly propagates changes to any * managed GPU buffers. */ setUniforms(uniforms: Partial<{ [group in keyof TPropGroups]: Partial; }>): void; /** * Returns the allocation size for the named uniform buffer. * * This may exceed the packed layout size because minimum buffer-size policy is * applied at the store layer. */ getUniformBufferByteLength(uniformBufferName: keyof TPropGroups): number; /** * Returns packed binary data that can be uploaded to the named uniform buffer. * * The returned view length matches the packed block size and is not padded to * the store's minimum allocation size. */ getUniformBufferData(uniformBufferName: keyof TPropGroups): Uint8Array; /** * Creates an unmanaged uniform buffer initialized with the current or supplied values. */ createUniformBuffer(uniformBufferName: keyof TPropGroups, uniforms?: Partial<{ [group in keyof TPropGroups]: Partial; }>): Buffer; /** Returns the managed uniform buffer for the named block. */ getManagedUniformBuffer(uniformBufferName: keyof TPropGroups): Buffer; /** * Updates every managed uniform buffer whose source uniforms have changed. * * @returns The first redraw reason encountered, or `false` if nothing changed. */ updateUniformBuffers(): false | string; /** * Updates one managed uniform buffer if its corresponding block is dirty. * * @returns The redraw reason for the update, or `false` if no write occurred. */ updateUniformBuffer(uniformBufferName: keyof TPropGroups): false | string; } //# sourceMappingURL=uniform-store.d.ts.map