From 87d9ffed565e93b2f45861807b847a116d4439af Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 13 Dec 2024 15:49:47 -0800 Subject: [PATCH] [naga valid]: Clean up validation of `Statement::ImageStore`. Move image class validation to a more natural spot. --- naga/src/valid/function.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 8193fbba88..a41ad00299 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -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(),