diff --git a/src/atta/graphics/apis/vulkan/image.cpp b/src/atta/graphics/apis/vulkan/image.cpp index a06754bd7..5aab8791 100644 --- a/src/atta/graphics/apis/vulkan/image.cpp +++ b/src/atta/graphics/apis/vulkan/image.cpp @@ -7,6 +7,7 @@ #include #include +#include #include // TODO should not have UI code here @@ -328,8 +329,11 @@ void Image::allocMemory() { } void Image::destroy() { - if (_imGuiDescriptorSet != VK_NULL_HANDLE) + if (_imGuiDescriptorSet != VK_NULL_HANDLE) { + // Make sure ImGui is not using image before removing it + vkDeviceWaitIdle(common::getDevice()->getHandle()); ImGui_ImplVulkan_RemoveTexture(_imGuiDescriptorSet); + } if (_imageView != VK_NULL_HANDLE) vkDestroyImageView(_device->getHandle(), _imageView, nullptr); if (_sampler != VK_NULL_HANDLE) diff --git a/src/atta/graphics/windows/glfwWindow.cpp b/src/atta/graphics/windows/glfwWindow.cpp index 50b22866..dc774c16 100644 --- a/src/atta/graphics/windows/glfwWindow.cpp +++ b/src/atta/graphics/windows/glfwWindow.cpp @@ -101,7 +101,8 @@ GlfwWindow::GlfwWindow(const CreateInfo& info) : Window(info) { glfwSetErrorCallback([](int error, const char* description) { LOG_ERROR("gfx::Window", "GLFW error($0): $1", error, std::string(description)); }); - glfwMakeContextCurrent(_window); + if (info.useOpenGL) + glfwMakeContextCurrent(_window); #ifdef ATTA_OS_WEB int w = canvas_get_width(); diff --git a/src/atta/ui/manager.cpp b/src/atta/ui/manager.cpp index 4281baf4..ea0a5450 100644 --- a/src/atta/ui/manager.cpp +++ b/src/atta/ui/manager.cpp @@ -64,6 +64,9 @@ void Manager::startUpImpl() { } void Manager::shutDownImpl() { + // Make sure all rendering operations are done + gfx::getGraphicsAPI()->waitDevice(); + switch (gfx::getGraphicsAPI()->getType()) { case gfx::GraphicsAPI::OPENGL: ImGui_ImplOpenGL3_Shutdown();