adrien-ben / imgui-rs-vulkan-renderer

A Vulkan renderer for imgui-rs using Ash
MIT License
63 stars 19 forks source link

Combo boxes broken #40

Closed colinmarc closed 7 months ago

colinmarc commented 7 months ago

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).

colinmarc commented 7 months ago

I was able to run the test_window example now (I have the same issue as #34), and I wasn't able to reproduce the issue with the combo boxes. The only difference in my case is I'm using dynamic rendering.

Here is the source code if you want to try and reproduce. It's a very simple app.

adrien-ben commented 7 months ago

Hi,

You might be trying to render the next frame before the previous is done rendering.

If you're rendering multiple frames at the same time, you should set the in_flight_frames parameter to the number of frames you render concurrently when creating the renderer instance. That way the renderer will use different buffers for each frame.

adrien-ben commented 7 months ago

I just noticed the link to the source code. That's the line you should modify. Should look something like:

Some(imgui_vulkan::Renderer::with_default_allocator(
                &self.instance,
                self.pdevice,
                device.clone(),
                self.present_queue.queue,
                self.present_queue.command_pool,
                imgui_vulkan::DynamicRendering {
                    color_attachment_format: surface_format.format,
                    depth_attachment_format: None,
                },
                imgui,
                Some(Options {
                    in_flight_frames: frames.len(),
                    ..Default::default()
                }),
            )?)
colinmarc commented 7 months ago

Yup, that must have been it. Thank you!