https://github.com/adrien-ben/imgui-rs-vulkan-renderer
A Vulkan renderer for imgui-rs using Ash
https://github.com/adrien-ben/imgui-rs-vulkan-renderer
ash imgui rust vulkan
Last synced: 6 months ago
JSON representation
A Vulkan renderer for imgui-rs using Ash
- Host: GitHub
- URL: https://github.com/adrien-ben/imgui-rs-vulkan-renderer
- Owner: adrien-ben
- License: mit
- Created: 2020-01-22T06:02:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-05T16:43:45.000Z (over 1 year ago)
- Last Synced: 2024-05-06T16:57:00.879Z (over 1 year ago)
- Topics: ash, imgui, rust, vulkan
- Language: Rust
- Homepage:
- Size: 1.98 MB
- Stars: 62
- Watchers: 4
- Forks: 17
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# imgui-rs-vulkan-renderer
[](https://crates.io/crates/imgui-rs-vulkan-renderer)
[](https://docs.rs/imgui-rs-vulkan-renderer)
[](https://github.com/adrien-ben/imgui-rs-vulkan-renderer/actions)
[](https://github.com/adrien-ben/imgui-rs-vulkan-renderer/actions)A Vulkan renderer for [imgui-rs][imgui-rs] using [Ash][ash].

## Compatibility
| crate | imgui | ash | gpu-allocator (feature) | vk-mem (feature) |
|----------------|-------|--------------|-------------------------|-----------------------------------------|
| [1.14.0, 1.16] | 0.12 | 0.38 | 0.27 | 0.4.0 |
| 1.13.0 | 0.12 | [0.34, 0.37] | 0.26 | 0.3.0 |
| 1.12.0 | 0.11 | [0.34, 0.37] | 0.25 | 0.3.0 |
| 1.11.0 | 0.11 | [0.34, 0.37] | 0.25 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.10.0 | 0.11 | [0.34, 0.37] | 0.23 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.9.0 | 0.11 | [0.34, 0.37] | 0.22 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.8.0 | 0.10 | [0.34, 0.37] | 0.22 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.7.0 | 0.10 | [0.34, 0.37] | [0.19, 0.21] | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.6.x | 0.9 | [0.34, 0.37] | [0.19, 0.21] | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.5.0 | 0.8 | [0.34, 0.37] | 0.19 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.4.0 | 0.8 | [0.34, 0.37] | 0.18 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.3.0 | 0.8 | [0.34, 0.37] | 0.18 | 0.2.3 ([forked][forked-mem-rs-034-037]) |
| 1.2.0 | 0.8 | 0.36 | 0.17 | 0.2.3 ([forked][forked-mem-rs-036]) |
| 1.1.x | 0.8 | 0.35 | 0.15 | 0.2.3 ([forked][forked-mem-rs-035]) |
| 1.0.0 | 0.8 | 0.35 | 0.14 | 0.2.3 ([forked][forked-mem-rs-035]) |## 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.
- Vertex/Index buffers
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).- Frames in flight
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.- No draw call execution
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
The renderer supports custom textures. See `Renderer::textures` for details.
- Custom Vulkan allocators
Custom Vulkan allocators are not supported for the moment.
## Features
### gpu-allocator
This feature adds support for [gpu-allocator][gpu-allocator]. It adds `Renderer::with_gpu_allocator` which takes
a `Arc>`. All internal allocator are then done using the allocator.### vk-mem
This feature adds support for [vk-mem-rs][vk-mem-rs]. It adds `Renderer::with_vk_mem_allocator` which takes
a `Arc>`. All internal allocator are then done using the allocator.> I'm still not sure with the `Arc>` stuff. It works for me but i'm unsure it'a the best way to go.
> Any suggestion is welcome.### dynamic-rendering
This feature is useful if you want to integrate the library in an app making use of Vulkan's dynamic rendering.
When enabled, functions that usually takes a `vk::RenderPass` as argument will now take a `DynamicRendering` which
contains the format of the color attachment the UI will be drawn to and an optional depth attachment format.## Integration
You can find an example of integration in the [common module](examples/common/mod.rs) of the examples.
```rust
// Example with default allocator
let renderer = Renderer::with_default_allocator(
&instance,
physical_device,
device.clone(),
graphics_queue,
command_pool,
render_pass,
&mut imgui,
Some(Options {
in_flight_frames: 1,
..Default::default()
}),
).unwrap();
```## Examples
You can run a set of examples by running the following command:
```sh
# If you want to enable validation layers
export VK_LAYER_PATH=$VULKAN_SDK/Bin
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation# Or with Powershell
$env:VK_LAYER_PATH = "$env:VULKAN_SDK\Bin"
$env:VK_INSTANCE_LAYERS = "VK_LAYER_KHRONOS_validation"# 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
# - creating_windows
# - custom_textures
# - disablement
# - draw_list
# - hello_world
# - id_wrangling
# - keyboard
# - long_list
# - long_table
# - multiple_fonts
# - progress_bar
# - radio_button
# - slider
# - tables_api
# - test_drawing_channels_split
# - test_window_impl
# - test_window
# - text_callbacks
# - text_input
```[imgui-rs]: https://github.com/Gekkio/imgui-rs
[ash]: https://github.com/MaikKlein/ash
[gpu-allocator]: https://github.com/Traverse-Research/gpu-allocator
[vk-mem-rs]: https://github.com/adrien-ben/vk-mem-rs
[forked-mem-rs-035]: https://github.com/adrien-ben/vk-mem-rs/tree/0.2.3-ash-0.35
[forked-mem-rs-036]: https://github.com/adrien-ben/vk-mem-rs/tree/0.2.3-ash-0.36
[forked-mem-rs-034-037]: https://github.com/adrien-ben/vk-mem-rs/tree/0.2.3-ash-0.34-0.37