librashader_reflect/
error.rsuse crate::reflect::semantics::UniformMemberBlock;
use thiserror::Error;
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ShaderCompileError {
#[cfg(feature = "unstable-naga-in")]
#[error("shader")]
NagaCompileError(Vec<naga::front::glsl::Error>),
#[error("error when compiling with glslang: {0}")]
GlslangError(#[from] glslang::error::GlslangError),
#[error("error when initializing glslang")]
CompilerInitError,
#[error("spirv-cross error: {0:?}")]
SpirvCrossCompileError(#[from] spirv_cross2::SpirvCrossError),
#[cfg(all(target_os = "windows", feature = "dxil"))]
#[error("spirv-to-dxil error: {0:?}")]
SpirvToDxilCompileError(#[from] spirv_to_dxil::SpirvToDxilError),
#[cfg(all(feature = "wgsl", feature = "naga"))]
#[error("naga error when compiling wgsl: {0:?}")]
NagaWgslError(#[from] naga::back::wgsl::Error),
#[cfg(feature = "naga")]
#[error("naga error when compiling spirv: {0:?}")]
NagaSpvError(#[from] naga::back::spv::Error),
#[cfg(all(feature = "naga", feature = "msl"))]
#[error("naga error when compiling msl: {0:?}")]
NagaMslError(#[from] naga::back::msl::Error),
#[cfg(any(feature = "naga", feature = "wgsl"))]
#[error("naga validation error: {0}")]
NagaValidationError(#[from] naga::WithSpan<naga::valid::ValidationError>),
}
#[derive(Debug)]
pub enum SemanticsErrorKind {
InvalidUniformBufferCount(usize),
InvalidPushBufferCount(usize),
InvalidPushBufferSize(u32),
InvalidLocation(u32),
InvalidDescriptorSet(u32),
InvalidInputCount(usize),
InvalidOutputCount(usize),
MissingBinding,
InvalidBinding(u32),
InvalidResourceType,
InvalidRange(u32),
InvalidEntryPointCount(usize),
UnknownSemantics(String),
InvalidTypeForSemantic(String),
}
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum ShaderReflectError {
#[error("spirv cross error: {0}")]
SpirvCrossError(#[from] spirv_cross2::SpirvCrossError),
#[error("error when verifying vertex semantics: {0:?}")]
VertexSemanticError(SemanticsErrorKind),
#[error("error when verifying texture semantics {0:?}")]
FragmentSemanticError(SemanticsErrorKind),
#[error("vertex and fragment shader must have same UBO binding. declared {vertex} in vertex, got {fragment} in fragment")]
MismatchedUniformBuffer { vertex: u32, fragment: u32 },
#[error("filter chain is non causal: tried to access target {target} in pass {pass}")]
NonCausalFilterChain { pass: usize, target: usize },
#[error("the offset of {semantic} was declared as {expected} but found as {received} in pass {pass}")]
MismatchedOffset {
semantic: String,
expected: usize,
received: usize,
ty: UniformMemberBlock,
pass: usize,
},
#[error("the size of {semantic} was found declared as {vertex} in vertex shader but found as {fragment} in fragment in pass {pass}")]
MismatchedSize {
semantic: String,
vertex: u32,
fragment: u32,
pass: usize,
},
#[error("binding {0} is already in use")]
BindingInUse(u32),
#[cfg(feature = "naga")]
#[error("naga spirv error: {0}")]
NagaInputError(#[from] naga::front::spv::Error),
#[cfg(feature = "naga")]
#[error("naga validation error: {0}")]
NagaReflectError(#[from] naga::WithSpan<naga::valid::ValidationError>),
}
#[cfg(feature = "unstable-naga-in")]
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
ShaderCompileError::NagaCompileError(err)
}
}