Add asset to check for aligned size
This commit is contained in:
parent
1d4e2946c9
commit
cdc2fa94d9
1 changed files with 3 additions and 2 deletions
|
@ -78,8 +78,9 @@ fn calc_padding(adr: vk::DeviceSize, align: vk::DeviceSize) -> vk::DeviceSize {
|
||||||
|
|
||||||
impl<T> Align<T> {
|
impl<T> Align<T> {
|
||||||
pub unsafe fn new(ptr: *mut (), alignment: vk::DeviceSize, size: vk::DeviceSize) -> Self {
|
pub unsafe fn new(ptr: *mut (), alignment: vk::DeviceSize, size: vk::DeviceSize) -> Self {
|
||||||
let offset = size_of::<T>() as vk::DeviceSize +
|
let padding = calc_padding(size_of::<T>() as vk::DeviceSize, alignment);
|
||||||
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 {
|
Align {
|
||||||
ptr,
|
ptr,
|
||||||
offset,
|
offset,
|
||||||
|
|
Loading…
Add table
Reference in a new issue