Class GorgonDrawCallBuilderCommon<TB, TDc>
Common functionality for the a draw call fluent builder.
Inheritance
Implements
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public abstract class GorgonDrawCallBuilderCommon<TB, TDc> : IGorgonFluentBuilderAllocator<TB, TDc, IGorgonAllocator<TDc>>, IGorgonFluentBuilder<TB, TDc> where TB : GorgonDrawCallBuilderCommon<TB, TDc> where TDc : GorgonDrawCallCommon
Type Parameters
Name | Description |
---|---|
TB | The type of builder. |
TDc | The type of draw call. |
Remarks
A draw call is an immutable object that contains all of the state required to render mesh information. For each mesh an application needs to render, an single draw call should be issued via the Submit(GorgonDrawCall, in GorgonColor?, int, int) methods.
State management is handled internally by Gorgon so that duplicate states are not set and thus, performance is not impacted by redundant states.
This builder type uses a fluent interface to assemble the draw call, its resources and its GorgonPipelineState.
Properties
| Edit this page View SourceDrawCall
Property to return the draw call being edited.
Declaration
protected TDc DrawCall { get; }
Property Value
Type | Description |
---|---|
TDc |
See Also
Methods
| Edit this page View SourceBuild()
Function to return the draw call.
Declaration
public TDc Build()
Returns
Type | Description |
---|---|
TDc | The draw call created or updated by this builder. |
Exceptions
Type | Condition |
---|---|
GorgonException | Thrown if a GorgonVertexShader is not assigned to the VertexShader property with the PipelineState(GorgonPipelineStateBuilder) command. |
See Also
| Edit this page View SourceBuild(IGorgonAllocator<TDc>)
Function to return the draw call.
Declaration
public TDc Build(IGorgonAllocator<TDc> allocator)
Parameters
Type | Name | Description |
---|---|---|
IGorgonAllocator<TDc> | allocator | The allocator used to create an instance of the object |
Returns
Type | Description |
---|---|
TDc | The draw call created or updated by this builder. |
Remarks
Using an allocator
can provide different strategies when building draw calls. If omitted, the draw call will be created using the standard new keyword.
A custom allocator can be beneficial because it allows us to use a pool for allocating the objects, and thus allows for recycling of objects. This keeps the garbage collector happy by keeping objects around for as long as we need them, instead of creating objects that can potentially end up in the large object heap or in Gen 2.
A draw call requires that at least a vertex shader be bound. If none is present, then the method will throw an exception.
Exceptions
Type | Condition |
---|---|
GorgonException | Thrown if a GorgonVertexShader is not assigned to the VertexShader property with the PipelineState(GorgonPipelineStateBuilder) command. |
See Also
| Edit this page View SourceClear()
Function to clear the builder to a default state.
Declaration
public TB Clear()
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
See Also
| Edit this page View SourceConstantBuffer(ShaderType, GorgonConstantBufferView, int)
Function to set a constant buffer for a specific shader stage.
Declaration
public TB ConstantBuffer(ShaderType shaderType, GorgonConstantBufferView constantBuffer, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The shader stage to use. |
GorgonConstantBufferView | constantBuffer | The constant buffer to assign. |
int | slot | The slot for the constant buffer. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceConstantBuffers(ShaderType, IReadOnlyList<GorgonConstantBufferView>, int)
Function to set the constant buffers for a specific shader stage.
Declaration
public TB ConstantBuffers(ShaderType shaderType, IReadOnlyList<GorgonConstantBufferView> constantBuffers, int startSlot = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The shader stage to use. |
IReadOnlyList<GorgonConstantBufferView> | constantBuffers | The constant buffers to copy. |
int | startSlot | [Optional] The starting slot to use when copying the list. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceOnClear()
Function to clear the draw call.
Declaration
protected abstract TB OnClear()
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
See Also
| Edit this page View SourceOnCreate(IGorgonAllocator<TDc>)
Function to create a new draw call.
Declaration
protected abstract TDc OnCreate(IGorgonAllocator<TDc> allocator)
Parameters
Type | Name | Description |
---|---|---|
IGorgonAllocator<TDc> | allocator | The allocator to use when creating draw call objects. |
Returns
Type | Description |
---|---|
TDc | A new draw call. |
See Also
| Edit this page View SourceOnResetTo(TDc)
Function to reset the properties of the draw call to the draw call passed in.
Declaration
protected abstract TB OnResetTo(TDc drawCall)
Parameters
Type | Name | Description |
---|---|---|
TDc | drawCall | The draw call to copy from. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
See Also
| Edit this page View SourceOnUpdate(TDc)
Function to update the properties of the draw call from the working copy to the final copy.
Declaration
protected abstract void OnUpdate(TDc finalCopy)
Parameters
Type | Name | Description |
---|---|---|
TDc | finalCopy | The object representing the finalized copy. |
See Also
| Edit this page View SourcePipelineState(GorgonPipelineState)
Function to set the pipeline state for this draw call.
Declaration
public TB PipelineState(GorgonPipelineState pipelineState)
Parameters
Type | Name | Description |
---|---|---|
GorgonPipelineState | pipelineState | The pipeline state to assign. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourcePipelineState(GorgonPipelineStateBuilder)
Function to set the pipeline state for this draw call.
Declaration
public TB PipelineState(GorgonPipelineStateBuilder pipelineState)
Parameters
Type | Name | Description |
---|---|---|
GorgonPipelineStateBuilder | pipelineState | The pipeline state to assign. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
See Also
| Edit this page View SourceReadWriteView(in GorgonReadWriteViewBinding, int)
Function to assign a single read/write (unordered access) view to the draw call.
Declaration
public TB ReadWriteView(in GorgonReadWriteViewBinding resourceView, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonReadWriteViewBinding | resourceView | The shader resource view to assign. |
int | slot | [Optional] The slot used to asign the view. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceReadWriteViews(IReadOnlyList<GorgonReadWriteViewBinding>, int)
Function to assign the list of read/write (unordered access) views to the draw call.
Declaration
public TB ReadWriteViews(IReadOnlyList<GorgonReadWriteViewBinding> resourceViews, int startSlot = 0)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<GorgonReadWriteViewBinding> | resourceViews | The shader resource views to copy. |
int | startSlot | [Optional] The starting slot to use when copying the list. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface . |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceResetTo(TDc)
Function to reset the builder to the specified draw call state.
Declaration
public TB ResetTo(TDc drawCall = null)
Parameters
Type | Name | Description |
---|---|---|
TDc | drawCall | [Optional] The specified draw call state to copy. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
See Also
| Edit this page View SourceSamplerState(ShaderType, GorgonSamplerState, int)
Function to assign a sampler to a shader on the pipeline.
Declaration
public TB SamplerState(ShaderType shaderType, GorgonSamplerState sampler, int index = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The type of shader to update. |
GorgonSamplerState | sampler | The sampler to assign. |
int | index | [Optional] The index of the sampler. |
Returns
Type | Description |
---|---|
TB | The fluent interface for this builder. |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the |
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceSamplerState(ShaderType, GorgonSamplerStateBuilder, int)
Function to assign a sampler to a shader on the pipeline.
Declaration
public TB SamplerState(ShaderType shaderType, GorgonSamplerStateBuilder sampler, int index = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The type of shader to update. |
GorgonSamplerStateBuilder | sampler | The sampler to assign. |
int | index | [Optional] The index of the sampler. |
Returns
Type | Description |
---|---|
TB | The fluent interface for this builder. |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceSamplerStates(ShaderType, IReadOnlyList<GorgonSamplerState>, int)
Function to assign a list of samplers to a shader on the pipeline.
Declaration
public TB SamplerStates(ShaderType shaderType, IReadOnlyList<GorgonSamplerState> samplers, int index = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The type of shader to update. |
IReadOnlyList<GorgonSamplerState> | samplers | The samplers to assign. |
int | index | [Optional] The index to use when copying the list. |
Returns
Type | Description |
---|---|
TB | The fluent interface for this builder. |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the |
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceShaderResource(ShaderType, GorgonShaderResourceView, int)
Function to assign a single shader resource view to the draw call.
Declaration
public TB ShaderResource(ShaderType shaderType, GorgonShaderResourceView resourceView, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The shader stage to use. |
GorgonShaderResourceView | resourceView | The shader resource view to assign. |
int | slot | [Optional] The slot used to asign the view. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceShaderResources(ShaderType, IReadOnlyList<GorgonShaderResourceView>, int)
Function to assign the list of shader resource views to the draw call.
Declaration
public TB ShaderResources(ShaderType shaderType, IReadOnlyList<GorgonShaderResourceView> resourceViews, int startSlot = 0)
Parameters
Type | Name | Description |
---|---|---|
ShaderType | shaderType | The shader stage to use. |
IReadOnlyList<GorgonShaderResourceView> | resourceViews | The shader resource views to copy. |
int | startSlot | [Optional] The starting slot to use when copying the list. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface . |
Remarks
Compute shaders are not supported in this method will throw an exception.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
NotSupportedException | Thrown if the |
See Also
| Edit this page View SourceStreamOutBuffer(in GorgonStreamOutBinding, int)
Function to set a stream out binding for the draw call.
Declaration
public TB StreamOutBuffer(in GorgonStreamOutBinding binding, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonStreamOutBinding | binding | The stream out binding to use. |
int | slot | [Optional] The slot for the binding. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceStreamOutBuffers(IReadOnlyList<GorgonStreamOutBinding>)
Function to set a list of stream out bindings for the draw call.
Declaration
public TB StreamOutBuffers(IReadOnlyList<GorgonStreamOutBinding> bindings)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<GorgonStreamOutBinding> | bindings | The stream out bindings to use. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceVertexBuffer(GorgonInputLayout, in GorgonVertexBufferBinding, int)
Function to set a vertex buffer binding for the draw call.
Declaration
public TB VertexBuffer(GorgonInputLayout layout, in GorgonVertexBufferBinding binding, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonInputLayout | layout | The input layout to use. |
GorgonVertexBufferBinding | binding | The vertex buffer binding to set. |
int | slot | [Optional] The slot for the binding. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceVertexBuffers(GorgonInputLayout, IReadOnlyList<GorgonVertexBufferBinding>)
Function to set the vertex buffer bindings for the draw call.
Declaration
public TB VertexBuffers(GorgonInputLayout layout, IReadOnlyList<GorgonVertexBufferBinding> bindings)
Parameters
Type | Name | Description |
---|---|---|
GorgonInputLayout | layout | The input layout to use. |
IReadOnlyList<GorgonVertexBufferBinding> | bindings | The vertex buffer bindings to set. |
Returns
Type | Description |
---|---|
TB | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |