GPU: Fix crash on Android upon returning from the background
This commit is contained in:
committed by
Ethan Lee
parent
c2710bd4e8
commit
e5731f9bac
@@ -4363,7 +4363,9 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
&supportsPresent);
|
&supportsPresent);
|
||||||
|
|
||||||
// Initialize these in case anything fails
|
// Initialize these in case anything fails
|
||||||
|
outputDetails->formats = NULL;
|
||||||
outputDetails->formatsLength = 0;
|
outputDetails->formatsLength = 0;
|
||||||
|
outputDetails->presentModes = NULL;
|
||||||
outputDetails->presentModesLength = 0;
|
outputDetails->presentModesLength = 0;
|
||||||
|
|
||||||
if (!supportsPresent) {
|
if (!supportsPresent) {
|
||||||
@@ -4386,22 +4388,33 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
surface,
|
surface,
|
||||||
&outputDetails->formatsLength,
|
&outputDetails->formatsLength,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false);
|
if (result != VK_SUCCESS) {
|
||||||
|
// Make sure the driver didn't mess up this value.
|
||||||
|
outputDetails->formatsLength = 0;
|
||||||
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false);
|
||||||
|
}
|
||||||
result = renderer->vkGetPhysicalDeviceSurfacePresentModesKHR(
|
result = renderer->vkGetPhysicalDeviceSurfacePresentModesKHR(
|
||||||
physicalDevice,
|
physicalDevice,
|
||||||
surface,
|
surface,
|
||||||
&outputDetails->presentModesLength,
|
&outputDetails->presentModesLength,
|
||||||
NULL);
|
NULL);
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false);
|
if (result != VK_SUCCESS) {
|
||||||
|
// Make sure the driver didn't mess up this value.
|
||||||
|
outputDetails->presentModesLength = 0;
|
||||||
|
// Reset this one, too.
|
||||||
|
outputDetails->formatsLength = 0;
|
||||||
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Generate the arrays, if applicable
|
// Generate the arrays, if applicable
|
||||||
|
|
||||||
outputDetails->formats = NULL;
|
|
||||||
if (outputDetails->formatsLength != 0) {
|
if (outputDetails->formatsLength != 0) {
|
||||||
outputDetails->formats = (VkSurfaceFormatKHR *)SDL_malloc(
|
outputDetails->formats = (VkSurfaceFormatKHR *)SDL_malloc(
|
||||||
sizeof(VkSurfaceFormatKHR) * outputDetails->formatsLength);
|
sizeof(VkSurfaceFormatKHR) * outputDetails->formatsLength);
|
||||||
|
|
||||||
if (!outputDetails->formats) { // OOM
|
if (!outputDetails->formats) { // OOM
|
||||||
|
outputDetails->formatsLength = 0;
|
||||||
|
outputDetails->presentModesLength = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4412,17 +4425,22 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
outputDetails->formats);
|
outputDetails->formats);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
SDL_free(outputDetails->formats);
|
SDL_free(outputDetails->formats);
|
||||||
|
outputDetails->formats = NULL;
|
||||||
|
outputDetails->formatsLength = 0;
|
||||||
|
outputDetails->presentModesLength = 0;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false);
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfaceFormatsKHR, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outputDetails->presentModes = NULL;
|
|
||||||
if (outputDetails->presentModesLength != 0) {
|
if (outputDetails->presentModesLength != 0) {
|
||||||
outputDetails->presentModes = (VkPresentModeKHR *)SDL_malloc(
|
outputDetails->presentModes = (VkPresentModeKHR *)SDL_malloc(
|
||||||
sizeof(VkPresentModeKHR) * outputDetails->presentModesLength);
|
sizeof(VkPresentModeKHR) * outputDetails->presentModesLength);
|
||||||
|
|
||||||
if (!outputDetails->presentModes) { // OOM
|
if (!outputDetails->presentModes) { // OOM
|
||||||
SDL_free(outputDetails->formats);
|
SDL_free(outputDetails->formats);
|
||||||
|
outputDetails->formats = NULL;
|
||||||
|
outputDetails->formatsLength = 0;
|
||||||
|
outputDetails->presentModesLength = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4434,6 +4452,10 @@ static bool VULKAN_INTERNAL_QuerySwapchainSupport(
|
|||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
SDL_free(outputDetails->formats);
|
SDL_free(outputDetails->formats);
|
||||||
SDL_free(outputDetails->presentModes);
|
SDL_free(outputDetails->presentModes);
|
||||||
|
outputDetails->formats = NULL;
|
||||||
|
outputDetails->presentModes = NULL;
|
||||||
|
outputDetails->formatsLength = 0;
|
||||||
|
outputDetails->presentModesLength = 0;
|
||||||
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false);
|
CHECK_VULKAN_ERROR_AND_RETURN(result, vkGetPhysicalDeviceSurfacePresentModesKHR, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4526,12 +4548,6 @@ static Uint32 VULKAN_INTERNAL_CreateSwapchain(
|
|||||||
windowData->surface,
|
windowData->surface,
|
||||||
NULL);
|
NULL);
|
||||||
windowData->surface = VK_NULL_HANDLE;
|
windowData->surface = VK_NULL_HANDLE;
|
||||||
if (swapchainSupportDetails.formatsLength > 0) {
|
|
||||||
SDL_free(swapchainSupportDetails.formats);
|
|
||||||
}
|
|
||||||
if (swapchainSupportDetails.presentModesLength > 0) {
|
|
||||||
SDL_free(swapchainSupportDetails.presentModes);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user