phr00t / FocusEngine

Focus Game Engine. This is Stride/Xenko fast-tracked for Phr00t's Software games. Improvements over the original Focus on Vulkan support, PC platforms, VR, performance & ease. Cherry-picks commits from other forks as needed.
MIT License
97 stars 11 forks source link

Vulkan crash on Fullscreen [mostly fixed] #59

Closed phr00t closed 5 years ago

phr00t commented 5 years ago

Switching to fullscreen while using the Vulkan API causes an "Error Device Lost" to happen sometime later in the rendering chain. Might need to recreate the swap chain if not done already when fullscreen changes.

Noticed this problem shortly after fixing window resizing & haven't explored it much yet.

phr00t commented 5 years ago

CreateSwapChain() needs to be called after the SDL call to set the window fullscreen. Currently the "event" likes to call the Swap Chain IsFullscreen first (where CreateSwapChain happens), and then the SDL call later, which is what I think is leading to the crash.

phr00t commented 5 years ago

Disregard the above comment -- it was a theory that didn't hold up. Order of functions seem to be OK when stepping through while debugging.

Trying to switch to fullscreen on startup, so I can use Vulkan validation easier, reports this problem:

Error: [ VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 ] Object: 0x2127107f180 (Type = 3) | vkCreateSwapchainKHR() called with imageExtent = (1280,720), which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (1920,1080), minImageExtent = (1920,1080), maxImageExtent = (1920,1080). The Vulkan spec states: imageExtent must be between minImageExtent and maxImageExtent, inclusive, where minImageExtent and maxImageExtent are members of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageExtent-01274) ([0] Validation)

1280x720 is the resolution I'm trying to switch to, while my native resolution is 1920x1080.

phr00t commented 5 years ago

Got it getting into fullscreen in development, but just on game startup! If you switch back to window, and then try to go back to fullscreen -- the device still gets lost. However, great progress!

phr00t commented 5 years ago

This commit: https://github.com/phr00t/xenko/commit/915d898598d7273cf7b035a89bf6a4e8834e2c12

... seems to completely fix the issue in my release builds. I was still having a crash in debug when going from fullscreen, to windowed & back to fullscreen... but it isn't happening in my release builds anymore. So, this might be fixed... will monitor.

phr00t commented 5 years ago

Crash still happens occasionally when switching between modes while running. Probably a synchronization issue somewhere.

phr00t commented 5 years ago

Fixed with https://github.com/phr00t/xenko/commit/4e1b502baae7cadd33f86ce2bc40b0c3ff92a8f3