2020-02-01 20:39:39 +00:00
|
|
|
/// Used to represent one of many possible errors that may be omitted by the
|
|
|
|
/// rendering subsystem.
|
2019-09-26 03:19:45 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum RenderError {
|
|
|
|
PipelineError(gfx::PipelineStateError<String>),
|
|
|
|
UpdateError(gfx::UpdateError<usize>),
|
|
|
|
TexUpdateError(gfx::UpdateError<[u16; 3]>),
|
|
|
|
CombinedError(gfx::CombinedError),
|
|
|
|
BufferCreationError(gfx::buffer::CreationError),
|
|
|
|
IncludeError(glsl_include::Error),
|
|
|
|
MappingError(gfx::mapping::Error),
|
|
|
|
CopyError(gfx::CopyError<[u16; 3], usize>),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::PipelineStateError<String>> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::PipelineStateError<String>) -> Self { Self::PipelineError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::PipelineStateError<&str>> for RenderError {
|
|
|
|
fn from(err: gfx::PipelineStateError<&str>) -> Self {
|
|
|
|
match err {
|
|
|
|
gfx::PipelineStateError::DescriptorInit(err) => {
|
|
|
|
gfx::PipelineStateError::DescriptorInit(err.into())
|
2020-02-01 20:39:39 +00:00
|
|
|
},
|
2019-09-26 03:19:45 +00:00
|
|
|
err => err,
|
|
|
|
}
|
|
|
|
.into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<gfx::shade::ProgramError> for RenderError {
|
|
|
|
fn from(err: gfx::shade::ProgramError) -> Self {
|
|
|
|
gfx::PipelineStateError::<String>::Program(err).into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl From<gfx::UpdateError<usize>> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::UpdateError<usize>) -> Self { Self::UpdateError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::UpdateError<[u16; 3]>> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::UpdateError<[u16; 3]>) -> Self { Self::TexUpdateError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::CombinedError> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::CombinedError) -> Self { Self::CombinedError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::TargetViewError> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::TargetViewError) -> Self { Self::CombinedError(err.into()) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::ResourceViewError> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::ResourceViewError) -> Self { Self::CombinedError(err.into()) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::texture::CreationError> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::texture::CreationError) -> Self { Self::CombinedError(err.into()) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::buffer::CreationError> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::buffer::CreationError) -> Self { Self::BufferCreationError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<glsl_include::Error> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: glsl_include::Error) -> Self { Self::IncludeError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::mapping::Error> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::mapping::Error) -> Self { Self::MappingError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<gfx::CopyError<[u16; 3], usize>> for RenderError {
|
2020-02-01 20:39:39 +00:00
|
|
|
fn from(err: gfx::CopyError<[u16; 3], usize>) -> Self { Self::CopyError(err) }
|
2019-09-26 03:19:45 +00:00
|
|
|
}
|