mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-25 08:14:20 +00:00
Changed ShaderInterfaceMismatchError
to be more verbose (#862)
* Changed `ShaderInterfaceMismatchError` to be more verbose * Add entry to changelog
This commit is contained in:
parent
e590f22bf2
commit
c60265c67b
@ -1,5 +1,7 @@
|
|||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- Changed `ShaderInterfaceMismatchError` to be more verbose.
|
||||||
|
|
||||||
# Version 0.7.2 (2017-10-09)
|
# Version 0.7.2 (2017-10-09)
|
||||||
|
|
||||||
- Allow `impl_vertex!` to support generic structs.
|
- Allow `impl_vertex!` to support generic structs.
|
||||||
|
@ -458,7 +458,10 @@ unsafe impl<T, I> ShaderInterfaceDefMatch<I> for T
|
|||||||
{
|
{
|
||||||
fn matches(&self, other: &I) -> Result<(), ShaderInterfaceMismatchError> {
|
fn matches(&self, other: &I) -> Result<(), ShaderInterfaceMismatchError> {
|
||||||
if self.elements().len() != other.elements().len() {
|
if self.elements().len() != other.elements().len() {
|
||||||
return Err(ShaderInterfaceMismatchError::ElementsCountMismatch);
|
return Err(ShaderInterfaceMismatchError::ElementsCountMismatch {
|
||||||
|
self_elements: self.elements().len() as u32,
|
||||||
|
other_elements: other.elements().len() as u32,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for a in self.elements() {
|
for a in self.elements() {
|
||||||
@ -473,7 +476,11 @@ unsafe impl<T, I> ShaderInterfaceDefMatch<I> for T
|
|||||||
};
|
};
|
||||||
|
|
||||||
if a.format != b.format {
|
if a.format != b.format {
|
||||||
return Err(ShaderInterfaceMismatchError::FormatMismatch);
|
return Err(ShaderInterfaceMismatchError::FormatMismatch {
|
||||||
|
location: loc,
|
||||||
|
self_format: a.format,
|
||||||
|
other_format: b.format,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enforce this?
|
// TODO: enforce this?
|
||||||
@ -484,28 +491,54 @@ unsafe impl<T, I> ShaderInterfaceDefMatch<I> for T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: since we check that the number of elements is the same, we don't need to iterate
|
||||||
|
// over b's elements.
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Error that can happen when the interface mismatches between two shader stages.
|
/// Error that can happen when the interface mismatches between two shader stages.
|
||||||
// TODO: improve diagnostic a bit
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum ShaderInterfaceMismatchError {
|
pub enum ShaderInterfaceMismatchError {
|
||||||
ElementsCountMismatch,
|
/// The number of elements is not the same between the two shader interfaces.
|
||||||
MissingElement { location: u32 },
|
ElementsCountMismatch {
|
||||||
FormatMismatch,
|
/// Number of elements in the first interface.
|
||||||
|
self_elements: u32,
|
||||||
|
/// Number of elements in the second interface.
|
||||||
|
other_elements: u32,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// An element is missing from one of the interfaces.
|
||||||
|
MissingElement {
|
||||||
|
/// Location of the missing element.
|
||||||
|
location: u32,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// The format of an element does not match.
|
||||||
|
FormatMismatch {
|
||||||
|
/// Location of the element that mismatches.
|
||||||
|
location: u32,
|
||||||
|
/// Format in the first interface.
|
||||||
|
self_format: Format,
|
||||||
|
/// Format in the second interface.
|
||||||
|
other_format: Format
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for ShaderInterfaceMismatchError {
|
impl error::Error for ShaderInterfaceMismatchError {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
ShaderInterfaceMismatchError::ElementsCountMismatch =>
|
ShaderInterfaceMismatchError::ElementsCountMismatch { .. } => {
|
||||||
"the number of elements mismatches",
|
"the number of elements mismatches"
|
||||||
ShaderInterfaceMismatchError::MissingElement { .. } => "an element is missing",
|
},
|
||||||
ShaderInterfaceMismatchError::FormatMismatch =>
|
ShaderInterfaceMismatchError::MissingElement { .. } => {
|
||||||
"the format of an element does not match",
|
"an element is missing"
|
||||||
|
},
|
||||||
|
ShaderInterfaceMismatchError::FormatMismatch { .. } => {
|
||||||
|
"the format of an element does not match"
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user