diff --git a/README.md b/README.md index 79e2403b..b15382d0 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ let allocation = allocator location: MemoryLocation::CpuToGpu, linear: true, // Buffers are always linear allocation_scheme: AllocationScheme::GpuAllocatorManaged, + allow_capacity_increase: true, }).unwrap(); // Bind memory to the buffer diff --git a/examples/vulkan-buffer.rs b/examples/vulkan-buffer.rs index dcf0b9ca..bd83ee3b 100644 --- a/examples/vulkan-buffer.rs +++ b/examples/vulkan-buffer.rs @@ -110,6 +110,7 @@ fn main() { linear: true, allocation_scheme: AllocationScheme::GpuAllocatorManaged, name: "Test allocation (Gpu Only)", + allow_capacity_increase: true, }) .unwrap(); @@ -143,6 +144,7 @@ fn main() { linear: true, allocation_scheme: AllocationScheme::GpuAllocatorManaged, name: "Test allocation (Cpu to Gpu)", + allow_capacity_increase: true, }) .unwrap(); @@ -176,6 +178,7 @@ fn main() { linear: true, allocation_scheme: AllocationScheme::GpuAllocatorManaged, name: "Test allocation (Gpu to Cpu)", + allow_capacity_increase: true, }) .unwrap(); diff --git a/src/lib.rs b/src/lib.rs index b148ace0..86170d95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,6 +66,7 @@ //! location: MemoryLocation::CpuToGpu, //! linear: true, // Buffers are always linear //! allocation_scheme: AllocationScheme::GpuAllocatorManaged, +//! allow_capacity_increase: true, //! }).unwrap(); //! //! // Bind memory to the buffer diff --git a/src/vulkan/mod.rs b/src/vulkan/mod.rs index 549222b2..d406fecb 100644 --- a/src/vulkan/mod.rs +++ b/src/vulkan/mod.rs @@ -37,6 +37,8 @@ pub struct AllocationCreateDesc<'a> { pub linear: bool, /// Determines how this allocation should be managed. pub allocation_scheme: AllocationScheme, + /// Allow the allocator to request additional memory from the device to fulfill this request. + pub allow_capacity_increase: bool, } /// Wrapper type to only mark a raw pointer [`Send`] + [`Sync`] without having to @@ -579,6 +581,10 @@ impl MemoryType { } } + if !desc.allow_capacity_increase { + return Err(AllocationError::OutOfMemory); + } + let new_memory_block = MemoryBlock::new( device, memblock_size,