diff --git a/CHANGELOG.md b/CHANGELOG.md index 86481abe9..fa3c1d37f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ Bottom level categories: #### naga - Fixed overflow detection and argument domain validation for `acosh`, `length`, `normalize`, and `pow` in constant evaluation. By @ecoricemon in [#9249](https://github.com/gfx-rs/wgpu/pull/9249). +- Naga no longer allows derivative operations on `f16`. WGSL does not currently allow this, although [it may be added in the future](https://github.com/gpuweb/gpuweb/issues/5482). By @andyleiserson in [#9154](https://github.com/gfx-rs/wgpu/pull/9154). #### Metal diff --git a/cts_runner/fail.lst b/cts_runner/fail.lst index 4dc324ec1..a31f5e4a3 100644 --- a/cts_runner/fail.lst +++ b/cts_runner/fail.lst @@ -86,7 +86,6 @@ webgpu:shader,validation,expression,call,builtin,countLeadingZeros:* // 98%, ato webgpu:shader,validation,expression,call,builtin,countOneBits:* // 98%, atomic type validation gap, https://github.com/gfx-rs/wgpu/issues/5474 webgpu:shader,validation,expression,call,builtin,countTrailingZeros:* // 98%, atomic type validation gap, https://github.com/gfx-rs/wgpu/issues/5474 webgpu:shader,validation,expression,call,builtin,cross:* // 86%, abstract int/float overflow issues in const eval -webgpu:shader,validation,expression,call,builtin,derivatives:* // 83%, f16 support not properly validated webgpu:shader,validation,expression,call,builtin,determinant:* // 71%, abstract int/float const eval issues webgpu:shader,validation,expression,call,builtin,distance:* // 66%, scalar distance uses wrong formula (sqrt instead of abs) webgpu:shader,validation,expression,call,builtin,dot4I8Packed:* // 91%, missing const eval (#4507) diff --git a/cts_runner/test.lst b/cts_runner/test.lst index f571e55ac..58191c0df 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -383,6 +383,7 @@ webgpu:shader,validation,expression,call,builtin,ceil:* webgpu:shader,validation,expression,call,builtin,cos:* webgpu:shader,validation,expression,call,builtin,cosh:* webgpu:shader,validation,expression,call,builtin,degrees:* +webgpu:shader,validation,expression,call,builtin,derivatives:* webgpu:shader,validation,expression,call,builtin,distance:values:stage="constant";type="f32" webgpu:shader,validation,expression,call,builtin,dot:* webgpu:shader,validation,expression,call,builtin,exp:* diff --git a/naga/src/proc/type_methods.rs b/naga/src/proc/type_methods.rs index 6328136e5..038cfe8f7 100644 --- a/naga/src/proc/type_methods.rs +++ b/naga/src/proc/type_methods.rs @@ -422,8 +422,8 @@ impl crate::TypeInner { }) } - /// If the type is a Vector or a Scalar return a tuple of the vector size (or None - /// for Scalars), and the scalar kind. Returns (None, None) for other types. + /// If the type is a scalar or vector (not a matrix), return a tuple of the vector + /// size (or `None` for scalars), and the scalar kind. Returns `None` for other types. pub const fn vector_size_and_scalar( &self, ) -> Option<(Option, crate::Scalar)> { diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index 2369f2aa5..fd6a7e4c5 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -1182,18 +1182,13 @@ impl super::Validator { ShaderStages::all() } E::Derivative { expr, .. } => { - match resolver[expr] { - Ti::Scalar(Sc { - kind: Sk::Float, .. - }) - | Ti::Vector { - scalar: - Sc { - kind: Sk::Float, .. - }, - .. - } => {} - _ => return Err(ExpressionError::InvalidDerivative), + let Some((_, scalar)) = resolver[expr].vector_size_and_scalar() else { + return Err(ExpressionError::InvalidDerivative); + }; + if scalar.kind != Sk::Float || scalar.width < 4 { + // Derivatives are not supported for `f16`, although support may be added + // in the future, see https://github.com/gpuweb/gpuweb/issues/5482. + return Err(ExpressionError::InvalidDerivative); } ShaderStages::FRAGMENT }