woof icon indicating copy to clipboard operation
woof copied to clipboard

Blackscreens my entire computer upon pressing windows key

Open kw-create opened this issue 9 months ago • 5 comments

It seems like if I have the game in fullscreen, specifically exclusive fullscreen, then press the windows key, no issues, but when I then renenter the game and press the windows key to exit again (both times with the game unpaused), my whole screen goes black forever, and nothing fixes it except restarting the computer. Alt f4, task manager, ctrl alt delete, nothing. Please fix. It happens consistently

kw-create avatar May 08 '24 21:05 kw-create

I can't reproduce it on Windows 10. Maybe you accidentally turned off the display backlight? (Win + F5 on my laptop)

rfomin avatar May 09 '24 02:05 rfomin

I'm on windows 11, I can reproduce it consistently, and win + F5 doesn't do anything unless I press Fn.

kw-create avatar May 09 '24 02:05 kw-create

I got a black screen in Windows 10, it's inconsistent and I can get rid of it with Alt-Tab. Looks like a Windows problem, we don't do anything with the Win key in the code. So should we disable the Win key altogether?

rfomin avatar May 09 '24 03:05 rfomin

Did @kw-create try Alt+Tab instead of the Windows key? Just to confirm that only the latter has the issue.

MrAlaux avatar May 09 '24 03:05 MrAlaux

alt+tab back into doom is the only thing that fixes it. Still happens almost 100% of the time. I can also cause the issue by using alt + tab instead of pressing the windows key.

kw-create avatar May 09 '24 06:05 kw-create

I just dealt with a slightly bad undervolt that would cause crashes alt-tabbing basic games even though running demanding raytraced stuff was OK. Something about instability at relatively light loads and things boosting weirdly and crashing. Any chance you've done something similar?

ak-988 avatar May 24 '24 01:05 ak-988

I just dealt with a slightly bad undervolt that would cause crashes alt-tabbing basic games even though running demanding raytraced stuff was OK. Something about instability at relatively light loads and things boosting weirdly and crashing. Any chance you've done something similar?

I can replicate the issue, it's related to how "Exclusive Fullscreen" works on Windows with some drivers/hardware. Not sure if we can fix it.

rfomin avatar May 24 '24 02:05 rfomin

Using SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS seems to be a workaround. Maybe on Windows platforms this should be set when using exclusive fullscreen, and unset otherwise.

ceski-1 avatar May 27 '24 19:05 ceski-1

Using SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS seems to be a workaround. Maybe on Windows platforms this should be set when using exclusive fullscreen, and unset otherwise.

I've tried this:

diff --git a/src/i_video.c b/src/i_video.c
index ecd69b6..fd47b8e 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1562,6 +1562,8 @@ static void I_InitGraphicsMode(void)
             }
             // [FG] exclusive fullscreen
             flags |= SDL_WINDOW_FULLSCREEN;
+            SDL_SetHintWithPriority(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "1",
+                                    SDL_HINT_OVERRIDE);
         }
         else
         {

Still the same problem. It's inconsistent on my system, but after a few tries I get a black screen again. Can you reproduce this?

rfomin avatar May 28 '24 01:05 rfomin

Can you reproduce this?

Sorry, I was mistaken. I had capped fps, which doesn't seem affected by this bug (alt+tab is fine). With uncapped fps, I can reproduce the bug and SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS doesn't seem to help.

ceski-1 avatar May 28 '24 02:05 ceski-1

Disabling "batching" just before window creation seems to fix it. I'm not entirely sure why or what the consequences might be. This also seems to lower input latency.

diff --git a/src/i_video.c b/src/i_video.c
index ecd69b67..a84655f9 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1576,6 +1576,8 @@ static void I_InitGraphicsMode(void)
 
     I_GetWindowPosition(&window_x, &window_y, w, h);
 
+    SDL_SetHint(SDL_HINT_RENDER_BATCHING, "0");
+
     // [FG] create rendering window
 
     screen = SDL_CreateWindow(PROJECT_STRING, window_x, window_y, w, h, flags);

There is also SDL_HINT_WINDOWS_USE_D3D9EX but I didn't need to set it.

ceski-1 avatar May 28 '24 05:05 ceski-1

SDL_HINT_RENDER_BATCHING will be removed in SDL3: https://github.com/libsdl-org/SDL/commit/6ba90f77752ab0350f28fb228c5dde550244904e

ceski-1 avatar May 28 '24 05:05 ceski-1

SDL_SetHint(SDL_HINT_RENDER_BATCHING, "0");

Yes, it works for me.

I always thought that "batch rendering" was the main difference between d3d9 and d3d11/d3d12 and the main reason for better performance. Hopefully this will be fixed in SDL3.

rfomin avatar May 28 '24 10:05 rfomin

Fixed in https://github.com/fabiangreffrath/woof/commit/27214764335906e7dc22f04be0c6c16489dc6b30

rfomin avatar Jun 09 '24 03:06 rfomin