From c2e77fce08360f90dc4fe264283ca07f844682ee Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Fri, 12 Nov 2021 18:32:51 +0000 Subject: [PATCH] vkr: add vkr_descriptor_pool_release Signed-off-by: Yiwei Zhang Reviewed-by: Chia-I Wu --- src/venus/vkr_descriptor_set.c | 5 ++--- src/venus/vkr_descriptor_set.h | 8 ++++++++ src/venus/vkr_device.c | 8 ++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/venus/vkr_descriptor_set.c b/src/venus/vkr_descriptor_set.c index a30a065..efb0618 100644 --- a/src/venus/vkr_descriptor_set.c +++ b/src/venus/vkr_descriptor_set.c @@ -57,8 +57,7 @@ vkr_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context *dispatch, if (!pool) return; - vkr_context_remove_objects(ctx, &pool->descriptor_sets); - + vkr_descriptor_pool_release(ctx, pool); vkr_descriptor_pool_destroy_and_remove(ctx, args); } @@ -78,7 +77,7 @@ vkr_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *dispatch, vn_replace_vkResetDescriptorPool_args_handle(args); args->ret = vkResetDescriptorPool(args->device, args->descriptorPool, args->flags); - vkr_context_remove_objects(ctx, &pool->descriptor_sets); + vkr_descriptor_pool_release(ctx, pool); list_inithead(&pool->descriptor_sets); } diff --git a/src/venus/vkr_descriptor_set.h b/src/venus/vkr_descriptor_set.h index 1a7f15d..1a31cfa 100644 --- a/src/venus/vkr_descriptor_set.h +++ b/src/venus/vkr_descriptor_set.h @@ -8,6 +8,8 @@ #include "vkr_common.h" +#include "vkr_context.h" + struct vkr_descriptor_set_layout { struct vkr_object base; }; @@ -50,4 +52,10 @@ vkr_context_init_descriptor_set_dispatch(struct vkr_context *ctx); void vkr_context_init_descriptor_update_template_dispatch(struct vkr_context *ctx); +static inline void +vkr_descriptor_pool_release(struct vkr_context *ctx, struct vkr_descriptor_pool *pool) +{ + vkr_context_remove_objects(ctx, &pool->descriptor_sets); +} + #endif /* VKR_DESCRIPTOR_SET_H */ diff --git a/src/venus/vkr_device.c b/src/venus/vkr_device.c index 9c7bd3c..c463161 100644 --- a/src/venus/vkr_device.c +++ b/src/venus/vkr_device.c @@ -282,13 +282,9 @@ vkr_device_object_destroy(struct vkr_context *ctx, vkDestroySampler(device, obj->handle.sampler, NULL); break; case VK_OBJECT_TYPE_DESCRIPTOR_POOL: { - /* Destroying VkDescriptorPool frees all VkDescriptorSet objects that were allocated - * from it. - */ + /* Destroying VkDescriptorPool frees all VkDescriptorSet allocated inside. */ vkDestroyDescriptorPool(device, obj->handle.descriptor_pool, NULL); - - struct vkr_descriptor_pool *pool = (struct vkr_descriptor_pool *)obj; - vkr_context_remove_objects(ctx, &pool->descriptor_sets); + vkr_descriptor_pool_release(ctx, (struct vkr_descriptor_pool *)obj); break; } case VK_OBJECT_TYPE_FRAMEBUFFER: