Struct VertexElement
A description of a single element for the input-assembler stage. This structure is related to SharpDX.Direct3D11.InputElement.
[DataContract]
[DataSerializer(typeof(VertexElement.Serializer))]
public struct VertexElement : IEquatable<VertexElement>
- Implements
- Extension Methods
Remarks
Because SharpDX.Direct3D11.InputElement requires to have the same VertexBufferLayout.SlotIndex, VertexBufferLayout.VertexClassification and VertexBufferLayout.instanceDataStepRate, the VertexBufferLayout structure encapsulates a set of VertexElement for a particular slot, classification and instance data step rate. Unlike the default SharpDX.Direct3D11.InputElement, this structure accepts a semantic name with a postfix number that will be automatically extracted to the semantic index.
Constructors
VertexElement(string, PixelFormat)
Initializes a new instance of the VertexElement structure.
public VertexElement(string semanticName, PixelFormat format)
Parameters
semanticNamestringThe semantic name associated with this element, such as
"POSITION","TEXCOORD", or"NORMAL".
If the semantic name contains a postfix number, this number will be used as a semantic index, such as"TEXCOORD1"or"COLOR0".formatPixelFormatThe data format of the element, such as R32G32B32_Float (equivalent to Vector3) or R8G8B8A8_UNorm (equivalent to a 32-bit, 8bpc RGBA color).
Exceptions
VertexElement(string, int, PixelFormat, int)
Initializes a new instance of the VertexElement structure.
public VertexElement(string semanticName, int semanticIndex, PixelFormat format, int alignedByteOffset = -1)
Parameters
semanticNamestringThe semantic name associated with this element, such as
"POSITION","TEXCOORD", or"NORMAL".semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name, such as the
1in"TEXCOORD1"or the0in"COLOR0".formatPixelFormatThe data format of the element, such as R32G32B32_Float (equivalent to Vector3) or R8G8B8A8_UNorm (equivalent to a 32-bit, 8bpc RGBA color).
alignedByteOffsetintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Exceptions
- ArgumentException
- ArgumentException
Cannot specify a semantic index in the
semanticNamewhen using this constructor. Use the constructor with explicit semantic index instead (VertexElement(string, PixelFormat)).
Fields
AppendAligned
Returns a value that can be used for the offset parameter of an Vertex Element to indicate that the element should be aligned directly after the previous one, including any packing if neccessary.
public const int AppendAligned = -1
Field Value
Properties
AlignedByteOffset
The byte offset from the start of the vertex to this element.
public readonly int AlignedByteOffset { get; }
Property Value
Remarks
Use -1 (or a constant like AppendAligned to automatically align the element after the previous one,
including any packing if necessary.
Format
The data format of the element, such as R32G32B32_Float or R8G8B8A8_UNorm.
public readonly PixelFormat Format { get; }
Property Value
Remarks
This must match the format expected by the Shader and the layout of the Vertex Buffer.
SemanticAsText
Gets the HLSL semantic name associated with this element, such as "POSITION", "TEXCOORD", or "NORMAL".
It can contain a postfix number, the SemanticIndex, such as "TEXCOORD1" or "COLOR0".
public readonly string SemanticAsText { get; }
Property Value
Remarks
This name must match the semantic used in the Vertex Shader input signature.
- See Also
SemanticIndex
Gets the semantic index for the element, used when multiple elements share the same semantic name.
public readonly int SemanticIndex { get; }
Property Value
Remarks
For example, a 4x4 matrix might be passed as four "TEXCOORD" elements with indices 0 through 3.
SemanticName
Gets the HLSL semantic name associated with this element, such as "POSITION", "TEXCOORD", or "NORMAL".
public readonly string SemanticName { get; }
Property Value
Remarks
This name must match the semantic used in the Vertex Shader input signature.
Methods
BiTangent(PixelFormat, int)
Declares a VertexElement with the semantic "BITANGENT".
public static VertexElement BiTangent(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"BITANGENT"semantic.
BiTangent(int, PixelFormat, int)
Declares a VertexElement with the semantic "BITANGENT".
public static VertexElement BiTangent(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"BITANGENT"semantic.
BiTangent<T>(int, int)
Declares a VertexElement with the semantic "BITANGENT".
public static VertexElement BiTangent<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"BITANGENT"semantic.
Type Parameters
TThe type of the bitangent element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
Color(PixelFormat, int)
Declares a VertexElement with the semantic "COLOR".
public static VertexElement Color(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"COLOR"semantic.
Color(int, PixelFormat, int)
Declares a VertexElement with the semantic "COLOR".
public static VertexElement Color(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"COLOR"semantic.
Color<T>(int, int)
Declares a VertexElement with the semantic "COLOR".
public static VertexElement Color<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"COLOR"semantic.
Type Parameters
TThe type of the color element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
ConvertTypeToFormat<T>()
Converts a type T to its equivalent PixelFormat.
public static PixelFormat ConvertTypeToFormat<T>() where T : struct
Returns
- PixelFormat
The equivalent PixelFormat to
T.
Type Parameters
TThe type of the Vertex Element to convert.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
Equals(VertexElement)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(VertexElement other)
Parameters
otherVertexElementAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Normal(PixelFormat, int)
Declares a VertexElement with the semantic "NORMAL".
public static VertexElement Normal(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"NORMAL"semantic.
Normal(int, PixelFormat, int)
Declares a VertexElement with the semantic "NORMAL".
public static VertexElement Normal(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"NORMAL"semantic.
Normal<T>(int, int)
Declares a VertexElement with the semantic "NORMAL".
public static VertexElement Normal<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"NORMAL"semantic.
Type Parameters
TThe type of the normal element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
Position(PixelFormat, int)
Declares a VertexElement with the semantic "POSITION".
public static VertexElement Position(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"POSITION"semantic.
Position(int, PixelFormat, int)
Declares a VertexElement with the semantic "POSITION".
public static VertexElement Position(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"POSITION"semantic.
PositionTransformed(PixelFormat, int)
Declares a VertexElement with the semantic "SV_POSITION" (transformed position).
public static VertexElement PositionTransformed(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"SV_POSITION"semantic.
PositionTransformed(int, PixelFormat, int)
Declares a VertexElement with the semantic "SV_POSITION" (transformed position).
public static VertexElement PositionTransformed(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"SV_POSITION"semantic.
PositionTransformed<T>(int, int)
Declares a VertexElement with the semantic "SV_POSITION" (transformed position).
public static VertexElement PositionTransformed<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"SV_POSITION"semantic.
Type Parameters
TThe type of the tranformed position element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
Position<T>(int, int)
Declares a VertexElement with the semantic "POSITION".
public static VertexElement Position<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"POSITION"semantic.
Type Parameters
TThe type of the position element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
Tangent(PixelFormat, int)
Declares a VertexElement with the semantic "TANGENT".
public static VertexElement Tangent(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"TANGENT"semantic.
Tangent(int, PixelFormat, int)
Declares a VertexElement with the semantic "TANGENT".
public static VertexElement Tangent(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"TANGENT"semantic.
Tangent<T>(int, int)
Declares a VertexElement with the semantic "TANGENT".
public static VertexElement Tangent<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"TANGENT"semantic.
Type Parameters
TThe type of the tangent element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
TextureCoordinate(PixelFormat, int)
Declares a VertexElement with the semantic "TEXCOORD" (texture coordinates).
public static VertexElement TextureCoordinate(PixelFormat format, int offsetInBytes = -1)
Parameters
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"TEXCOORD"semantic.
TextureCoordinate(int, PixelFormat, int)
Declares a VertexElement with the semantic "TEXCOORD" (texture coordinates).
public static VertexElement TextureCoordinate(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
formatPixelFormatThe data format of the element.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"TEXCOORD"semantic.
TextureCoordinate<T>(int, int)
Declares a VertexElement with the semantic "TEXCOORD" (texture coordinates).
public static VertexElement TextureCoordinate<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndexintThe semantic index for the element, used when multiple elements share the same semantic name.
offsetInBytesintThe byte offset from the start of the vertex to this element. Use
-1(or a constant like AppendAligned to automatically align the element after the previous one.
Returns
- VertexElement
A new Vertex Element that represents the
"TEXCOORD"semantic.
Type Parameters
TThe type of the texture coordinates element.
Exceptions
- NotSupportedException
The specified
Tis not supported. It cannot be converted to a PixelFormat.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(VertexElement, VertexElement)
public static bool operator ==(VertexElement left, VertexElement right)
Parameters
leftVertexElementrightVertexElement
Returns
operator !=(VertexElement, VertexElement)
public static bool operator !=(VertexElement left, VertexElement right)
Parameters
leftVertexElementrightVertexElement