diff --git a/ash/src/util.rs b/ash/src/util.rs index ed81f3c..4dca72c 100644 --- a/ash/src/util.rs +++ b/ash/src/util.rs @@ -78,8 +78,9 @@ fn calc_padding(adr: vk::DeviceSize, align: vk::DeviceSize) -> vk::DeviceSize { impl Align { pub unsafe fn new(ptr: *mut (), alignment: vk::DeviceSize, size: vk::DeviceSize) -> Self { - let offset = size_of::() as vk::DeviceSize + - calc_padding(size_of::() as vk::DeviceSize, alignment); + let padding = calc_padding(size_of::() as vk::DeviceSize, alignment); + let offset = size_of::() as vk::DeviceSize + padding; + assert!(calc_padding(size, alignment) == 0, "size must be aligned"); Align { ptr, offset,