Class InputElementAttribute
An attribute to mark a field in a value type as an input element.
Implements
Inherited Members
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
[AttributeUsage(AttributeTargets.Field)]
public class InputElementAttribute : Attribute, _Attribute
Remarks
Apply this to a field in a value type to allow the CreateUsingType<T>(GorgonGraphics, GorgonVertexShader) method to parse the value type and build an input element element list from it.
Using Unknown for the format will tell the library to try and figure out the type from the field/property. This will only work on members that return the following types:
If the type of the member is not on this list, then an exception will be thrown when the input layout is generated.
Constructors
| Edit this page View SourceInputElementAttribute(int, string)
Initializes a new instance of the InputElementAttribute class.
Declaration
public InputElementAttribute(int fieldOrder, string context)
Parameters
Type | Name | Description |
---|---|---|
int | fieldOrder | Explicit layout order of the field when being parsed from the type. |
string | context | The context of the element. |
Remarks
Using this constructor will indicate that the ordering of the elements within the layout will be based on the fieldOrder
passed to this constructor. All offsets for the elements
will automaticaly be derived from the Format, if specified. Otherwise, the type of the member will be used instead.
InputElementAttribute(string, BufferFormat, int)
Initializes a new instance of the InputElementAttribute class.
Declaration
public InputElementAttribute(string context, BufferFormat format, int offset)
Parameters
Type | Name | Description |
---|---|---|
string | context | The context of the element. |
BufferFormat | format | The format/type of the element. |
int | offset | Offset of the element in the structure. |
Properties
| Edit this page View SourceContext
Property to return the context of the element.
Declaration
public string Context { get; }
Property Value
Type | Description |
---|---|
string |
Remarks
This is a string value that corresponds to a shader semantic. For example, to specify a normal, the user would set this to "Normal". With the exception of the position element (which must be named "SV_Position"), these contexts can be any name as long as it maps to a corresponding vertex element in the shader.
Format
Property to set or return the format of the data.
Declaration
public BufferFormat Format { get; set; }
Property Value
Type | Description |
---|---|
BufferFormat |
Remarks
This is used to specify the type of data for the element, and will also determine how many bytes the element will occupy.
Index
Property to set or return the index of the context.
Declaration
public int Index { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
This is used to differentiate between elements with the same Context. For example, to define a 2nd set of texture coordinates, use the same Context for the element and define this value as 1 in the constructor.
InstanceCount
Property to set or return the number of instances to draw.
Declaration
public int InstanceCount { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
The number of instances to draw using the same per-instance data before moving to the next element.
If the Instanced value is set to false, then this value will be set to 0.
Instanced
Property to set or return whether this data is instanced or per vertex.
Declaration
public bool Instanced { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Indicates that the element should be included in instancing.
Offset
Property to return the offset of the element within the structure.
Declaration
public int Offset { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This is used to determine the order in which an element will appear after another element. For example, if the previous element has a format of R32G32B32A32_Float and an offset of 0, then this value needs to be set to 16. If this element were to use a format of R32G32_Float, then the following element would have an offset of 16 + 8 (24).
Slot
Property to set or return the vertex buffer slot this element will use.
Declaration
public int Slot { get; set; }
Property Value
Type | Description |
---|---|
int |
Remarks
Multiple vertex buffers can be used to identify parts of the same vertex. This is used to minimize the amount of data being written to a vertex buffer and provide better performance.
This value has a valid range of 0 to 15, inclusive.