Skip to content

Commit 06ee718

Browse files
[naga] Allow Scalar for MathFunction::Distance (gfx-rs#7530)
Co-authored-by: Erich Gubler <[email protected]>
1 parent 09178f2 commit 06ee718

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

CHANGELOG.md

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

5959
- Removed `MaintainBase` in favor of using `PollType`. By @waywardmonkeys in [#7508](https://github.com/gfx-rs/wgpu/pull/7508).
6060

61+
### Bug Fixes
62+
63+
#### Naga
64+
65+
- Allow scalars as the first argument of the `distance` built-in function. By @bernhl in [#7530](https://github.com/gfx-rs/wgpu/pull/7530).
66+
6167
## v25.0.1 (2025-04-11)
6268

6369
### 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)