Skip to content

Commit 780d070

Browse files
bernhlErichDonGubler
authored andcommitted
[naga] Allow Scalar for MathFunction::Distance (gfx-rs#7530)
Co-authored-by: Erich Gubler <[email protected]>
1 parent 9463cb1 commit 780d070

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ Naga now infers the correct binding layout when a resource appears only in an as
8787

8888
- Fix validation error when creating a non-mappable buffer using the committed allocation scheme. By @cwfitzgerald and @ErichDonGubler in [#7519](https://github.com/gfx-rs/wgpu/pull/7519).
8989

90+
### Bug Fixes
91+
92+
#### Naga
93+
94+
- Allow scalars as the first argument of the `distance` built-in function. By @bernhl in [#7530](https://github.com/gfx-rs/wgpu/pull/7530).
95+
9096
## v25.0.1 (2025-04-11)
9197

9298
### Bug Fixes

naga/src/proc/overloads/mathfunction.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ impl ir::MathFunction {
9292
Mf::Ldexp => ldexp().into(),
9393
Mf::Outer => outer().into(),
9494
Mf::Cross => regular!(2, VEC3 of FLOAT).into(),
95-
Mf::Distance => regular!(2, VECN of FLOAT_ABSTRACT_UNIMPLEMENTED -> Scalar).into(),
95+
Mf::Distance => {
96+
regular!(2, SCALAR|VECN of FLOAT_ABSTRACT_UNIMPLEMENTED -> Scalar).into()
97+
}
9698
Mf::Length => regular!(1, SCALAR|VECN of FLOAT_ABSTRACT_UNIMPLEMENTED -> Scalar).into(),
9799
Mf::Normalize => regular!(1, VECN of FLOAT_ABSTRACT_UNIMPLEMENTED).into(),
98100
Mf::FaceForward => regular!(3, VECN of FLOAT_ABSTRACT_UNIMPLEMENTED).into(),

naga/tests/naga/wgsl_errors.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3419,6 +3419,9 @@ fn too_many_arguments_2() {
34193419
│ ^^^^^^^^ ^^ argument #2 has type `i32`
34203420
34213421
= note: `distance` accepts the following types for argument #2:
3422+
= note: allowed type: f32
3423+
= note: allowed type: f16
3424+
= note: allowed type: f64
34223425
= note: allowed type: vec2<f32>
34233426
= note: allowed type: vec2<f16>
34243427
= note: allowed type: vec2<f64>

0 commit comments

Comments
 (0)