Skip to content

Commit

Permalink
add layer env var to hide present wait ext
Browse files Browse the repository at this point in the history
  • Loading branch information
brainantifreeze committed Dec 19, 2024
1 parent 1c9495c commit 4da5c0a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion layer/VkLayer_FROG_gamescope_wsi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ namespace GamescopeWSILayer {
return s_ensureMinImageCount;
}

static bool getHidePresentWait() {
static bool s_hidePresentWait = []() -> bool {
if (auto hide = parseEnv<bool>("GAMESCOPE_WSI_HIDE_PRESENT_WAIT_EXT")) {
return *hide;
}
return false;
}();
return s_hidePresentWait;
}

// Taken from Mesa, licensed under MIT.
//
// No real reason to rewrite this code,
Expand Down Expand Up @@ -588,7 +598,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)
Expand Down Expand Up @@ -893,6 +907,10 @@ namespace GamescopeWSILayer {
const vkroots::VkInstanceDispatch* pDispatch,
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures2* pFeatures) {
if (getHidePresentWait()) {
fprintf(stderr, "[Gamescope WSI] Removing VkPhysicalDevicePresentWaitFeaturesKHR because GAMESCOPE_WSI_HIDE_PRESENT_WAIT_EXT is set\n");
vkroots::RemoveFromChain<VkPhysicalDevicePresentWaitFeaturesKHR>(pFeatures);
}
pDispatch->GetPhysicalDeviceFeatures2(physicalDevice, pFeatures);
}

Expand Down

0 comments on commit 4da5c0a

Please sign in to comment.