mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +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>
This commit is contained in:
parent
6fbb87851c
commit
fc5c671e87
1 changed files with 3 additions and 2 deletions
|
|
@ -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