Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions examples/vulkan-buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ fn main() {
linear: true,
allocation_scheme: AllocationScheme::GpuAllocatorManaged,
name: "Test allocation (Gpu Only)",
allow_capacity_increase: true,
})
.unwrap();

Expand Down Expand Up @@ -143,6 +144,7 @@ fn main() {
linear: true,
allocation_scheme: AllocationScheme::GpuAllocatorManaged,
name: "Test allocation (Cpu to Gpu)",
allow_capacity_increase: true,
})
.unwrap();

Expand Down Expand Up @@ -176,6 +178,7 @@ fn main() {
linear: true,
allocation_scheme: AllocationScheme::GpuAllocatorManaged,
name: "Test allocation (Gpu to Cpu)",
allow_capacity_increase: true,
})
.unwrap();

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -579,6 +581,10 @@ impl MemoryType {
}
}

if !desc.allow_capacity_increase {
return Err(AllocationError::OutOfMemory);
}

Comment on lines +584 to +587
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would need to be implemented on all backends for feature parity before merging.

let new_memory_block = MemoryBlock::new(
device,
memblock_size,
Expand Down