librashader_reflect/
error.rs1use crate::reflect::semantics::UniformMemberBlock;
2use thiserror::Error;
3
4#[non_exhaustive]
6#[derive(Error, Debug)]
7pub enum ShaderCompileError {
8 #[cfg(feature = "naga-in")]
10 #[error("error when parsing wgsl: {0}")]
11 NagaCompileError(#[from] naga::front::wgsl::ParseError),
12
13 #[cfg(feature = "glslang-in")]
15 #[error("error when compiling with glslang: {0}")]
16 GlslangError(#[from] glslang::error::GlslangError),
17
18 #[cfg(feature = "glslang-in")]
20 #[error("error when initializing glslang")]
21 CompilerInitError,
22
23 #[cfg(feature = "cross")]
25 #[error("spirv-cross error: {0:?}")]
26 SpirvCrossCompileError(#[from] spirv_cross2::SpirvCrossError),
27
28 #[cfg(all(target_os = "windows", feature = "dxil"))]
30 #[error("spirv-to-dxil error: {0:?}")]
31 SpirvToDxilCompileError(#[from] spirv_to_dxil::SpirvToDxilError),
32
33 #[cfg(all(feature = "wgsl", feature = "naga"))]
35 #[error("naga error when compiling wgsl: {0:?}")]
36 NagaWgslError(#[from] naga::back::wgsl::Error),
37
38 #[cfg(feature = "naga")]
40 #[error("naga error when compiling spirv: {0:?}")]
41 NagaSpvError(#[from] naga::back::spv::Error),
42
43 #[cfg(all(feature = "naga", feature = "msl"))]
45 #[error("naga error when compiling msl: {0:?}")]
46 NagaMslError(#[from] naga::back::msl::Error),
47
48 #[cfg(any(feature = "naga", feature = "wgsl"))]
50 #[error("naga validation error: {0}")]
51 NagaValidationError(#[from] naga::WithSpan<naga::valid::ValidationError>),
52}
53
54#[derive(Debug)]
56pub enum SemanticsErrorKind {
57 InvalidUniformBufferCount(usize),
59 InvalidPushBufferCount(usize),
61 InvalidPushBufferSize(u32),
63 InvalidLocation(u32),
65 InvalidDescriptorSet(u32),
67 InvalidInputCount(usize),
69 InvalidOutputCount(usize),
71 MissingBinding,
73 InvalidBinding(u32),
75 InvalidResourceType,
77 InvalidRange(u32),
79 InvalidEntryPointCount(usize),
81 UnknownSemantics(String),
83 InvalidTypeForSemantic(String),
85}
86
87#[non_exhaustive]
89#[derive(Error, Debug)]
90pub enum ShaderReflectError {
91 #[cfg(feature = "cross")]
93 #[error("spirv cross error: {0}")]
94 SpirvCrossError(#[from] spirv_cross2::SpirvCrossError),
95 #[error("error when verifying vertex semantics: {0:?}")]
97 VertexSemanticError(SemanticsErrorKind),
98 #[error("error when verifying texture semantics {0:?}")]
100 FragmentSemanticError(SemanticsErrorKind),
101 #[error("vertex and fragment shader must have same UBO binding. declared {vertex} in vertex, got {fragment} in fragment")]
103 MismatchedUniformBuffer { vertex: u32, fragment: u32 },
104 #[error("filter chain is non causal: tried to access target {target} in pass {pass}")]
107 NonCausalFilterChain { pass: usize, target: usize },
108 #[error("the offset of {semantic} was declared as {expected} but found as {received} in pass {pass}")]
110 MismatchedOffset {
111 semantic: String,
112 expected: usize,
113 received: usize,
114 ty: UniformMemberBlock,
115 pass: usize,
116 },
117 #[error("the size of {semantic} was found declared as {vertex} in vertex shader but found as {fragment} in fragment in pass {pass}")]
119 MismatchedSize {
120 semantic: String,
121 vertex: u32,
122 fragment: u32,
123 pass: usize,
124 },
125 #[error("binding {0} is already in use")]
127 BindingInUse(u32),
128 #[cfg(feature = "naga")]
130 #[error("naga spirv error: {0}")]
131 NagaInputError(#[from] naga::front::spv::Error),
132 #[cfg(feature = "naga")]
134 #[error("naga validation error: {0}")]
135 NagaReflectError(#[from] naga::WithSpan<naga::valid::ValidationError>),
136}