kondrak / vkQuake2

id Software's Quake 2 v3.21 with mission packs and Vulkan support (Windows, Linux, macOS, FreeBSD, Raspberry Pi 4)
GNU General Public License v2.0
896 stars 91 forks source link

Corruptions/black screen/ view stretched on screen rotation. #113

Closed dor666 closed 3 years ago

dor666 commented 3 years ago

Rotating a screen causes corruptions like this on Intel:

on NVidia black parts instead of corruptions:

Game is unplayable then (view is stretched, hud not)

To reproduce if you do not have laptop with automatic screen rotation:

  1. Download MultiMonitorTool

  2. Create two shortcuts to executable, one rotating, and one resetting: Here assuming your display is named \.\DISPLAY1 ( you can verify it in MultiMonitorTool GUI)

    MultiMonitorTool.exe /SetOrientation \.\DISPLAY1 90 MultiMonitorTool.exe /SetOrientation \.\DISPLAY1 0

  3. Attach shortcuts as firsts icons on taskbar ( this will make them available at Win+1 and Win+2 hotkeys)

  4. Launch a game

  5. Make sure in video options, that exclusive fullscreen and fullscreen are disabled.

  6. Rotate screen with hotkey

  7. Click anywhere in game window.

  8. Game will recreate swapchain (due to VK_SUBOPTIMAL_KHR or VK_ERROR_OUT_OF_DATE_KHR)

  9. Now you will see stretched image with corruptions(intel), black part(nvidia).

Using WindowInspector, I see that after rotating screen. Client Rect is rotated too: image Looking at source, I don't see a place where rotating of window happens, and I don't see such rotation in apps like vkCube.

Using renderdoc, I see that corruptions/black parts are never cleared/drawn.

After rotating back and clicking at game window. Swapchain is recreated correctly.

Feel free to close the issue if you feel impact is too low. I'm curious why clientRect gets rotated too.

kondrak commented 3 years ago

This issue occurs if the game tries to render to a window of a size that extends the actual screen - glitches are just uncleared image areas (this is disabled by default and can be toggled via vk_clear command). I never bothered looking into it seeing that OpenGL also doesn't handle situations like these too well (fov and positioning is incorrect). This doesn't impact normal usage, so there's little benefit in spending time on getting this fixed. I'll be happy to accept PRs if you feel like playing around with the code here.