Class Gorgon2DShaderStateBuilder<T>
A fluent interface used to create shader states for use with a Gorgon2DBatchState.
Implements
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class Gorgon2DShaderStateBuilder<T> : IGorgonFluentBuilderAllocator<Gorgon2DShaderStateBuilder<T>, Gorgon2DShaderState<T>, IGorgonAllocator<Gorgon2DShaderState<T>>>, IGorgonFluentBuilder<Gorgon2DShaderStateBuilder<T>, Gorgon2DShaderState<T>> where T : GorgonShader
Type Parameters
Name | Description |
---|---|
T | The type of shader. |
Remarks
This builder creates shader states for state information wrapped around shaders based on GorgonShader. States built by this type are used for passing shader programs and related states to the Gorgon2DBatchState when setting up a batch render via Begin(Gorgon2DBatchState, GorgonCameraCommon).
If a custom pixel or vertex shader is assigned to the state, then developers should note which resource slots, and constant buffer slots are used by the 2D renderer itself. Gorgon will allow overriding of these slots, but in those cases, some information may no longer available and things may not work as expected. The following slots are use by the 2D renderer:
Shader Type | Resource type | Slot # | Purpose |
---|---|---|---|
Pixel | Texture/Sampler | 0 | Primary sprite texture/sampler. |
Pixel | Texture | 1 | Additional texture for effects. |
Pixel | Constants | 0 | Data for alpha testing. |
Pixel and Vertex | Constants | 12 | Timing data. |
Pixel and Vertex | Constants | 13 | Miscellaneous data (e.g. target width and height) |
Vertex | Constants | 0 | View/Projection matrix for the CurrentCamera (or the default camera if null). |
Vertex | Constants | 1 | Data for a polygon sprite. |
Methods
| Edit this page View SourceBuild()
Function to return the object.
Declaration
public Gorgon2DShaderState<T> Build()
Returns
Type | Description |
---|---|
Gorgon2DShaderState<T> | The object created or updated by this builder. |
See Also
| Edit this page View SourceBuild(IGorgonAllocator<Gorgon2DShaderState<T>>)
Function to return the object.
Declaration
public Gorgon2DShaderState<T> Build(IGorgonAllocator<Gorgon2DShaderState<T>> allocator)
Parameters
Type | Name | Description |
---|---|---|
IGorgonAllocator<Gorgon2DShaderState<T>> | allocator | The allocator used to create an instance of the object |
Returns
Type | Description |
---|---|
Gorgon2DShaderState<T> | The object created or updated by this builder. |
Remarks
Using an allocator
can provide different strategies when building objects. If omitted, the object 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.
See Also
| Edit this page View SourceClear()
Function to clear the builder to a default state.
Declaration
public Gorgon2DShaderStateBuilder<T> Clear()
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface. |
See Also
| Edit this page View SourceConstantBuffer(GorgonConstantBufferView, int)
Function to set a constant buffer for a specific shader stage.
Declaration
public Gorgon2DShaderStateBuilder<T> ConstantBuffer(GorgonConstantBufferView constantBuffer, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonConstantBufferView | constantBuffer | The constant buffer to assign. |
int | slot | The slot for the constant buffer. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceConstantBuffers(IReadOnlyList<GorgonConstantBufferView>, int)
Function to set the constant buffers for a specific shader stage.
Declaration
public Gorgon2DShaderStateBuilder<T> ConstantBuffers(IReadOnlyList<GorgonConstantBufferView> constantBuffers, int startSlot = 0)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<GorgonConstantBufferView> | constantBuffers | The constant buffers to copy. |
int | startSlot | [Optional] The starting slot to use when copying the list. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceResetTo(Gorgon2DShaderState<T>)
Function to reset the builder to the specified object state.
Declaration
public Gorgon2DShaderStateBuilder<T> ResetTo(Gorgon2DShaderState<T> builderObject = null)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2DShaderState<T> | builderObject | [Optional] The specified object state to copy. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface. |
See Also
| Edit this page View SourceSamplerState(GorgonSamplerState, int)
Function to assign a sampler to a shader on the pipeline.
Declaration
public Gorgon2DShaderStateBuilder<T> SamplerState(GorgonSamplerState sampler, int index = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonSamplerState | sampler | The sampler to assign. |
int | index | [Optional] The index of the sampler. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the |
See Also
| Edit this page View SourceSamplerState(GorgonSamplerStateBuilder, int)
Function to assign a sampler to a shader on the pipeline.
Declaration
public Gorgon2DShaderStateBuilder<T> SamplerState(GorgonSamplerStateBuilder sampler, int index = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonSamplerStateBuilder | sampler | The sampler to assign. |
int | index | [Optional] The index of the sampler. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the |
See Also
| Edit this page View SourceSamplerStates(IReadOnlyList<GorgonSamplerState>, int)
Function to assign a list of samplers to a shader on the pipeline.
Declaration
public Gorgon2DShaderStateBuilder<T> SamplerStates(IReadOnlyList<GorgonSamplerState> samplers, int index = 0)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<GorgonSamplerState> | samplers | The samplers to assign. |
int | index | [Optional] The starting index to use when copying. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the |
See Also
| Edit this page View SourceShader(T)
Function to assign the current shader.
Declaration
public Gorgon2DShaderStateBuilder<T> Shader(T shader)
Parameters
Type | Name | Description |
---|---|---|
T | shader | The shader to assign. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface. |
Remarks
This method is used to share an existing GorgonShader amongst many 2D shader instances. Shared shader objects are not owned by the resulting Gorgon2DShaderState<T>, and must have their lifetimes managed by the user.
See Also
| Edit this page View SourceShaderResource(GorgonShaderResourceView, int)
Function to assign a single shader resource view to the draw call.
Declaration
public Gorgon2DShaderStateBuilder<T> ShaderResource(GorgonShaderResourceView resourceView, int slot = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonShaderResourceView | resourceView | The shader resource view to assign. |
int | slot | [Optional] The slot used to asign the view. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceShaderResources(IReadOnlyList<GorgonShaderResourceView>, int)
Function to assign the list of shader resource views to the shader.
Declaration
public Gorgon2DShaderStateBuilder<T> ShaderResources(IReadOnlyList<GorgonShaderResourceView> resourceViews, int startSlot = 0)
Parameters
Type | Name | Description |
---|---|---|
IReadOnlyList<GorgonShaderResourceView> | resourceViews | The shader resource views to copy. |
int | startSlot | [Optional] The starting slot to use when copying the list. |
Returns
Type | Description |
---|---|
Gorgon2DShaderStateBuilder<T> | The fluent builder interface . |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |