mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[naga] Reduce indentation in ImageLoad expression validation.
In `naga::valid::expression::validate_expression`, use a let-else statement so that the outermost control flow follows the success path, and errors are close to the conditions that trigger them.
This commit is contained in:
parent
5304c3ca4a
commit
de1b9a0899
@ -631,19 +631,18 @@ impl super::Validator {
|
|||||||
level,
|
level,
|
||||||
} => {
|
} => {
|
||||||
let ty = Self::global_var_ty(module, function, image)?;
|
let ty = Self::global_var_ty(module, function, image)?;
|
||||||
match module.types[ty].inner {
|
let Ti::Image {
|
||||||
Ti::Image {
|
|
||||||
class,
|
class,
|
||||||
arrayed,
|
arrayed,
|
||||||
dim,
|
dim,
|
||||||
} => {
|
} = module.types[ty].inner
|
||||||
|
else {
|
||||||
|
return Err(ExpressionError::ExpectedImageType(ty));
|
||||||
|
};
|
||||||
|
|
||||||
match resolver[coordinate].image_storage_coordinates() {
|
match resolver[coordinate].image_storage_coordinates() {
|
||||||
Some(coord_dim) if coord_dim == dim => {}
|
Some(coord_dim) if coord_dim == dim => {}
|
||||||
_ => {
|
_ => return Err(ExpressionError::InvalidImageCoordinateType(dim, coordinate)),
|
||||||
return Err(ExpressionError::InvalidImageCoordinateType(
|
|
||||||
dim, coordinate,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if arrayed != array_index.is_some() {
|
if arrayed != array_index.is_some() {
|
||||||
return Err(ExpressionError::InvalidImageArrayIndex);
|
return Err(ExpressionError::InvalidImageArrayIndex);
|
||||||
@ -662,9 +661,7 @@ impl super::Validator {
|
|||||||
(None, false) => {}
|
(None, false) => {}
|
||||||
(Some(sample), true) => {
|
(Some(sample), true) => {
|
||||||
if resolver[sample].scalar_kind() != Some(Sk::Sint) {
|
if resolver[sample].scalar_kind() != Some(Sk::Sint) {
|
||||||
return Err(ExpressionError::InvalidImageOtherIndexType(
|
return Err(ExpressionError::InvalidImageOtherIndexType(sample));
|
||||||
sample,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -679,17 +676,12 @@ impl super::Validator {
|
|||||||
kind: Sk::Sint | Sk::Uint,
|
kind: Sk::Sint | Sk::Uint,
|
||||||
width: _,
|
width: _,
|
||||||
}) => {}
|
}) => {}
|
||||||
_ => {
|
_ => return Err(ExpressionError::InvalidImageArrayIndexType(level)),
|
||||||
return Err(ExpressionError::InvalidImageArrayIndexType(level))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
return Err(ExpressionError::InvalidImageOtherIndex);
|
return Err(ExpressionError::InvalidImageOtherIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => return Err(ExpressionError::ExpectedImageType(ty)),
|
|
||||||
}
|
|
||||||
ShaderStages::all()
|
ShaderStages::all()
|
||||||
}
|
}
|
||||||
E::ImageQuery { image, query } => {
|
E::ImageQuery { image, query } => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user