Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    GraphicsResourceAllocator Class

    Namespace: Stride.Graphics
    Assembly: Stride.Graphics.dll

    A GraphicsResource allocator tracking usage reference and allowing to recycle unused resources based on a recycle policy.

    System.Object → DisposeBase → ComponentBase → GraphicsResourceAllocator
    Derived from GraphicsResourceAllocator:

    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.

    | Improve this Doc View Source

    Constructors


    GraphicsResourceAllocator(GraphicsDevice)

    Initializes a new instance of the GraphicsResourceAllocator class.

    public GraphicsResourceAllocator(GraphicsDevice graphicsDevice)
    Parameters
    Type Name Description
    GraphicsDevice graphicsDevice

    The graphics device.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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
    ComponentBase.Destroy()

    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

    Inherited Members

    ComponentBase.Tags
    ComponentBase.Name
    ComponentBase.ICollectorHolder.Collector
    ComponentBase.OnNameChanged()
    ComponentBase.ToString()
    DisposeBase.Dispose()
    DisposeBase.IsDisposed
    DisposeBase.IReferencable.ReferenceCount
    DisposeBase.IReferencable.AddReference()
    DisposeBase.IReferencable.Release()
    DisposeBase.OnAddReference()
    DisposeBase.OnReleaseReference()

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    GraphicsResourceAllocatorExtensions.GetTemporaryTexture2D(GraphicsResourceAllocator, TextureDescription)
    GraphicsResourceAllocatorExtensions.GetTemporaryTexture2D(GraphicsResourceAllocator, Int32, Int32, PixelFormat, TextureFlags, Int32)
    GraphicsResourceAllocatorExtensions.GetTemporaryTexture2D(GraphicsResourceAllocator, Int32, Int32, PixelFormat, MipMapCount, TextureFlags, Int32)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation