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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use std::{
convert::TryInto,
fmt::{Debug, Error, Formatter},
ops::Deref
};
use ash::version::EntryV1_0;
use crate::util::fmt::VkVersion;
pub mod enumerate;
#[cfg(test)]
pub mod test;
#[derive(Clone)]
pub struct Entry {
entry: ash::Entry
}
impl Entry {
pub fn new() -> Result<Self, ash::LoadingError> {
Ok(Entry {
entry: ash::Entry::new()?
})
}
pub fn instance_layers(
&self
) -> Result<
impl ExactSizeIterator<Item = enumerate::InstanceLayerProperties>,
enumerate::EnumerateError
> {
Ok(self
.entry
.enumerate_instance_layer_properties()?
.into_iter()
.map(|v| v.try_into().unwrap()))
}
pub fn instance_extensions(
&self
) -> Result<
impl ExactSizeIterator<Item = enumerate::InstanceExtensionProperties>,
enumerate::EnumerateError
> {
Ok(self
.entry
.enumerate_instance_extension_properties()?
.into_iter()
.map(|v| v.try_into().unwrap()))
}
pub fn instance_version(&self) -> VkVersion {
match self.entry.try_enumerate_instance_version() {
Ok(Some(v)) => VkVersion(v),
Ok(None) => VkVersion::new(1, 0, 0),
Err(err) => unreachable!("{}", err)
}
}
}
impl Deref for Entry {
type Target = ash::Entry;
fn deref(&self) -> &Self::Target {
&self.entry
}
}
impl Debug for Entry {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
f.debug_struct("Entry")
.field("entry", &"<ash::Entry>")
.finish()
}
}