Struct VertexElement
A description of a single element for the input-assembler stage. This structure is related to Direct3D11.InputElement.
[DataContract]
[DataSerializer(typeof(VertexElement.Serializer))]
public struct VertexElement : IEquatable<VertexElement>
- Implements
Remarks
Because 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 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 struct.
public VertexElement(string semanticName, PixelFormat format)
Parameters
semanticName
stringName of the semantic.
format
PixelFormatThe format.
Remarks
If the semantic name contains a postfix number, this number will be used as a semantic index.
VertexElement(string, int, PixelFormat, int)
Initializes a new instance of the VertexElement struct.
public VertexElement(string semanticName, int semanticIndex, PixelFormat format, int alignedByteOffset = -1)
Parameters
semanticName
stringName of the semantic.
semanticIndex
intIndex of the semantic.
format
PixelFormatThe format.
alignedByteOffset
intThe aligned byte offset.
Fields
AppendAligned
Returns a value that can be used for the offset parameter of an InputElement to indicate that the element should be aligned directly after the previous element, including any packing if neccessary.
public const int AppendAligned = -1
Field Value
- int
A value used to align input elements.
Properties
AlignedByteOffset
Optional. Offset (in bytes) between each element. Use D3D11_APPEND_ALIGNED_ELEMENT for convenience to define the current element directly after the previous one, including any packing if necessary.
public int AlignedByteOffset { get; }
Property Value
Format
The data type of the element data. See SharpDX.DXGI.Format.
public PixelFormat Format { get; }
Property Value
SemanticAsText
The HLSL semantic associated with this element in a shader input-signature.
public string SemanticAsText { get; }
Property Value
SemanticIndex
The semantic index for the element. A semantic index modifies a semantic, with an integer index number. A semantic index is only needed in a case where there is more than one element with the same semantic. For example, a 4x4 matrix would have four components each with the semantic name
matrix
, however each of the four component would have different semantic indices (0, 1, 2, and 3).
public int SemanticIndex { get; }
Property Value
SemanticName
The HLSL semantic associated with this element in a shader input-signature.
public string SemanticName { get; }
Property Value
Methods
BiTangent(PixelFormat, int)
Declares a VertexElement with the semantic "BITANGENT".
public static VertexElement BiTangent(PixelFormat format, int offsetInBytes = -1)
Parameters
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
BiTangent(int, PixelFormat, int)
Declares a VertexElement with the semantic "BITANGENT".
public static VertexElement BiTangent(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this 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
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the BiTangent semantic.
Color(PixelFormat, int)
Declares a VertexElement with the semantic "COLOR".
public static VertexElement Color(PixelFormat format, int offsetInBytes = -1)
Parameters
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Color(int, PixelFormat, int)
Declares a VertexElement with the semantic "COLOR".
public static VertexElement Color(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this 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
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the Color semantic.
ConvertTypeToFormat<T>()
public static PixelFormat ConvertTypeToFormat<T>() where T : struct
Returns
Type Parameters
T
Equals(VertexElement)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(VertexElement other)
Parameters
other
VertexElementAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override 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
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Normal(int, PixelFormat, int)
Declares a VertexElement with the semantic "NORMAL".
public static VertexElement Normal(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this 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
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the Normal semantic.
Position(PixelFormat, int)
Declares a VertexElement with the semantic "POSITION".
public static VertexElement Position(PixelFormat format, int offsetInBytes = -1)
Parameters
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Position(int, PixelFormat, int)
Declares a VertexElement with the semantic "POSITION".
public static VertexElement Position(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
PositionTransformed(PixelFormat, int)
Declares a VertexElement with the semantic "SV_POSITION".
public static VertexElement PositionTransformed(PixelFormat format, int offsetInBytes = -1)
Parameters
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
PositionTransformed(int, PixelFormat, int)
Declares a VertexElement with the semantic "SV_POSITION".
public static VertexElement PositionTransformed(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
PositionTransformed<T>(int, int)
Declares a VertexElement with the semantic "SV_POSITION".
public static VertexElement PositionTransformed<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the PositionTransformed semantic.
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
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the Position semantic.
Tangent(PixelFormat, int)
Declares a VertexElement with the semantic "TANGENT".
public static VertexElement Tangent(PixelFormat format, int offsetInBytes = -1)
Parameters
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Tangent(int, PixelFormat, int)
Declares a VertexElement with the semantic "TANGENT".
public static VertexElement Tangent(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this 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
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the Tangent semantic.
TextureCoordinate(PixelFormat, int)
Declares a VertexElement with the semantic "TEXCOORD".
public static VertexElement TextureCoordinate(PixelFormat format, int offsetInBytes = -1)
Parameters
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
TextureCoordinate(int, PixelFormat, int)
Declares a VertexElement with the semantic "TEXCOORD".
public static VertexElement TextureCoordinate(int semanticIndex, PixelFormat format, int offsetInBytes = -1)
Parameters
semanticIndex
intThe semantic index.
format
PixelFormatFormat of this element.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
TextureCoordinate<T>(int, int)
Declares a VertexElement with the semantic "TEXCOORD".
public static VertexElement TextureCoordinate<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct
Parameters
semanticIndex
intThe semantic index.
offsetInBytes
intThe offset in bytes of this element. Use AppendAligned to compute automatically the offset from previous elements.
Returns
- VertexElement
A new instance of VertexElement that represents this semantic.
Type Parameters
T
Type of the TextureCoordinate semantic.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(VertexElement, VertexElement)
public static bool operator ==(VertexElement left, VertexElement right)
Parameters
left
VertexElementright
VertexElement
Returns
operator !=(VertexElement, VertexElement)
public static bool operator !=(VertexElement left, VertexElement right)
Parameters
left
VertexElementright
VertexElement