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
use crate::command::Level;
use crate::Backend;
use smallvec::SmallVec;
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 {
self.allocate_vec(1, level).pop().unwrap()
}
unsafe fn allocate_vec(&mut self, num: usize, level: Level) -> SmallVec<[B::CommandBuffer; 1]> {
(0 .. num).map(|_| self.allocate_one(level)).collect()
}
unsafe fn free<I>(&mut self, buffers: I)
where
I: IntoIterator<Item = B::CommandBuffer>;
}