diff --git a/src/vulkan/runtime/vk_object.c b/src/vulkan/runtime/vk_object.c index 4fe0db7c89e..fb53ce6cb00 100644 --- a/src/vulkan/runtime/vk_object.c +++ b/src/vulkan/runtime/vk_object.c @@ -52,6 +52,15 @@ vk_object_base_finish(struct vk_object_base *base) vk_free(&base->device->alloc, base->object_name); } +void +vk_object_base_recycle(struct vk_object_base *base) +{ + struct vk_device *device = base->device; + VkObjectType obj_type = base->type; + vk_object_base_finish(base); + vk_object_base_init(device, base, obj_type); +} + void * vk_object_alloc(struct vk_device *device, const VkAllocationCallbacks *alloc, diff --git a/src/vulkan/runtime/vk_object.h b/src/vulkan/runtime/vk_object.h index f60c2005f4e..79157f241bb 100644 --- a/src/vulkan/runtime/vk_object.h +++ b/src/vulkan/runtime/vk_object.h @@ -83,6 +83,17 @@ void vk_object_base_init(struct vk_device *device, */ void vk_object_base_finish(struct vk_object_base *base); +/** Recycles a vk_object_base + * + * This should be called when an object is recycled and handed back to the + * client as if it were a new object. When it's called is not important as + * long as it's called between when the client thinks the object was destroyed + * and when the client sees it again as a supposedly new object. + * + * @param[inout] base The vk_object_base being recycled + */ +void vk_object_base_recycle(struct vk_object_base *base); + static inline void vk_object_base_assert_valid(ASSERTED struct vk_object_base *base, ASSERTED VkObjectType obj_type)