Add asset to check for aligned size

This commit is contained in:
Maik Klein 2017-06-11 20:38:03 +02:00
parent 1d4e2946c9
commit cdc2fa94d9

View file

@ -78,8 +78,9 @@ fn calc_padding(adr: vk::DeviceSize, align: vk::DeviceSize) -> vk::DeviceSize {
impl<T> Align<T> {
pub unsafe fn new(ptr: *mut (), alignment: vk::DeviceSize, size: vk::DeviceSize) -> Self {
let offset = size_of::<T>() as vk::DeviceSize +
calc_padding(size_of::<T>() as vk::DeviceSize, alignment);
let padding = calc_padding(size_of::<T>() as vk::DeviceSize, alignment);
let offset = size_of::<T>() as vk::DeviceSize + padding;
assert!(calc_padding(size, alignment) == 0, "size must be aligned");
Align {
ptr,
offset,