mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-25 17:50:39 +02:00
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:
parent
0a4a0df283
commit
95215a094a
1 changed files with 13 additions and 5 deletions
|
|
@ -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 *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue