From aed086d399e1ba59c0af7dbf870f8fc0d9e50a21 Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Thu, 29 Jul 2021 16:08:52 +0000 Subject: [PATCH] vkr: refactor to add vkr_physical_device_destroy The same call cannot be reused in physical device enumeration error, because apps can still normally destroy objects without mistake. Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu Reviewed-by: Ryan Neph --- src/vkr_renderer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vkr_renderer.c b/src/vkr_renderer.c index 09e9f74..f76b386 100644 --- a/src/vkr_renderer.c +++ b/src/vkr_renderer.c @@ -1046,16 +1046,24 @@ vkr_dispatch_vkCreateInstance(struct vn_dispatch_context *dispatch, ctx->instance = instance; } +static void +vkr_physical_device_destroy(struct vkr_context *ctx, + struct vkr_physical_device *physical_dev) +{ + free(physical_dev->extensions); + + util_hash_table_remove_u64(ctx->object_table, physical_dev->base.id); +} + static void vkr_instance_destroy(struct vkr_context *ctx, struct vkr_instance *instance) { - /* TODO cleanup all objects instead? */ for (uint32_t i = 0; i < instance->physical_device_count; i++) { struct vkr_physical_device *physical_dev = instance->physical_devices[i]; if (!physical_dev) break; - free(physical_dev->extensions); - util_hash_table_remove_u64(ctx->object_table, physical_dev->base.id); + + vkr_physical_device_destroy(ctx, physical_dev); } if (ctx->validate_level != VKR_CONTEXT_VALIDATE_NONE) {