anv: reduce struct anv_image_memory_range from 32 to 24 bytes

Reorder its members to fill the current padding hole, reducing the
struct size from 32 to 24.

This struct appears multiple times inside struct anv_image and its
members, so this change brings down sizeof(struct anv_image) from
1744 to 1600.

We went from:

struct anv_image_memory_range {
	enum anv_image_memory_binding binding;           /*     0     4 */

	/* XXX 4 bytes hole, try to pack */

	uint64_t                   offset;               /*     8     8 */
	uint64_t                   size;                 /*    16     8 */
	uint32_t                   alignment;            /*    24     4 */

	/* size: 32, cachelines: 1, members: 4 */
	/* sum members: 24, holes: 1, sum holes: 4 */
	/* padding: 4 */
	/* last cacheline: 32 bytes */
};

to:

struct anv_image_memory_range {
	enum anv_image_memory_binding binding;           /*     0     4 */
	uint32_t                   alignment;            /*     4     4 */
	uint64_t                   size;                 /*     8     8 */
	uint64_t                   offset;               /*    16     8 */

	/* size: 24, cachelines: 1, members: 4 */
	/* last cacheline: 24 bytes */
};

Considering we can have tens of thousands of anv_image structs
allocated at the same time on gaming workloads, this can save us a few
MB of memory. It ain't much but it's honest work.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28700>
This commit is contained in:
Paulo Zanoni 2024-04-10 20:56:39 -07:00 committed by Marge Bot
parent 7f608fc206
commit ad4d13f184
2 changed files with 7 additions and 7 deletions

View file

@ -170,9 +170,9 @@ image_binding_grow(const struct anv_device *device,
*out_range = (struct anv_image_memory_range) {
.binding = binding,
.offset = offset,
.size = size,
.alignment = alignment,
.size = size,
.offset = offset,
};
return VK_SUCCESS;
@ -1044,9 +1044,9 @@ memory_ranges_equal(struct anv_image_memory_range a,
struct anv_image_memory_range b)
{
return a.binding == b.binding &&
a.offset == b.offset &&
a.alignment == b.alignment &&
a.size == b.size &&
a.alignment == b.alignment;
a.offset == b.offset;
}
#endif

View file

@ -4987,14 +4987,14 @@ struct anv_image_memory_range {
ANV_IMAGE_MEMORY_BINDING_END,
} binding;
uint32_t alignment;
uint64_t size;
/**
* Offset is relative to the start of the binding created by
* vkBindImageMemory, not to the start of the bo.
*/
uint64_t offset;
uint64_t size;
uint32_t alignment;
};
/**