Novum / vkQuake

Vulkan Quake port based on QuakeSpasm
GNU General Public License v2.0
1.83k stars 222 forks source link

When switching to fullscreen game terminates with Quake Error: "Couldn't create swap chain". #261

Closed gargelblaster closed 3 years ago

gargelblaster commented 3 years ago

When trying to switch to fullscreen mode in the video options menu, the game terminates with a message box "Quake Error" saying "Couldn't create swap chain". The problem first occurred on vkQuake version 1.05.0. On version 1.04.1 everything works fine. Machine specs are as follows:

Dell notebook OS: Windows 7 64-Bit CPU: Intel Core i7 5600U with integrated HD Graphics 5500 Dedicated GPU: Nvidia Geforce 840M with Geforce Driver GRD 457.30 WHQL Standard

vkQuake is running on the Nvidia GPU.

LethalManBoob commented 3 years ago

vid_desktopfullscreen i think is the command that fixes it. fullscreen exclusive isnt even a thing in vulkan for a long time. its in there, but disabled for some stupid reason.

Novum commented 3 years ago

Driver bug.

Since 1.05.0 vkQuake makes use of exclusive fullscreen. As LethalManBoob said workaround is to use vid_desktopfullscreen. Apparently the driver pretends that it supports it and then fails to actually create a swap chain.

gargelblaster commented 3 years ago

As long as I play using the screen's native resolution, a borderless window is fine. However, on complex maps like ad_tears I'd like to use a lower resolution to gain some fps. Currently this is possible only in a window smaller than the screen. I had tried vid_desktopfullscreen already. But it seems to have no effect. Playing in a lower resolution scaled to fullscreen is possible in version 1.04.1.

Novum commented 3 years ago

I'll add some code that tries to create the swap chain again without the full screen exclusivity, but I can't test this. It's really an NVIDIA bug.

Novum commented 3 years ago

82a896687c1161001729bae5ca3ebb458065ec05

gargelblaster commented 3 years ago

Thanks a lot for the effort. I greatly appreciate your work. Will there be a new release or, if not, would it be possible to provide an executable for testing? Unfortunately I don't have a build system in place.

dorian-apanel-intel commented 3 years ago

I guess that this laptop screen is connected to integrated card, so discrete GPU will not enter exclusive mode for sure. Trying to recreate swapchain without exclusive mode is a right approach (vkQuake2 does it too).

Novum commented 3 years ago

The right thing would be that the driver to not advertise that it can do exclusive full screen in the first place if it can't. The extension specifically has a way to query this on the fly.

dorian-apanel-intel commented 3 years ago

@Novum For hardware related stuff I agree. But driver may need to exit exclusive mode at runtime (it depends on OS and other apps), game should be prepared for it.

Novum commented 3 years ago

@dorian-apanel-intel I really don't understand what you are going on about. I call vkGetPhysicalDeviceSurfaceCapabilities2KHR right before I create the swap chain and pass VkSurfaceCapabilitiesFullScreenExclusiveEXT which specifically has a "fullScreenExclusiveSupported" return value exactly for this.

It's still a driver bug.

dorian-apanel-intel commented 3 years ago

@Novum vkCreateSwapchainKHR can fail even if fullScreenExclusiveSupported is true. It is stated in Vulkan spec:

In some cases, swapchain creation may fail if exclusive full-screen mode is requested for application control, but for some implementation-specific reason exclusive full-screen access is unavailable for the particular combination of parameters provided. If this occurs, VK_ERROR_INITIALIZATION_FAILED will be returned.

In some cases this is not a driver bug, so it is better to recreate instead of terminating the game in my opinion.