A Vulkan renderer for imgui-rs using Ash.
The renderer records drawing command to a command buffer supplied by the application. Here is a little breakdown of the features of this crate and how they work.
The renderer creates a vertex buffer and a index buffer that will be updated every time
Renderer::cmd_draw
is called. If the vertex/index count is more than what the buffers can
actually hold then the buffers are resized (actually destroyed then re-created).
The renderer support having multiple frames in flight. You need to specify the number of frames during initialization of the renderer. The renderer manages one vertex and index buffer per frame.
The Renderer::cmd_draw
only record commands to a command buffer supplied by the application. It does not submit anything to the gpu.
Custom textures are not supported for the moment.
Custom Vulkan allocators are not supported for the moment.
You can find an example of integration in the common module of the examples.
RendererVkContext
traitYou need to implement that trait that will be used to access Vulkan resources such as the instance and device.
Renderer
structThis is the main struct of the renderer. It has 3 function:
Renderer::new
create and initialize the renderer. It takes:
RendererVkContext
RenderPass
use during renderingRenderer::cmd_draw
records commands required to render the ui. Tt takes:
RendererVkContext
CommandBuffer
to record commands toDrawData
generated by imgui-rsRenderer::destroy
release all gpu resources allocated by the renderer. It takes:
RendererVkContext
Renderer::new
and Renderer::cmd_draw
return a RendererResult
which is defined as follows:
rust
type RendererResult<T> = Result<T, RendererError>;
You can run a set of examples by running the following command:
```sh
export VKLAYERPATH=$VULKANSDK/Bin export VKINSTANCELAYERS=VKLAYERKHRONOSvalidation
./compile_shaders.sh
cargo run --example
```