2022-10-26 16:19:04 +11:00
|
|
|
use crate::reflect::semantics::MemberOffset;
|
2022-10-27 17:22:44 +11:00
|
|
|
use thiserror::Error;
|
2022-10-23 17:36:41 +11:00
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum ShaderCompileError {
|
|
|
|
#[error("shader")]
|
|
|
|
NagaCompileError(Vec<naga::front::glsl::Error>),
|
|
|
|
|
|
|
|
#[error("shaderc")]
|
|
|
|
ShaderCCompileError(#[from] shaderc::Error),
|
|
|
|
|
|
|
|
#[error("shaderc init")]
|
|
|
|
ShaderCInitError,
|
2022-11-07 16:25:11 +11:00
|
|
|
|
|
|
|
#[error("cross")]
|
|
|
|
SpirvCrossCompileError(#[from] spirv_cross::ErrorCode),
|
2022-10-23 17:36:41 +11:00
|
|
|
}
|
|
|
|
|
2022-10-24 14:22:26 +11:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum SemanticsErrorKind {
|
2022-10-26 13:13:39 +11:00
|
|
|
InvalidUniformBufferCount(usize),
|
|
|
|
InvalidPushBufferSize(u32),
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidLocation(u32),
|
|
|
|
InvalidDescriptorSet(u32),
|
|
|
|
InvalidInputCount(usize),
|
|
|
|
InvalidOutputCount(usize),
|
|
|
|
InvalidBinding(u32),
|
|
|
|
InvalidResourceType,
|
2022-10-26 13:13:39 +11:00
|
|
|
InvalidRange(u32),
|
2022-10-26 16:19:04 +11:00
|
|
|
UnknownSemantics(String),
|
2022-10-27 17:22:44 +11:00
|
|
|
InvalidTypeForSemantic(String),
|
2022-10-24 14:22:26 +11:00
|
|
|
}
|
|
|
|
|
2022-10-23 17:36:41 +11:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum ShaderReflectError {
|
|
|
|
#[error("shader")]
|
|
|
|
NagaCompileError(#[from] naga::front::spv::Error),
|
|
|
|
#[error("spirv")]
|
|
|
|
SpirvCrossError(#[from] spirv_cross::ErrorCode),
|
2022-10-26 13:13:39 +11:00
|
|
|
#[error("rspirv")]
|
|
|
|
RspirvParseError(#[from] rspirv::binary::ParseState),
|
2022-10-24 14:22:26 +11:00
|
|
|
#[error("error when verifying vertex semantics")]
|
|
|
|
VertexSemanticError(SemanticsErrorKind),
|
|
|
|
#[error("error when verifying texture semantics")]
|
|
|
|
FragmentSemanticError(SemanticsErrorKind),
|
|
|
|
#[error("vertx and fragment shader must have same binding")]
|
2022-10-26 13:13:39 +11:00
|
|
|
MismatchedUniformBuffer { vertex: u32, fragment: u32 },
|
|
|
|
#[error("filter chain is non causal")]
|
2022-10-26 16:19:04 +11:00
|
|
|
NonCausalFilterChain { pass: u32, target: u32 },
|
|
|
|
#[error("mismatched offset")]
|
2022-10-27 17:22:44 +11:00
|
|
|
MismatchedOffset {
|
|
|
|
semantic: String,
|
|
|
|
vertex: MemberOffset,
|
|
|
|
fragment: MemberOffset,
|
|
|
|
},
|
2022-10-26 16:19:04 +11:00
|
|
|
#[error("mismatched component")]
|
2022-10-27 17:22:44 +11:00
|
|
|
MismatchedComponent {
|
|
|
|
semantic: String,
|
|
|
|
vertex: u32,
|
|
|
|
fragment: u32,
|
|
|
|
},
|
|
|
|
#[error("the binding is already in use")]
|
|
|
|
BindingInUse(u32),
|
2022-10-23 17:36:41 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Vec<naga::front::glsl::Error>> for ShaderCompileError {
|
|
|
|
fn from(err: Vec<naga::front::glsl::Error>) -> Self {
|
|
|
|
ShaderCompileError::NagaCompileError(err)
|
|
|
|
}
|
|
|
|
}
|