Skip to content

Commit

Permalink
fix(nvidia): allow disabling Vulkan extension for nvidia to work
Browse files Browse the repository at this point in the history
This adds a workaround for ValveSoftware#1592 which removes the
VkPhysicalDevicePresentWaitFeaturesKHR extension in
the layer if the environment variable
GAMESCOPE_WSI_HIDE_PRESENT_WAIT_EXT is set.

This resolves the current freezing issue on nVidia
in dx12 (without having to set
VKD3D_DISABLE_EXTENSIONS), dx11 (without having
to patch DXVK not to use the extension) and in
native vulkan games.
  • Loading branch information
brainantifreeze authored and antheas committed Jan 19, 2025
1 parent 1337c54 commit dca8781
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 @@ -496,7 +496,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 @@ -801,6 +805,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 Expand Up @@ -1015,6 +1023,16 @@ namespace GamescopeWSILayer {
return value;
}

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

static uint32_t getMinImageCount() {
static uint32_t s_minImageCount = []() -> uint32_t {
if (auto minCount = parseEnv<uint32_t>("GAMESCOPE_WSI_MIN_IMAGE_COUNT")) {
Expand Down

0 comments on commit dca8781

Please sign in to comment.