2023-01-29 18:30:58 +11:00
|
|
|
use crate::reflect::semantics::UniformMemberBlock;
|
2022-10-27 17:22:44 +11:00
|
|
|
use thiserror::Error;
|
2022-10-23 17:36:41 +11:00
|
|
|
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Error type for shader compilation.
|
2022-11-28 15:37:45 +11:00
|
|
|
#[non_exhaustive]
|
2022-10-23 17:36:41 +11:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum ShaderCompileError {
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Compile error from naga.
|
2023-01-16 10:36:38 +11:00
|
|
|
#[cfg(feature = "unstable-naga")]
|
2022-10-23 17:36:41 +11:00
|
|
|
#[error("shader")]
|
|
|
|
NagaCompileError(Vec<naga::front::glsl::Error>),
|
|
|
|
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Compilation error from shaderc (glslang).
|
2022-10-23 17:36:41 +11:00
|
|
|
#[error("shaderc")]
|
|
|
|
ShaderCCompileError(#[from] shaderc::Error),
|
|
|
|
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Error when initializing the shaderc compiler.
|
2022-10-23 17:36:41 +11:00
|
|
|
#[error("shaderc init")]
|
|
|
|
ShaderCInitError,
|
2022-11-07 16:25:11 +11:00
|
|
|
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Error when transpiling from spirv-cross.
|
2022-11-07 16:25:11 +11:00
|
|
|
#[error("cross")]
|
|
|
|
SpirvCrossCompileError(#[from] spirv_cross::ErrorCode),
|
2023-02-05 09:53:51 +11:00
|
|
|
|
|
|
|
/// Error when transpiling from spirv-to-dxil
|
|
|
|
#[cfg(feature = "dxil")]
|
|
|
|
#[error("spirv-to-dxil")]
|
2023-02-07 11:22:53 +11:00
|
|
|
SpirvToDxilCompileError(#[from] spirv_to_dxil::SpirvToDxilError),
|
2022-10-23 17:36:41 +11:00
|
|
|
}
|
|
|
|
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The error kind encountered when reflecting shader semantics.
|
2022-10-24 14:22:26 +11:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum SemanticsErrorKind {
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The number of uniform buffers was invalid. Only one UBO is permitted.
|
2022-10-26 13:13:39 +11:00
|
|
|
InvalidUniformBufferCount(usize),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The number of push constant blocks was invalid. Only one push constant block is permitted.
|
2022-10-26 13:13:39 +11:00
|
|
|
InvalidPushBufferSize(u32),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The location of a varying was invalid.
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidLocation(u32),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The requested descriptor set was invalid. Only descriptor set 0 is available.
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidDescriptorSet(u32),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The number of inputs to the shader was invalid.
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidInputCount(usize),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The number of outputs declared was invalid.
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidOutputCount(usize),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The declared binding point was invalid.
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidBinding(u32),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The declared resource type was invalid.
|
2022-10-24 14:22:26 +11:00
|
|
|
InvalidResourceType,
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The range of a struct member was invalid.
|
2022-10-26 13:13:39 +11:00
|
|
|
InvalidRange(u32),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The requested uniform or texture name was not provided semantics.
|
2022-10-26 16:19:04 +11:00
|
|
|
UnknownSemantics(String),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The type of the requested uniform was not compatible with the provided semantics.
|
2022-10-27 17:22:44 +11:00
|
|
|
InvalidTypeForSemantic(String),
|
2022-10-24 14:22:26 +11:00
|
|
|
}
|
|
|
|
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Error type for shader reflection.
|
2022-11-28 15:37:45 +11:00
|
|
|
#[non_exhaustive]
|
2022-10-23 17:36:41 +11:00
|
|
|
#[derive(Error, Debug)]
|
|
|
|
pub enum ShaderReflectError {
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Compile error from naga.
|
2023-01-16 10:36:38 +11:00
|
|
|
#[cfg(feature = "unstable-naga")]
|
2022-10-23 17:36:41 +11:00
|
|
|
#[error("shader")]
|
|
|
|
NagaCompileError(#[from] naga::front::spv::Error),
|
2022-12-01 17:50:16 +11:00
|
|
|
|
|
|
|
/// Reflection error from spirv-cross.
|
2022-11-22 08:21:50 +11:00
|
|
|
#[error("spirv")]
|
|
|
|
SpirvCrossError(#[from] spirv_cross::ErrorCode),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Error when validating vertex shader semantics.
|
2022-10-24 14:22:26 +11:00
|
|
|
#[error("error when verifying vertex semantics")]
|
|
|
|
VertexSemanticError(SemanticsErrorKind),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// Error when validating fragment shader semantics.
|
2022-10-24 14:22:26 +11:00
|
|
|
#[error("error when verifying texture semantics")]
|
|
|
|
FragmentSemanticError(SemanticsErrorKind),
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The vertex and fragment shader must have the same UBO binding location.
|
|
|
|
#[error("vertex and fragment shader must have same binding")]
|
2022-10-26 13:13:39 +11:00
|
|
|
MismatchedUniformBuffer { vertex: u32, fragment: u32 },
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The filter chain was found to be non causal. A pass tried to access the target output
|
|
|
|
/// in the future.
|
2022-10-26 13:13:39 +11:00
|
|
|
#[error("filter chain is non causal")]
|
2022-11-20 10:48:54 +11:00
|
|
|
NonCausalFilterChain { pass: usize, target: usize },
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The offset of the given uniform did not match up in both the vertex and fragment shader.
|
2022-10-26 16:19:04 +11:00
|
|
|
#[error("mismatched offset")]
|
2022-10-27 17:22:44 +11:00
|
|
|
MismatchedOffset {
|
|
|
|
semantic: String,
|
2023-01-29 17:57:09 +11:00
|
|
|
expected: usize,
|
|
|
|
received: usize,
|
|
|
|
ty: UniformMemberBlock,
|
2023-01-29 18:30:58 +11:00
|
|
|
pass: usize,
|
2022-10-27 17:22:44 +11:00
|
|
|
},
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The size of the given uniform did not match up in both the vertex and fragment shader.
|
2022-10-26 16:19:04 +11:00
|
|
|
#[error("mismatched component")]
|
2022-12-01 17:50:16 +11:00
|
|
|
MismatchedSize {
|
2022-10-27 17:22:44 +11:00
|
|
|
semantic: String,
|
|
|
|
vertex: u32,
|
|
|
|
fragment: u32,
|
2023-01-29 18:30:58 +11:00
|
|
|
pass: usize,
|
2022-10-27 17:22:44 +11:00
|
|
|
},
|
2022-12-01 17:50:16 +11:00
|
|
|
/// The binding number is already in use.
|
2022-10-27 17:22:44 +11:00
|
|
|
#[error("the binding is already in use")]
|
|
|
|
BindingInUse(u32),
|
2022-10-23 17:36:41 +11:00
|
|
|
}
|
|
|
|
|
2023-01-16 10:36:38 +11:00
|
|
|
#[cfg(feature = "unstable-naga")]
|
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)
|
|
|
|
}
|
|
|
|
}
|