Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions source_common/framework/manual_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,13 +751,15 @@ VKAPI_ATTR void VKAPI_CALL layer_vkDestroyInstance_default(VkInstance instance,
std::unique_lock<std::mutex> lock {g_vulkanLock};
auto* layer = Instance::retrieve(instance);

// Layer proxy must be destroyed before the driver version
// so we can clean up any layer-owned resources
// Save the driver function to avoid a use-after free when proxy is destroyed
auto destroyInstance = layer->driver.vkDestroyInstance;

// Layer proxy must be destroyed before the driver object as we use its dispatchable handle
Instance::destroy(layer);

// Release the lock to call into the driver
lock.unlock();
layer->driver.vkDestroyInstance(instance, pAllocator);
destroyInstance(instance, pAllocator);
}

/* See Vulkan API for documentation. */
Expand Down Expand Up @@ -839,13 +841,15 @@ VKAPI_ATTR void VKAPI_CALL layer_vkDestroyDevice_default(VkDevice device, const
std::unique_lock<std::mutex> lock {g_vulkanLock};
auto* layer = Device::retrieve(device);

// Layer proxy must be destroyed before the driver version
// so we can clean up any layer-owned resources
// Save the driver function to avoid a use-after free when proxy is destroyed
auto destroyDevice = layer->driver.vkDestroyDevice;

// Layer proxy must be destroyed before the driver object as we use its dispatchable handle
Device::destroy(layer);

// Release the lock to call into the driver
lock.unlock();
layer->driver.vkDestroyDevice(device, pAllocator);
destroyDevice(device, pAllocator);
}

/* See Vulkan API for documentation. */
Expand Down