Documentation / device / Pool
Class: Pool
Defined in: libs/device/src/pool.ts:9
ObjectPool class is responsible for managing and reusing textures and framebuffers.
Constructors
Constructor
new Pool(
device,id,memCostThreshold?):Pool
Defined in: libs/device/src/pool.ts:38
Creates an instance of Pool class
Parameters
device
Rendering device
id
string | symbol
memCostThreshold?
number = ...
Returns
Pool
Accessors
id
Get Signature
get id():
string|symbol
Defined in: libs/device/src/pool.ts:54
Id for this pool
Returns
string | symbol
Methods
autoRelease()
autoRelease():
void
Defined in: libs/device/src/pool.ts:57
Returns
void
fetchTemporalTexture2D()
fetchTemporalTexture2D(
autoRelease,format,width,height,mipmapping?,preferred?):Texture2D<unknown>
Defined in: libs/device/src/pool.ts:82
Fetch a temporal 2D texture from the object pool.
Parameters
autoRelease
boolean
Whether the texture should be automatically released at the next frame.
format
The format of the texture.
width
number
The width of the texture.
height
number
The height of the texture.
mipmapping?
boolean = false
Whether this texture support mipmapping
preferred?
A previously released matching texture to reacquire when available.
Returns
Texture2D<unknown>
The fetched Texture2D object.
fetchTemporalTexture2DArray()
fetchTemporalTexture2DArray(
autoRelease,format,width,height,numLayers,mipmapping?,preferred?):Texture2DArray<unknown>
Defined in: libs/device/src/pool.ts:123
Fetch a temporal 2D array texture from the object pool.
Parameters
autoRelease
boolean
Whether the texture should be automatically released at the next frame.
format
Format of the texture.
width
number
Width of the texture.
height
number
Height of the texture.
numLayers
number
Layer count of the texture
mipmapping?
boolean = false
Whether this texture support mipmapping
preferred?
A previously released matching texture to reacquire when available.
Returns
Texture2DArray<unknown>
The fetched Texture2DArray object.
fetchTemporalTextureCube()
fetchTemporalTextureCube(
autoRelease,format,size,mipmapping?):TextureCube<unknown>
Defined in: libs/device/src/pool.ts:162
Fetch a temporal Cube texture from the object pool.
Parameters
autoRelease
boolean
Whether the texture should be automatically released at the next frame.
format
Format of the texture.
size
number
size of the texture.
mipmapping?
boolean = false
Whether this texture support mipmapping
Returns
TextureCube<unknown>
The fetched TextureCube object.
fetchTemporalFramebuffer()
fetchTemporalFramebuffer<
T>(autoRelease,width,height,colorTexOrFormat,depthTexOrFormat?,mipmapping?,sampleCount?,ignoreDepthStencil?,attachmentMipLevel?,attachmentCubeface?,attachmentLayer?):FrameBuffer<unknown>
Defined in: libs/device/src/pool.ts:199
Creates a temporal framebuffer from the object pool.
Type Parameters
T
T extends BaseTexture<unknown>
Parameters
autoRelease
boolean
Whether the framebuffer should be automatically released at the next frame.
width
number
Width of the framebuffer
height
number
Height of the framebuffer
colorTexOrFormat
MaybeArray<TextureFormat | T>
depthTexOrFormat?
TextureFormat | T
mipmapping?
boolean = false
Whether mipmapping should be enabled when creating color attachment textures, default is false.
sampleCount?
number = 1
The sample count for the framebuffer, default is 1.
ignoreDepthStencil?
boolean = true
Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
attachmentMipLevel?
number = 0
The mipmap level to which the color attachment will render, default is 0
attachmentCubeface?
number = 0
The cubemap face to which the color attachment will render, default is 0
attachmentLayer?
number = 0
The texture layer to which the color attachment will render, default is 0
Returns
FrameBuffer<unknown>
The fetched FrameBuffer object.
createTemporalFramebuffer()
createTemporalFramebuffer(
autoRelease,colorAttachments,depthAttachment?,sampleCount?,ignoreDepthStencil?,attachmentMipLevel?,attachmentCubeface?,attachmentLayer?):FrameBuffer<unknown>
Defined in: libs/device/src/pool.ts:258
Creates a temporal framebuffer from the object pool.
Parameters
autoRelease
boolean
Whether the framebuffer should be automatically released at the next frame.
colorAttachments
BaseTexture<unknown>[]
Array of color attachments for the framebuffer.
depthAttachment?
BaseTexture<unknown> = null
Depth attachment for the framebuffer.
sampleCount?
number = 1
The sample count for the framebuffer, default is 1.
ignoreDepthStencil?
boolean = true
Whether to ignore depth stencil when resolving msaa framebuffer, default is true.
attachmentMipLevel?
number = 0
The mipmap level to which the color attachment will render, default is 0.
attachmentCubeface?
number = 0
The cubemap face to which the color attachment will render, default is 0.
attachmentLayer?
number = 0
The texture layer to which the color attachment will render, default is 0.
Returns
FrameBuffer<unknown>
The fetched FrameBuffer object.
disposeTexture()
disposeTexture(
texture):void
Defined in: libs/device/src/pool.ts:315
Dispose a texture that is allocated from the object pool.
Parameters
texture
The texture to dispose.
Returns
void
releaseTexture()
releaseTexture(
texture):void
Defined in: libs/device/src/pool.ts:322
Release a texture back to the object pool.
Parameters
texture
The texture to release.
Returns
void
retainTexture()
retainTexture(
texture):void
Defined in: libs/device/src/pool.ts:336
Increment reference counter for given texture
Parameters
texture
The texture to retain
Returns
void
hasTexture()
hasTexture(
texture):boolean
Defined in: libs/device/src/pool.ts:351
Check whether a texture is currently tracked by this pool.
Parameters
texture
The texture to check.
Returns
boolean
True if the texture was allocated from this pool and has not been fully released.
disposeFrameBuffer()
disposeFrameBuffer(
fb):void
Defined in: libs/device/src/pool.ts:358
Dispose a framebuffer that is allocated from the object pool.
Parameters
fb
The framebuffer to dispose.
Returns
void
releaseFrameBuffer()
releaseFrameBuffer(
fb):void
Defined in: libs/device/src/pool.ts:371
Release a framebuffer back to the object pool.
Parameters
fb
The framebuffer to release.
Returns
void
retainFrameBuffer()
retainFrameBuffer(
fb):void
Defined in: libs/device/src/pool.ts:392
Increment reference counter for given framebuffer
Parameters
fb
The framebuffer to retain
Returns
void
purge()
purge():
void
Defined in: libs/device/src/pool.ts:403
Purge the object pool by disposing all free framebuffers and textures.
Returns
void