From ace15540207c24a066e62fad5100e5c05c4cc8c5 Mon Sep 17 00:00:00 2001 From: Dynamitos Date: Mon, 6 Apr 2026 17:29:55 +0200 Subject: [PATCH] Fixing glfw package breaking changes --- Regex.txt | 2 -- cpp.hint | 4 ---- src/Engine/Graphics/Vulkan/Graphics.cpp | 5 +++++ src/Engine/Graphics/Vulkan/Resources.cpp | 2 -- src/Engine/Graphics/Vulkan/Window.cpp | 13 +++++++++---- vcpkg.json | 8 ++++++-- 6 files changed, 20 insertions(+), 14 deletions(-) delete mode 100644 Regex.txt delete mode 100644 cpp.hint diff --git a/Regex.txt b/Regex.txt deleted file mode 100644 index 62641ae..0000000 --- a/Regex.txt +++ /dev/null @@ -1,2 +0,0 @@ -(?[A-Z_]*) = [0-9]*, -case SE_${enum}:\nreturn VK_${enum}; \ No newline at end of file diff --git a/cpp.hint b/cpp.hint deleted file mode 100644 index 4abe4a3..0000000 --- a/cpp.hint +++ /dev/null @@ -1,4 +0,0 @@ -// Hint files help the Visual Studio IDE interpret Visual C++ identifiers -// such as names of functions and macros. -// For more information see https://go.microsoft.com/fwlink/?linkid=865984 -#define DECLARE_REF(x) diff --git a/src/Engine/Graphics/Vulkan/Graphics.cpp b/src/Engine/Graphics/Vulkan/Graphics.cpp index d3c7540..b074c8b 100644 --- a/src/Engine/Graphics/Vulkan/Graphics.cpp +++ b/src/Engine/Graphics/Vulkan/Graphics.cpp @@ -688,6 +688,11 @@ Array Graphics::getRequiredExtensions() { } void Graphics::initInstance(GraphicsInitializer initInfo) { +#if defined(GLFW_WAYLAND_LIBDECOR) && defined(GLFW_WAYLAND_DISABLE_LIBDECOR) + // Work around libdecor runtime regressions on some Wayland stacks. + glfwInitHint(GLFW_WAYLAND_LIBDECOR, GLFW_WAYLAND_DISABLE_LIBDECOR); +#endif + if (!glfwInit()) { throw std::runtime_error("Failed to initialize GLFW"); } diff --git a/src/Engine/Graphics/Vulkan/Resources.cpp b/src/Engine/Graphics/Vulkan/Resources.cpp index b01a771..377b8d9 100644 --- a/src/Engine/Graphics/Vulkan/Resources.cpp +++ b/src/Engine/Graphics/Vulkan/Resources.cpp @@ -1,8 +1,6 @@ #include "Resources.h" -#include "Command.h" #include "Enums.h" #include "Graphics.h" -#include "Window.h" using namespace Seele; using namespace Seele::Vulkan; diff --git a/src/Engine/Graphics/Vulkan/Window.cpp b/src/Engine/Graphics/Vulkan/Window.cpp index 4b5974f..03bf805 100644 --- a/src/Engine/Graphics/Vulkan/Window.cpp +++ b/src/Engine/Graphics/Vulkan/Window.cpp @@ -61,6 +61,7 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo) glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &contentScaleX, &contentScaleY); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); + glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE); GLFWwindow* handle = glfwCreateWindow(createInfo.width / contentScaleX, createInfo.height / contentScaleY, createInfo.title, nullptr, nullptr); if (handle == nullptr) { const char* glfwError = nullptr; @@ -125,6 +126,9 @@ void Window::beginFrame() { imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex)); imageAvailableSemaphores[currentSemaphoreIndex]->encodeSignal(); imageAvailableFences[currentSemaphoreIndex]->submit(); + // The image was reacquired, so the previous presentation using this image's + // renderDone semaphore has completed and it can be safely reused + renderingDoneSemaphores[currentImageIndex]->resolveSignal(); graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, imageAvailableSemaphores[currentSemaphoreIndex]); static double start = glfwGetTime(); @@ -138,9 +142,9 @@ void Window::endFrame() { swapChainTextures[currentImageIndex]->changeLayout(Gfx::SE_IMAGE_LAYOUT_PRESENT_SRC_KHR, Gfx::SE_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_TOP_OF_PIPE_BIT); - renderingDoneSemaphores[currentSemaphoreIndex]->rotateSemaphore(); - graphics->getGraphicsCommands()->submitCommands(renderingDoneSemaphores[currentSemaphoreIndex]); - VkSemaphore renderDoneHandle = renderingDoneSemaphores[currentSemaphoreIndex]->getHandle(); + renderingDoneSemaphores[currentImageIndex]->rotateSemaphore(); + graphics->getGraphicsCommands()->submitCommands(renderingDoneSemaphores[currentImageIndex]); + VkSemaphore renderDoneHandle = renderingDoneSemaphores[currentImageIndex]->getHandle(); VkPresentInfoKHR presentInfo = { .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .pNext = nullptr, @@ -158,7 +162,7 @@ void Window::endFrame() { } else { VK_CHECK(r); } - renderingDoneSemaphores[currentSemaphoreIndex]->resolveSignal(); + renderingDoneSemaphores[currentImageIndex]->encodeSignal(); currentSemaphoreIndex = (currentSemaphoreIndex + 1) % Gfx::numFramesBuffered; currentFrameIndex = currentSemaphoreIndex; // graphics->waitDeviceIdle(); @@ -270,6 +274,7 @@ void Window::chooseSwapExtent() { } void Window::createSwapChain() { + graphics->waitDeviceIdle(); uint32 imageCount = Gfx::numFramesBuffered; VkSwapchainCreateInfoKHR createInfo = { .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, diff --git a/vcpkg.json b/vcpkg.json index c467f19..8a4e3e0 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -3,7 +3,6 @@ { "name": "vulkan" }, - "vulkan-loader", { "name": "vulkan-memory-allocator" }, @@ -11,7 +10,12 @@ "stb", "entt", "freetype", - "glfw3", + { + "name": "glfw3", + "features": [ + "wayland" + ] + }, "glm", "ktx", "nlohmann-json",