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.
  • Field Details

    • INPUT_RATE_VERTEX

      public static final int INPUT_RATE_VERTEX
      Input rates other than 0 and 1 are not supported.
      See Also:
    • INPUT_RATE_INSTANCE

      public static final int INPUT_RATE_INSTANCE
      See Also:
  • Constructor Details

    • VertexInputLayout

      public VertexInputLayout(@Nonnull VertexInputLayout.AttributeSet... attributeSets)
      Enable all attributes for each AttributeSet.
      See Also:
    • 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

      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:
    • 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.