adrien-ben / imgui-rs-vulkan-renderer Goto Github PK
View Code? Open in Web Editor NEWA Vulkan renderer for imgui-rs using Ash
License: MIT License
A Vulkan renderer for imgui-rs using Ash
License: MIT License
Clean checkout and build:
Compiling vk-mem v0.2.2
error[E0432]: unresolved import `ash::version`
--> /home/<user>/.cargo/registry/src/github.com-1ecc6299db9ec823/vk-mem-0.2.2/src/lib.rs:753:18
|
753 | use ash::version::{DeviceV1_0, DeviceV1_1, InstanceV1_0};
| ^^^^^^^ could not find `version` in `ash`
See this issue which explains the problem of the breaking change in ash
and recommends changing to gpu-allocator
I'm not entirely sure if it's my code's fault or not, but I tried to integrate this project to mine (I'm following https://vkguide.dev/ but in rust so nothing too big) and now I get a validation error (ERROR_VALIDATION_FAILED_EXT
) when creating the Renderer. Running the project in Release (so with the validator disabled), there doesn't seem to have anything wrong.
Here's the piece of code that doesn't pass the validator :
let imgui_renderer = ImguiRenderer::with_vk_mem_allocator(
ManuallyDrop::into_inner(gpu_allocator.clone()),
logical_device_creation_data.device.clone(),
logical_device_creation_data.graphics_queue,
immediate_command_pool,
imgui_rs_vulkan_renderer::DynamicRendering {
color_attachment_format: swapchain_creation_data.swapchain_format,
depth_attachment_format: None,
},
&mut imgui,
Some(imgui_rs_vulkan_renderer::Options {
in_flight_frames: FRAME_OVERLAP,
..Default::default()
}),
)?;
You can find the full project here : https://gitlab.com/Stowy/vulkan-guide
I've looked over you're project, it's great. The one feature I was most interested in was the handling of images. For my project, I decided to hack the imgui C source to report when an image was used, so the renderer could smartly discard unused images.
https://gitlab.com/cheako/ash-tray-rs/-/blob/master/src/imguiash.rs
This may be of interest, it uses Rust's reference system to call Vulkan's destroy()
methods.
https://gitlab.com/cheako/ash-tray-rs/-/blob/master/src/vk_helper.rs
I'd appreciate any comments, it's difficult to tell if I'm on the right path or have wandered into the weeds.
Sorry for noob question, don't understand much about vulkan (yet)
https://github.com/adrien-ben/imgui-rs-vulkan-renderer/blob/master/examples/common/mod.rs#L1048
Here you set background color to white.
How do I set a background image?
Please feel free to point me at some reading if my answer is too noobish :D
Thanks
My application's renderpass has three attachment: [color, depth, color_resolve], then create imgui renderer by Renderer::with_gpu_allocator
with my existed renderpass. then show error as follow.
related codes:
I try to find the usage example from your repo: gltf-viewer-rs and vulkan-examples-rs, but it seems both of them are using Dynamic Rendering feature.
Should I create another renderpass, framebuffer, image and image_view? I want to create a game engine editor like adriengivry/Overload, should I create another Vulkan renderer for imgui?
My project code: Latias94/eureka
Just go with cargo r
[Validation] [VUID-VkGraphicsPipelineCreateInfo-multisampledRenderToSingleSampled-06853 (822655899)] :
Validation Error: [ VUID-VkGraphicsPipelineCreateInfo-multisampledRenderToSingleSampled-06853 ] Object 0: handle = 0x14c137eaad0, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x3108bb9b |
vkCreateGraphicsPipelines: pCreateInfo[0].pMultisampleState->rasterizationSamples (1) does not match the number of samples of the RenderPass color and/or depth attachment.
The Vulkan spec states: If the pipeline is being created with fragment output interface state, and none of the VK_AMD_mixed_attachment_samples extension, the VK_NV_framebuffer_mixed_samples extension,
or the multisampledRenderToSingleSampled feature are enabled, and if subpass uses color and/or depth/stencil attachments,
then the rasterizationSamples member of pMultisampleState must be the same as the sample count for those subpass attachments
(https://vulkan.lunarg.com/doc/view/1.3.236.0/windows/1.3-extensions/vkspec.html#VUID-VkGraphicsPipelineCreateInfo-multisampledRenderToSingleSampled-06853)
[Validation] [VUID-vkCmdDrawIndexed-rasterizationSamples-04740 (-329854293)] : Validation Error: [ VUID-vkCmdDrawIndexed-rasterizationSamples-04740 ] Object 0: handle = 0x2b424a0000000034, type = VK_OBJECT_TYPE_PIPELINE; Object 1: handle = 0xdd3a8a0000000015, type = VK_OBJECT_TYPE_RENDER_PASS; | MessageID = 0xec56d2ab |
vkCmdDrawIndexed: In VkPipeline 0x2b424a0000000034[] the sample count is VK_SAMPLE_COUNT_1_BIT while the current VkRenderPass 0xdd3a8a0000000015[] has VK_SAMPLE_COUNT_8_BIT and they need to be the same.
The Vulkan spec states: If rasterization is not disabled in the bound graphics pipeline, and neither the VK_AMD_mixed_attachment_samples nor the VK_NV_framebuffer_mixed_samples extensions are enabled,
then VkPipelineMultisampleStateCreateInfo::rasterizationSamples must be the same as the current subpass color and/or depth/stencil attachments
(https://vulkan.lunarg.com/doc/view/1.3.236.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-rasterizationSamples-04740)
Hi, great crate!
I'm hitting issues with the combo boxes in the basic demo window. They don't open, and I get validation errors:
Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] | MessageID = 0xe4549c11 | vkDestroyBuffer(): can't be called on VkBuffer 0x51820000000007b[] that is currently in use by VkCommandBuffer 0x623e27b8c140[]. The Vulkan spec states: All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyBuffer-buffer-00922)
I wanted to see if this happens in the test_window
example here, but I couldn't get it to open correctly (I think some winit issue).
I was noticing a crash in my app where typing quickly (in an imgui window which displays the text) causes a DEVICE_LOST error on MacOS (using MoltenVK). I debugged this and it turned out to by a free-while-in-use of the vertex buffer. See code
I got this message from the Metal debugger:
-[MTLDebugDevice notifyExternalReferencesNonZeroOnDealloc:]:2885: failed assertion `The following Metal object is being destroyed while still required to be alive by the command buffer 0x13180a600 (label: vkQueueSubmit CommandBuffer on Queue 0-0):
I'm not sure how to fix this, maybe with a counter in mesh
to wait at least in_flight_frames
before calling allocator.destory_buffer
when using dynamic rendering after the recorded command is called it gives a validation layer error that says the following:
This call must be issued inside an active render pass. The Vulkan spec states: This command must only be called inside of a render pass instance
Maybe I'm missing something, but I couldn't find a example running dynamic-rendering to compare it to.
Since v1.6.0, opening a popup modal gives the following validation errors:
2023-01-10T09:47:44.423Z ERROR [test_window::common] VALIDATION - "Validation Error: [ VUID-vkCmdSetScissor-x-00595 ] Object 0: handle = 0x1e5704e2ea0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0xa54a6ff8 | vkCmdSetScissor: pScissors[0].offset.x (=-1) is negative. The Vulkan spec states: The x and y members of offset member of any element of pScissors must be greater than or equal to 0 (https://vulkan.lunarg.com/doc/view/1.3.204.1/windows/1.3-extensions/vkspec.html#VUID-vkCmdSetScissor-x-00595)"
VUID-vkCmdSetScissor-x-00595(ERROR / SPEC): msgNum: -1521848328 - Validation Error: [ VUID-vkCmdSetScissor-x-00595 ] Object 0: handle = 0x1e5704e2ea0, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0xa54a6ff8 | vkCmdSetScissor: pScissors[0].offset.y (=-1) is negative. The Vulkan spec states: The x and y members of offset member of any element of pScissors must be greater than or equal to 0 (https://vulkan.lunarg.com/doc/view/1.3.204.1/windows/1.3-extensions/vkspec.html#VUID-vkCmdSetScissor-x-00595)
Objects: 1
[0] 0x1e5704e2ea0, type: 6, name: NULL
This is the log of the test window example.
This seems to be happen because the coordinates of the clip rect computed by imgui can be negative. So it might be a good idea to clamp the clipping rect like in the reference Vulkan backend.
I'm trying to figure out whats missing exactly. If you have any ideas I'm happy to hear them and send a PR with anything that ends up working. ๐
The issue mentioned here has broken this repo.
It can temporarily be resolved replacing line 24 of Cargo.toml with
vk-mem = { git = "https://github.com/Chris--B/vk-mem-rs", optional = true }
However this restricts the ash version to <0.33, and depends on some random repo. I don't know enough about cargo to propose a better solution.
I can run the examples fine, but trying to integrate into my own application causes the UI to render incorrectly (see attached image). Interaction works ok, I can shade, move and resize the window, just seems like none of the widgets are getting drawn. This is copying the ui from the hello world example. I get the same result on both master and imgui-0.8
Was just hoping you might look at the image and say "ah, that's obviously because you forgot to..."
I'd like to add support for vma (vk-mem-rs) as a feature.
Note that it will not provide support for custom allocators.
Steps to replicate this issue:
$ cat Cargo.toml
[package]
name = "hello_renderer"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
imgui-rs-vulkan-renderer = { version = "1.0.0", features = ["vk-mem"] }
with cargo version:
$ cargo --version
cargo 1.58.0-nightly (294967c53 2021-11-29)
It seems that cargo still uses the vk-mem-0.2.2
.
$ cargo build
Updating crates.io index
Compiling cfg-if v1.0.0
Compiling cc v1.0.72
Compiling proc-macro2 v1.0.36
Compiling libc v0.2.112
Compiling unicode-xid v0.2.2
Compiling parking_lot_core v0.8.5
Compiling syn v1.0.84
Compiling smallvec v1.7.0
Compiling bytemuck v1.7.3
Compiling scopeguard v1.1.0
Compiling ash v0.35.0+1.2.203
Compiling log v0.4.14
Compiling bitflags v1.3.2
Compiling chlorine v1.0.10
Compiling instant v0.1.12
Compiling libloading v0.7.2
Compiling lock_api v0.4.5
Compiling safe_arch v0.5.2
Compiling wide v0.6.5
Compiling imgui-sys v0.8.2
Compiling vk-mem v0.2.2
Compiling quote v1.0.14
Compiling parking_lot v0.11.2
Compiling ultraviolet v0.8.1
Compiling thiserror-impl v1.0.30
Compiling thiserror v1.0.30
Compiling imgui v0.8.2
error[E0432]: unresolved import `ash::version`
--> /home/chrox/.cargo/registry/src/github.com-1ecc6299db9ec823/vk-mem-0.2.2/src/lib.rs:753:18
|
753 | use ash::version::{DeviceV1_0, DeviceV1_1, InstanceV1_0};
| ^^^^^^^ could not find `version` in `ash`
For more information about this error, try `rustc --explain E0432`.
error: could not compile `vk-mem` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
And this issue is solved when this commit is reverted.
When running test_window
example I get blank window. When I resize the window back and forth some content gets displayed. See video for demonstration of the bug:
I see no errors in stdout, but just in case I will attach it here.
cargo run --example test_window
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running `target/debug/examples/test_window`
2023-02-03T21:37:36.611Z INFO [test_window::common] Create application
2023-02-03T21:37:36.611Z DEBUG [test_window::common] Creating window and event loop
2023-02-03T21:37:36.642Z TRACE [crossfont::ft::fc::font_set] Number of fonts is 42
2023-02-03T21:37:36.642Z TRACE [crossfont::ft] Got font path="/usr/local/share/fonts/dejavu/DejaVuSans.ttf", index=0
2023-02-03T21:37:36.642Z DEBUG [crossfont::ft] Loaded Face Face { ft_face: Font Face: Book, load_flags: TARGET_LIGHT, render_mode: "Normal", lcd_filter: 1 }
2023-02-03T21:37:36.647Z DEBUG [test_window::common] Creating vulkan instance
2023-02-03T21:37:36.684Z DEBUG [test_window::common] Creating vulkan physical device
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - "linux_read_sorted_physical_devices:"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " Original order:"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [0] llvmpipe (LLVM 15.0.7, 256 bits)"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [1] AMD Radeon Pro W5700 (RADV NAVI10)"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " Sorted order:"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [0] AMD Radeon Pro W5700 (RADV NAVI10) "
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [1] llvmpipe (LLVM 15.0.7, 256 bits) "
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - "linux_read_sorted_physical_devices:"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " Original order:"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [0] llvmpipe (LLVM 15.0.7, 256 bits)"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [1] AMD Radeon Pro W5700 (RADV NAVI10)"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " Sorted order:"
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [0] AMD Radeon Pro W5700 (RADV NAVI10) "
2023-02-03T21:37:36.686Z INFO [test_window::common] GENERAL - " [1] llvmpipe (LLVM 15.0.7, 256 bits) "
2023-02-03T21:37:36.687Z DEBUG [test_window::common] Selected physical device: "AMD Radeon Pro W5700 (RADV NAVI10)"
2023-02-03T21:37:36.687Z DEBUG [test_window::common] Creating vulkan device and graphics and present queues
2023-02-03T21:37:36.688Z INFO [test_window::common] GENERAL - " Using \"AMD Radeon Pro W5700 (RADV NAVI10)\" with driver: \"/usr/local/lib/libvulkan_radeon.so\"\n"
2023-02-03T21:37:36.700Z DEBUG [test_window::common] Creating vulkan swapchain
2023-02-03T21:37:36.700Z DEBUG [test_window::common] Swapchain format: SurfaceFormatKHR { format: B8G8R8A8_UNORM, color_space: SRGB_NONLINEAR }
2023-02-03T21:37:36.700Z DEBUG [test_window::common] Swapchain present mode: FIFO
2023-02-03T21:37:36.701Z DEBUG [test_window::common] Swapchain extent: Extent2D { width: 1024, height: 768 }
2023-02-03T21:37:36.701Z DEBUG [test_window::common] Swapchain image count: 4
2023-02-03T21:37:36.701Z DEBUG [test_window::common] Creating vulkan render pass
2023-02-03T21:37:36.701Z DEBUG [test_window::common] Creating vulkan framebuffers
2023-02-03T21:37:36.703Z DEBUG [imgui_rs_vulkan_renderer::renderer] Creating imgui renderer with options Options { in_flight_frames: 1, enable_depth_test: false, enable_depth_write: false }
2023-02-03T21:37:36.703Z DEBUG [imgui_rs_vulkan_renderer::renderer::vulkan] Creating vulkan descriptor set layout
2023-02-03T21:37:36.703Z DEBUG [imgui_rs_vulkan_renderer::renderer::vulkan] Creating vulkan pipeline layout
2023-02-03T21:37:36.785Z DEBUG [imgui_rs_vulkan_renderer::renderer::vulkan] Creating vulkan descriptor pool
2023-02-03T21:37:36.785Z DEBUG [imgui_rs_vulkan_renderer::renderer::vulkan] Creating vulkan descriptor set
2023-02-03T21:37:36.785Z INFO [test_window::common] Starting application
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Window was resized. New size is PhysicalSize { width: 1906, height: 1019 }
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Recreating the swapchain
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Creating vulkan swapchain
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Swapchain format: SurfaceFormatKHR { format: B8G8R8A8_UNORM, color_space: SRGB_NONLINEAR }
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Swapchain present mode: FIFO
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Swapchain extent: Extent2D { width: 1024, height: 768 }
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Swapchain image count: 4
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Creating vulkan render pass
2023-02-03T21:37:36.788Z DEBUG [test_window::common] Creating vulkan framebuffers
2023-02-03T21:37:36.789Z TRACE [imgui_rs_vulkan_renderer::renderer::mesh] Resizing vertex buffers
2023-02-03T21:37:36.789Z TRACE [imgui_rs_vulkan_renderer::renderer::mesh] Resizing index buffers
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Window was resized. New size is PhysicalSize { width: 3812, height: 2038 }
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Recreating the swapchain
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Creating vulkan swapchain
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Swapchain format: SurfaceFormatKHR { format: B8G8R8A8_UNORM, color_space: SRGB_NONLINEAR }
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Swapchain present mode: FIFO
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Swapchain extent: Extent2D { width: 1024, height: 768 }
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Swapchain image count: 4
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Creating vulkan render pass
2023-02-03T21:37:36.795Z DEBUG [test_window::common] Creating vulkan framebuffers
Hi,
How to make example like this
https://github.com/imgui-rs/imgui-rs/blob/main/imgui-glow-renderer/examples/glow_02_triangle.rs
with ash and this render backend?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.