Table of Contents

Class BatchBase<TDrawInfo>

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

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

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

Type Parameters

TDrawInfo

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

Inheritance
BatchBase<TDrawInfo>
Implements
Derived
Inherited Members
Extension Methods

Constructors

BatchBase(GraphicsDevice, EffectBytecode, EffectBytecode, ResourceBufferInfo, VertexDeclaration, int)

protected BatchBase(GraphicsDevice device, EffectBytecode defaultEffectByteCode, EffectBytecode defaultEffectByteCodeSRgb, BatchBase<TDrawInfo>.ResourceBufferInfo resourceBufferInfo, VertexDeclaration vertexDeclaration, int indexSize = 2)

Parameters

device GraphicsDevice
defaultEffectByteCode EffectBytecode
defaultEffectByteCodeSRgb EffectBytecode
resourceBufferInfo BatchBase<TDrawInfo>.ResourceBufferInfo
vertexDeclaration VertexDeclaration
indexSize int

Fields

DefaultEffect

protected readonly EffectInstance DefaultEffect

Field Value

EffectInstance

DefaultEffectSRgb

protected readonly EffectInstance DefaultEffectSRgb

Field Value

EffectInstance

ResourceContext

protected BatchBase<TDrawInfo>.DeviceResourceContext ResourceContext

Field Value

BatchBase<TDrawInfo>.DeviceResourceContext

ResourceContextPool

protected readonly ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext> ResourceContextPool

Field Value

ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext>

blendState

protected BlendStateDescription? blendState

Field Value

BlendStateDescription?

depthStencilState

protected DepthStencilStateDescription? depthStencilState

Field Value

DepthStencilStateDescription?

graphicsDevice

protected GraphicsDevice graphicsDevice

Field Value

GraphicsDevice

mutablePipeline

protected MutablePipelineState mutablePipeline

Field Value

MutablePipelineState

rasterizerState

protected RasterizerStateDescription? rasterizerState

Field Value

RasterizerStateDescription?

samplerState

protected SamplerState samplerState

Field Value

SamplerState

sortMode

protected SpriteSortMode sortMode

Field Value

SpriteSortMode

stencilReferenceValue

protected int stencilReferenceValue

Field Value

int

Properties

BackToFrontComparer

protected BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo> BackToFrontComparer { get; set; }

Property Value

BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo>

Effect

The effect used for the current Begin/End session.

protected EffectInstance Effect { get; }

Property Value

EffectInstance

FrontToBackComparer

protected BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo> FrontToBackComparer { get; set; }

Property Value

BatchBase<TDrawInfo>.QueueComparer<BatchBase<TDrawInfo>.ElementInfo>

GraphicsContext

protected GraphicsContext GraphicsContext { get; }

Property Value

GraphicsContext

Parameters

Gets the parameters applied on the SpriteBatch effect.

public ParameterCollection Parameters { get; }

Property Value

ParameterCollection

The parameters.

TextureComparer

protected BatchBase<TDrawInfo>.TextureIdComparer TextureComparer { get; set; }

Property Value

BatchBase<TDrawInfo>.TextureIdComparer

Methods

Begin(GraphicsContext, EffectInstance, SpriteSortMode, BlendStateDescription?, SamplerState, DepthStencilStateDescription?, RasterizerStateDescription?, int)

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

graphicsContext GraphicsContext

The graphics context to use.

effect EffectInstance

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

sessionSortMode SpriteSortMode

Sprite drawing order used for the Begin/End session.

sessionBlendState BlendStateDescription?

Blending state used for the Begin/End session

sessionSamplerState SamplerState

Texture sampling used for the Begin/End session

sessionDepthStencilState DepthStencilStateDescription?

Depth and stencil state used for the Begin/End session

sessionRasterizerState RasterizerStateDescription?

Rasterization state used for the Begin/End session

stencilValue int

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

Exceptions

InvalidOperationException

Only one SpriteBatch at a time can use SpriteSortMode.Immediate

CheckBeginHasBeenCalled(string)

protected void CheckBeginHasBeenCalled(string functionName)

Parameters

functionName string

CheckEndHasBeenCalled(string)

protected void CheckEndHasBeenCalled(string functionName)

Parameters

functionName string

Destroy()

Disposes of object resources.

protected override void Destroy()

Draw(Texture, in ElementInfo)

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

Parameters

texture Texture
elementInfo BatchBase<TDrawInfo>.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 ElementInfo, IntPtr, IntPtr, int)

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

elementInfo BatchBase<TDrawInfo>.ElementInfo

The structure containing the information about the element to draw.

vertexPointer IntPtr

The pointer to the vertex array buffer to update.

indexPointer IntPtr

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

vexterStartOffset int

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