protonscr

Horizon Zero Dawn stops rendering when focusing out in fullscreen mode or leaving it with Alt+Enter

vkd3dclosed
HansKristian-Work/vkd3d-proton#715 · opened 2021-06-24 by gofman · updated 2021-06-25 · 2 comments · github
Ggofman 2021-06-24 github

Alt+Enter does its job fine when going from windowed mode to fullscreen. When going from fullscreen to windowed, the game window disappears (the game still works as a process).

Alt-tabbing out of the fullscreen behaves leaves a black window stays on screen without rendering anything in there.

An immediate reason for this behaviour is the game initially (before creating the swapchain) calls SetWindowPos setting the window origin to 0,-10000 (out of the screen).
vkd3d-proton gets the window size just once at swapchain initialization, and sets this size back when going out of fullscreen in d3d12_swapchain_SetFullscreenState(). Meanwhile, application is changing window position and size after the swapchain is created. Also probably worth mentioning that the game calls MakeWindowAssociation(DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_WINDOW_CHANGES) but this did not affect anything in my testing.
It looks like the game aims to fully manage its window itself, including Alt+Enter processing (which, as I understand, would not currently work with vkd3d-proton otherwise).

I am attaching the patch which roughly simulates the game behaviour in triangle demo, and also has a potential fix which queries window size in d3d12_swapchain_SetFullscreenState() when going from windowed mode.
To see the effect, run the triangle with the changes and go to fullscreen with Alt+Enter and then back to windowed mode.
Being run on Windows with native d3d12, the window ends up being 800x600.
On Windows with vkd3d-proton d3d12 (without the potential fix in the patch), the window disappears after going out of fullscreen just like in game.

0001-vkd3d-Update-original_window_rect-in-d3d12_swapchain.txt

HHansKristian-Work maintainer 2021-06-25 github

Nice find! I'll have a look.

HHansKristian-Work maintainer 2021-06-25 github

Ok, the patch seems fine. I tested HZD on Windows as well, and the game behavior matches vkd3d-proton with the patch:

  • Alt-tabbing out will minimize the window as well.
  • Alt + Enter works as expected.

This also matches DXVK behavior, which queries the rect on entering fullscreen: https://github.com/doitsujin/dxvk/blob/master/src/dxgi/dxgi_swapchain.cpp#L568

Nothing extracted yet.