[naga valid]: Clean up validation of Statement::ImageStore.

Move image class validation to a more natural spot.
This commit is contained in:
Jim Blandy
2024-12-13 15:49:47 -08:00
parent 1a06279ca9
commit 87d9ffed56

View File

@@ -1060,6 +1060,14 @@ impl super::Validator {
.with_handle(image, context.expressions));
};
// It had better be a storage image, since we're writing to it.
let crate::ImageClass::Storage { format, .. } = class else {
return Err(FunctionError::InvalidImageStore(
ExpressionError::InvalidImageClass(class),
)
.with_span_handle(image, context.expressions));
};
// The `coordinate` operand must be a vector of the appropriate size.
if !context
.resolve_type(coordinate, &self.valid_expression_set)?
@@ -1097,14 +1105,6 @@ impl super::Validator {
}
}
// It had better be a storage image, since we're writing to it.
let crate::ImageClass::Storage { format, .. } = class else {
return Err(FunctionError::InvalidImageStore(
ExpressionError::InvalidImageClass(class),
)
.with_span_handle(image, context.expressions));
};
let value_ty = crate::TypeInner::Vector {
size: crate::VectorSize::Quad,
scalar: format.into(),