Package icyllis.arc3d.engine

# Class VertexInputLayout

java.lang.Object
icyllis.arc3d.engine.VertexInputLayout

@Immutable public final class VertexInputLayout extends Object
Describes the vertex input state of a graphics pipeline.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `VertexInputLayout.Attribute`
  Describes a vertex or instance attribute.
  `static class`
  `VertexInputLayout.AttributeSet`
  A set of attributes that can iterated.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `INPUT_RATE_INSTANCE`
  `static final int`
  `INPUT_RATE_VERTEX`
  Input rates other than 0 and 1 are not supported.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VertexInputLayout(VertexInputLayout.AttributeSet... attributeSets)`
  Enable all attributes for each AttributeSet.
  `VertexInputLayout(VertexInputLayout.AttributeSet[] attributeSets, int[] masks)`
  The constructor wraps the two given arrays (no copy), the caller should ensure the immutability.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getAttributeCount(int binding)`
  Returns the number of used attributes (input variables).
  `Iterator<VertexInputLayout.Attribute>`
  `getAttributes(int binding)`
  Returns an iterator of used attributes.
  `int`
  `getBindingCount()`
  Returns the number of binding points.
  `int`
  `getInputRate(int binding)`
  Returns the input rate for the given binding point.
  `int`
  `getLocationCount(int binding)`
  Returns the number of used per-vertex attribute locations (slots).
  `int`
  `getStride(int binding)`
  Returns the number of bytes from one vertex to the next vertex, including paddings.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### INPUT_RATE_VERTEX

    public static final int INPUT_RATE_VERTEX
    Input rates other than 0 and 1 are not supported.
    See Also:
      - Constant Field Values

  - ### INPUT_RATE_INSTANCE

    public static final int INPUT_RATE_INSTANCE
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### VertexInputLayout

    public VertexInputLayout(@Nonnull VertexInputLayout.AttributeSet... attributeSets)
    Enable all attributes for each AttributeSet.
    See Also:
      - `VertexInputLayout(AttributeSet[], int[])`

  - ### VertexInputLayout

    public VertexInputLayout(@Nonnull VertexInputLayout.AttributeSet[] attributeSets, @Nullable int[] masks)
    The constructor wraps the two given arrays (no copy), the caller should ensure the immutability.

    Each AttributeSet contains all attributes for the corresponding binding point. It may be shared across `VertexInputLayout` instances, then the masks array is used to control which attributes of the corresponding AttributeSet need to be used. A binding point can be empty but that is discouraged.

    E.g. if you want the 0, 2, 3 attributes are enabled, then mask is 0b1101.

- ## Method Details

  - ### getBindingCount

    public int getBindingCount()
    Returns the number of binding points.

  - ### getAttributeCount

    public int getAttributeCount(int binding)
    Returns the number of used attributes (input variables). Note: attribute of a matrix type counts as just one.
    See Also:
      - `getLocationCount(int)`

  - ### getLocationCount

    public int getLocationCount(int binding)
    Returns the number of used per-vertex attribute locations (slots). An attribute (variable) may take up multiple consecutive locations. The max number of locations matches the max number of attributes in `Caps`.
    See Also:
      - `SLDataType.locations(byte)`
      - `getAttributeCount(int)`
      - `Caps.MAX_VERTEX_ATTRIBUTES`

  - ### getStride

    public int getStride(int binding)
    Returns the number of bytes from one vertex to the next vertex, including paddings. A common practice is to populate the vertex's memory using an implicit array of structs. In this case, it is best to assert that: stride == sizeof(struct).

  - ### getInputRate

    public int getInputRate(int binding)
    Returns the input rate for the given binding point. 0 means per-vertex data, 1 means per-instance data.

  - ### getAttributes

    @Nonnull public Iterator<VertexInputLayout.Attribute> getAttributes(int binding)
    Returns an iterator of used attributes. It's safe to call even if there's no attribute. The iterator handles hides two pieces of complexity:
    1. It skips unused attributes (see mask in constructor).
    2. It always returns an attribute with a known offset.