Stride

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

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

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

    BatchBase<TDrawInfo> Class

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

    Base class to batch a group of draw calls into one.

    System.Object → DisposeBase → ComponentBase → BatchBase<TDrawInfo>
    Derived from BatchBase<TDrawInfo>: Sprite3DBatch SpriteBatch UIBatch

    public abstract class BatchBase<TDrawInfo> : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder where TDrawInfo : struct
    Type Parameters
    Name Description
    TDrawInfo

    A structure containing all the required information to draw one element of the batch.

    Name Description
    Constructors
    BatchBase(GraphicsDevice, EffectBytecode, EffectBytecode, BatchBase<TDrawInfo>.ResourceBufferInfo, VertexDeclaration, Int32)
    Fields
    blendState
    DefaultEffect
    DefaultEffectSRgb
    depthStencilState
    graphicsDevice
    mutablePipeline
    rasterizerState
    ResourceContext
    ResourceContextPool
    samplerState
    sortMode
    stencilReferenceValue
    Properties
    BackToFrontComparer
    Effect

    The effect used for the current Begin/End session.

    FrontToBackComparer
    GraphicsContext
    Parameters

    Gets the parameters applied on the SpriteBatch effect.

    TextureComparer
    Methods
    Begin(GraphicsContext, EffectInstance, SpriteSortMode, Nullable<BlendStateDescription>, SamplerState, Nullable<DepthStencilStateDescription>, Nullable<RasterizerStateDescription>, Int32)

    Begins a sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil, rasterizer state objects and a custom effect. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, depthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default effect shader.

    CheckBeginHasBeenCalled(String)
    CheckEndHasBeenCalled(String)
    Destroy()
    Draw(Texture, in BatchBase<TDrawInfo>.ElementInfo)
    End()

    Flushes the sprite batch and restores the device state to how it was before Begin was called.

    PrepareForRendering()
    UpdateBufferValuesFromElementInfo(ref BatchBase<TDrawInfo>.ElementInfo, IntPtr, IntPtr, Int32)

    Update the mapped vertex and index buffer values using the provided element info.

    | Improve this Doc View Source

    Constructors


    BatchBase(GraphicsDevice, EffectBytecode, EffectBytecode, BatchBase<TDrawInfo>.ResourceBufferInfo, VertexDeclaration, Int32)

    protected BatchBase(GraphicsDevice device, EffectBytecode defaultEffectByteCode, EffectBytecode defaultEffectByteCodeSRgb, BatchBase<TDrawInfo>.ResourceBufferInfo resourceBufferInfo, VertexDeclaration vertexDeclaration, int indexSize = 2)
    Parameters
    Type Name Description
    GraphicsDevice device
    EffectBytecode defaultEffectByteCode
    EffectBytecode defaultEffectByteCodeSRgb
    BatchBase.ResourceBufferInfo<> resourceBufferInfo
    VertexDeclaration vertexDeclaration
    System.Int32 indexSize
    | Improve this Doc View Source

    Fields


    blendState

    protected BlendStateDescription? blendState
    Field Value
    Type Description
    System.Nullable<BlendStateDescription>

    DefaultEffect

    protected readonly EffectInstance DefaultEffect
    Field Value
    Type Description
    EffectInstance

    DefaultEffectSRgb

    protected readonly EffectInstance DefaultEffectSRgb
    Field Value
    Type Description
    EffectInstance

    depthStencilState

    protected DepthStencilStateDescription? depthStencilState
    Field Value
    Type Description
    System.Nullable<DepthStencilStateDescription>

    graphicsDevice

    protected GraphicsDevice graphicsDevice
    Field Value
    Type Description
    GraphicsDevice

    mutablePipeline

    protected MutablePipelineState mutablePipeline
    Field Value
    Type Description
    MutablePipelineState

    rasterizerState

    protected RasterizerStateDescription? rasterizerState
    Field Value
    Type Description
    System.Nullable<RasterizerStateDescription>

    ResourceContext

    protected BatchBase<TDrawInfo>.DeviceResourceContext ResourceContext
    Field Value
    Type Description
    BatchBase.DeviceResourceContext<>

    ResourceContextPool

    protected readonly ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext> ResourceContextPool
    Field Value
    Type Description
    System.Threading.ThreadLocal<BatchBase.DeviceResourceContext<>>

    samplerState

    protected SamplerState samplerState
    Field Value
    Type Description
    SamplerState

    sortMode

    protected SpriteSortMode sortMode
    Field Value
    Type Description
    SpriteSortMode

    stencilReferenceValue

    protected int stencilReferenceValue
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    Properties


    BackToFrontComparer

    protected BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo> BackToFrontComparer { get; set; }
    Property Value
    Type Description
    BatchBase.QueueComparer<BatchBase.ElementInfo<>>

    Effect

    The effect used for the current Begin/End session.

    protected EffectInstance Effect { get; }
    Property Value
    Type Description
    EffectInstance

    FrontToBackComparer

    protected BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo> FrontToBackComparer { get; set; }
    Property Value
    Type Description
    BatchBase.QueueComparer<BatchBase.ElementInfo<>>

    GraphicsContext

    protected GraphicsContext GraphicsContext { get; }
    Property Value
    Type Description
    GraphicsContext

    Parameters

    Gets the parameters applied on the SpriteBatch effect.

    public ParameterCollection Parameters { get; }
    Property Value
    Type Description
    ParameterCollection

    The parameters.


    TextureComparer

    protected BatchBase<TDrawInfo>.TextureIdComparer TextureComparer { get; set; }
    Property Value
    Type Description
    BatchBase.TextureIdComparer<>
    | Improve this Doc View Source

    Methods


    Begin(GraphicsContext, EffectInstance, SpriteSortMode, Nullable<BlendStateDescription>, SamplerState, Nullable<DepthStencilStateDescription>, Nullable<RasterizerStateDescription>, Int32)

    Begins a sprite batch rendering using the specified sorting mode and blend state, sampler, depth stencil, rasterizer state objects and a custom effect. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, depthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default effect shader.

    protected void Begin(GraphicsContext graphicsContext, EffectInstance effect, SpriteSortMode sessionSortMode, BlendStateDescription? sessionBlendState, SamplerState sessionSamplerState, DepthStencilStateDescription? sessionDepthStencilState, RasterizerStateDescription? sessionRasterizerState, int stencilValue)
    Parameters
    Type Name Description
    GraphicsContext graphicsContext

    The graphics context to use.

    EffectInstance effect

    The effect to use for this begin/end draw session (default effect if null)

    SpriteSortMode sessionSortMode

    Sprite drawing order used for the Begin/End session.

    System.Nullable<BlendStateDescription> sessionBlendState

    Blending state used for the Begin/End session

    SamplerState sessionSamplerState

    Texture sampling used for the Begin/End session

    System.Nullable<DepthStencilStateDescription> sessionDepthStencilState

    Depth and stencil state used for the Begin/End session

    System.Nullable<RasterizerStateDescription> sessionRasterizerState

    Rasterization state used for the Begin/End session

    System.Int32 stencilValue

    The value of the stencil buffer to take as reference for the Begin/End session

    Exceptions
    Type Condition
    System.InvalidOperationException

    Only one SpriteBatch at a time can use SpriteSortMode.Immediate


    CheckBeginHasBeenCalled(String)

    protected void CheckBeginHasBeenCalled(string functionName)
    Parameters
    Type Name Description
    System.String functionName

    CheckEndHasBeenCalled(String)

    protected void CheckEndHasBeenCalled(string functionName)
    Parameters
    Type Name Description
    System.String functionName

    Destroy()

    protected override void Destroy()
    Overrides
    ComponentBase.Destroy()

    Draw(Texture, in BatchBase<TDrawInfo>.ElementInfo)

    protected void Draw(Texture texture, in BatchBase<TDrawInfo>.ElementInfo elementInfo)
    Parameters
    Type Name Description
    Texture texture
    BatchBase.ElementInfo<> elementInfo

    End()

    Flushes the sprite batch and restores the device state to how it was before Begin was called.

    public void End()

    PrepareForRendering()

    protected virtual void PrepareForRendering()

    UpdateBufferValuesFromElementInfo(ref BatchBase<TDrawInfo>.ElementInfo, IntPtr, IntPtr, Int32)

    Update the mapped vertex and index buffer values using the provided element info.

    protected abstract void UpdateBufferValuesFromElementInfo(ref BatchBase<TDrawInfo>.ElementInfo elementInfo, IntPtr vertexPointer, IntPtr indexPointer, int vexterStartOffset)
    Parameters
    Type Name Description
    BatchBase.ElementInfo<> elementInfo

    The structure containing the information about the element to draw.

    System.IntPtr vertexPointer

    The pointer to the vertex array buffer to update.

    System.IntPtr indexPointer

    The pointer to the index array buffer to update. This value is null if the index buffer used is static.

    System.Int32 vexterStartOffset

    The offset in the vertex buffer where the vertex of the element starts


    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)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

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