pub struct Renderer { /* private fields */ }
Expand description

Vulkan renderer for imgui.

It records rendering command to the provided command buffer at each call to cmd_draw.

The renderer holds a set of vertex/index buffers per in flight frames. Vertex and index buffers are resized at each call to cmd_draw if draw data does not fit.

Implementations

Initialize and return a new instance of the renderer.

At initialization all Vulkan resources are initialized and font texture is created and uploaded to the gpu. Vertex and index buffers are not created yet.

Arguments
  • instance - A reference to a Vulkan instance.
  • physical_device - A Vulkan physical device.
  • device - A Vulkan device.
  • queue - A Vulkan queue. It will be used to submit commands during initialization to upload data to the gpu. The type of queue must be supported by the following commands: vkCmdCopyBufferToImage, vkCmdPipelineBarrier
  • command_pool - A Vulkan command pool used to allocate command buffers to upload textures to the gpu.
  • render_pass - The render pass used to render the gui.
  • imgui - The imgui context.
  • options - Optional parameters of the renderer.
Errors
  • RendererError - If the number of in flight frame in incorrect.
  • RendererError - If any Vulkan or io error is encountered during initialization.

Change the render pass to render to.

Useful if you need to render to a new render pass but don’t want to rebuild the entire renderer. It will rebuild the graphics pipeline from scratch so it is an expensive operation.

Arguments
  • render_pass - The render pass used to render the gui.
Errors
  • RendererError - If any Vulkan error is encountered during pipeline creation.

Returns the texture mapping used by the renderer to lookup textures.

Textures are provided by the application as vk::DescriptorSets.

Example
let descriptor_set = ...;
// Insert a vk::DescriptorSet in the renderer textures map.
// The renderer returns a generated texture id.
let texture_id = renderer.textures().insert(descriptor_set);
...
// Create an `Image` that references the texture by its id.
Image::new(texture_id, [100, 100]).build(&ui);
Caveat

Provided vk::DescriptorSets must be created with a descriptor set layout that is compatible with the one used by the renderer. See Pipeline Layout Compatibility.

Update the fonts texture after having added new fonts to imgui.

Arguments
  • queue - A Vulkan queue. It will be used to submit commands during initialization to upload data to the gpu. The type of queue must be supported by the following commands: vkCmdCopyBufferToImage, vkCmdPipelineBarrier
  • command_pool - A Vulkan command pool used to allocate command buffers to upload textures to the gpu.
  • imgui - The imgui context.
Errors
  • RendererError - If any error is encountered during texture update.

Record commands required to render the gui.RendererError.

Arguments
  • command_buffer - The Vulkan command buffer that command will be recorded to.
  • draw_data - A reference to the imgui DrawData containing rendering data.
Errors
  • RendererError - If any Vulkan error is encountered during command recording.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.