diff --git a/client/render/imgui_impl.cpp b/client/render/imgui_impl.cpp index 6368c83a..8048eb58 100644 --- a/client/render/imgui_impl.cpp +++ b/client/render/imgui_impl.cpp @@ -188,7 +188,7 @@ static const std::array pool_sizes = } }; -imgui_context::imgui_context(vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span controllers_, vk::Extent2D size, float resolution, vk::Format format) : +imgui_context::imgui_context(vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span controllers_, vk::Extent2D size, float resolution, vk::Format format, int image_count) : device(device), queue_family_index(queue_family_index), queue(queue), @@ -226,9 +226,8 @@ imgui_context::imgui_context(vk::raii::Device& device, uint32_t queue_family_ind .PipelineCache = *application::get_pipeline_cache(), .DescriptorPool = *descriptor_pool, .Subpass = 0, - // image count is not actually used because we don't use a WSI swapchain - .MinImageCount = 2, // imgui_viewport::frames_in_flight, - .ImageCount = 2, //imgui_viewport::frames_in_flight, + .MinImageCount = 2, + .ImageCount = (uint32_t)image_count, // used to cycle between VkBuffers in ImGui_ImplVulkan_RenderDrawData .MSAASamples = VK_SAMPLE_COUNT_1_BIT, .Allocator = nullptr, .CheckVkResultFn = check_vk_result, @@ -463,7 +462,7 @@ imgui_context::~imgui_context() for(auto& f: frames) f.command_buffer.release(); - // Wait for fences here and not in imgui_viewport::~imgui_viewport so that the command buffers have finished when ImGui_ImplVulkan_Shutdown is called + // Wait for fences before ImGui_ImplVulkan_Shutdown is called std::vector fences; for(auto& f: frames) fences.push_back(*f.fence); diff --git a/client/render/imgui_impl.h b/client/render/imgui_impl.h index ad6593a9..eb240eaf 100644 --- a/client/render/imgui_impl.h +++ b/client/render/imgui_impl.h @@ -98,7 +98,7 @@ private: std::optional ray_plane_intersection(const imgui_context::controller_state& in); public: - imgui_context(vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span controllers, vk::Extent2D size, float resolution, vk::Format format); + imgui_context(vk::raii::Device& device, uint32_t queue_family_index, vk::raii::Queue& queue, XrSpace world, std::span controllers, vk::Extent2D size, float resolution, vk::Format format, int image_count); ~imgui_context(); void set_position(glm::vec3 position, glm::quat orientation) diff --git a/client/scenes/lobby.cpp b/client/scenes/lobby.cpp index 7cb1b662..783670c1 100644 --- a/client/scenes/lobby.cpp +++ b/client/scenes/lobby.cpp @@ -646,7 +646,7 @@ void scenes::lobby::on_focused() vk::Extent2D gui_size(1500, 1000); swapchain_imgui = xr::swapchain(session, device, swapchain_format, gui_size.width, gui_size.height); - imgui_ctx.emplace(device, queue_family_index, queue, world_space, imgui_inputs, gui_size, 1000, swapchain_format); + imgui_ctx.emplace(device, queue_family_index, queue, world_space, imgui_inputs, gui_size, 1000, swapchain_format, swapchain_imgui.images().size()); } void scenes::lobby::on_unfocused()