mirror of
https://github.com/storytold/wgpu.git
synced 2026-12-01 10:34:57 +01:00
fix(naga): Calculate 1D distance using abs (#8903)
This commit is contained in:
1 parent
723cb5db0c
commit
6495ef3f9d
2 files changed
+19
-7
No files matched your search
@@ -223,6 +223,8 @@ webgpu:shader,validation,expression,binary,short_circuiting_and_or:array_overrid
|
||||
webgpu:shader,validation,expression,binary,short_circuiting_and_or:invalid_types:*
|
||||
webgpu:shader,validation,expression,binary,short_circuiting_and_or:scalar_vector:op="%26%26";lhs="bool";rhs="bool"
|
||||
webgpu:shader,validation,expression,call,builtin,all:arguments:test="ptr_deref"
|
||||
webgpu:shader,validation,expression,call,builtin,distance:values:stage="constant";type="f32"
|
||||
webgpu:shader,validation,expression,call,builtin,length:scalar:stage="constant";type="f32"
|
||||
webgpu:shader,validation,expression,call,builtin,max:values:*
|
||||
// FAIL: others in `value_constructor` due to https://github.com/gfx-rs/wgpu/issues/4720, possibly more
|
||||
webgpu:shader,validation,expression,call,builtin,value_constructor:array_value:*
|
||||
|
||||
@@ -1791,7 +1791,12 @@ impl<'a> ConstantEvaluator<'a> {
|
||||
F: core::ops::Mul<F>,
|
||||
F: num_traits::Float + iter::Sum,
|
||||
{
|
||||
e.iter().map(|&ei| ei * ei).sum::<F>().sqrt()
|
||||
if e.len() == 1 {
|
||||
// Avoids possible overflow in squaring
|
||||
e[0].abs()
|
||||
} else {
|
||||
e.iter().map(|&ei| ei * ei).sum::<F>().sqrt()
|
||||
}
|
||||
}
|
||||
|
||||
let result = match_literal_vector!(match e1 => Literal {
|
||||
@@ -1812,12 +1817,17 @@ impl<'a> ConstantEvaluator<'a> {
|
||||
F: core::ops::Mul<F>,
|
||||
F: num_traits::Float + iter::Sum + core::ops::Sub,
|
||||
{
|
||||
a.iter()
|
||||
.zip(b.iter())
|
||||
.map(|(&aa, &bb)| aa - bb)
|
||||
.map(|ei| ei * ei)
|
||||
.sum::<F>()
|
||||
.sqrt()
|
||||
if a.len() == 1 {
|
||||
// Avoids possible overflow in squaring
|
||||
(a[0] - b[0]).abs()
|
||||
} else {
|
||||
a.iter()
|
||||
.zip(b.iter())
|
||||
.map(|(&aa, &bb)| aa - bb)
|
||||
.map(|ei| ei * ei)
|
||||
.sum::<F>()
|
||||
.sqrt()
|
||||
}
|
||||
}
|
||||
let result = match_literal_vector!(match (e1, e2) => Literal {
|
||||
Float => |e1, e2| { float_distance(e1, e2) },
|
||||
|
||||
Reference in new issue
Block a user