Table of Contents

Class GraphicsResourceAllocator

Namespace
Stride.Graphics
Assembly
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
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

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

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

resource GraphicsResource

CreateBuffer(BufferDescription, PixelFormat)

Creates a temporary buffer.

protected virtual Buffer CreateBuffer(BufferDescription description, PixelFormat viewFormat)

Parameters

description BufferDescription

The description.

viewFormat PixelFormat

The shader view format on the buffer

Returns

Buffer

Buffer.

CreateQueryPool(QueryPoolDescription, PixelFormat)

protected virtual QueryPool CreateQueryPool(GraphicsResourceAllocator.QueryPoolDescription description, PixelFormat viewFormat)

Parameters

description GraphicsResourceAllocator.QueryPoolDescription
viewFormat PixelFormat

Returns

QueryPool

CreateTexture(TextureDescription, PixelFormat)

Creates a texture for output.

protected virtual Texture CreateTexture(TextureDescription description, PixelFormat viewFormat)

Parameters

description TextureDescription

The description.

viewFormat PixelFormat

The 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

queryType QueryType
queryCount int

Returns

QueryPool

GetTemporaryBuffer(BufferDescription, PixelFormat)

Gets a texture for the specified description.

public Buffer GetTemporaryBuffer(BufferDescription description, PixelFormat viewFormat = PixelFormat.None)

Parameters

description BufferDescription

The description.

viewFormat PixelFormat

The 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

description TextureDescription

The 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

recyclePolicy GraphicsResourceRecyclePolicyDelegate

The recycle policy.

Exceptions

ArgumentNullException

recyclePolicy

ReleaseReference(GraphicsResourceBase)

Decrements the reference to a temporary resource.

public void ReleaseReference(GraphicsResourceBase resource)

Parameters

resource GraphicsResourceBase