doitsujin / dxvk

Vulkan-based implementation of D3D8, 9, 10 and 11 for Linux / Wine
zlib License
13.03k stars 835 forks source link

Error: Couldn't switch to requested monitor resolution #3946

Closed BaldousHuxley closed 5 months ago

BaldousHuxley commented 6 months ago

Hello, Since a week or so ago I keep encountering this error every time I try to launch a game from Heroic Launcher or Steam alike:

Screenshot_20240404_224652

I'm on Fedora 39 (KDE Wayland) on a laptop with dedicated Nvidia GPU, and am not yet very proficient in the ways of Linux. I tried reinstalling Fedora several times (for this and other unrelated issues) and for a couple of days everything works flawlessly, but then breaks suddenly and without any evident reason. Searching online for answers I found that disabling the "Auto Install/Update DXVK on Prefix" and "Auto Install/Update VKD3D on Prefix" options on Heroic works as a rough patch; similarly, setting PROTON_USE_WINED3D11=1 %COMMAND% as a launch option on Steam, I manage to launch the games (albeit with major graphical glitches and performance impairments). I figured to ask here about it since the issue seems to be related to dxvk. Here is one of the games' log file after a launch attempt: game-LastPlay.log Any help is appreciated as I really don't know how to approach this. Thanks

Edit: since I forgot to mention it, here's my system information.

Doesn't seem to be a Wayland-specific issue because the error pops up in X11 sessions too. Furthermore, sometimes (though rarely) upon booting up everything works without throwing any errors, and I can perfectly play my games.

Edit 2: I found a temporary solution that works really well for some reason. Before opening your preferred game launcher, you just need to run sudo vulkaninfo. After doing so every game runs flawlessly and the system behaves like there wasn't any error in the first place. I can't really wrap my head around it as of why it works, but I'm not complaining tbh

Edit3: Found a permanent solution, check my last comment!

doitsujin commented 6 months ago

err: D3D11SwapChain: Failed to recreate swap chain: -13 err: DXGI: CreateSwapChainForHwnd: Failed to create swap chain, hr -2147467259

Looks like some problem with PRIME maybe? For some reason we're unable to create a Vulkan swap chain on the game's window, but the reason for that can be pretty much anything from messed up driver setup (shouldn't really be a problem since Turing should just work out of the box), your wine/proton build being weird, Heroic setting weird environment variables that fuck things up, or the specific game doing something weird. Extremely hard to remote-debug these things.

Maybe try something like DXVK_FILTER_DEVICE_NAME=Intel to force it to run on the integrated GPU and see if that works for now.

BaldousHuxley commented 6 months ago

I don't really know about the drivers, installed smoothly from rpmfusion and signed for safe boot. I already reinstalled them once to be sure a few days ago, but the issue persisted. Setting DXVK_FILTER_DEVICE_NAME=Intel does run the game, but of course there are performance hits on more demanding titles (for the record, almost every game I tried firing up from both Steam and Heroic throws this error). Since remote-debugging is not viable, how would I go about investigating it? I'm pretty new to Linux so I'm just asking about some good debugging practices. Also, in the event I manage to launch the game, would the log be of any use? Thank you for your patience. I'm kinda going insane with this

BaldousHuxley commented 5 months ago

Hello, with the help of some (way) more knowledgeable people (than me) I found a solution for anyone having the same issue. Basically the root of it was that during boot, one of the Nvidia kernel modules failed to load. In my case, nvidia-modprobe failed to initialize, and as a result, some key system files were missing at startup; for me it was the /dev/nvidia-modeset device file. The curious thing is that vulkaninfo fixed the issue because it directly attempts to call nvidia-modprobe after the boot initialization (as explained well here and also here). This means that running vulkaninfo deals the same exact result as running nvidia-modprobe -m (to load the modeset module and create the missing file). Now, the easiest and preferred way to automatically run nvidia-modprobe when the Nvidia module is loaded during boot, is by setting a custom udev rule: the structure of which is almost identical to this one made for Arch. There are some personal differences in the KERNEL and DRIVER arguments based on how each is called in the host machine, so let's go step by step:

  1. You may want to check if you have nvidia-drm.modeset=1 in the boot parameters. If not, it is preferred to add it (there are plenty of resources online on how to add a boot parameter in GRUB, I don't wanna make expansive explanations. Also note that depending on the distro of choice, the spelling could need a _ instead of - so check for your distro);
  2. Create a new file in /etc/udev/rules.d called nvidia-modprobe.rules;
  3. Copy the contents of the Arch rule in the newly created file;
  4. Run udevadm info -a -n /dev/dri/cardX, where X is the number of your dGPU. Should be either 0 or 1 (you should be able to infer which card the command targeted by looking at the output anyways);
  5. Find the right KERNEL and DRIVER entries listed by the command and replace the default ones in the nvidia-modprobe.rules file with those (in my case they were KERNEL=="card1" and DRIVER=="");
  6. Add the right flags to the line RUN+="/usr/bin/nvidia-modprobe -c 0 -u". I, for example, had to add -m to rebuild the right missing module (modeset);
  7. Save the file, reboot and you should be good!
K0bin commented 5 months ago

Thanks for reporting back.