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.
Description
Section titled “Description”It presents in MAILBOX when the surface offers it, FIFO otherwise.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
WindowVulkanHost | create(long window) factory | Creates the host of the window with 2 frames in flight. |
WindowVulkanHost | create(long window, int framesInFlight) factory | 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. |
Methods
Section titled “Methods”Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
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. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
this | beginFrame() fluent | 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. |
this | endFrame() fluent | Ends the command buffer, submits it and presents the image. |
void | destroy() | Waits for the device and destroys the swapchain, the surface, the device and the instance; call it after VulkanBackend.destroy(). |
Creation details
Section titled “Creation details”create
Section titled “create”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.
Method details
Section titled “Method details”getCommandBuffer
Section titled “getCommandBuffer”VkCommandBuffer getCommandBuffer()
Returns the command buffer of the current slot.
getTargetView
Section titled “getTargetView”long getTargetView()
Returns the view of the acquired image of the swapchain.
getTargetImage
Section titled “getTargetImage”long getTargetImage()
Returns the acquired image of the swapchain.
getQueue
Section titled “getQueue”VkQueue getQueue()
Returns the graphics and present queue.
getDevice
Section titled “getDevice”VkDevice getDevice()
Returns the logical device.
getFramesInFlight
Section titled “getFramesInFlight”int getFramesInFlight()
Returns the number of frames in flight.
getInstance
Section titled “getInstance”VkInstance getInstance()
Returns the Vulkan instance.
getQueueFamilyIndex
Section titled “getQueueFamilyIndex”int getQueueFamilyIndex()
Returns the family of the queue.
getPhysicalDevice
Section titled “getPhysicalDevice”VkPhysicalDevice getPhysicalDevice()
Returns the physical device.
getFrameIndex
Section titled “getFrameIndex”int getFrameIndex()
Returns the slot of the current frame.
getTargetWidth
Section titled “getTargetWidth”int getTargetWidth()
Returns the width of the swapchain images, in pixels.
getTargetHeight
Section titled “getTargetHeight”int getTargetHeight()
Returns the height of the swapchain images, in pixels.
getFrameNumber
Section titled “getFrameNumber”long getFrameNumber()
Returns the number of frames begun since the host was created.
isFrameActive
Section titled “isFrameActive”boolean isFrameActive()
If true, a frame is begun and not ended.
getColorFormat
Section titled “getColorFormat”int getColorFormat()
Returns the format of the swapchain images.
beginFrame
Section titled “beginFrame”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.
endFrame
Section titled “endFrame”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.
destroy
Section titled “destroy”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
