/** * A uniform buffer represents a GPU memory buffer storing the uniforms. * * @ignore */ export class UniformBuffer { /** * Create a new UniformBuffer instance. * * @param {GraphicsDevice} graphicsDevice - The graphics device used to manage this uniform * buffer. * @param {UniformBufferFormat} format - Format of the uniform buffer. * @param {boolean} [persistent] - Whether the buffer is persistent. Defaults to true. */ constructor(graphicsDevice: GraphicsDevice, format: UniformBufferFormat, persistent?: boolean); device: GraphicsDevice; /** @type {boolean} */ persistent: boolean; /** @type {DynamicBufferAllocation} */ allocation: DynamicBufferAllocation; /** @type {Float32Array} */ storageFloat32: Float32Array; /** @type {Int32Array} */ storageInt32: Int32Array; /** @type {Uint32Array} */ storageUint32: Uint32Array; /** * Where this uniform buffer's data starts in the storage views, in 4 byte elements. Zero for a * persistent buffer, which owns its storage, and the offset of the allocation for a * non-persistent one, which borrows the storage of a dynamic buffer. * * @type {number} */ storageOffset: number; format: UniformBufferFormat; impl: any; /** * Frees resources associated with this uniform buffer. */ destroy(): void; get offset(): number; /** * Assign the storage a persistent uniform buffer owns. This runs once per buffer, unlike * {@link UniformBuffer#assignDynamicStorage}. * * @param {Int32Array} storage - The storage to assign to this uniform buffer. */ assignStorage(storage: Int32Array): void; /** * Borrow the storage views of the dynamic buffer this uniform buffer was allocated from, and * remember where in them its own data starts. The views span the whole dynamic buffer, so this * creates none of its own - it runs for every draw that updates a non-persistent buffer. * * @param {DynamicBuffer} dynamicBuffer - The buffer the allocation came from. * @param {number} storageOffset - Where the allocation starts in the views, in 4 byte elements. */ assignDynamicStorage(dynamicBuffer: DynamicBuffer, storageOffset: number): void; /** * Called when the rendering context was lost. It releases all context related resources. */ loseContext(): void; /** * Called when the rendering context is restored. Recreates the GPU buffer and re-uploads the * data from the persistent CPU storage. Only persistent uniform buffers are tracked for context * loss; non-persistent ones are re-allocated from the dynamic buffers on their next update. */ restoreContext(): void; /** * Assign a value to the uniform specified by its format. This is the fast version of assigning * a value to a uniform, avoiding any lookups. * * @param {UniformFormat} uniformFormat - The format of the uniform. * @param {any} value - The value to assign to the uniform. */ setUniform(uniformFormat: UniformFormat, value: any): void; /** * Assign a value to the uniform specified by name. * * @param {string} name - The name of the uniform. * @param {any} value - The value to assign to the uniform. */ set(name: string, value: any): void; startUpdate(dynamicBindGroup: any): void; endUpdate(): void; /** * Uploads the storage of a persistent uniform buffer to the GPU. Use this after writing to * the storage directly, instead of {@link UniformBuffer#update} which reads the values from * the scope. * * @ignore */ upload(): void; /** * @param {DynamicBindGroup} [dynamicBindGroup] - The function fills in the info about the * dynamic bind group for this frame, which uses this uniform buffer. Only used if the uniform * buffer is non-persistent. This allows the uniform buffer to be used without having to create * a bind group for it. Note that the bind group can only contains this single uniform buffer, * and no other resources. */ update(dynamicBindGroup?: DynamicBindGroup): void; } import type { GraphicsDevice } from './graphics-device.js'; import { DynamicBufferAllocation } from './dynamic-buffers.js'; import type { UniformBufferFormat } from './uniform-buffer-format.js'; import type { DynamicBuffer } from './dynamic-buffer.js'; import type { UniformFormat } from './uniform-buffer-format.js'; import type { DynamicBindGroup } from './bind-group.js';