Skip to content

WindowVulkanHost

final class WindowVulkanHost
Implements: IVulkanHost
Package: dev.joid.backend.vulkan.host · Module: backend-vulkan · Source: WindowVulkanHost.java
Backends: Vulkan

The Vulkan host of a GLFW window, which owns the instance, the device and a swapchain that follows the size of the window.

It presents in MAILBOX when the surface offers it, FIFO otherwise.

ReturnsSignatureSummary
WindowVulkanHostcreate(long window) factoryCreates the host of the window with 2 frames in flight.
WindowVulkanHostcreate(long window, int framesInFlight) factoryCreates the host of the window with that many frames in flight: 1 waits for each frame, 2 or more records the next frame while the GPU draws the previous ones.

ReturnsSignatureSummary
VkCommandBuffergetCommandBuffer()Returns the command buffer of the current slot.
longgetTargetView()Returns the view of the acquired image of the swapchain.
longgetTargetImage()Returns the acquired image of the swapchain.
VkQueuegetQueue()Returns the graphics and present queue.
VkDevicegetDevice()Returns the logical device.
intgetFramesInFlight()Returns the number of frames in flight.
VkInstancegetInstance()Returns the Vulkan instance.
intgetQueueFamilyIndex()Returns the family of the queue.
VkPhysicalDevicegetPhysicalDevice()Returns the physical device.
intgetFrameIndex()Returns the slot of the current frame.
intgetTargetWidth()Returns the width of the swapchain images, in pixels.
intgetTargetHeight()Returns the height of the swapchain images, in pixels.
longgetFrameNumber()Returns the number of frames begun since the host was created.
booleanisFrameActive()If true, a frame is begun and not ended.
intgetColorFormat()Returns the format of the swapchain images.
ReturnsSignatureSummary
thisbeginFrame() fluentWaits for the slot of the frame, acquires the next image of the swapchain, recreating it when the window changed size, starts the command buffer and clears the image to black.
thisendFrame() fluentEnds the command buffer, submits it and presents the image.
voiddestroy()Waits for the device and destroys the swapchain, the surface, the device and the instance; call it after VulkanBackend.destroy().

WindowVulkanHost create(long window) factory

Creates the host of the window with 2 frames in flight. Throws an IllegalStateException when Vulkan is missing, or when no Vulkan 1.3 device can present to the window.

WindowVulkanHost create(long window, int framesInFlight) factory

Throws:

  • IllegalArgumentException: A Vulkan window host needs at least one frame in flight, got …: pass 1 to wait for each frame, 2 or more to record the next frame while the GPU draws the previous ones

Creates the host of the window with that many frames in flight: 1 waits for each frame, 2 or more records the next frame while the GPU draws the previous ones. Throws an IllegalArgumentException below 1.

VkCommandBuffer getCommandBuffer()

Returns the command buffer of the current slot.

long getTargetView()

Returns the view of the acquired image of the swapchain.

long getTargetImage()

Returns the acquired image of the swapchain.

VkQueue getQueue()

Returns the graphics and present queue.

VkDevice getDevice()

Returns the logical device.

int getFramesInFlight()

Returns the number of frames in flight.

VkInstance getInstance()

Returns the Vulkan instance.

int getQueueFamilyIndex()

Returns the family of the queue.

VkPhysicalDevice getPhysicalDevice()

Returns the physical device.

int getFrameIndex()

Returns the slot of the current frame.

int getTargetWidth()

Returns the width of the swapchain images, in pixels.

int getTargetHeight()

Returns the height of the swapchain images, in pixels.

long getFrameNumber()

Returns the number of frames begun since the host was created.

boolean isFrameActive()

If true, a frame is begun and not ended.

int getColorFormat()

Returns the format of the swapchain images.

this beginFrame() fluent

Throws:

  • IllegalStateException: The Vulkan window frame has already begun, call endFrame() first

Waits for the slot of the frame, acquires the next image of the swapchain, recreating it when the window changed size, starts the command buffer and clears the image to black. Throws an IllegalStateException when a frame is already begun.

this endFrame() fluent

Throws:

  • IllegalStateException: The Vulkan window frame has not begun, call beginFrame() first

Ends the command buffer, submits it and presents the image. Throws an IllegalStateException when no frame is begun.

void destroy()

Waits for the device and destroys the swapchain, the surface, the device and the instance; call it after VulkanBackend.destroy(). destroy() ends a frame left open, begun and not ended.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page