Class VulkanModuleVulkan

java.lang.Object
io.codetoil.curved_spacetime.MainCallback
io.codetoil.curved_spacetime.vulkan.VulkanModuleVulkan

public class VulkanModuleVulkan extends MainCallback
Owns the Vulkan objects that outlive any one window: the instance, the physical device, and the logical device.

Registered as a MainCallback so that its lifetime is tied to the engine rather than to a scene. Everything scene- or surface-specific — swap chains, render passes, framebuffers — is built on top of these by the render modules, which reach them through the getters here.

Creation order matters and is not negotiable: the instance must exist before a physical device can be selected, and a physical device before a logical one can be created. clean() unwinds in the reverse order, after waiting for the device to go idle.

  • Field Details

    • vulkanModuleVulkanInstance

      protected VulkanModuleVulkanInstance vulkanModuleVulkanInstance
      The Vulkan instance, created first during init().
    • vulkanModulePhysicalDevice

      protected VulkanModulePhysicalDevice vulkanModulePhysicalDevice
      The selected physical device.
    • vulkanModuleLogicalDevice

      protected VulkanModuleLogicalDevice vulkanModuleLogicalDevice
      The logical device created against the selected physical device.
  • Constructor Details

    • VulkanModuleVulkan

      public VulkanModuleVulkan(MainModuleEngine mainModuleEngine, VulkanModuleEntrypoint entrypoint)
      Creates the Vulkan callback.

      No Vulkan object is created until init() runs on the engine's callback thread.

      Parameters:
      mainModuleEngine - the engine this callback belongs to
      entrypoint - the Vulkan module's entrypoint, supplying configuration and logger
  • Method Details

    • init

      public void init()
      Creates the instance, selects a physical device, and creates the logical device.
      Specified by:
      init in class MainCallback
      Throws:
      RuntimeException - if no suitable physical device is available, or if any Vulkan call fails
    • loop

      public void loop()
      Description copied from class: MainCallback
      Advances this callback by one frame.

      Called repeatedly at the frame rate the engine's configuration specifies.

      Specified by:
      loop in class MainCallback
    • clean

      public void clean()
      Description copied from class: MainCallback
      Releases whatever this callback acquired in MainCallback.init().
      Specified by:
      clean in class MainCallback
    • getVulkanModuleVulkanInstance

      public VulkanModuleVulkanInstance getVulkanModuleVulkanInstance()
      Returns the Vulkan instance.
      Returns:
      the instance, or null before init()
    • getVulkanModulePhysicalDevice

      public VulkanModulePhysicalDevice getVulkanModulePhysicalDevice()
      Returns the selected physical device.
      Returns:
      the physical device, or null before init()
    • getVulkanModuleLogicalDevice

      public VulkanModuleLogicalDevice getVulkanModuleLogicalDevice()
      Returns the logical device.
      Returns:
      the logical device, or null before init()