Skip to content

vulkan: reduce struct vk_object_base by 8 bytes

Paulo Zanoni requested to merge pzanoni/mesa:vk_object_base-repack into main
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.

Merge request reports