mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
70 lines
3.1 KiB
Diff
70 lines
3.1 KiB
Diff
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
|
|
index 54e4efc..93038f2 100644
|
|
--- a/src/rendervulkan.cpp
|
|
+++ b/src/rendervulkan.cpp
|
|
@@ -452,0 +453,2 @@ bool CVulkanDevice::createDevice()
|
|
+ bool supportsPresentId = false;
|
|
+ bool supportsPresentWait = false;
|
|
@@ -453,0 +456,4 @@ bool CVulkanDevice::createDevice()
|
|
+ if ( strcmp(ext.extensionName, VK_KHR_PRESENT_ID_EXTENSION_NAME) == 0 )
|
|
+ supportsPresentId = true;
|
|
+ if ( strcmp(ext.extensionName, VK_KHR_PRESENT_WAIT_EXTENSION_NAME) == 0 )
|
|
+ supportsPresentWait = true;
|
|
@@ -520,0 +527,19 @@ bool CVulkanDevice::createDevice()
|
|
+ if ( supportsPresentId && supportsPresentWait )
|
|
+ {
|
|
+ VkPhysicalDevicePresentWaitFeaturesKHR waitFeatures = {
|
|
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR,
|
|
+ };
|
|
+ VkPhysicalDevicePresentIdFeaturesKHR idFeatures = {
|
|
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR,
|
|
+ .pNext = &waitFeatures,
|
|
+ };
|
|
+ VkPhysicalDeviceFeatures2 features = {
|
|
+ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
|
+ .pNext = &idFeatures,
|
|
+ };
|
|
+ vk.GetPhysicalDeviceFeatures2( physDev(), &features );
|
|
+ m_bSupportsPresentWait = idFeatures.presentId && waitFeatures.presentWait;
|
|
+ }
|
|
+ if ( GetBackend()->UsesVulkanSwapchain() && !m_bSupportsPresentWait )
|
|
+ vk_log.infof( "Present ID/wait unavailable; using timer-based pacing." );
|
|
+
|
|
@@ -573,2 +598,5 @@ bool CVulkanDevice::createDevice()
|
|
- enabledExtensions.push_back( VK_KHR_PRESENT_ID_EXTENSION_NAME );
|
|
- enabledExtensions.push_back( VK_KHR_PRESENT_WAIT_EXTENSION_NAME );
|
|
+ if ( m_bSupportsPresentWait )
|
|
+ {
|
|
+ enabledExtensions.push_back( VK_KHR_PRESENT_ID_EXTENSION_NAME );
|
|
+ enabledExtensions.push_back( VK_KHR_PRESENT_WAIT_EXTENSION_NAME );
|
|
+ }
|
|
@@ -649 +677 @@ bool CVulkanDevice::createDevice()
|
|
- .pNext = &presentIdFeatures,
|
|
+ .pNext = m_bSupportsPresentWait ? static_cast<void *>( &presentIdFeatures ) : static_cast<void *>( &features13 ),
|
|
@@ -3089 +3117 @@ void vulkan_present_to_window( void )
|
|
- .pNext = &presentIdInfo,
|
|
+ .pNext = g_device.supportsPresentWait() ? &presentIdInfo : nullptr,
|
|
@@ -3097,2 +3125,5 @@ void vulkan_present_to_window( void )
|
|
- g_currentPresentWaitId = presentId;
|
|
- g_currentPresentWaitId.notify_all();
|
|
+ if ( g_device.supportsPresentWait() )
|
|
+ {
|
|
+ g_currentPresentWaitId = presentId;
|
|
+ g_currentPresentWaitId.notify_all();
|
|
+ }
|
|
@@ -3164 +3195,2 @@ gamescope::OwningRc<CVulkanTexture> vulkan_create_flat_texture( uint32_t width,
|
|
- flags.bFlippable = true;
|
|
+ // A swapchain backend samples this texture locally; it never scans it out.
|
|
+ flags.bFlippable = !GetBackend()->UsesVulkanSwapchain();
|
|
@@ -3665 +3697 @@ bool vulkan_init( VkInstance instance, VkSurfaceKHR surface )
|
|
- if ( GetBackend()->UsesVulkanSwapchain() )
|
|
+ if ( GetBackend()->UsesVulkanSwapchain() && g_device.supportsPresentWait() )
|
|
diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp
|
|
index fa519db..91f7793 100644
|
|
--- a/src/rendervulkan.hpp
|
|
+++ b/src/rendervulkan.hpp
|
|
@@ -864,0 +865 @@ public:
|
|
+ inline bool supportsPresentWait() {return m_bSupportsPresentWait;}
|
|
@@ -932,0 +934 @@ protected:
|
|
+ bool m_bSupportsPresentWait = false;
|