mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-21 14:24:18 +00:00
Fix alignment checks when allocating buffers (#2476)
This commit is contained in:
parent
89e75cae2d
commit
817436b13c
@ -252,13 +252,7 @@ where
|
||||
}
|
||||
|
||||
/// Allocates a subbuffer with the given `layout`.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// - Panics if `layout.alignment()` exceeds `64`.
|
||||
pub fn allocate(&self, layout: DeviceLayout) -> Result<Subbuffer<[u8]>, MemoryAllocatorError> {
|
||||
assert!(layout.alignment().as_devicesize() <= 64);
|
||||
|
||||
unsafe { &mut *self.state.get() }.allocate(layout)
|
||||
}
|
||||
}
|
||||
|
@ -376,14 +376,12 @@ impl Buffer {
|
||||
/// # Panics
|
||||
///
|
||||
/// - Panics if `create_info.size` is not zero.
|
||||
/// - Panics if `layout.alignment()` is greater than 64.
|
||||
pub fn new(
|
||||
allocator: Arc<dyn MemoryAllocator>,
|
||||
mut create_info: BufferCreateInfo,
|
||||
allocation_info: AllocationCreateInfo,
|
||||
layout: DeviceLayout,
|
||||
) -> Result<Arc<Self>, Validated<AllocateBufferError>> {
|
||||
assert!(layout.alignment().as_devicesize() <= 64);
|
||||
// TODO: Enable once sparse binding materializes
|
||||
// assert!(!allocate_info.flags.contains(BufferCreateFlags::SPARSE_BINDING));
|
||||
|
||||
|
@ -300,6 +300,8 @@ where
|
||||
/// [`SubbufferAllocator`]: super::allocator::SubbufferAllocator
|
||||
/// [`RawBuffer::assume_bound`]: crate::buffer::sys::RawBuffer::assume_bound
|
||||
pub fn read(&self) -> Result<BufferReadGuard<'_, T>, HostAccessError> {
|
||||
assert!(T::LAYOUT.alignment().as_devicesize() <= 64);
|
||||
|
||||
let allocation = match self.buffer().memory() {
|
||||
BufferMemory::Normal(a) => a,
|
||||
BufferMemory::Sparse => todo!("`Subbuffer::read` doesn't support sparse binding yet"),
|
||||
@ -391,6 +393,8 @@ where
|
||||
/// [`SubbufferAllocator`]: super::allocator::SubbufferAllocator
|
||||
/// [`RawBuffer::assume_bound`]: crate::buffer::sys::RawBuffer::assume_bound
|
||||
pub fn write(&self) -> Result<BufferWriteGuard<'_, T>, HostAccessError> {
|
||||
assert!(T::LAYOUT.alignment().as_devicesize() <= 64);
|
||||
|
||||
let allocation = match self.buffer().memory() {
|
||||
BufferMemory::Normal(a) => a,
|
||||
BufferMemory::Sparse => todo!("`Subbuffer::write` doesn't support sparse binding yet"),
|
||||
|
Loading…
Reference in New Issue
Block a user