Gorgon
Show / Hide Table of Contents

Class GorgonInputLayout

Defines the layout of an input item within a buffer.

Inheritance
object
GorgonInputLayout
Implements
IGorgonNamedObject
IEquatable<GorgonInputLayout>
IDisposable
Inherited Members
object.ToString()
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Core
Assembly: Gorgon.Graphics.Core.dll
Syntax
public sealed class GorgonInputLayout : IGorgonNamedObject, IEquatable<GorgonInputLayout>, IDisposable
Remarks

This defines the layout of a piece of data within a buffer, specifically, a vertex within a vertex buffer. The layout is defined by a list of GorgonInputElement values that determine how the data within the layout is arranged.

Users may create a layout manually, or, derive it from a value type (struct). If deriving from a value type, then the members of the value type must be decorated with a InputElementAttribute to define where the member is located within the layout data structure.

Constructors

| Edit this page View Source

GorgonInputLayout(GorgonGraphics, string, GorgonVertexShader, IEnumerable<GorgonInputElement>)

Initializes a new instance of the GorgonInputLayout class.

Declaration
public GorgonInputLayout(GorgonGraphics graphics, string name, GorgonVertexShader shader, IEnumerable<GorgonInputElement> elements)
Parameters
Type Name Description
GorgonGraphics graphics

The video adapter interface used to create this input layout.

string name

Name of the object.

GorgonVertexShader shader

Vertex shader to bind the layout with.

IEnumerable<GorgonInputElement> elements

The input elements to assign to this layout.

Exceptions
Type Condition
ArgumentNullException

Thrown when the name, graphics, shader, or the elements parameter is null.

ArgumentEmptyException

Thrown when the name, or the elements parameter is empty.

ArgumentException

Thrown when an element with the same context, slot and index appears more than once in the elements parameter.

Properties

| Edit this page View Source

Elements

Property to return the input elements for this layout.

Declaration
public IReadOnlyList<GorgonInputElement> Elements { get; }
Property Value
Type Description
IReadOnlyList<GorgonInputElement>
| Edit this page View Source

Graphics

Property to return the graphics interface that owns the object.

Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type Description
GorgonGraphics
| Edit this page View Source

Name

Property to return the name of this object.

Declaration
public string Name { get; }
Property Value
Type Description
string
Remarks

For best practises, the name should only be set once during the lifetime of an object. Hence, this interface only provides a read-only implementation of this property.

| Edit this page View Source

Shader

Property to return the shader that is bound with this input layout.

Declaration
public GorgonShader Shader { get; }
Property Value
Type Description
GorgonShader
| Edit this page View Source

SizeInBytes

Property to return the input object size in bytes.

Declaration
public int SizeInBytes { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

CreateUsingType(GorgonGraphics, Type, GorgonVertexShader)

Declaration
public static GorgonInputLayout CreateUsingType(GorgonGraphics graphics, Type type, GorgonVertexShader shader)
Parameters
Type Name Description
GorgonGraphics graphics
Type type
GorgonVertexShader shader
Returns
Type Description
GorgonInputLayout
Exceptions
Type Condition
ArgumentNullException
ArgumentException
| Edit this page View Source

CreateUsingType<T>(GorgonGraphics, GorgonVertexShader)

Declaration
public static GorgonInputLayout CreateUsingType<T>(GorgonGraphics graphics, GorgonVertexShader shader) where T : unmanaged
Parameters
Type Name Description
GorgonGraphics graphics
GorgonVertexShader shader
Returns
Type Description
GorgonInputLayout
Type Parameters
Name Description
T
| Edit this page View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()
| Edit this page View Source

ElementsFromType(Type)

Declaration
public static IReadOnlyList<GorgonInputElement> ElementsFromType(Type type)
Parameters
Type Name Description
Type type
Returns
Type Description
IReadOnlyList<GorgonInputElement>
Exceptions
Type Condition
ArgumentNullException
ArgumentException
GorgonException
| Edit this page View Source

ElementsFromType<T>()

Function to retrieve the input elements from the type passed in.

Declaration
public static IReadOnlyList<GorgonInputElement> ElementsFromType<T>() where T : unmanaged
Returns
Type Description
IReadOnlyList<GorgonInputElement>

A list of input elements used to build the input layout.

Type Parameters
Name Description
T

The type to evaluate.

| Edit this page View Source

Equals(GorgonInputLayout)

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

Declaration
public bool Equals(GorgonInputLayout layout)
Parameters
Type Name Description
GorgonInputLayout layout

An object to compare with this object.

Returns
Type Description
bool

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

| Edit this page View Source

Equals(object)

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

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

An object to compare with this object.

Returns
Type Description
bool

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

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

GetElement(string, int, int?)

Function to retrieve an element by its context, and optionally, its context index and/or slot.

Declaration
public GorgonInputElement? GetElement(string context, int index = 0, int? slot = null)
Parameters
Type Name Description
string context

The context name for the element.

int index

[Optional] The context index for the element.

int? slot

[Optional] The slot for the element.

Returns
Type Description
GorgonInputElement?

The element if found, or null if not.

| Edit this page View Source

GetElementsByContext(string, int?)

Function to retrieve any elements for a context.

Declaration
public IReadOnlyList<GorgonInputElement> GetElementsByContext(string context, int? index = null)
Parameters
Type Name Description
string context

The context of the elements to look up.

int? index

[Optional] The context index to restrict the elements to.

Returns
Type Description
IReadOnlyList<GorgonInputElement>

A list of input elements that belong to the specified context and index (if supplied).

| Edit this page View Source

GetElementsForSlot(int)

Function to retrieve any elements for a given slot number.

Declaration
public IReadOnlyList<GorgonInputElement> GetElementsForSlot(int slot)
Parameters
Type Name Description
int slot

The slot to look up.

Returns
Type Description
IReadOnlyList<GorgonInputElement>

A list of input elements that belong to the specified slot.

| 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
object.GetHashCode()
| Edit this page View Source

GetSlotSize(int)

Property to return the size, in bytes, of the elements for a given slot.

Declaration
public int GetSlotSize(int slot)
Parameters
Type Name Description
int slot

The slot index assigned to the elements.

Returns
Type Description
int

The size of the elements in the slot, in bytes.

| Edit this page View Source

NormalizeOffsets()

Function to normalize the offsets in the element list.

Declaration
public void NormalizeOffsets()
Remarks

This is used to rebuild the offsets for the elements assigned to this layout. Ensure that this input layout is not bound to the pipeline before normalizing. Otherwise, an invalid binding will occur.

This will use the order of the elements as they appear in the list passed to this object to determine the offsets.

| Edit this page View Source

ToStreamOutLayout(int, byte)

Function to convert this input layout into a GorgonStreamOutLayout

Declaration
public GorgonStreamOutLayout ToStreamOutLayout(int stream = 0, byte slot = 0)
Parameters
Type Name Description
int stream

[Optional] The output stream to use.

byte slot

[Optional] The associated stream output buffer that is bound to the pipeline.

Returns
Type Description
GorgonStreamOutLayout

A new GorgonStreamOutLayout derived from this input layout.

Remarks

When streaming data out from the GPU, the layout of that data must be defined as a GorgonStreamOutLayout, which is quite similar to an input layout. For convenience, this method will create a new GorgonStreamOutLayout that uses the same semantics as the input layout.

See Also
GorgonStreamOutLayout

Implements

IGorgonNamedObject
IEquatable<T>
IDisposable

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