Fix segfaults when starting vulkan without a working vulkan driver.

RetroArch will crash in several places when running vulkan in an
environment that does not have working vulkan drivers.

This should guard against those crashes and allow RetroArch to fail
safely in those cases.
This commit is contained in:
orbea 2018-08-24 18:07:57 -07:00
parent a6d5931412
commit 260ce526c2
2 changed files with 14 additions and 2 deletions

View File

@ -1827,7 +1827,10 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
VK_DEBUG_REPORT_WARNING_BIT_EXT |
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
info.pfnCallback = vulkan_debug_cb;
vkCreateDebugReportCallbackEXT(vk->context.instance, &info, NULL, &vk->context.debug_callback);
if (vk->context.instance)
vkCreateDebugReportCallbackEXT(vk->context.instance, &info, NULL,
&vk->context.debug_callback);
}
RARCH_LOG("[Vulkan]: Enabling Vulkan debug layers.\n");
#endif

View File

@ -744,6 +744,9 @@ static bool vulkan_init_default_filter_chain(vk_t *vk)
memset(&info, 0, sizeof(info));
if (!vk->context)
return false;
info.device = vk->context->device;
info.gpu = vk->context->gpu;
info.memory_properties = &vk->context->memory_properties;
@ -832,7 +835,7 @@ static bool vulkan_init_filter_chain(vk_t *vk)
static void vulkan_init_resources(vk_t *vk)
{
if (!vk)
if (!vk->context)
return;
vk->num_swapchain_images = vk->context->num_swapchain_images;
@ -855,6 +858,9 @@ static void vulkan_init_static_resources(vk_t *vk)
VkPipelineCacheCreateInfo cache = {
VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO };
if (!vk->context)
return;
vkCreatePipelineCache(vk->context->device,
&cache, NULL, &vk->pipelines.cache);
@ -2357,6 +2363,9 @@ static void vulkan_viewport_info(void *data, struct video_viewport *vp)
video_driver_get_size(&width, &height);
if (!vk)
return;
/* Make sure we get the correct viewport. */
vulkan_set_viewport(vk, width, height, false, true);