Gorgon
Show / Hide Table of Contents

Struct GorgonInputElement

An input element for a buffer.

Implements
IGorgonNamedObject
IGorgonEquatableByRef<GorgonInputElement>
IEquatable<GorgonInputElement>
Inherited Members
ValueType.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public readonly struct GorgonInputElement : IGorgonNamedObject, IGorgonEquatableByRef<GorgonInputElement>, IEquatable<GorgonInputElement>
Remarks

This defines a single element within a GorgonInputLayout, and its relationship with other elements in that layout.

A GorgonInputLayout will use an array of these items to define individual elements for an input slot.

Constructors

| Edit this page View Source

GorgonInputElement(string, BufferFormat, int, int, int, bool, int)

Initializes a new instance of the GorgonInputElement class.

Declaration
public GorgonInputElement(string context, BufferFormat format, int offset, int index = 0, int slot = 0, bool instanced = false, int instanceCount = 0)
Parameters
Type Name Description
string context

The context for the element. This is used to indicate the HLSL semantic for the element.

BufferFormat format

The format and type of the element.

int offset

The offset, in bytes, between each element.

int index

[Optional] The index of the element. This is used when there are multiple elements with the same context. It allows the HLSL shader to differentiate between the elements.

int slot

[Optional] The input assembler slot for the element. This is used to accomodate a vertex buffer bound at a specific slot (e.g. a vertex buffer at slot 3 would use this input element also assigned at slot 3).

bool instanced

[Optional] true if using instanced data, false if not.

int instanceCount

[Optional] Number of instances, using the same per-instance data before moving to the next element. This value will be ignored if the instanced parameter is set to false.

Remarks

The slot parameter must be between 0 and 15 (inclusive). A value outside of this range will cause an exception to be thrown.

Exceptions
Type Condition
ArgumentNullException

Thrown when the context parameter is null.

ArgumentEmptyException

Thrown when the context parameter is empty.

ArgumentException

Thrown when the format parameter is not supported.

ArgumentOutOfRangeException

Thrown when the slot parameter is less than 0 or greater than 15.

Fields

| Edit this page View Source

SizeInBytes

Property to return the size, in bytes, of this element.

Declaration
public readonly int SizeInBytes
Field Value
Type Description
int
Remarks

This is directly influenced by the Format value.

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 return the format of the data.

Declaration
public BufferFormat Format { get; }
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 return The index of the context.

Declaration
public int Index { get; }
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 return the number of instances to draw.

Declaration
public int InstanceCount { get; }
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 return whether this data is instanced or per vertex.

Declaration
public bool Instanced { get; }
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 this element compared to other elements.

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 return the vertex buffer slot this element will use.

Declaration
public int Slot { get; }
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.

Methods

| Edit this page View Source

Equals(GorgonInputElement)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(GorgonInputElement other)
Parameters
Type Name Description
GorgonInputElement other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

Equals(in GorgonInputElement)

Function to compare this instance with another.

Declaration
public bool Equals(in GorgonInputElement other)
Parameters
Type Name Description
GorgonInputElement other

The other instance to use for comparison.

Returns
Type Description
bool

true if equal, false if not.

| Edit this page View Source

Equals(in GorgonInputElement, in GorgonInputElement)

Function to determine if two instances are equal.

Declaration
public static bool Equals(in GorgonInputElement left, in GorgonInputElement right)
Parameters
Type Name Description
GorgonInputElement left

The first instance to compare.

GorgonInputElement right

The second instance to compare.

Returns
Type Description
bool

true if equal, false if not.

| Edit this page View Source

Equals(object)

Determines whether the specified object is equal to this instance.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

The object to compare with this instance.

Returns
Type Description
bool

true if the specified object is equal to this instance; otherwise, false.

Overrides
ValueType.Equals(object)
| Edit this page View Source

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
ValueType.GetHashCode()

Operators

| Edit this page View Source

operator ==(in GorgonInputElement, in GorgonInputElement)

Implements the operator ==.

Declaration
public static bool operator ==(in GorgonInputElement left, in GorgonInputElement right)
Parameters
Type Name Description
GorgonInputElement left

The left.

GorgonInputElement right

The right.

Returns
Type Description
bool

The result of the operator.

| Edit this page View Source

operator !=(in GorgonInputElement, in GorgonInputElement)

Implements the operator !=.

Declaration
public static bool operator !=(in GorgonInputElement left, in GorgonInputElement right)
Parameters
Type Name Description
GorgonInputElement left

The left.

GorgonInputElement right

The right.

Returns
Type Description
bool

The result of the operator.

Implements

IGorgonNamedObject
IGorgonEquatableByRef<T>
IEquatable<T>

Extension Methods

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