upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_present.h
diff options
context:
space:
mode:
authorAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 13:00:38 +0100
committerAlxcBTW <187763517+AlxcBTW@users.noreply.github.com>2026-11-22 13:00:38 +0100
commitc03b573a161c1bf0f4cab9d6ab7eb8e712187ecc (patch)
tree1cbd0648d560f1e7cf9d6342803d9c13a97894d4 /runtime/src/vulkan_present.h
parent6728a00c2a27d9e21785d262f5ab8479c819dc89 (diff)
PresentX tear: review fixes
- find_tear_mode rejects a mode whose surface caps lack the swapchain's image usage or extent. - present_timing: a repeated or stale token is never late. - percent_scanned is measured at commit, so it agrees with the display time. - The "no effect" log distinguishes the kill switch from a missing extension or mode. - LEONIDA_PRESENT_NO_TEAR is read with _dupenv_s: any non-empty value but "0" disables. - xbox_present_test: the real-time comment is back where it belongs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/vulkan_present.h')
-rw-r--r--runtime/src/vulkan_present.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h
index cc782a17d..148ddb7ae 100644
--- a/runtime/src/vulkan_present.h
+++ b/runtime/src/vulkan_present.h
@@ -647,7 +647,7 @@ private:
647 VkSwapchainPresentModesCreateInfoKHR switchable{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_KHR}; 647 VkSwapchainPresentModesCreateInfoKHR switchable{VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_KHR};
648 std::array<VkPresentModeKHR, 2> switchable_modes{VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_MAX_ENUM_KHR}; 648 std::array<VkPresentModeKHR, 2> switchable_modes{VK_PRESENT_MODE_FIFO_KHR, VK_PRESENT_MODE_MAX_ENUM_KHR};
649 VkPresentModeKHR tear = VK_PRESENT_MODE_MAX_ENUM_KHR; 649 VkPresentModeKHR tear = VK_PRESENT_MODE_MAX_ENUM_KHR;
650 if (vsync && mode == VK_PRESENT_MODE_FIFO_KHR) tear = find_tear_mode(modes, info.minImageCount); 650 if (vsync && mode == VK_PRESENT_MODE_FIFO_KHR) tear = find_tear_mode(modes, info.minImageCount, info.imageUsage, info.imageExtent);
651 if (tear != VK_PRESENT_MODE_MAX_ENUM_KHR) { 651 if (tear != VK_PRESENT_MODE_MAX_ENUM_KHR) {
652 switchable_modes[1] = tear; 652 switchable_modes[1] = tear;
653 switchable.presentModeCount = 2; 653 switchable.presentModeCount = 2;
@@ -702,8 +702,10 @@ private:
702#ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1 702#ifdef LEONIDA_SWAPCHAIN_MAINTENANCE1
703 // The mode a FIFO swapchain can also present in, so that a late frame can be shown at once: IMMEDIATE, else 703 // The mode a FIFO swapchain can also present in, so that a late frame can be shown at once: IMMEDIATE, else
704 // FIFO_RELAXED, each only if the surface lists it and reports it compatible with FIFO (VK_KHR_surface_maintenance1). 704 // FIFO_RELAXED, each only if the surface lists it and reports it compatible with FIFO (VK_KHR_surface_maintenance1).
705 // `min_images` is raised to what that mode needs too. MAX_ENUM when there is none or the extension is not in use. 705 // `min_images` is raised to what that mode needs too. The mode must also accept the swapchain's image usage and
706 VkPresentModeKHR find_tear_mode(const std::vector<VkPresentModeKHR>& modes, std::uint32_t& min_images) { 706 // extent (its capabilities can differ from FIFO's). MAX_ENUM when there is none or the extension is not in use.
707 VkPresentModeKHR find_tear_mode(const std::vector<VkPresentModeKHR>& modes, std::uint32_t& min_images,
708 VkImageUsageFlags usage, VkExtent2D extent) {
707 if (!maintenance1_ || !vkGetPhysicalDeviceSurfaceCapabilities2KHR_) return VK_PRESENT_MODE_MAX_ENUM_KHR; 709 if (!maintenance1_ || !vkGetPhysicalDeviceSurfaceCapabilities2KHR_) return VK_PRESENT_MODE_MAX_ENUM_KHR;
708 // The capabilities of the surface for one present mode, and the modes it can switch to from there. 710 // The capabilities of the surface for one present mode, and the modes it can switch to from there.
709 const auto ask = [&](VkPresentModeKHR asked, VkSurfaceCapabilitiesKHR& caps, 711 const auto ask = [&](VkPresentModeKHR asked, VkSurfaceCapabilitiesKHR& caps,
@@ -734,6 +736,10 @@ private:
734 continue; 736 continue;
735 VkSurfaceCapabilitiesKHR mode_caps{}; 737 VkSurfaceCapabilitiesKHR mode_caps{};
736 if (!ask(wanted, mode_caps, nullptr, nullptr)) continue; 738 if (!ask(wanted, mode_caps, nullptr, nullptr)) continue;
739 if ((mode_caps.supportedUsageFlags & usage) != usage) continue;
740 if (extent.width < mode_caps.minImageExtent.width || extent.height < mode_caps.minImageExtent.height ||
741 extent.width > mode_caps.maxImageExtent.width || extent.height > mode_caps.maxImageExtent.height)
742 continue;
737 // One image count that every mode of the swapchain accepts. 743 // One image count that every mode of the swapchain accepts.
738 std::uint32_t count = std::max({min_images, fifo_caps.minImageCount, mode_caps.minImageCount}); 744 std::uint32_t count = std::max({min_images, fifo_caps.minImageCount, mode_caps.minImageCount});
739 const std::uint32_t most = std::min(fifo_caps.maxImageCount ? fifo_caps.maxImageCount : UINT32_MAX, 745 const std::uint32_t most = std::min(fifo_caps.maxImageCount ? fifo_caps.maxImageCount : UINT32_MAX,