From 9aaed2c0cc3c5faf2f3aaba95fafa3b13ac74c93 Mon Sep 17 00:00:00 2001 From: Jamie Nicol Date: Wed, 20 Aug 2025 08:30:54 +0100 Subject: [PATCH] [naga] Ensure validation rejects invalid sample operations of `ImageClass::External` images. (#8121) textureSampleBaseClampToEdge() is valid when called on a `texture_external` texture, but all other sample operations are invalid. Previously validation was succeeding for these operations on an external texture in cases where the same operation on a `texture_2d` would be allowed. We must therefore explicitly check for ImageClass::External and disallow invalid sample operations. --- naga/src/valid/expression.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index a34f3aa9e..5661094f3 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -590,6 +590,11 @@ impl super::Validator { } } + // External textures can only be sampled using clamp_to_edge. + if matches!(class, crate::ImageClass::External) && !clamp_to_edge { + return Err(ExpressionError::InvalidImageClass(class)); + } + // check level properties match level { crate::SampleLevel::Auto => ShaderStages::FRAGMENT,