Update docs for Align
This commit is contained in:
parent
139dc2aa3b
commit
65e1a7689d
1 changed files with 7 additions and 8 deletions
|
@ -3,14 +3,13 @@ use std::marker::PhantomData;
|
|||
use std::mem::size_of;
|
||||
use vk;
|
||||
|
||||
/// `Align` handles dynamic alignment. x86 aligns on 4 byte boundries but GPUs
|
||||
/// sometimes have different requirements. For example if the user wants to create
|
||||
/// a Uniform buffer of a Vec3<f32>, `get_buffer_memory_requirements` might return
|
||||
/// an alignment of 16 bytes. A Vec3<f32> has a size of 12 bytes. The memory layout
|
||||
/// for a `Vec<Vec3<f32>>` will be contigous, because 4 is a multiple of 12. But Vulkan
|
||||
/// expects a 4 byte padding in between each Vec3<f32>, if the alignment is 16 bytes.
|
||||
/// `Vec3<f32>, 4bytes, Vec3<f32>, 4bytes, Vec3<f32>...`. Align is able to take a slice
|
||||
/// that is allocated on 4 bytes boundries, and insert the correct amount of paddings.
|
||||
/// `Align` handles dynamic alignment. The is useful for dynamic uniform buffers where
|
||||
/// the alignment might be different. For example a 4x4 f32 matrix has a size of 64 bytes
|
||||
/// but the min alignment for a dynamic uniform buffer might be 256 bytes. A slice of `&[Mat4x4<f32>]`
|
||||
/// has a memory layout of `[[64 bytes], [64 bytes], [64 bytes]]`, but it might need to have a memory
|
||||
/// layout of `[[256 bytes], [256 bytes], [256 bytes]].
|
||||
/// `Align::copy_from_slice` will copy a slice of `&[T]` directly into the host memory without
|
||||
/// an additional allocation and with the correct alignment.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Align<T> {
|
||||
ptr: *mut vk::c_void,
|
||||
|
|
Loading…
Add table
Reference in a new issue