Class GraphicsResourceAllocator
A GraphicsResource allocator tracking usage reference and allowing to recycle unused resources based on a recycle policy.
public class GraphicsResourceAllocator : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder
- Inheritance
-
GraphicsResourceAllocator
- Implements
- Inherited Members
- Extension Methods
Remarks
This class is threadsafe. Accessing a member will lock globally this instance.
Constructors
GraphicsResourceAllocator(GraphicsDevice)
Initializes a new instance of the GraphicsResourceAllocator class.
public GraphicsResourceAllocator(GraphicsDevice graphicsDevice)
Parameters
graphicsDeviceGraphicsDeviceThe graphics device.
Properties
RecyclePolicy
Gets or sets the default recycle policy. Default is always recycle no matter the state of the resources.
public GraphicsResourceRecyclePolicyDelegate RecyclePolicy { get; set; }
Property Value
- GraphicsResourceRecyclePolicyDelegate
The default recycle policy.
Services
Gets the services registry.
public IServiceRegistry Services { get; }
Property Value
- IServiceRegistry
The services registry.
Methods
AddReference(GraphicsResource)
Increments the reference to a temporary resource.
public void AddReference(GraphicsResource resource)
Parameters
resourceGraphicsResource
CreateBuffer(BufferDescription, PixelFormat)
Creates a temporary buffer.
protected virtual Buffer CreateBuffer(BufferDescription description, PixelFormat viewFormat)
Parameters
descriptionBufferDescriptionThe description.
viewFormatPixelFormatThe shader view format on the buffer
Returns
- Buffer
Buffer.
CreateQueryPool(QueryPoolDescription, PixelFormat)
protected virtual QueryPool CreateQueryPool(GraphicsResourceAllocator.QueryPoolDescription description, PixelFormat viewFormat)
Parameters
descriptionGraphicsResourceAllocator.QueryPoolDescriptionviewFormatPixelFormat
Returns
CreateTexture(TextureDescription, PixelFormat)
Creates a texture for output.
protected virtual Texture CreateTexture(TextureDescription description, PixelFormat viewFormat)
Parameters
descriptionTextureDescriptionThe description.
viewFormatPixelFormatThe pixel format seen by the shader
Returns
- Texture
Texture.
Destroy()
Disposes of object resources.
protected override void Destroy()
GetQueryPool(QueryType, int)
public QueryPool GetQueryPool(QueryType queryType, int queryCount)
Parameters
Returns
GetTemporaryBuffer(BufferDescription, PixelFormat)
Gets a texture for the specified description.
public Buffer GetTemporaryBuffer(BufferDescription description, PixelFormat viewFormat = PixelFormat.None)
Parameters
descriptionBufferDescriptionThe description.
viewFormatPixelFormatThe pixel format seen by the shader
Returns
- Buffer
A texture
GetTemporaryTexture(TextureDescription)
Gets a texture for the specified description.
public Texture GetTemporaryTexture(TextureDescription description)
Parameters
descriptionTextureDescriptionThe description.
Returns
- Texture
A texture
Recycle()
Recycles unused resources (with a ReferenceCount == 0 ) with the RecyclePolicy. By Default, no recycle policy installed.
public void Recycle()
Recycle(GraphicsResourceRecyclePolicyDelegate)
Recycles unused resource with the specified recycle policy.
public void Recycle(GraphicsResourceRecyclePolicyDelegate recyclePolicy)
Parameters
recyclePolicyGraphicsResourceRecyclePolicyDelegateThe recycle policy.
Exceptions
- ArgumentNullException
recyclePolicy
ReleaseReference(GraphicsResourceBase)
Decrements the reference to a temporary resource.
public void ReleaseReference(GraphicsResourceBase resource)
Parameters
resourceGraphicsResourceBase