From bbc75cc59dd7ced2fa6af63b2b518ef323109591 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 18 Apr 2016 12:10:38 +0200 Subject: [PATCH] Follow-up fix for 840338140dd, the same thing could happen on replay * This is fixed upstream in the loader, but only on master and people could be running 1.0.5 or 1.0.8 for a long time, so we can't afford to just leave it to the loader to fix --- .../vulkan/wrappers/vk_device_funcs.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index eac68ceb3..1651b1a1e 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -322,6 +322,12 @@ bool WrappedVulkan::Serialise_vkEnumeratePhysicalDevices( RDCASSERT(count > physIndex); devices = new VkPhysicalDevice[count]; + if(physIndex >= m_PhysicalDevices.size()) + { + m_PhysicalDevices.resize(physIndex+1); + m_MemIdxMaps.resize(physIndex+1); + } + vkr = ObjDisp(instance)->EnumeratePhysicalDevices(Unwrap(instance), &count, devices); RDCASSERTEQUAL(vkr, VK_SUCCESS); @@ -329,16 +335,21 @@ bool WrappedVulkan::Serialise_vkEnumeratePhysicalDevices( pd = devices[physIndex]; + for(size_t i=0; i < m_PhysicalDevices.size(); i++) + { + // physical devices might be re-created inside EnumeratePhysicalDevices every time, so + // we need to re-wrap any previously enumerated physical devices + if(m_PhysicalDevices[i] != VK_NULL_HANDLE) + { + RDCASSERTNOTEQUAL(i, physIndex); + GetWrapped(m_PhysicalDevices[i])->RewrapObject(devices[i]); + } + } + SAFE_DELETE_ARRAY(devices); GetResourceManager()->WrapResource(instance, pd); GetResourceManager()->AddLiveResource(physId, pd); - - if(physIndex >= m_PhysicalDevices.size()) - { - m_PhysicalDevices.resize(physIndex+1); - m_MemIdxMaps.resize(physIndex+1); - } m_PhysicalDevices[physIndex] = pd;