GraphicsResourceAllocator Class
Namespace: Stride.GraphicsAssembly: Stride.Graphics.dll
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
Remarks
This class is threadsafe. Accessing a member will lock globally this instance.
| Name | Description | |
|---|---|---|
| Constructors | ||
| GraphicsResourceAllocator(GraphicsDevice) | Initializes a new instance of the GraphicsResourceAllocator class. |
|
| Properties | ||
| RecyclePolicy | Gets or sets the default recycle policy. Default is always recycle no matter the state of the resources. |
|
| Services | Gets the services registry. |
|
| Methods | ||
| AddReference(GraphicsResource) | Increments the reference to a temporary resource. |
|
| CreateBuffer(BufferDescription, PixelFormat) | Creates a temporary buffer. |
|
| CreateQueryPool(GraphicsResourceAllocator.QueryPoolDescription, PixelFormat) | ||
| CreateTexture(TextureDescription, PixelFormat) | Creates a texture for output. |
|
| Destroy() | ||
| GetQueryPool(QueryType, Int32) | ||
| GetTemporaryBuffer(BufferDescription, PixelFormat) | Gets a texture for the specified description. |
|
| GetTemporaryTexture(TextureDescription) | Gets a texture for the specified description. |
|
| Recycle() | Recycles unused resources (with a ReferenceCount == 0 ) with the RecyclePolicy. By Default, no recycle policy installed. |
|
| Recycle(GraphicsResourceRecyclePolicyDelegate) | Recycles unused resource with the specified recycle policy. |
|
| ReleaseReference(GraphicsResourceBase) | Decrements the reference to a temporary resource. |
|
Constructors
GraphicsResourceAllocator(GraphicsDevice)
Initializes a new instance of the GraphicsResourceAllocator class.
public GraphicsResourceAllocator(GraphicsDevice graphicsDevice)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsDevice | graphicsDevice | The 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
| Type | Description |
|---|---|
| GraphicsResourceRecyclePolicyDelegate | The default recycle policy. |
Services
Gets the services registry.
public IServiceRegistry Services { get; }
Property Value
| Type | Description |
|---|---|
| IServiceRegistry | The services registry. |
Methods
AddReference(GraphicsResource)
Increments the reference to a temporary resource.
public void AddReference(GraphicsResource resource)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsResource | resource |
CreateBuffer(BufferDescription, PixelFormat)
Creates a temporary buffer.
protected virtual Buffer CreateBuffer(BufferDescription description, PixelFormat viewFormat)
Parameters
| Type | Name | Description |
|---|---|---|
| BufferDescription | description | The description. |
| PixelFormat | viewFormat | The shader view format on the buffer |
Returns
| Type | Description |
|---|---|
| Buffer | Buffer. |
CreateQueryPool(GraphicsResourceAllocator.QueryPoolDescription, PixelFormat)
protected virtual QueryPool CreateQueryPool(GraphicsResourceAllocator.QueryPoolDescription description, PixelFormat viewFormat)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsResourceAllocator.QueryPoolDescription | description | |
| PixelFormat | viewFormat |
Returns
| Type | Description |
|---|---|
| QueryPool |
CreateTexture(TextureDescription, PixelFormat)
Creates a texture for output.
protected virtual Texture CreateTexture(TextureDescription description, PixelFormat viewFormat)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureDescription | description | The description. |
| PixelFormat | viewFormat | The pixel format seen by the shader |
Returns
| Type | Description |
|---|---|
| Texture | Texture. |
Destroy()
protected override void Destroy()
Overrides
GetQueryPool(QueryType, Int32)
public QueryPool GetQueryPool(QueryType queryType, int queryCount)
Parameters
| Type | Name | Description |
|---|---|---|
| QueryType | queryType | |
| System.Int32 | queryCount |
Returns
| Type | Description |
|---|---|
| QueryPool |
GetTemporaryBuffer(BufferDescription, PixelFormat)
Gets a texture for the specified description.
public Buffer GetTemporaryBuffer(BufferDescription description, PixelFormat viewFormat = PixelFormat.None)
Parameters
| Type | Name | Description |
|---|---|---|
| BufferDescription | description | The description. |
| PixelFormat | viewFormat | The pixel format seen by the shader |
Returns
| Type | Description |
|---|---|
| Buffer | A texture |
GetTemporaryTexture(TextureDescription)
Gets a texture for the specified description.
public Texture GetTemporaryTexture(TextureDescription description)
Parameters
| Type | Name | Description |
|---|---|---|
| TextureDescription | description | The description. |
Returns
| Type | Description |
|---|---|
| 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
| Type | Name | Description |
|---|---|---|
| GraphicsResourceRecyclePolicyDelegate | recyclePolicy | The recycle policy. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | recyclePolicy |
ReleaseReference(GraphicsResourceBase)
Decrements the reference to a temporary resource.
public void ReleaseReference(GraphicsResourceBase resource)
Parameters
| Type | Name | Description |
|---|---|---|
| GraphicsResourceBase | resource |