mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-01 10:18:05 +02:00
nir: Fix nir_fmax_abs_vec_comp
This failed to take fabs of the first component, implementing an unintended
formula that would return the right results in some common cases but is wrong in
general:
max { x, |y|, |z| }
instead of the intended
max { |x|, |y|, |z| }
Reexpress the implementation to make correctness obvious.
Fixes: 272e927d0e ("nir/spirv: initial handling of OpenCL.std extension opcodes")
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18754>
(cherry picked from commit fc5c671e87)
This commit is contained in:
parent
d39f908b20
commit
f132890130
2 changed files with 4 additions and 3 deletions
|
|
@ -94,7 +94,7 @@
|
|||
"description": "nir: Fix nir_fmax_abs_vec_comp",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "272e927d0e9fed6e791d706ff5d895b6c2036fc0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -62,9 +62,10 @@ nir_nan_check2(nir_builder *b, nir_ssa_def *x, nir_ssa_def *y, nir_ssa_def *res)
|
|||
static inline nir_ssa_def *
|
||||
nir_fmax_abs_vec_comp(nir_builder *b, nir_ssa_def *vec)
|
||||
{
|
||||
nir_ssa_def *res = nir_channel(b, vec, 0);
|
||||
nir_ssa_def *abs = nir_fabs(b, vec);
|
||||
nir_ssa_def *res = nir_channel(b, abs, 0);
|
||||
for (unsigned i = 1; i < vec->num_components; ++i)
|
||||
res = nir_fmax(b, res, nir_fabs(b, nir_channel(b, vec, i)));
|
||||
res = nir_fmax(b, res, nir_channel(b, abs, i));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue