vulkan: Add a concept of recycling an object

This is not necessarily a full re-initialization of the object but is
whatever is necessary/expedient for the client to see it as a new object
and not the one it has seen before.  For vk_base_object, this removes
any private data and resets the object name to NULL.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18324>
This commit is contained in:
Jason Ekstrand
2022-08-30 11:06:39 -05:00
committed by Marge Bot
parent 63b1290c2f
commit ea9e7ecdc1
2 changed files with 20 additions and 0 deletions

View File

@@ -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,

View File

@@ -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)