1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
mod dedicated;
mod dynamic;
mod linear;
use crate::block::Block;
pub use self::{
dedicated::{DedicatedAllocator, DedicatedBlock},
dynamic::{DynamicAllocator, DynamicBlock, DynamicConfig},
linear::{LinearAllocator, LinearBlock, LinearConfig},
};
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Kind {
Dedicated,
Dynamic,
Linear,
}
pub trait Allocator<B: gfx_hal::Backend> {
type Block: Block<B>;
fn kind() -> Kind;
fn alloc(
&mut self,
device: &B::Device,
size: u64,
align: u64,
) -> Result<(Self::Block, u64), gfx_hal::device::AllocationError>;
fn free(&mut self, device: &B::Device, block: Self::Block) -> u64;
}