diff --git a/Editor/src/EditorLayer.cpp b/Editor/src/EditorLayer.cpp index fdea2437..5dc09fdf 100644 --- a/Editor/src/EditorLayer.cpp +++ b/Editor/src/EditorLayer.cpp @@ -23,6 +23,7 @@ void EditorLayer::OnUpdate() Nuake::Engine::Tick(); Nuake::Engine::Draw(); + /* auto sceneFramebuffer = GetApplication().GetWindow()->GetFrameBuffer(); // Draw gizmos @@ -70,8 +71,8 @@ void EditorLayer::OnUpdate() m_EditorInterface->Draw(); m_EditorInterface->Update(Nuake::Engine::GetTimestep()); - Nuake::Engine::EndDraw(); + */ Nuake::Input::Update(); } diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 0fbd576d..67aaa4fd 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -110,11 +110,11 @@ namespace Nuake { mCommandBuffer = &commandBuffer; // Load textures - NuakeTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/editor-icon.png"); - CloseIconTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/close-icon.png"); - MaximizeTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/maximize-icon.png"); - RestoreTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/restore-icon.png"); - MinimizeTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/minimize-icon.png"); + //NuakeTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/editor-icon.png"); + //CloseIconTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/close-icon.png"); + //MaximizeTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/maximize-icon.png"); + //RestoreTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/restore-icon.png"); + //MinimizeTexture = Nuake::TextureManager::Get()->GetTexture("Resources/Images/minimize-icon.png"); Logger::Log("Creating editor windows", "window", VERBOSE); filesystem = new FileSystemUI(this); @@ -2072,9 +2072,9 @@ namespace Nuake { cam->Translation = transform.GetGlobalPosition(); cam->SetTransform(glm::inverse(transform.GetGlobalTransform())); - auto sceneRenderer = Engine::GetCurrentScene()->m_SceneRenderer; - sceneRenderer->BeginRenderScene(cam->GetPerspective(), cam->GetTransform(), cam->Translation); - sceneRenderer->RenderScene(*Engine::GetCurrentScene().get(), *virtualCamera.get(), false); + static SceneRenderer sceneRenderer = Nuake::SceneRenderer(); + sceneRenderer.BeginRenderScene(cam->GetPerspective(), cam->GetTransform(), cam->Translation); + sceneRenderer.RenderScene(*Engine::GetCurrentScene().get(), *virtualCamera.get(), false); virtualCamera->Clear(); ImGui::Image((void*)virtualCamera->GetTexture()->GetID(), { 640, 360 }, { 0, 1 }, {1, 0}); @@ -2447,7 +2447,7 @@ namespace Nuake { auto window = Window::Get(); window->SetDecorated(true); - window->ShowTitleBar(false); + //window->ShowTitleBar(false); window->SetSize({ 1600, 900 }); window->Center(); frameCount = 0; @@ -2560,6 +2560,7 @@ namespace Nuake { ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, isMaximized ? ImVec2(6.0f, 8.0f) : ImVec2(1.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 3.0f); + ImGui::PushStyleColor(ImGuiCol_MenuBarBg, UI::PrimaryCol); ImGui::Begin("DockSpaceWindow22", nullptr, window_flags); ImGui::PopStyleColor(); // MenuBarBg @@ -2673,6 +2674,10 @@ namespace Nuake { DrawLogger(); filesystem->Draw(); filesystem->DrawDirectoryExplorer(); + + //auto node = ImGui::DockBuilderGetNode(1); + //node->SizeRef = { node->Size.x, 50.0f }; + if (isNewProject) { ImVec2 center = ImGui::GetMainViewport()->GetCenter(); diff --git a/Editor/src/Windows/EditorSelectionPanel.cpp b/Editor/src/Windows/EditorSelectionPanel.cpp index 938beb44..2f8f3695 100644 --- a/Editor/src/Windows/EditorSelectionPanel.cpp +++ b/Editor/src/Windows/EditorSelectionPanel.cpp @@ -2048,10 +2048,10 @@ void EditorSelectionPanel::DrawFieldTypeString(entt::meta_data& field, entt::met std::string controlId = std::string("##") + displayName; ImGui::InputText(controlId.c_str(), &fieldValProxy); - if (fieldValProxy != fieldVal) - { - Engine::GetProject()->IsDirty = true; - } + //if (fieldValProxy != fieldVal) + //{ + // Engine::GetProject()->IsDirty = true; + //} } else { diff --git a/Editor/src/Windows/WelcomeWindow.cpp b/Editor/src/Windows/WelcomeWindow.cpp index 6f471539..84b0eff6 100644 --- a/Editor/src/Windows/WelcomeWindow.cpp +++ b/Editor/src/Windows/WelcomeWindow.cpp @@ -42,11 +42,11 @@ namespace Nuake const std::string projectIconPath = Path + "/../icon.png"; if (FileSystem::FileExists(projectIconPath, true)) { - ProjectIcon = TextureManager::Get()->GetTexture(projectIconPath); + //ProjectIcon = TextureManager::Get()->GetTexture(projectIconPath); } else { - ProjectIcon = TextureManager::Get()->GetTexture("Resources/Images/nuake-logo.png"); + //ProjectIcon = TextureManager::Get()->GetTexture("Resources/Images/nuake-logo.png"); } } else @@ -87,7 +87,7 @@ namespace Nuake } // Load Nuake logo - _NuakeLogo = TextureManager::Get()->GetTexture(NUAKE_LOGO_PATH); + //_NuakeLogo = TextureManager::Get()->GetTexture(NUAKE_LOGO_PATH); } void WelcomeWindow::LoadQueuedProject() diff --git a/Nuake/src/Rendering/Vulkan/VulkanRenderer.cpp b/Nuake/src/Rendering/Vulkan/VulkanRenderer.cpp index 48c7e839..af433f5d 100644 --- a/Nuake/src/Rendering/Vulkan/VulkanRenderer.cpp +++ b/Nuake/src/Rendering/Vulkan/VulkanRenderer.cpp @@ -70,8 +70,12 @@ void VkRenderer::CleanUp() vkDestroyFence(Device, Frames[i].RenderFence, nullptr); vkDestroySemaphore(Device, Frames[i].RenderSemaphore, nullptr); vkDestroySemaphore(Device, Frames[i].SwapchainSemaphore, nullptr); + + Frames[i].LocalDeletionQueue.flush(); } + MainDeletionQueue.flush(); + DestroySwapchain(); vkDestroySurfaceKHR(Instance, Surface, nullptr); diff --git a/Nuake/src/Rendering/Vulkan/VulkanRenderer.h b/Nuake/src/Rendering/Vulkan/VulkanRenderer.h index 4e29ad41..10ef42af 100644 --- a/Nuake/src/Rendering/Vulkan/VulkanRenderer.h +++ b/Nuake/src/Rendering/Vulkan/VulkanRenderer.h @@ -8,6 +8,31 @@ namespace Nuake { + // Since we need to delete things in order, and manually doing it in the cleanup is +// too tedious to maintain. We will use a queue of destructor to execute in inverse order +// of insertion + struct DeletionQueue + { + std::deque> Deletors; + + void push_function(std::function&& function) + { + Deletors.push_back(function); + } + + void flush() + { + // reverse iterate the deletion queue to execute all the functions + for (auto it = Deletors.rbegin(); it != Deletors.rend(); it++) + { + (*it)(); //call functors + } + + Deletors.clear(); + } + }; + + // GPU has Vk Queue family type // 2x Queue -> All operation // 2x Queue -> Computer operation @@ -38,8 +63,11 @@ namespace Nuake // Two, one for window, other for rendering VkSemaphore SwapchainSemaphore, RenderSemaphore; VkFence RenderFence; // CPU wait for next frame + + DeletionQueue LocalDeletionQueue; // Local when destroying this frame }; + constexpr unsigned int FRAME_OVERLAP = 2; class VkRenderer @@ -71,6 +99,8 @@ namespace Nuake VkQueue GPUQueue; uint32_t GPUQueueFamily; + DeletionQueue MainDeletionQueue; + public: static VkRenderer& Get() {