imgui-rs-vulkan-renderer

Version Docs.rs Build Status Publish Status

A Vulkan renderer for imgui-rs using Ash.

screenshot

Compatibility

| crate | imgui | ash | gpu-allocator (feature) | vk-mem (feature) | |-------|-------|------|-------------------------|---------------------------------| | 1.0.0 | 0.8 | 0.35 | 0.14 | 0.2.3 (forked) |

How it works

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.

The renderer supports custom textures. See Renderer::textures for details.

Custom Vulkan allocators are not supported for the moment.

Features

gpu-allocator

This feature adds support for gpu-allocator. It adds Renderer::with_gpu_allocator which takes a Arc<Mutex<gpu_allocator::vulkan::Allocator>>. All internal allocator are then done using the allocator.

vk-mem

This feature adds support for vk-mem-rs. It adds Renderer::with_vk_mem_allocator which takes a Arc<Mutex<vk_mem::Allocator>>. All internal allocator are then done using the allocator.

I'm still not sure with the Arc<Mutex<...>> stuff. It works for me but i'm unsure it'a the best way to go. Any suggestion is welcome.

Integration

You can find an example of integration in the common module of the examples.

Examples

You can run a set of examples by running the following command:

```sh

If you want to enable validation layers

export VKLAYERPATH=$VULKANSDK/Bin export VKINSTANCELAYERS=VKLAYERKHRONOSvalidation

Or with Powershell

$env:VKLAYERPATH = "$env:VULKANSDK\Bin" $env:VKINSTANCELAYERS = "VKLAYERKHRONOSvalidation"

If you changed the shader code (you'll need glslangValidator on you PATH)

There is also a PowerShell version (compile_shaders.ps1)

./compile_shaders.sh

Run an example

cargo run --example

Example can be one of the following value:

- collapsing_header

- color_button

- custom_textures

- disablement

- draw_list

- hello_world

- keyboard

- long_list

- multiple fonts

- progress_bar

- radio_button

- slider : TODO: crashes

- tables_api

- testdrawingchannels_split

- testwindowimpl

- test_window

- text_callbacks

- text_input

```