-
Notifications
You must be signed in to change notification settings - Fork 2.5k
GPU: Fix Android surface and swapchain recreation on app resume #14676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
My latest commit fixes |
|
Do my latest two commits still work? Do you see any other issues with them? |
|
Your latest commit doesn't work because initially I had it like that, but then |
Ah, okay, that makes sense. Can you revert my latest commit and double check that? |
|
Maybe also add a code comment explaining why updating that variable is delayed, so someone doesn't try to "clean it up" later? |
|
Unless I've missed something, this should be all good. BTW, this is my first time doing a reviewed PR like this! |
|
Looks good, thanks! |
Description
I want to put this up for review since this doesn't look very clean to me and I'm not sure about the best way to do it (for example, the pointer to
vkCreateAndroidSurfaceKHR()is retrieved every time it's used), but the problem is (mostly) fixed.I've found the cause of failure when switching apps with SDL GPU. Not only the swapchain needs to be recreated, the surface must be recreated, too. I'm still getting an error which I haven't managed to fix:
vkCreateSwapchainKHR VK_ERROR_NATIVE_WINDOW_IN_USE_KHR. But at least now we can ignore it and rendering will continue the next frame after resuming the app, fixing the regression made in 1260c10.Usage notes: In order to avoid another error, the app should stop rendering (stop calling
SDL_WaitAndAcquireGPUSwapchainTexture()) when the eventSDL_EVENT_WINDOW_FOCUS_LOSTSDL_EVENT_DID_ENTER_BACKGROUNDis received, and resume rendering onSDL_EVENT_WINDOW_FOCUS_GAINEDSDL_EVENT_DID_ENTER_FOREGROUND.