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 std::fmt;
use std::error;
#[derive(Debug)]
pub enum Error {
CorruptedSpirv(&'static str),
UnsupportedSpirv(&'static str),
MismatchedManifest,
}
impl Error {
pub const INSTR_TOO_SHORT: Self = Self::CorruptedSpirv("instruction is too short");
pub const STR_NOT_TERMINATED: Self = Self::CorruptedSpirv("instruction has a string operand that is not terminated by nul");
pub const UNENCODED_ENUM: Self = Self::CorruptedSpirv("instruction has a unencoded enumeration value");
pub const ID_COLLISION: Self = Self::CorruptedSpirv("id can only be assigned once");
pub const NAME_COLLISION: Self = Self::CorruptedSpirv("item can only be named once");
pub const DECO_COLLISION: Self = Self::CorruptedSpirv("item can only be decorated of a kind once");
pub const MISSING_DECO: Self = Self::CorruptedSpirv("missing decoration");
pub const TY_NOT_FOUND: Self = Self::CorruptedSpirv("cannot find a suitable type");
pub const CONST_NOT_FOUND: Self = Self::CorruptedSpirv("cannot find a suitable constant");
pub const UNDECLARED_VAR: Self = Self::CorruptedSpirv("accessing undeclared variable");
pub const DESC_BIND_COLLISION: Self = Self::CorruptedSpirv("descriptor binding cannot be shared");
pub const UNKNOWN_NBIND: Self = Self::CorruptedSpirv("binding count cannot be determined");
pub const MULTI_PUSH_CONST: Self = Self::CorruptedSpirv("an entry point cannot have multiple push constant blocks");
pub const SPEC_ID_COLLISION: Self = Self::CorruptedSpirv("specialization id can only be assigned once");
pub const FUNC_NOT_FOUND: Self = Self::CorruptedSpirv("cannot find a function");
pub const BROKEN_ACCESS_CHAIN: Self = Self::CorruptedSpirv("pointer in access chain points to non-existing type");
pub const ACCESS_CONFLICT: Self = Self::CorruptedSpirv("variable is both read-only and write-only");
pub const UNSUPPORTED_TY: Self = Self::UnsupportedSpirv("unsupported type");
pub const UNSUPPORTED_IMG_CFG: Self = Self::UnsupportedSpirv("unsupport image configuration");
pub const UNSUPPORTED_SPEC: Self = Self::UnsupportedSpirv("unsupported specialization");
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Error::*;
match self {
CorruptedSpirv(msg) => write!(f, "spirv binary is corrupted: {}", msg),
UnsupportedSpirv(msg) => write!(f, "spirv binary used unsupported feature: {}", msg),
MismatchedManifest => write!(f, "mismatched manifest cannot be merged"),
}
}
}
impl error::Error for Error { }
pub type Result<T> = std::result::Result<T, Error>;