diff options
| author | Ryderadzeee <craftercrashonname@gmail.com> | 2026-11-22 17:45:31 +0400 |
|---|---|---|
| committer | Ryderadzeee <craftercrashonname@gmail.com> | 2026-11-22 19:00:41 +0400 |
| commit | 7b48c194c021e190cb79291effc6d968aafd1ace (patch) | |
| tree | a27e4370a13b40d239d487b41ab4e3c15ecd6e83 /runtime/src/vulkan_present.h | |
| parent | 6a6704df1592e1dc4a3215ddf1423a78adb52045 (diff) | |
Use Vulkan swapchain maintenance aliases supported by older headers
Diffstat (limited to 'runtime/src/vulkan_present.h')
| -rw-r--r-- | runtime/src/vulkan_present.h | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h index d9f53baa5..15a706668 100644 --- a/runtime/src/vulkan_present.h +++ b/runtime/src/vulkan_present.h | |||
| @@ -22,9 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | #include "vulkan_backend.h" | 23 | #include "vulkan_backend.h" |
| 24 | 24 | ||
| 25 | // Both extension names share the structures (the KHR one was promoted from the EXT one); headers older than the | 25 | // Use the original EXT spellings. They are aliases of the promoted KHR types and are available in older headers. |
| 26 | // promotion do not have the KHR types, and the presenter then never tears. | 26 | #if defined(VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME) && defined(VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME) |
| 27 | #if defined(VK_KHR_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME) && defined(VK_KHR_SURFACE_MAINTENANCE_1_EXTENSION_NAME) | ||
| 28 | #define LEONIDA_SWAPCHAIN_MAINTENANCE1 1 | 27 | #define LEONIDA_SWAPCHAIN_MAINTENANCE1 1 |
| 29 | #endif | 28 | #endif |
| 30 | 29 | ||
| @@ -315,7 +314,7 @@ public: | |||
| 315 | present.pImageIndices = ℑ | 314 | present.pImageIndices = ℑ |
| 316 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 | 315 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 |
| 317 | // The swapchain was created with FIFO and tear_mode_ (both come from the same recreate). | 316 | // The swapchain was created with FIFO and tear_mode_ (both come from the same recreate). |
| 318 | VkSwapchainPresentModeInfoKHR present_mode{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_KHR}; | 317 | VkSwapchainPresentModeInfoEXT present_mode{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT}; |
| 319 | const bool tearing = tear && vsync_ && tear_supported(); | 318 | const bool tearing = tear && vsync_ && tear_supported(); |
| 320 | if (tearing) { | 319 | if (tearing) { |
| 321 | present_mode.swapchainCount = 1; | 320 | present_mode.swapchainCount = 1; |
| @@ -694,7 +693,7 @@ private: | |||
| 694 | info.presentMode = mode; | 693 | info.presentMode = mode; |
| 695 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 | 694 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 |
| 696 | // A vsync swapchain that can also be presented in IMMEDIATE (or FIFO_RELAXED), switched per present. | 695 | // A vsync swapchain that can also be presented in IMMEDIATE (or FIFO_RELAXED), switched per present. |
| 697 | VkSwapchainPresentModesCreateInfoKHR switchable{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_KHR}; | 696 | VkSwapchainPresentModesCreateInfoEXT switchable{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_EXT}; |
| 698 | std::array<VkPresentModeKHR, 2> switchable_modes{VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_MAX_ENUM_KHR}; | 697 | std::array<VkPresentModeKHR, 2> switchable_modes{VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_MAX_ENUM_KHR}; |
| 699 | VkPresentModeKHR tear = VK_PRESENT_MODE_MAX_ENUM_KHR; | 698 | VkPresentModeKHR tear = VK_PRESENT_MODE_MAX_ENUM_KHR; |
| 700 | if (vsync && mode == VK_PRESENT_MODE_FIFO_KHR) tear = find_tear_mode(modes, info.minImageCount, info.imageUsage, info.imageExtent); | 699 | if (vsync && mode == VK_PRESENT_MODE_FIFO_KHR) tear = find_tear_mode(modes, info.minImageCount, info.imageUsage, info.imageExtent); |
| @@ -762,11 +761,11 @@ private: | |||
| 762 | // The capabilities of the surface for one present mode, and the modes it can switch to from there. | 761 | // The capabilities of the surface for one present mode, and the modes it can switch to from there. |
| 763 | const auto ask = [&](VkPresentModeKHR asked, VkSurfaceCapabilitiesKHR& caps, | 762 | const auto ask = [&](VkPresentModeKHR asked, VkSurfaceCapabilitiesKHR& caps, |
| 764 | std::array<VkPresentModeKHR, 16>* compatible, std::uint32_t* compatible_count) { | 763 | std::array<VkPresentModeKHR, 16>* compatible, std::uint32_t* compatible_count) { |
| 765 | VkSurfacePresentModeKHR for_mode{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_KHR}; | 764 | VkSurfacePresentModeEXT for_mode{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT}; |
| 766 | for_mode.presentMode = asked; | 765 | for_mode.presentMode = asked; |
| 767 | VkPhysicalDeviceSurfaceInfo2KHR surface_info{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, &for_mode}; | 766 | VkPhysicalDeviceSurfaceInfo2KHR surface_info{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, &for_mode}; |
| 768 | surface_info.surface = surface_; | 767 | surface_info.surface = surface_; |
| 769 | VkSurfacePresentModeCompatibilityKHR compat{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR}; | 768 | VkSurfacePresentModeCompatibilityEXT compat{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT}; |
| 770 | if (compatible) { | 769 | if (compatible) { |
| 771 | compat.presentModeCount = std::uint32_t(compatible->size()); | 770 | compat.presentModeCount = std::uint32_t(compatible->size()); |
| 772 | compat.pPresentModes = compatible->data(); | 771 | compat.pPresentModes = compatible->data(); |