nir: extend copysign for no-integer hw

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30934>
This commit is contained in:
Alyssa Rosenzweig 2024-09-03 09:27:42 -04:00 committed by Marge Bot
parent 0a4a0df283
commit 95215a094a

View file

@ -144,13 +144,21 @@ nir_bitselect(nir_builder *b, nir_def *x, nir_def *y, nir_def *s)
static inline nir_def *
nir_copysign(nir_builder *b, nir_def *x, nir_def *y)
{
uint64_t masks = 1ull << (x->bit_size - 1);
uint64_t maskv = ~masks;
if (b->shader->options->no_integers) {
/* Unlike the integer path, this is not signed zero correct. We assume
* integerless backends don't care.
*/
nir_def *abs = nir_fabs(b, x);
return nir_bcsel(b, nir_flt_imm(b, y, 0.0), nir_fneg(b, abs), abs);
} else {
uint64_t masks = 1ull << (x->bit_size - 1);
uint64_t maskv = ~masks;
nir_def *s = nir_imm_intN_t(b, masks, x->bit_size);
nir_def *v = nir_imm_intN_t(b, maskv, x->bit_size);
nir_def *s = nir_imm_intN_t(b, masks, x->bit_size);
nir_def *v = nir_imm_intN_t(b, maskv, x->bit_size);
return nir_ior(b, nir_iand(b, x, v), nir_iand(b, y, s));
return nir_ior(b, nir_iand(b, x, v), nir_iand(b, y, s));
}
}
static inline nir_def *