diff --git a/CHANGELOG.md b/CHANGELOG.md index 90d0f1621..d0f25b96f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,12 @@ Naga now infers the correct binding layout when a resource appears only in an as - Removed `MaintainBase` in favor of using `PollType`. By @waywardmonkeys in [#7508](https://github.com/gfx-rs/wgpu/pull/7508). +### Bug Fixes + +#### Naga + +- Allow scalars as the first argument of the `distance` built-in function. By @bernhl in [#7530](https://github.com/gfx-rs/wgpu/pull/7530). + ## v25.0.1 (2025-04-11) ### Bug Fixes diff --git a/naga/src/proc/overloads/mathfunction.rs b/naga/src/proc/overloads/mathfunction.rs index da6e594b7..f3e5dfa74 100644 --- a/naga/src/proc/overloads/mathfunction.rs +++ b/naga/src/proc/overloads/mathfunction.rs @@ -92,7 +92,9 @@ impl ir::MathFunction { Mf::Ldexp => ldexp().into(), Mf::Outer => outer().into(), Mf::Cross => regular!(2, VEC3 of FLOAT).into(), - Mf::Distance => regular!(2, VECN of FLOAT_ABSTRACT_UNIMPLEMENTED -> Scalar).into(), + Mf::Distance => { + regular!(2, SCALAR|VECN of FLOAT_ABSTRACT_UNIMPLEMENTED -> Scalar).into() + } Mf::Length => regular!(1, SCALAR|VECN of FLOAT_ABSTRACT_UNIMPLEMENTED -> Scalar).into(), Mf::Normalize => regular!(1, VECN of FLOAT_ABSTRACT_UNIMPLEMENTED).into(), Mf::FaceForward => regular!(3, VECN of FLOAT_ABSTRACT_UNIMPLEMENTED).into(), diff --git a/naga/tests/naga/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs index 61953e49b..71e5b8717 100644 --- a/naga/tests/naga/wgsl_errors.rs +++ b/naga/tests/naga/wgsl_errors.rs @@ -3419,6 +3419,9 @@ fn too_many_arguments_2() { │ ^^^^^^^^ ^^ argument #2 has type `i32` │ = note: `distance` accepts the following types for argument #2: + = note: allowed type: f32 + = note: allowed type: f16 + = note: allowed type: f64 = note: allowed type: vec2 = note: allowed type: vec2 = note: allowed type: vec2