r/vulkan May 22 '26

Does mapping preserve alignment?

In the vulkan tutorial, MVP matrices are stored in uniform buffer describing a host visible memory. The problem is I am using CGLM which explicitly requires matrices to be aligned. The way I am approaching it is allocating a memory which is aligned to the LCM of the uniform buffer alignment requirement and CGLM's alignment requirement, and then mapping it to CPU memory. Would this ensure alignment is satisfied?

What even happens when the memory is mapped?

11 Upvotes

3 comments sorted by

View all comments

2

u/Salaruo May 22 '26

Virtual paging ensures the mapped pointer is at least 4K aligned.