From f7a9d64d73c0af568eceb107a876de5b35b0f388 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 22 Jan 2023 17:28:59 +0100 Subject: [PATCH] Fix crash when using multiple physical devices and HW core (#14889) * [Vulkan] Detect if wrong PhysicalDevice is returned. * [Vulkan] Actually query physical device before creating core device. --- gfx/common/vulkan_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 5d97b04994..9545a0eb02 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -1584,6 +1584,9 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk) iface = NULL; } + if (!vulkan_context_init_gpu(vk)) + return false; + if (!cached_device_vk && iface && iface->create_device) { struct retro_vulkan_context context = { 0 }; @@ -1605,6 +1608,9 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk) } else { + if (vk->context.gpu != VK_NULL_HANDLE && context.gpu != vk->context.gpu) + RARCH_ERR("[Vulkan]: Got unexpected VkPhysicalDevice, despite RetroArch using explicit physical device.\n"); + vk->context.destroy_device = iface->destroy_device; vk->context.device = context.device; @@ -1626,9 +1632,6 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk) cached_destroy_device_vk = NULL; } - if (!vulkan_context_init_gpu(vk)) - return false; - vkGetPhysicalDeviceProperties(vk->context.gpu, &vk->context.gpu_properties); vkGetPhysicalDeviceMemoryProperties(vk->context.gpu,