angband / angband

A free, single-player roguelike dungeon exploration game
1.32k stars 336 forks source link

MSYS2 & Cygwin/X SDL2: Game frozen when switch displays #5512

Open smbhax opened 2 years ago

smbhax commented 2 years ago

Windows 11 Home version two 1080p displays

MSYS2 1) Run an MSYS2-compiled SDL2 front end version of Angband on a two-display system in which the computer's display can move between the two 2) Switch to the other display == Angband is perfectly visible but pressing keys does nothing and there is no mouse response. If you switch back to the other display, you regain control but the screen is blanked (like the blanking in #5497 ).

Cygwin/X 1) Run a Cygwin-compiled SDL2 front end version of Angband via XLaunch on a two-display system in which the computer's display can move between the two 2) Switch to the other display == Angband is perfectly visible and if you have sound enabled you can hear sound feedback from your key inputs, but the display itself is frozen. If you switch back to the other display, the display remains frozen. I could CTRL+X to save and quit, but the quitting wasn't visible until I task-switched away and back.

This does not happen with the Windows front end or the SDL2 front end running in WSL Ubuntu.

backwardsEric commented 2 years ago

So, using the terminology from https://support.microsoft.com/en-us/windows/how-to-use-multiple-monitors-in-windows-329c6962-5a4d-b481-7baa-bec9671f728a , by switching displays are you hitting windows key+P and then selecting "PC screen only" or "Second screen only"? Or is it something different? If the desktop is extended across the two screens, do the MSYS2 SDL2 and Cygwin SDL2 versions work correctly after dragging the application's window from one screen to the other?

I'm not sure if it's relevant, but are the two screens driven by the same graphics adapter/card or different adapters/cards?

smbhax commented 2 years ago

It's an external monitor and the monitor built into my laptop; the HDMI cable from the laptop to the external monitor runs through an HDMI switcher; when I set the switcher to the laptop's HDMI-in, the display on the laptop's screen goes off, and reappears on the external monitor; when I set the switcher away from the laptop's HDMI-in, its display on the external monitor goes off, and reappears on the laptop's screen. The desktop is only on one display at a time.

Untitled-3 copy

The laptop has two graphics adapters: an integrated GPU and an nVidia card. According to this https://pcguide101.com/gpu/how-to-check-which-graphics-card-is-being-used/ , Task Manager shows an integrated GPU as "GPU 0," and a dedicated GPU like the nVidia as "GPU 1."

When I started out on the external monitor, angband.exe showed on GPU 1:

Untitled-4 copy

When I switched the display to the laptop monitor, it no longer had an associated GPU:

Untitled-4 copy

When I switched back to the external monitor, it showed back up on GPU 1:

Untitled-4 copy

backwardsEric commented 1 month ago

SDL2 on DirectX can generate SDL_RENDER_TARGETS_RESET (request reload of textures created with the SDL_TEXTUREACCESS_TARGET flag?) and SDL_RENDER_DEVICE_RESET (request recreation of all textures) events. Angband's SDL2 frontend is not doing anything in response to those events, and that may be the cause for this issue and for https://github.com/angband/angband/issues/5497 .