This register enables monitoring of memory (de)allocations and is intended for use in WebGL context for internal GPU memory allocation tracking. For it, a unique identifier for registration has to be created:
let gpuAllocReg = this.context.gpuAllocationRegister; const identifier = gpuAllocReg.createUniqueIdentifier('gpu-object');
Then allocations, deallocations, and reallocations can be registered:
gpuAllocReg.allocate(identifier, this.sizeofRGBAColorAttachment()); gpuAllocReg.allocate(identifier, this.sizeofDepthStencilAttachment()); // ... reallocation gpuAllocReg.reallocate(identifier, this.sizeofRGBAColorAttachment() + this.sizeofDepthStencilAttachment()); // ... uninitialize gpuAllocReg.reallocate(identifier, 0);
Requesting the allocated memory can be done as follows:
// memory allocated by identifier: console.log(mfCanvas.context.gpuAllocationRegister.toString()); //> IntermediateFBO: 10.582MiB, AccumulationPingFBO: 21.163MiB, AccumulationPongFBO: 21.163MiB // memory allocated over all identifiers: console.log(mfCanvas.context.gpuAllocationRegister.bytesToString()); //> 52.908MiB
Map that provides access to the accumulated memory allocations for all registered identifiers.
Cache for the overall number of allocated bytes (over all identifiers). This should always be the sum of the bytes allocated over each identifier, which can be validated using validate().
This property can be observed, e.g.,
Observable that can be used to subscribe to bytes value changes. Yields a 2-tuple of overall allocated bytes as number and pretty printed string.
Registers allocated bytes for a given identifier.
Identifier to register the allocated bytes for.
Allocated bytes to register for identifier.
Provides access to the allocated bytes for an identifier as well as the overall allocated bytes (when identifier is undefined, default). If the identifier is undefined, the overall allocated number of bytes is returned.
Identifier to return the allocated bytes for.
Asserts existence of an identifier.
Identifier to assert the existence of.
Utility for communicating this._bytes changes to its associated subject.
Provides a pretty printed string of the overall number of bytes or a specific identifier. If the identifier is undefined, the overall number of bytes is pretty printed.
Identifier to pretty print the bytes for.
Creates a unique identifier based on a given identifier: if the identifier is already unique it is returned as is. If not, an enumerated identifier is returned, e.g., 'TempFBO-2' when 'TempFBO' already exists. This also enables tracking for the identifier, thus, it should always be called before tracking/monitoring.
Requested identifier for allocation registration.
Registers deallocated bytes for a given identifier.
Identifier to register the deallocated bytes for.
Removes a previously created unique identifier from the allocation registry.
Identifier that is to be deleted from allocation registration.
Resets the previously allocated bytes for the given identifier and registers the given allocated bytes instead.
Identifier to register the reallocated bytes for.
Provides a pretty printed string of the allocated bytes of this register and their identifier. The output for a register of three objects could be as follows:
IntermediateFBO: 10.582MiB, AccumulationPingFBO: 21.163MiB, AccumulationPongFBO: 21.163MiB