Relax interpolation validation for vertex outputs

This commit is contained in:
Dzmitry Malyshau
2021-03-06 22:59:10 -05:00
committed by Dzmitry Malyshau
parent e92b35725c
commit 6afd72b8dd
3 changed files with 13 additions and 13 deletions

View File

@@ -4,6 +4,7 @@ SNAPSHOTS_IN=tests/in
SNAPSHOTS_OUT=tests/out
all:
cargo fmt
cargo test --all-features
cargo clippy --all-features

View File

@@ -471,6 +471,8 @@ pub struct GlobalVariable {
pub ty: Handle<Type>,
/// Initial value for this variable.
pub init: Option<Handle<Constant>>,
//TODO: require fragment input interpolation once the entry point I/O
// is refactored.
/// The interpolation qualifier, if any.
/// If the this `GlobalVariable` is a vertex output
/// or fragment input, `None` corresponds to the

View File

@@ -249,8 +249,8 @@ pub enum EntryPointError {
BindingCollision(Handle<crate::GlobalVariable>),
#[error("Built-in {0:?} is not applicable to this entry point")]
InvalidBuiltIn(crate::BuiltIn),
#[error("Interpolation of an integer has to be flat")]
InvalidIntegerInterpolation,
#[error("Location {location} onterpolation of an integer has to be flat")]
InvalidIntegerInterpolation { location: u32 },
#[error(transparent)]
Function(#[from] FunctionError),
}
@@ -1091,19 +1091,16 @@ impl Validator {
continue;
}
if let Some(crate::Binding::Location(_)) = var.binding {
match (stage, var.class) {
(crate::ShaderStage::Vertex, crate::StorageClass::Output)
| (crate::ShaderStage::Fragment, crate::StorageClass::Input) => {
match module.types[var.ty].inner.scalar_kind() {
Some(crate::ScalarKind::Float) => {}
Some(_) if var.interpolation != Some(crate::Interpolation::Flat) => {
return Err(EntryPointError::InvalidIntegerInterpolation);
}
_ => {}
if let Some(crate::Binding::Location(location)) = var.binding {
if stage == crate::ShaderStage::Fragment && var.class == crate::StorageClass::Input
{
match module.types[var.ty].inner.scalar_kind() {
Some(crate::ScalarKind::Float) => {}
Some(_) if var.interpolation != Some(crate::Interpolation::Flat) => {
return Err(EntryPointError::InvalidIntegerInterpolation { location });
}
_ => {}
}
_ => {}
}
}