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
110
use crate::reflect::semantics::UniformMemberBlock;
use thiserror::Error;
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ShaderCompileError {
#[cfg(feature = "unstable-naga")]
#[error("shader")]
NagaCompileError(Vec<naga::front::glsl::Error>),
#[error("shaderc")]
ShaderCCompileError(#[from] shaderc::Error),
#[error("shaderc init")]
ShaderCInitError,
#[error("cross")]
SpirvCrossCompileError(#[from] spirv_cross::ErrorCode),
#[cfg(feature = "dxil")]
#[error("spirv-to-dxil")]
SpirvToDxilCompileError(#[from] spirv_to_dxil::SpirvToDxilError),
}
#[derive(Debug)]
pub enum SemanticsErrorKind {
InvalidUniformBufferCount(usize),
InvalidPushBufferSize(u32),
InvalidLocation(u32),
InvalidDescriptorSet(u32),
InvalidInputCount(usize),
InvalidOutputCount(usize),
InvalidBinding(u32),
InvalidResourceType,
InvalidRange(u32),
UnknownSemantics(String),
InvalidTypeForSemantic(String),
}
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ShaderReflectError {
#[cfg(feature = "unstable-naga")]
#[error("shader")]
NagaCompileError(#[from] naga::front::spv::Error),
#[error("spirv")]
SpirvCrossError(#[from] spirv_cross::ErrorCode),
#[error("error when verifying vertex semantics")]
VertexSemanticError(SemanticsErrorKind),
#[error("error when verifying texture semantics")]
FragmentSemanticError(SemanticsErrorKind),
#[error("vertex and fragment shader must have same binding")]
MismatchedUniformBuffer { vertex: u32, fragment: u32 },
#[error("filter chain is non causal")]
NonCausalFilterChain { pass: usize, target: usize },
#[error("mismatched offset")]
MismatchedOffset {
semantic: String,
expected: usize,
received: usize,
ty: UniformMemberBlock,
pass: usize,
},
#[error("mismatched component")]
MismatchedSize {
semantic: String,
vertex: u32,
fragment: u32,
pass: usize,
},
#[error("the binding is already in use")]
BindingInUse(u32),
}
#[cfg(feature = "unstable-naga")]
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
ShaderCompileError::NagaCompileError(err)
}
}