From dd7fe810cc7dfdbe02f4153d869ffb3d948760ea Mon Sep 17 00:00:00 2001 From: brainantifreeze Date: Thu, 19 Dec 2024 09:16:15 +0000 Subject: [PATCH] add layer env var to hide present wait ext --- layer/VkLayer_FROG_gamescope_wsi.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/layer/VkLayer_FROG_gamescope_wsi.cpp b/layer/VkLayer_FROG_gamescope_wsi.cpp index 718a2604f3..de5f3ee442 100644 --- a/layer/VkLayer_FROG_gamescope_wsi.cpp +++ b/layer/VkLayer_FROG_gamescope_wsi.cpp @@ -183,6 +183,17 @@ namespace GamescopeWSILayer { return s_ensureMinImageCount; } + static bool getHidePresentWait() { + static bool s_hidePresentWait = []() -> bool { + if (auto ensure = parseEnv("GAMESCOPE_WSI_HIDE_PRESENT_WAIT_EXT")) { + fprintf(stderr, "[Gamescope WSI] Removing VkPhysicalDevicePresentWaitFeaturesKHR because GAMESCOPE_WSI_HIDE_PRESENT_WAIT_EXT is set\n"); + return *ensure; + } + return false; + }(); + return s_hidePresentWait; + } + // Taken from Mesa, licensed under MIT. // // No real reason to rewrite this code, @@ -588,7 +599,11 @@ namespace GamescopeWSILayer { createInfo.ppEnabledExtensionNames = enabledExts.data(); setenv("vk_xwayland_wait_ready", "false", 0); - setenv("vk_khr_present_wait", "true", 0); + if (getHidePresentWait()) { + setenv("vk_khr_present_wait", "false", 0); + } else { + setenv("vk_khr_present_wait", "true", 0); + } VkResult result = pfnCreateInstanceProc(&createInfo, pAllocator, pInstance); if (result != VK_SUCCESS) @@ -893,6 +908,8 @@ namespace GamescopeWSILayer { const vkroots::VkInstanceDispatch* pDispatch, VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures) { + if (getHidePresentWait()) + vkroots::RemoveFromChain(pFeatures); pDispatch->GetPhysicalDeviceFeatures2(physicalDevice, pFeatures); }