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:
Diffstat (limited to 'runtime/src/vulkan_present.h')
-rw-r--r--runtime/src/vulkan_present.h18
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 = &image; 315 present.pImageIndices = &image;
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();