Package icyllis.arc3d.compiler

# Enum Class MemoryLayout

java.lang.Object
java.lang.Enum<MemoryLayout>
icyllis.arc3d.compiler.MemoryLayout

All Implemented Interfaces:
  `Serializable`, `Comparable<MemoryLayout>`, `Constable`

public enum MemoryLayout extends Enum<MemoryLayout>
Standard layout for interface blocks, according to OpenGL and Vulkan specification.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class java.lang.Enum

  `Enum.EnumDesc<E extends Enum<E>>`

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `Extended`
  SPIR-V extended alignment, for uniform blocks.
  `Scalar`
  Scalar alignment, may be slower than std430, for Vulkan if supported.
  `Std140`
  OpenGL standard layout, for uniform blocks.
  `Std430`
  OpenGL standard layout, for push constants and shader storage blocks.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `alignment(Type type)`
  Returns the alignment in bytes.
  `int`
  `alignment(Type type, int[] out)`
  Returns the alignment in bytes, also computes the size and stride simultaneously.
  `boolean`
  `isSupported(Type type)`
  Returns true if the type is host shareable, i.e., a composite type.
  `int`
  `size(Type type)`
  Returns the total size in bytes, including padding at the end.
  `int`
  `stride(Type type)`
  Returns the minimum stride for `SpvDecorationArrayStride` and `SpvDecorationMatrixStride`.
  `static MemoryLayout`
  `valueOf(String name)`
  Returns the enum constant of this class with the specified name.
  `static MemoryLayout[]`
  `values()`
  Returns an array containing the constants of this enum class, in the order they are declared.

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

  `clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### Std140

    public static final MemoryLayout Std140
    OpenGL standard layout, for uniform blocks. (GLSL only, OpenGL only)

    The base alignment of an array, matrix, and structure needs to be a multiple of 16.

  - ### Extended

    public static final MemoryLayout Extended
    SPIR-V extended alignment, for uniform blocks. (WGSL or SPIR-V, WebGPU, OpenGL or Vulkan)

    Similar to std140, the base alignment of an array and structure needs to be a multiple of 16, but that of a matrix does not.

  - ### Std430

    public static final MemoryLayout Std430
    OpenGL standard layout, for push constants and shader storage blocks. Can be used on uniform blocks for Vulkan, if supported. (GLSL, WGSL or SPIR-V, OpenGL, WebGPU or Vulkan)

  - ### Scalar

    public static final MemoryLayout Scalar
    Scalar alignment, may be slower than std430, for Vulkan if supported.

    Test only. We're unsure about if we can use the padding between the end of a structure or an array and the next multiple of alignment of that structure or array. glslang doesn't use it, but Vulkan spec allows it.

- ## Method Details

  - ### values

    public static MemoryLayout[] values()
    Returns an array containing the constants of this enum class, in the order they are declared.
    Returns:
      an array containing the constants of this enum class, in the order they are declared

  - ### valueOf

    public static MemoryLayout valueOf(String name)
    Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
    Parameters:
      `name` - the name of the enum constant to be returned.
    Returns:
      the enum constant with the specified name
    Throws:
      `IllegalArgumentException` - if this enum class has no constant with the specified name
      `NullPointerException` - if the argument is null

  - ### alignment

    public int alignment(@Nonnull Type type)
    Returns the alignment in bytes.

  - ### alignment

    public int alignment(@Nonnull Type type, @Nullable int[] out)
    Returns the alignment in bytes, also computes the size and stride simultaneously. out[0] holds `size(icyllis.arc3d.compiler.tree.Type)`, out[1] holds matrix stride, out[2] holds array stride. Matrix stride is non-zero only when the type is matrix or array-of-matrices. Array stride is non-zero only when the type is array.
    Parameters:
      `out` - size, matrix stride, array stride, respectively, can be null
    Returns:
      base alignment

  - ### stride

    public int stride(@Nonnull Type type)
    Returns the minimum stride for `SpvDecorationArrayStride` and `SpvDecorationMatrixStride`.

  - ### size

    public int size(@Nonnull Type type)
    Returns the total size in bytes, including padding at the end.

  - ### isSupported

    public boolean isSupported(@Nonnull Type type)
    Returns true if the type is host shareable, i.e., a composite type. Boolean type is not supported, use uint32 instead.