Class VulkanRenderModuleSwapChain
java.lang.Object
io.codetoil.curved_spacetime.render.vulkan.VulkanRenderModuleSwapChain
The swap chain: the queue of images the GPU renders into and the surface presents.
Its configuration is negotiated rather than chosen. The image count, extent, and pixel format are all clamped to what the surface reports it can do, so the requested values are treated as preferences. Present mode follows the vsync setting: FIFO waits for the display's refresh, immediate does not.
A swap chain is tied to the surface's dimensions, so resizing a window invalidates it and it must be rebuilt.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe pair of semaphores that order one frame's work.static final recordA pixel format paired with the colour space it is interpreted in. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intWhich image in the chain is currently being drawn.protected final LoggerThe logger this swap chain writes its diagnostics to.protected final longThe underlying Vulkan swap chain handle.protected final VulkanModuleLogicalDeviceThe device this swap chain was created on.protected final VulkanRenderModuleImageView[]One view per swap chain image, through which the images are rendered into.protected final VulkanRenderModuleSwapChain.VulkanSurfaceFormatThe pixel format and colour space agreed with the surface.protected final org.lwjgl.vulkan.VkExtent2DThe swap chain images' dimensions, allocated off-heap and freed bycleanup(). -
Constructor Summary
ConstructorsConstructorDescriptionVulkanRenderModuleSwapChain(VulkanModuleLogicalDevice vulkanModuleLogicalDevice, VulkanRenderModuleSurface surface, RenderModuleWindow renderModuleWindow, int requestedImages, boolean vsync, Logger logger) Creates a swap chain against the given surface. -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Destroys the image views and the swap chain, and frees the extent.intReturns which image in the chain is currently being drawn.Returns the views through which the swap chain images are rendered into.Returns the device this swap chain was created on.Returns the pixel format and colour space this swap chain presents in.org.lwjgl.vulkan.VkExtent2DReturns the swap chain images' dimensions.
-
Field Details
-
vulkanModuleLogicalDevice
The device this swap chain was created on. -
vulkanRenderModuleImageViews
One view per swap chain image, through which the images are rendered into. -
vulkanSurfaceFormat
The pixel format and colour space agreed with the surface. -
vulkanSwapChainExtent
protected final org.lwjgl.vulkan.VkExtent2D vulkanSwapChainExtentThe swap chain images' dimensions, allocated off-heap and freed bycleanup(). -
vkSwapChain
protected final long vkSwapChainThe underlying Vulkan swap chain handle. -
logger
The logger this swap chain writes its diagnostics to. -
currentFrame
protected int currentFrameWhich image in the chain is currently being drawn.
-
-
Constructor Details
-
VulkanRenderModuleSwapChain
public VulkanRenderModuleSwapChain(VulkanModuleLogicalDevice vulkanModuleLogicalDevice, VulkanRenderModuleSurface surface, RenderModuleWindow renderModuleWindow, int requestedImages, boolean vsync, Logger logger) Creates a swap chain against the given surface.The requested image count is clamped to the surface's supported range, and the extent to its supported bounds, so the resulting swap chain may differ from what was asked for.
- Parameters:
vulkanModuleLogicalDevice- the device to create the swap chain onsurface- the surface to present torenderModuleWindow- the window supplying the fallback extentrequestedImages- how many images are wanted, subject to surface limitsvsync- whether to wait for the display's refresh when presentinglogger- the logger to write swap chain diagnostics to- Throws:
AssertionError- if the swap chain or its image views cannot be created
-
-
Method Details
-
cleanup
public void cleanup()Destroys the image views and the swap chain, and frees the extent. -
getVulkanSurfaceFormat
Returns the pixel format and colour space this swap chain presents in.- Returns:
- the negotiated surface format
-
getVulkanLogicalDevice
Returns the device this swap chain was created on.- Returns:
- the owning logical device
-
getCurrentFrame
public int getCurrentFrame()Returns which image in the chain is currently being drawn.- Returns:
- the current frame index
-
getVulkanSwapChainExtent
public org.lwjgl.vulkan.VkExtent2D getVulkanSwapChainExtent()Returns the swap chain images' dimensions.- Returns:
- the extent, owned by this object and freed by
cleanup()
-
getVulkanImageViews
Returns the views through which the swap chain images are rendered into.- Returns:
- one image view per swap chain image, owned by this object
-