diff options
| author | hachem <im@hachem.wtf> | 2026-08-23 22:39:47 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-08-23 22:39:47 +0200 |
| commit | 4a72c63f74bc055c29f397f54fca8e9613f4474d (patch) | |
| tree | 5b6f96f22a67f4e303ae72b6e9763d25a6dadd16 /src/platform/vulkan/vulkan_swapchain.cpp | |
| parent | 6ee03a2ea3c764f0364b2e61beb6812226facd4c (diff) | |
feat: wire the scene into the simulation engine
Diffstat (limited to 'src/platform/vulkan/vulkan_swapchain.cpp')
| -rw-r--r-- | src/platform/vulkan/vulkan_swapchain.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/platform/vulkan/vulkan_swapchain.cpp b/src/platform/vulkan/vulkan_swapchain.cpp index 914df62..c6157b0 100644 --- a/src/platform/vulkan/vulkan_swapchain.cpp +++ b/src/platform/vulkan/vulkan_swapchain.cpp @@ -117,7 +117,17 @@ namespace Donut::RHI sci.imageExtent = m_extent; sci.imageArrayLayers = 1; sci.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; sci.preTransform = caps.currentTransform; sci.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; - sci.presentMode = VK_PRESENT_MODE_FIFO_KHR; sci.clipped = VK_TRUE; + VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR; + if (!m_vsync) + { + uint32_t pmc = 0; vkGetPhysicalDeviceSurfacePresentModesKHR(m_physical, m_surface, &pmc, nullptr); + std::vector<VkPresentModeKHR> modes(pmc); + vkGetPhysicalDeviceSurfacePresentModesKHR(m_physical, m_surface, &pmc, modes.data()); + auto has = [&](VkPresentModeKHR m){ return std::find(modes.begin(), modes.end(), m) != modes.end(); }; + if (has(VK_PRESENT_MODE_IMMEDIATE_KHR)) present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR; + else if (has(VK_PRESENT_MODE_MAILBOX_KHR)) present_mode = VK_PRESENT_MODE_MAILBOX_KHR; + } + sci.presentMode = present_mode; sci.clipped = VK_TRUE; uint32_t fam[2] = { m_graphics_family, m_present_family }; if (m_graphics_family != m_present_family) { sci.imageSharingMode = VK_SHARING_MODE_CONCURRENT; sci.queueFamilyIndexCount = 2; sci.pQueueFamilyIndices = fam; } |
