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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use std::error;
use std::fmt;
use descriptor::descriptor::DescriptorDescSupersetError;
use descriptor::descriptor_set::DescriptorSetsCollection;
use descriptor::pipeline_layout::PipelineLayoutDesc;
pub fn check_descriptor_sets_validity<Pl, D>(pipeline: &Pl, descriptor_sets: &D)
-> Result<(), CheckDescriptorSetsValidityError>
where Pl: ?Sized + PipelineLayoutDesc,
D: ?Sized + DescriptorSetsCollection
{
for set_num in 0 .. pipeline.num_sets() {
for binding_num in 0 .. pipeline.num_bindings_in_set(set_num).unwrap_or(0) {
let set_desc = descriptor_sets.descriptor(set_num, binding_num);
let pipeline_desc = pipeline.descriptor(set_num, binding_num);
let (set_desc, pipeline_desc) = match (set_desc, pipeline_desc) {
(Some(s), Some(p)) => (s, p),
(None, Some(_)) =>
return Err(CheckDescriptorSetsValidityError::MissingDescriptor {
set_num: set_num,
binding_num: binding_num,
}),
(Some(_), None) => continue,
(None, None) => continue,
};
if let Err(err) = set_desc.is_superset_of(&pipeline_desc) {
return Err(CheckDescriptorSetsValidityError::IncompatibleDescriptor {
error: err,
set_num: set_num,
binding_num: binding_num,
});
}
}
}
Ok(())
}
#[derive(Debug, Clone)]
pub enum CheckDescriptorSetsValidityError {
MissingDescriptor {
set_num: usize,
binding_num: usize,
},
IncompatibleDescriptor {
error: DescriptorDescSupersetError,
set_num: usize,
binding_num: usize,
},
}
impl error::Error for CheckDescriptorSetsValidityError {
#[inline]
fn description(&self) -> &str {
match *self {
CheckDescriptorSetsValidityError::MissingDescriptor { .. } => {
"a descriptor is missing in the descriptor sets that were provided"
},
CheckDescriptorSetsValidityError::IncompatibleDescriptor { .. } => {
"a descriptor in the provided sets is not compatible with what is expected"
},
}
}
#[inline]
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
CheckDescriptorSetsValidityError::IncompatibleDescriptor { ref error, .. } => {
Some(error)
},
_ => None,
}
}
}
impl fmt::Display for CheckDescriptorSetsValidityError {
#[inline]
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "{}", error::Error::description(self))
}
}