tests: Only destroy the device if the context has one in vulkan_test_context_destroy().

If vulkan_test_context_init_device() was never called, or failed to
create a device, the context won't have a device.
This commit is contained in:
Giovanni Mascellani 2024-10-09 16:43:25 +02:00 committed by Henri Verbeet
parent ccc48291b3
commit 3285d1ad8c
Notes: Henri Verbeet 2024-10-10 20:09:13 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1166

View File

@ -342,6 +342,16 @@ static inline bool get_vulkan_queue_index(const struct vulkan_test_context *cont
return false;
}
static inline void vulkan_test_context_destroy_device(const struct vulkan_test_context *context)
{
VkDevice device = context->device;
VK_CALL(vkDestroyDescriptorPool(device, context->descriptor_pool, NULL));
VK_CALL(vkFreeCommandBuffers(device, context->command_pool, 1, &context->cmd_buffer));
VK_CALL(vkDestroyCommandPool(device, context->command_pool, NULL));
VK_CALL(vkDestroyDevice(device, NULL));
}
static inline bool vulkan_test_context_init_device(struct vulkan_test_context *context,
const VkDeviceCreateInfo *device_desc, uint32_t queue_index,
uint32_t max_resource_count, uint32_t max_sampler_count)
@ -402,12 +412,8 @@ static inline bool vulkan_test_context_init_device(struct vulkan_test_context *c
static inline void vulkan_test_context_destroy(const struct vulkan_test_context *context)
{
VkDevice device = context->device;
VK_CALL(vkDestroyDescriptorPool(device, context->descriptor_pool, NULL));
VK_CALL(vkFreeCommandBuffers(device, context->command_pool, 1, &context->cmd_buffer));
VK_CALL(vkDestroyCommandPool(device, context->command_pool, NULL));
VK_CALL(vkDestroyDevice(device, NULL));
if (context->device)
vulkan_test_context_destroy_device(context);
VK_CALL(vkDestroyInstance(context->instance, NULL));
}