From 571b5f5000b6ebc9a769d3cbea3c8d3c8bad4bce Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 24 Sep 2021 10:58:39 -0500 Subject: [PATCH] vulkan: Track which objects are client-visible When dealing with debug logging, it's useful to track when an object's construction is finished and it's now visible to the client. We can detect this pretty easily by setting a flag the first time foo_to_handle is called. As long as drivers only ever call that function at the end of object construction (they all do to my knowledge), this should be a reliable mechanism for detecting when a client knows about a handle. Tested-by: Boris Brezillon Reviewed-By: Mike Blumenkrantz Part-of: --- src/vulkan/util/vk_object.c | 1 + src/vulkan/util/vk_object.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/vulkan/util/vk_object.c b/src/vulkan/util/vk_object.c index 9aaee976adc..52dbeaedda6 100644 --- a/src/vulkan/util/vk_object.c +++ b/src/vulkan/util/vk_object.c @@ -38,6 +38,7 @@ vk_object_base_init(struct vk_device *device, base->_loader_data.loaderMagic = ICD_LOADER_MAGIC; base->type = obj_type; base->device = device; + base->client_visible = false; base->object_name = NULL; util_sparse_array_init(&base->private_data, sizeof(uint64_t), 8); } diff --git a/src/vulkan/util/vk_object.h b/src/vulkan/util/vk_object.h index 35404aa85f4..5b968d90f58 100644 --- a/src/vulkan/util/vk_object.h +++ b/src/vulkan/util/vk_object.h @@ -44,6 +44,9 @@ struct vk_object_base { struct vk_device *device; + /* True if this object is fully constructed and visible to the client */ + bool client_visible; + /* For VK_EXT_private_data */ struct util_sparse_array private_data; @@ -85,6 +88,8 @@ vk_object_base_from_u64_handle(uint64_t handle, VkObjectType obj_type) __driver_type ## _to_handle(struct __driver_type *_obj) \ { \ vk_object_base_assert_valid(&_obj->__base, __VK_TYPE); \ + if (_obj != NULL) \ + _obj->__base.client_visible = true; \ return (__VkType) _obj; \ } @@ -103,6 +108,8 @@ vk_object_base_from_u64_handle(uint64_t handle, VkObjectType obj_type) __driver_type ## _to_handle(struct __driver_type *_obj) \ { \ vk_object_base_assert_valid(&_obj->__base, __VK_TYPE); \ + if (_obj != NULL) \ + _obj->__base.client_visible = true; \ return (__VkType)(uintptr_t) _obj; \ }