Skip to content

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.

ReturnsSignatureSummary
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.

ReturnsSignatureSummary
voiddestroy()Destroys the render pass of the offscreen targets and the command pool.
voiddestroyImage(long[] image)Destroys the view, the image and the memory of an image created by createImage.
ReturnsSignatureSummary
voidtransition(VkCommandBuffer buffer, long image, int aspect, int oldLayout, int newLayout) staticRecords a barrier that moves the first level of the image from one layout to another.
voidtransition(VkCommandBuffer buffer, long image, int aspect, int oldLayout, int newLayout, int baseLevel, int levels) staticRecords a barrier that moves a range of levels of the image from one layout to another.
ReturnsSignatureSummary
VkQueuegetQueue()Returns the queue of the host.
VkDevicegetDevice()Returns the logical device.
intgetDepthFormat()Returns the depth format of the offscreen targets.
longgetCommandPool()Returns the command pool of the one-shot submissions.
StringgetDeviceName()Returns the name of the physical device.
intgetMaxTextureSize()Returns the largest width and height of an image, in pixels.
longgetUniformAlignment()Returns the alignment of the offsets of uniform buffers, in bytes.
intgetDepthStencilFormat()Returns the depth and stencil format of the screen target.
longgetOffscreenRenderPass()Returns the render pass of the offscreen targets.
VkPhysicalDevicegetPhysicalDevice()Returns the physical device.
VkPhysicalDeviceMemoryPropertiesgetMemoryProperties()Returns the memory types and heaps of the physical device.
ReturnsSignatureSummary
longcreateRenderPass(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.
voidsubmit(Consumer recorder)Records commands into a one-shot command buffer, submits it and waits for the queue.
longcreateCommandPool(VkDevice device, int queueFamilyIndex) staticCreates a command pool for that queue family, whose buffers can be reset.
longcreateImageView(VkDevice device, long image, int format, int aspect, int levels) staticCreates a 2D view of the image, with that format, aspect and number of levels.
voidcheck(int result, String action) staticThrows an IllegalStateException that names the call when the Vulkan result is not VK_SUCCESS.
TypeNameValueSummary
intTEXTURE_FORMATVK10.VK_FORMAT_B8G8R8A8_UNORMThe format of every texture and framebuffer color image of JOID, B8G8R8A8_UNORM.

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.

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.

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.

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.

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<VkCommandBuffer> recorder)

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:

  • 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.

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

Report a problem with this page