Class GorgonInputLayout
Defines the layout of an input item within a buffer.
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonInputLayout : IGorgonNamedObject, IEquatable<GorgonInputLayout>, IDisposable
Remarks
This defines the layout of a piece of data within a buffer, specifically, a vertex within a vertex buffer. The layout is defined by a list of GorgonInputElement values that determine how the data within the layout is arranged.
Users may create a layout manually, or, derive it from a value type (struct
). If deriving from a value type, then the members of the value type must be decorated with a
InputElementAttribute to define where the member is located within the layout data structure.
Constructors
| Edit this page View SourceGorgonInputLayout(GorgonGraphics, string, GorgonVertexShader, IEnumerable<GorgonInputElement>)
Initializes a new instance of the GorgonInputLayout class.
Declaration
public GorgonInputLayout(GorgonGraphics graphics, string name, GorgonVertexShader shader, IEnumerable<GorgonInputElement> elements)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | The video adapter interface used to create this input layout. |
string | name | Name of the object. |
GorgonVertexShader | shader | Vertex shader to bind the layout with. |
IEnumerable<GorgonInputElement> | elements | The input elements to assign to this layout. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
ArgumentException | Thrown when an element with the same context, slot and index appears more than once in the |
Properties
| Edit this page View SourceElements
Property to return the input elements for this layout.
Declaration
public IReadOnlyList<GorgonInputElement> Elements { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<GorgonInputElement> |
Graphics
Property to return the graphics interface that owns the object.
Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
GorgonGraphics |
Name
Property to return the name of this object.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
For best practises, the name should only be set once during the lifetime of an object. Hence, this interface only provides a read-only implementation of this property.
Shader
Property to return the shader that is bound with this input layout.
Declaration
public GorgonShader Shader { get; }
Property Value
Type | Description |
---|---|
GorgonShader |
SizeInBytes
Property to return the input object size in bytes.
Declaration
public int SizeInBytes { get; }
Property Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceCreateUsingType(GorgonGraphics, Type, GorgonVertexShader)
Declaration
public static GorgonInputLayout CreateUsingType(GorgonGraphics graphics, Type type, GorgonVertexShader shader)
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | |
Type | type | |
GorgonVertexShader | shader |
Returns
Type | Description |
---|---|
GorgonInputLayout |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentException |
CreateUsingType<T>(GorgonGraphics, GorgonVertexShader)
Declaration
public static GorgonInputLayout CreateUsingType<T>(GorgonGraphics graphics, GorgonVertexShader shader) where T : unmanaged
Parameters
Type | Name | Description |
---|---|---|
GorgonGraphics | graphics | |
GorgonVertexShader | shader |
Returns
Type | Description |
---|---|
GorgonInputLayout |
Type Parameters
Name | Description |
---|---|
T |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
ElementsFromType(Type)
Declaration
public static IReadOnlyList<GorgonInputElement> ElementsFromType(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
IReadOnlyList<GorgonInputElement> |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | |
ArgumentException | |
GorgonException |
ElementsFromType<T>()
Function to retrieve the input elements from the type passed in.
Declaration
public static IReadOnlyList<GorgonInputElement> ElementsFromType<T>() where T : unmanaged
Returns
Type | Description |
---|---|
IReadOnlyList<GorgonInputElement> | A list of input elements used to build the input layout. |
Type Parameters
Name | Description |
---|---|
T | The type to evaluate. |
Equals(GorgonInputLayout)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(GorgonInputLayout layout)
Parameters
Type | Name | Description |
---|---|---|
GorgonInputLayout | layout | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object)
Indicates whether the current object is equal to another object of the same type.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Overrides
| Edit this page View SourceGetElement(string, int, int?)
Function to retrieve an element by its context, and optionally, its context index and/or slot.
Declaration
public GorgonInputElement? GetElement(string context, int index = 0, int? slot = null)
Parameters
Type | Name | Description |
---|---|---|
string | context | The context name for the element. |
int | index | [Optional] The context index for the element. |
int? | slot | [Optional] The slot for the element. |
Returns
Type | Description |
---|---|
GorgonInputElement? | The element if found, or null if not. |
GetElementsByContext(string, int?)
Function to retrieve any elements for a context.
Declaration
public IReadOnlyList<GorgonInputElement> GetElementsByContext(string context, int? index = null)
Parameters
Type | Name | Description |
---|---|---|
string | context | The context of the elements to look up. |
int? | index | [Optional] The context index to restrict the elements to. |
Returns
Type | Description |
---|---|
IReadOnlyList<GorgonInputElement> | A list of input elements that belong to the specified context and index (if supplied). |
GetElementsForSlot(int)
Function to retrieve any elements for a given slot number.
Declaration
public IReadOnlyList<GorgonInputElement> GetElementsForSlot(int slot)
Parameters
Type | Name | Description |
---|---|---|
int | slot | The slot to look up. |
Returns
Type | Description |
---|---|
IReadOnlyList<GorgonInputElement> | A list of input elements that belong to the specified slot. |
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
| Edit this page View SourceGetSlotSize(int)
Property to return the size, in bytes, of the elements for a given slot.
Declaration
public int GetSlotSize(int slot)
Parameters
Type | Name | Description |
---|---|---|
int | slot | The slot index assigned to the elements. |
Returns
Type | Description |
---|---|
int | The size of the elements in the slot, in bytes. |
NormalizeOffsets()
Function to normalize the offsets in the element list.
Declaration
public void NormalizeOffsets()
Remarks
This is used to rebuild the offsets for the elements assigned to this layout. Ensure that this input layout is not bound to the pipeline before normalizing. Otherwise, an invalid binding will occur.
This will use the order of the elements as they appear in the list passed to this object to determine the offsets.
ToStreamOutLayout(int, byte)
Function to convert this input layout into a GorgonStreamOutLayout
Declaration
public GorgonStreamOutLayout ToStreamOutLayout(int stream = 0, byte slot = 0)
Parameters
Type | Name | Description |
---|---|---|
int | stream | [Optional] The output stream to use. |
byte | slot | [Optional] The associated stream output buffer that is bound to the pipeline. |
Returns
Type | Description |
---|---|
GorgonStreamOutLayout | A new GorgonStreamOutLayout derived from this input layout. |
Remarks
When streaming data out from the GPU, the layout of that data must be defined as a GorgonStreamOutLayout, which is quite similar to an input layout. For convenience, this method will create a new GorgonStreamOutLayout that uses the same semantics as the input layout.