VulkanContext
final class VulkanContext
Package: dev.joid.backend.vulkan.render · Module: backend-vulkan · Source: VulkanContext.java
Backends: Vulkan
The device of the host seen by the Vulkan renderer, with its render passes, image and buffer creation, and one-shot submissions.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| VulkanContext(IVulkanHost host) | Reads the device of the host, its limits and its depth formats, and creates a command pool and the render pass of the offscreen targets. |
Methods
Section titled “Methods”Lifecycle
Section titled “Lifecycle”| Returns | Signature | Summary |
|---|---|---|
void | destroy() | Destroys the render pass of the offscreen targets and the command pool. |
void | destroyImage(long[] image) | Destroys the view, the image and the memory of an image created by createImage. |
Animation
Section titled “Animation”| Returns | Signature | Summary |
|---|---|---|
void | transition(VkCommandBuffer buffer, long image, int aspect, int oldLayout, int newLayout) static | Records a barrier that moves the first level of the image from one layout to another. |
void | transition(VkCommandBuffer buffer, long image, int aspect, int oldLayout, int newLayout, int baseLevel, int levels) static | Records a barrier that moves a range of levels of the image from one layout to another. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
VkQueue | getQueue() | Returns the queue of the host. |
VkDevice | getDevice() | Returns the logical device. |
int | getDepthFormat() | Returns the depth format of the offscreen targets. |
long | getCommandPool() | Returns the command pool of the one-shot submissions. |
String | getDeviceName() | Returns the name of the physical device. |
int | getMaxTextureSize() | Returns the largest width and height of an image, in pixels. |
long | getUniformAlignment() | Returns the alignment of the offsets of uniform buffers, in bytes. |
int | getDepthStencilFormat() | Returns the depth and stencil format of the screen target. |
long | getOffscreenRenderPass() | Returns the render pass of the offscreen targets. |
VkPhysicalDevice | getPhysicalDevice() | Returns the physical device. |
VkPhysicalDeviceMemoryProperties | getMemoryProperties() | Returns the memory types and heaps of the physical device. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
long | createRenderPass(int colorFormat, int depthFormat, boolean clearDepth) | Returns a render pass that loads the color of that format, and clears or loads the depth of the other format, the stencil with it when the format has one. |
long[] | createImage(int width, int height, int format, int usage, int aspect, int levels) | Creates an image of device memory and its view, and returns the image, the memory and the view handles, in that order. |
long[] | createBuffer(long size, int usage, int properties) | Creates a buffer with memory of those properties, and returns the buffer and the memory handles. |
void | submit(Consumer | Records commands into a one-shot command buffer, submits it and waits for the queue. |
long | createCommandPool(VkDevice device, int queueFamilyIndex) static | Creates a command pool for that queue family, whose buffers can be reset. |
long | createImageView(VkDevice device, long image, int format, int aspect, int levels) static | Creates a 2D view of the image, with that format, aspect and number of levels. |
void | check(int result, String action) static | Throws an IllegalStateException that names the call when the Vulkan result is not VK_SUCCESS. |
Constants and fields
Section titled “Constants and fields”| Type | Name | Value | Summary |
|---|---|---|---|
int | TEXTURE_FORMAT | VK10.VK_FORMAT_B8G8R8A8_UNORM | The format of every texture and framebuffer color image of JOID, B8G8R8A8_UNORM. |
Creation details
Section titled “Creation details”VulkanContext
Section titled “VulkanContext”VulkanContext(IVulkanHost host)
Reads the device of the host, its limits and its depth formats, and creates a command pool and the render pass of the offscreen targets.
Throws an IllegalStateException when the device supports no depth format of JOID.
Method details
Section titled “Method details”destroy
Section titled “destroy”void destroy()
Destroys the render pass of the offscreen targets and the command pool.
destroyImage
Section titled “destroyImage”void destroyImage(long[] image)
Destroys the view, the image and the memory of an image created by createImage.
transition
Section titled “transition”void transition(VkCommandBuffer buffer, long image, int aspect, int oldLayout, int newLayout) static
Records a barrier that moves the first level of the image from one layout to another.
void transition(VkCommandBuffer buffer, long image, int aspect, int oldLayout, int newLayout, int baseLevel, int levels) static
Records a barrier that moves a range of levels of the image from one layout to another.
getQueue
Section titled “getQueue”VkQueue getQueue()
Returns the queue of the host.
getDevice
Section titled “getDevice”VkDevice getDevice()
Returns the logical device.
getDepthFormat
Section titled “getDepthFormat”int getDepthFormat()
Returns the depth format of the offscreen targets.
getCommandPool
Section titled “getCommandPool”long getCommandPool()
Returns the command pool of the one-shot submissions.
getDeviceName
Section titled “getDeviceName”String getDeviceName()
Returns the name of the physical device.
getMaxTextureSize
Section titled “getMaxTextureSize”int getMaxTextureSize()
Returns the largest width and height of an image, in pixels.
getUniformAlignment
Section titled “getUniformAlignment”long getUniformAlignment()
Returns the alignment of the offsets of uniform buffers, in bytes.
getDepthStencilFormat
Section titled “getDepthStencilFormat”int getDepthStencilFormat()
Returns the depth and stencil format of the screen target.
getOffscreenRenderPass
Section titled “getOffscreenRenderPass”long getOffscreenRenderPass()
Returns the render pass of the offscreen targets.
getPhysicalDevice
Section titled “getPhysicalDevice”VkPhysicalDevice getPhysicalDevice()
Returns the physical device.
getMemoryProperties
Section titled “getMemoryProperties”VkPhysicalDeviceMemoryProperties getMemoryProperties()
Returns the memory types and heaps of the physical device.
createRenderPass
Section titled “createRenderPass”long createRenderPass(int colorFormat, int depthFormat, boolean clearDepth)
Returns a render pass that loads the color of that format, and clears or loads the depth of the other format, the stencil with it when the format has one.
createImage
Section titled “createImage”long[] createImage(int width, int height, int format, int usage, int aspect, int levels)
Creates an image of device memory and its view, and returns the image, the memory and the view handles, in that order.
createBuffer
Section titled “createBuffer”long[] createBuffer(long size, int usage, int properties)
Creates a buffer with memory of those properties, and returns the buffer and the memory handles.
submit
Section titled “submit”void submit(Consumer<VkCommandBuffer> recorder)
Records commands into a one-shot command buffer, submits it and waits for the queue.
createCommandPool
Section titled “createCommandPool”long createCommandPool(VkDevice device, int queueFamilyIndex) static
Creates a command pool for that queue family, whose buffers can be reset.
createImageView
Section titled “createImageView”long createImageView(VkDevice device, long image, int format, int aspect, int levels) static
Creates a 2D view of the image, with that format, aspect and number of levels.
void check(int result, String action) static
Throws:
IllegalStateException: … failed with the Vulkan error …, update the graphics driver or run with the Vulkan validation layers to find the call at fault
Throws an IllegalStateException that names the call when the Vulkan result is not VK_SUCCESS.
Constant and field details
Section titled “Constant and field details”TEXTURE_FORMAT
Section titled “TEXTURE_FORMAT”int TEXTURE_FORMAT
The format of every texture and framebuffer color image of JOID, B8G8R8A8_UNORM.
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
