Gorgon
Show / Hide Table of Contents

Class GorgonDrawCallBuilderCommon<TB, TDc>

Common functionality for the a draw call fluent builder.

Inheritance
object
GorgonDrawCallBuilderCommon<TB, TDc>
GorgonDrawCallBuilder
GorgonDrawIndexCallBuilder
Implements
IGorgonFluentBuilderAllocator<TB, TDc, IGorgonAllocator<TDc>>
IGorgonFluentBuilder<TB, TDc>
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
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 Source

DrawCall

Property to return the draw call being edited.

Declaration
protected TDc DrawCall { get; }
Property Value
Type Description
TDc
See Also
GorgonGraphics

Methods

| Edit this page View Source

Build()

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
GorgonGraphics
| Edit this page View Source

Build(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
GorgonGraphics
| Edit this page View Source

Clear()

Function to clear the builder to a default state.

Declaration
public TB Clear()
Returns
Type Description
TB

The fluent builder interface.

See Also
GorgonGraphics
| Edit this page View Source

ConstantBuffer(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 slot is less than 0, or greater than/equal to MaximumConstantBufferCount.

NotSupportedException

Thrown if the shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

ConstantBuffers(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 startSlot is less than 0, or greater than/equal to MaximumConstantBufferCount.

NotSupportedException

Thrown if the shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

OnClear()

Function to clear the draw call.

Declaration
protected abstract TB OnClear()
Returns
Type Description
TB

The fluent builder interface.

See Also
GorgonGraphics
| Edit this page View Source

OnCreate(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
GorgonGraphics
| Edit this page View Source

OnResetTo(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
GorgonGraphics
| Edit this page View Source

OnUpdate(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
GorgonGraphics
| Edit this page View Source

PipelineState(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 pipelineState parameter is null.

See Also
GorgonGraphics
| Edit this page View Source

PipelineState(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
GorgonGraphics
| Edit this page View Source

ReadWriteView(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 slot is less than 0, or greater than/equal to MaximumShaderResourceViewCount.

See Also
GorgonGraphics
| Edit this page View Source

ReadWriteViews(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 startSlot is less than 0, or greater than/equal to MaximumShaderResourceViewCount.

See Also
GorgonGraphics
| Edit this page View Source

ResetTo(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
GorgonGraphics
| Edit this page View Source

SamplerState(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 index parameter is less than 0, or greater than/equal to MaximumSamplerStateCount.

NotSupportedException

Thrown if the shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

SamplerState(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 shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

SamplerStates(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 index parameter is less than 0, or greater than/equal to MaximumSamplerStateCount.

NotSupportedException

Thrown if the shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

ShaderResource(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 slot is less than 0, or greater than/equal to MaximumShaderResourceViewCount.

NotSupportedException

Thrown if the shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

ShaderResources(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 startSlot is less than 0, or greater than/equal to MaximumShaderResourceViewCount.

NotSupportedException

Thrown if the shaderType is not valid.

See Also
GorgonGraphics
| Edit this page View Source

StreamOutBuffer(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 slot parameter is less than 0, or greater than/equal to MaximumStreamOutCount.

See Also
GorgonGraphics
| Edit this page View Source

StreamOutBuffers(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 bindings parameter is larger than the MaximumStreamOutCount.

See Also
GorgonGraphics
| Edit this page View Source

VertexBuffer(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 layout parameter is null.

ArgumentOutOfRangeException

Thrown when the slot parameter is less than 0, or greater than/equal to MaximumVertexBufferCount.

See Also
GorgonGraphics
| Edit this page View Source

VertexBuffers(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 layout parameter is null.

See Also
GorgonGraphics

Implements

IGorgonFluentBuilderAllocator<TB, TBo, TBa>
IGorgonFluentBuilder<TB, TBo>

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

GorgonGraphics
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author