Struct imgui_rs_vulkan_renderer::Renderer
source · pub struct Renderer { /* private fields */ }
Expand description
Implementations§
source§impl Renderer
impl Renderer
sourcepub fn with_default_allocator(
instance: &Instance,
physical_device: PhysicalDevice,
device: Device,
queue: Queue,
command_pool: CommandPool,
render_pass: RenderPass,
imgui: &mut Context,
options: Option<Options>
) -> RendererResult<Self>
pub fn with_default_allocator( instance: &Instance, physical_device: PhysicalDevice, device: Device, queue: Queue, command_pool: CommandPool, render_pass: RenderPass, imgui: &mut Context, options: Option<Options> ) -> RendererResult<Self>
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, vkCmdPipelineBarriercommand_pool
- A Vulkan command pool used to allocate command buffers to upload textures to the gpu.render_pass
- without dynamic-rendering feature - The render pass used to render the gui.dynamic_rendering
- with dynamic-rendering feature - Dynamic rendeing parametersimgui
- 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.
sourcepub fn set_render_pass(&mut self, render_pass: RenderPass) -> RendererResult<()>
pub fn set_render_pass(&mut self, render_pass: RenderPass) -> RendererResult<()>
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.
sourcepub fn textures(&mut self) -> &mut Textures<DescriptorSet>
pub fn textures(&mut self) -> &mut Textures<DescriptorSet>
Returns the texture mapping used by the renderer to lookup textures.
Textures are provided by the application as vk::DescriptorSet
s.
§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::DescriptorSet
s must be created with a descriptor set layout that is compatible with the one used by the renderer.
See Pipeline Layout Compatibility.
sourcepub fn update_fonts_texture(
&mut self,
queue: Queue,
command_pool: CommandPool,
imgui: &mut Context
) -> RendererResult<()>
pub fn update_fonts_texture( &mut self, queue: Queue, command_pool: CommandPool, imgui: &mut Context ) -> RendererResult<()>
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, vkCmdPipelineBarriercommand_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.
sourcepub fn cmd_draw(
&mut self,
command_buffer: CommandBuffer,
draw_data: &DrawData
) -> RendererResult<()>
pub fn cmd_draw( &mut self, command_buffer: CommandBuffer, draw_data: &DrawData ) -> RendererResult<()>
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 imguiDrawData
containing rendering data.
§Errors
RendererError
- If any Vulkan error is encountered during command recording.