From edf07649f46bae56c2b6b58693a384875a29c6ca Mon Sep 17 00:00:00 2001 From: Paulo Zanoni Date: Wed, 10 Apr 2024 21:39:49 -0700 Subject: [PATCH] vulkan: reduce struct vk_object_base by 8 bytes I know that, in the grand scheme of things, this isn't significant. The problem is: now that I know the hole is there, my OCD won't allow me to sleep until it's fixed. We went from: struct vk_object_base { VK_LOADER_DATA _loader_data; /* 0 8 */ VkObjectType type; /* 8 4 */ /* XXX 4 bytes hole, try to pack */ struct vk_device * device; /* 16 8 */ struct vk_instance * instance; /* 24 8 */ _Bool client_visible; /* 32 1 */ /* XXX 7 bytes hole, try to pack */ struct util_sparse_array private_data; /* 40 24 */ /* --- cacheline 1 boundary (64 bytes) --- */ char * object_name; /* 64 8 */ /* size: 72, cachelines: 2, members: 7 */ /* sum members: 61, holes: 2, sum holes: 11 */ /* last cacheline: 8 bytes */ }; to: struct vk_object_base { VK_LOADER_DATA _loader_data; /* 0 8 */ VkObjectType type; /* 8 4 */ _Bool client_visible; /* 12 1 */ /* XXX 3 bytes hole, try to pack */ struct vk_device * device; /* 16 8 */ struct vk_instance * instance; /* 24 8 */ struct util_sparse_array private_data; /* 32 24 */ char * object_name; /* 56 8 */ /* size: 64, cachelines: 1, members: 7 */ /* sum members: 61, holes: 1, sum holes: 3 */ }; which is cool because now the struct nicely fits in a cacheline. Reviewed-by: Georg Lehmann Reviewed-by: Yiwei Zhang Reviewed-by: Lionel Landwerlin Signed-off-by: Paulo Zanoni Part-of: --- src/vulkan/runtime/vk_object.c | 4 ++-- src/vulkan/runtime/vk_object.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vulkan/runtime/vk_object.c b/src/vulkan/runtime/vk_object.c index 8a4aaae2664..7015342924e 100644 --- a/src/vulkan/runtime/vk_object.c +++ b/src/vulkan/runtime/vk_object.c @@ -38,9 +38,9 @@ vk_object_base_init(struct vk_device *device, { base->_loader_data.loaderMagic = ICD_LOADER_MAGIC; base->type = obj_type; + base->client_visible = false; base->device = device; base->instance = NULL; - base->client_visible = false; base->object_name = NULL; util_sparse_array_init(&base->private_data, sizeof(uint64_t), 8); } @@ -51,9 +51,9 @@ void vk_object_base_instance_init(struct vk_instance *instance, { base->_loader_data.loaderMagic = ICD_LOADER_MAGIC; base->type = obj_type; + base->client_visible = false; base->device = NULL; base->instance = instance; - base->client_visible = false; base->object_name = NULL; util_sparse_array_init(&base->private_data, sizeof(uint64_t), 8); } diff --git a/src/vulkan/runtime/vk_object.h b/src/vulkan/runtime/vk_object.h index c95d6d90032..c94c7050215 100644 --- a/src/vulkan/runtime/vk_object.h +++ b/src/vulkan/runtime/vk_object.h @@ -50,6 +50,9 @@ struct vk_object_base { */ VkObjectType type; + /* True if this object is fully constructed and visible to the client */ + bool client_visible; + /** Pointer to the device in which this object exists, if any * * This is NULL for instances and physical devices but should point to a @@ -66,9 +69,6 @@ struct vk_object_base { */ struct vk_instance *instance; - /* 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;