Package icyllis.arc3d.compiler.spirv

# Class SPIRVCodeGenerator

java.lang.Object
icyllis.arc3d.compiler.CodeGenerator
icyllis.arc3d.compiler.spirv.SPIRVCodeGenerator

public final class SPIRVCodeGenerator extends CodeGenerator
SPIR-V code generator for OpenGL 4.5 and Vulkan 1.0 or above.

A SPIR-V module is a stream of uint32 words, the generated code is in host endianness, which can be little-endian or big-endian.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `GENERATOR_MAGIC_NUMBER`
  `final TargetApi`
  `mOutputTarget`
  `final SPIRVVersion`
  `mOutputVersion`
  `static final int`
  `NONE_ID`

  ### Fields inherited from class icyllis.arc3d.compiler.CodeGenerator

  `mCompiler, mTranslationUnit`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SPIRVCodeGenerator(ShaderCompiler compiler, TranslationUnit translationUnit, ShaderCaps shaderCaps)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ByteBuffer`
  `generateCode()`
  Generates the code and returns the pointer value.

  ### Methods inherited from class icyllis.arc3d.compiler.CodeGenerator

  `getContext`

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

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

- ## Field Details

  - ### GENERATOR_MAGIC_NUMBER

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

  - ### NONE_ID

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

  - ### mOutputTarget

    public final TargetApi mOutputTarget

  - ### mOutputVersion

    public final SPIRVVersion mOutputVersion

- ## Constructor Details

  - ### SPIRVCodeGenerator

    public SPIRVCodeGenerator(@Nonnull ShaderCompiler compiler, @Nonnull TranslationUnit translationUnit, @Nonnull ShaderCaps shaderCaps)

- ## Method Details

  - ### generateCode

    @Nullable public ByteBuffer generateCode()
    Description copied from class: `CodeGenerator`
    Generates the code and returns the pointer value. The code size in bytes is `Buffer.remaining()`. Check errors via `Context.getErrorHandler()`.

    The return value is a direct buffer, see `ByteBuffer.allocateDirect(int)`. A direct buffer wraps an address that points to off-heap memory, i.e. a native pointer. The byte order is `ByteOrder.nativeOrder()` and it's safe to pass the result to OpenGL and Vulkan API. There is no way to free this buffer explicitly, as it is subject to GC.

    Specified by:
      `generateCode` in class `CodeGenerator`
    Returns:
      the generated code, or null if there's an error