Gorgon
Show / Hide Table of Contents

Class InputElementAttribute

An attribute to mark a field in a value type as an input element.

Inheritance
object
Attribute
InputElementAttribute
Implements
_Attribute
Inherited Members
Attribute.GetCustomAttributes(MemberInfo, Type)
Attribute.GetCustomAttributes(MemberInfo, Type, bool)
Attribute.GetCustomAttributes(MemberInfo)
Attribute.GetCustomAttributes(MemberInfo, bool)
Attribute.IsDefined(MemberInfo, Type)
Attribute.IsDefined(MemberInfo, Type, bool)
Attribute.GetCustomAttribute(MemberInfo, Type)
Attribute.GetCustomAttribute(MemberInfo, Type, bool)
Attribute.GetCustomAttributes(ParameterInfo)
Attribute.GetCustomAttributes(ParameterInfo, Type)
Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
Attribute.GetCustomAttributes(ParameterInfo, bool)
Attribute.IsDefined(ParameterInfo, Type)
Attribute.IsDefined(ParameterInfo, Type, bool)
Attribute.GetCustomAttribute(ParameterInfo, Type)
Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
Attribute.GetCustomAttributes(Module, Type)
Attribute.GetCustomAttributes(Module)
Attribute.GetCustomAttributes(Module, bool)
Attribute.GetCustomAttributes(Module, Type, bool)
Attribute.IsDefined(Module, Type)
Attribute.IsDefined(Module, Type, bool)
Attribute.GetCustomAttribute(Module, Type)
Attribute.GetCustomAttribute(Module, Type, bool)
Attribute.GetCustomAttributes(Assembly, Type)
Attribute.GetCustomAttributes(Assembly, Type, bool)
Attribute.GetCustomAttributes(Assembly)
Attribute.GetCustomAttributes(Assembly, bool)
Attribute.IsDefined(Assembly, Type)
Attribute.IsDefined(Assembly, Type, bool)
Attribute.GetCustomAttribute(Assembly, Type)
Attribute.GetCustomAttribute(Assembly, Type, bool)
Attribute.Equals(object)
Attribute.GetHashCode()
Attribute.Match(object)
Attribute.IsDefaultAttribute()
Attribute.TypeId
object.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
object.MemberwiseClone()
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:

  • byte
  • sbyte
  • short
  • ushort
  • int
  • uint
  • long
  • ulong
  • float
  • Vector2
  • Vector3
  • Vector4
  • GorgonColor
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 Source

InputElementAttribute(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.

| Edit this page View Source

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 Source

Context

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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).

| Edit this page View Source

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.

Implements

_Attribute

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author