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
use crate::command::Level;
use crate::{Backend, PseudoVec};
use std::any::Any;
use std::fmt;
bitflags!(
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CommandPoolCreateFlags: u8 {
const TRANSIENT = 0x1;
const RESET_INDIVIDUAL = 0x2;
}
);
pub trait CommandPool<B: Backend>: fmt::Debug + Any + Send + Sync {
unsafe fn reset(&mut self, release_resources: bool);
unsafe fn allocate_one(&mut self, level: Level) -> B::CommandBuffer {
let mut result = PseudoVec(None);
self.allocate(1, level, &mut result);
result.0.unwrap()
}
unsafe fn allocate<E>(&mut self, num: usize, level: Level, list: &mut E)
where
E: Extend<B::CommandBuffer>,
{
list.extend((0 .. num).map(|_| self.allocate_one(level)));
}
unsafe fn free<I>(&mut self, buffers: I)
where
I: IntoIterator<Item = B::CommandBuffer>;
}