diff options
| author | jaybeebabageyus <jaybeebabageyus@users.noreply.github.com> | 2026-11-22 20:57:07 +0100 |
|---|---|---|
| committer | jaybeebabageyus <jaybeebabageyus@users.noreply.github.com> | 2026-11-22 20:57:07 +0100 |
| commit | 50e9dd32fa8d9ebb6ba22e559ca62fa95920b88d (patch) | |
| tree | d5b82116e556cfc96f96b7e575b91a049dd42fb9 /runtime/src/vulkan_present.h | |
| parent | 1188e6406e31870119a7e50c5972599db554a406 (diff) | |
| parent | 162821017ea3c286c8bec860f3ff94f037912061 (diff) | |
Merge remote-tracking branch 'upstream/main' into 2070-lifecycle-fix
# Conflicts:
# runtime/src/pe_loader.cpp
# runtime/src/pe_loader.h
# runtime/test/loader_tls_test.cpp
Diffstat (limited to 'runtime/src/vulkan_present.h')
| -rw-r--r-- | runtime/src/vulkan_present.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h index d9f53baa5..9a73d2f82 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 | ||
| @@ -225,11 +224,12 @@ public: | |||
| 225 | } | 224 | } |
| 226 | 225 | ||
| 227 | // The last presented frame as the swapchain stores it (4 bytes a texel, rows tightly packed, format() order). | 226 | // The last presented frame as the swapchain stores it (4 bytes a texel, rows tightly packed, format() order). |
| 228 | // Waits for the frame to finish. False when nothing was presented since enable_capture(). | 227 | // Waits for the frame to finish. False if no captured frame is available or the wait fails. |
| 229 | bool read_back(std::vector<std::uint8_t>& pixels, VkExtent2D* extent, VkFormat* format) { | 228 | bool read_back(std::vector<std::uint8_t>& pixels, VkExtent2D* extent, VkFormat* format) { |
| 230 | if (!capture_ || !capture_ptr_ || !captured_) return false; | 229 | if (!capture_ || !capture_ptr_ || !captured_) return false; |
| 231 | const Frame& frame = frames_[(frame_index_ + frames_.size() - 1) % frames_.size()]; | 230 | const Frame& frame = frames_[(frame_index_ + frames_.size() - 1) % frames_.size()]; |
| 232 | vkWaitForFences_(context_.device(), 1, &frame.done, VK_TRUE, UINT64_MAX); | 231 | if (vkWaitForFences_(context_.device(), 1, &frame.done, VK_TRUE, UINT64_MAX) != VK_SUCCESS) |
| 232 | return false; | ||
| 233 | pixels.assign(capture_ptr_, capture_ptr_ + std::size_t(captured_extent_.width) * captured_extent_.height * 4); | 233 | pixels.assign(capture_ptr_, capture_ptr_ + std::size_t(captured_extent_.width) * captured_extent_.height * 4); |
| 234 | if (extent) *extent = captured_extent_; | 234 | if (extent) *extent = captured_extent_; |
| 235 | if (format) *format = captured_format_; | 235 | if (format) *format = captured_format_; |
| @@ -315,7 +315,7 @@ public: | |||
| 315 | present.pImageIndices = ℑ | 315 | present.pImageIndices = ℑ |
| 316 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 | 316 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 |
| 317 | // The swapchain was created with FIFO and tear_mode_ (both come from the same recreate). | 317 | // 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}; | 318 | VkSwapchainPresentModeInfoEXT present_mode{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT}; |
| 319 | const bool tearing = tear && vsync_ && tear_supported(); | 319 | const bool tearing = tear && vsync_ && tear_supported(); |
| 320 | if (tearing) { | 320 | if (tearing) { |
| 321 | present_mode.swapchainCount = 1; | 321 | present_mode.swapchainCount = 1; |
| @@ -694,7 +694,7 @@ private: | |||
| 694 | info.presentMode = mode; | 694 | info.presentMode = mode; |
| 695 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 | 695 | #ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 |
| 696 | // A vsync swapchain that can also be presented in IMMEDIATE (or FIFO_RELAXED), switched per present. | 696 | // 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}; | 697 | 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}; | 698 | 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; | 699 | 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); | 700 | if (vsync && mode == VK_PRESENT_MODE_FIFO_KHR) tear = find_tear_mode(modes, info.minImageCount, info.imageUsage, info.imageExtent); |
| @@ -762,11 +762,11 @@ private: | |||
| 762 | // The capabilities of the surface for one present mode, and the modes it can switch to from there. | 762 | // 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, | 763 | const auto ask = [&](VkPresentModeKHR asked, VkSurfaceCapabilitiesKHR& caps, |
| 764 | std::array<VkPresentModeKHR, 16>* compatible, std::uint32_t* compatible_count) { | 764 | std::array<VkPresentModeKHR, 16>* compatible, std::uint32_t* compatible_count) { |
| 765 | VkSurfacePresentModeKHR for_mode{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_KHR}; | 765 | VkSurfacePresentModeEXT for_mode{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT}; |
| 766 | for_mode.presentMode = asked; | 766 | for_mode.presentMode = asked; |
| 767 | VkPhysicalDeviceSurfaceInfo2KHR surface_info{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, &for_mode}; | 767 | VkPhysicalDeviceSurfaceInfo2KHR surface_info{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, &for_mode}; |
| 768 | surface_info.surface = surface_; | 768 | surface_info.surface = surface_; |
| 769 | VkSurfacePresentModeCompatibilityKHR compat{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_KHR}; | 769 | VkSurfacePresentModeCompatibilityEXT compat{VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT}; |
| 770 | if (compatible) { | 770 | if (compatible) { |
| 771 | compat.presentModeCount = std::uint32_t(compatible->size()); | 771 | compat.presentModeCount = std::uint32_t(compatible->size()); |
| 772 | compat.pPresentModes = compatible->data(); | 772 | compat.pPresentModes = compatible->data(); |