Class BatchBase<TDrawInfo>
Base class to batch a group of draw calls into one.
public abstract class BatchBase<TDrawInfo> : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder where TDrawInfo : structType Parameters
- TDrawInfo
- A structure containing all the required information to draw one element of the batch. 
- Inheritance
- 
      objectBatchBase<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
- deviceGraphicsDevice
- defaultEffectByteCodeEffectBytecode
- defaultEffectByteCodeSRgbEffectBytecode
- resourceBufferInfoBatchBase<TDrawInfo>.ResourceBufferInfo
- vertexDeclarationVertexDeclaration
- indexSizeint
Fields
DefaultEffect
protected readonly EffectInstance DefaultEffectField Value
DefaultEffectSRgb
protected readonly EffectInstance DefaultEffectSRgbField Value
ResourceContext
protected BatchBase<TDrawInfo>.DeviceResourceContext ResourceContextField Value
- BatchBase<TDrawInfo>.DeviceResourceContext
ResourceContextPool
protected readonly ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext> ResourceContextPoolField Value
- ThreadLocal<BatchBase<TDrawInfo>.DeviceResourceContext>
blendState
protected BlendStateDescription? blendStateField Value
depthStencilState
protected DepthStencilStateDescription? depthStencilStateField Value
graphicsDevice
protected GraphicsDevice graphicsDeviceField Value
mutablePipeline
protected MutablePipelineState mutablePipelineField Value
rasterizerState
protected RasterizerStateDescription? rasterizerStateField Value
samplerState
protected SamplerState samplerStateField Value
sortMode
protected SpriteSortMode sortModeField Value
stencilReferenceValue
protected int stencilReferenceValueField Value
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
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
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
- graphicsContextGraphicsContext
- The graphics context to use. 
- effectEffectInstance
- The effect to use for this begin/end draw session (default effect if null) 
- sessionSortModeSpriteSortMode
- Sprite drawing order used for the Begin/End session. 
- sessionBlendStateBlendStateDescription?
- Blending state used for the Begin/End session 
- sessionSamplerStateSamplerState
- Texture sampling used for the Begin/End session 
- sessionDepthStencilStateDepthStencilStateDescription?
- Depth and stencil state used for the Begin/End session 
- sessionRasterizerStateRasterizerStateDescription?
- Rasterization state used for the Begin/End session 
- stencilValueint
- 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
- functionNamestring
CheckEndHasBeenCalled(string)
protected void CheckEndHasBeenCalled(string functionName)Parameters
- functionNamestring
Destroy()
Disposes of object resources.
protected override void Destroy()Draw(Texture, in ElementInfo)
protected void Draw(Texture texture, in BatchBase<TDrawInfo>.ElementInfo elementInfo)Parameters
- textureTexture
- elementInfoBatchBase<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, nint, nint, int)
Update the mapped vertex and index buffer values using the provided element info.
protected abstract void UpdateBufferValuesFromElementInfo(ref BatchBase<TDrawInfo>.ElementInfo elementInfo, nint vertexPointer, nint indexPointer, int vexterStartOffset)Parameters
- elementInfoBatchBase<TDrawInfo>.ElementInfo
- The structure containing the information about the element to draw. 
- vertexPointernint
- The pointer to the vertex array buffer to update. 
- indexPointernint
- The pointer to the index array buffer to update. This value is null if the index buffer used is static. 
- vexterStartOffsetint
- The offset in the vertex buffer where the vertex of the element starts