Class VulkanRenderModuleSurface

java.lang.Object
io.codetoil.curved_spacetime.render.vulkan.VulkanRenderModuleSurface
Direct Known Subclasses:
VulkanGLFWRenderModuleRenderModuleSurface

public abstract class VulkanRenderModuleSurface extends Object
A Vulkan surface: the bridge between a platform window and Vulkan's presentation machinery.

Creating one is inherently platform-specific, so this class holds only what is common — querying capabilities and negotiating a format — and leaves the actual creation to a subclass that knows the windowing library.

  • Field Details

    • vulkanModulePhysicalDevice

      protected final VulkanModulePhysicalDevice vulkanModulePhysicalDevice
      The physical device the surface's capabilities are queried against.
    • logger

      protected final Logger logger
      The logger this surface writes its diagnostics to.
  • Constructor Details

    • VulkanRenderModuleSurface

      public VulkanRenderModuleSurface(VulkanModulePhysicalDevice vulkanModulePhysicalDevice, Logger logger)
      Creates a surface bound to the given physical device.
      Parameters:
      vulkanModulePhysicalDevice - the device to query surface support against
      logger - the logger to write surface diagnostics to
  • Method Details

    • cleanup

      public abstract void cleanup()
      Destroys the surface and releases the platform resources behind it.
    • getSurfaceCaps

      public abstract org.lwjgl.vulkan.VkSurfaceCapabilitiesKHR getSurfaceCaps()
      Returns what this surface supports: image count bounds, extent bounds, and transforms.

      A swap chain must be built within these limits.

      Returns:
      the surface capabilities
    • getSurfaceFormat

      public abstract VulkanRenderModuleSurface.SurfaceFormat getSurfaceFormat()
      Returns the pixel format and colour space chosen for this surface.
      Returns:
      the negotiated surface format
    • calcSurfaceFormat

      protected VulkanRenderModuleSurface.SurfaceFormat calcSurfaceFormat()
      Picks a format from those the surface advertises.

      Prefers 32-bit BGRA in the sRGB non-linear colour space, which is what a display expects, and otherwise falls back to whatever the surface offers first.

      Returns:
      the chosen format and colour space
      Throws:
      RuntimeException - if the surface advertises no formats at all
    • getVkSurface

      public abstract long getVkSurface()
      Returns the underlying Vulkan handle.
      Returns:
      the VkSurfaceKHR handle