From 38b6663f3c1b5d8ebd2016933b5ce588e50093ea Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 25 Apr 2025 06:08:27 -0700 Subject: [PATCH] validation: Fix type compatibility for streams vs. vertex inputs (#7600) The old is_compatible_with handled scalar/scalar, scalar/vector, vector/vector, but was missing vector/scalar. Since is_compatible_with is only used by vertex shader inputs, and vertex shader inputs can't be matrices (only scalars and vectors), we can actually simplify this by removing the other match and just only checking the kind. Fixes #7568 --- wgpu-core/src/validation.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/wgpu-core/src/validation.rs b/wgpu-core/src/validation.rs index 17d65ee2a..5a34cd77b 100644 --- a/wgpu-core/src/validation.rs +++ b/wgpu-core/src/validation.rs @@ -815,19 +815,6 @@ impl NumericType { _ => false, } } - - fn is_compatible_with(&self, other: &NumericType) -> bool { - if self.scalar.kind != other.scalar.kind { - return false; - } - match (self.dim, other.dim) { - (NumericDimension::Scalar, NumericDimension::Scalar) => true, - (NumericDimension::Scalar, NumericDimension::Vector(_)) => true, - (NumericDimension::Vector(_), NumericDimension::Vector(_)) => true, - (NumericDimension::Matrix(..), NumericDimension::Matrix(..)) => true, - _ => false, - } - } } /// Return true if the fragment `format` is covered by the provided `output`. @@ -1221,8 +1208,10 @@ impl Interface { // For vertex attributes, there are defaults filled out // by the driver if data is not provided. naga::ShaderStage::Vertex => { + let is_compatible = + iv.ty.scalar.kind == provided.ty.scalar.kind; // vertex inputs don't count towards inter-stage - (iv.ty.is_compatible_with(&provided.ty), 0) + (is_compatible, 0) } naga::ShaderStage::Fragment => { if iv.interpolation != provided.interpolation {