mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 18:08:40 +02:00
pan/bit: Implement outmods
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4458>
This commit is contained in:
parent
ab58185604
commit
dbb8a564f2
1 changed files with 27 additions and 0 deletions
|
|
@ -184,6 +184,23 @@ bit_make_poly(add, a + b);
|
||||||
bit_make_float(fma, (a * b) + c);
|
bit_make_float(fma, (a * b) + c);
|
||||||
bit_make_poly(mov, a);
|
bit_make_poly(mov, a);
|
||||||
|
|
||||||
|
/* Modifiers */
|
||||||
|
|
||||||
|
static float
|
||||||
|
bit_outmod(float raw, enum bifrost_outmod mod)
|
||||||
|
{
|
||||||
|
switch (mod) {
|
||||||
|
case BIFROST_POS:
|
||||||
|
return MAX2(raw, 0.0);
|
||||||
|
case BIFROST_SAT_SIGNED:
|
||||||
|
return CLAMP(raw, -1.0, 1.0);
|
||||||
|
case BIFROST_SAT:
|
||||||
|
return CLAMP(raw, 0.0, 1.0);
|
||||||
|
default:
|
||||||
|
return raw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
|
bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
|
||||||
{
|
{
|
||||||
|
|
@ -247,6 +264,16 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
|
||||||
unreachable("Unsupported op");
|
unreachable("Unsupported op");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Apply outmod */
|
||||||
|
if (bi_has_outmod(ins) && ins->outmod != BIFROST_NONE) {
|
||||||
|
if (ins->dest_type == nir_type_float16) {
|
||||||
|
for (unsigned c = 0; c < 2; ++c)
|
||||||
|
dest.f16[c] = bh(bit_outmod(bf(dest.f16[c]), ins->outmod));
|
||||||
|
} else {
|
||||||
|
dest.f32 = bit_outmod(dest.f32, ins->outmod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Finally, store the result */
|
/* Finally, store the result */
|
||||||
bit_write(s, ins->dest, ins->dest_type, dest, FMA);
|
bit_write(s, ins->dest, ins->dest_type, dest, FMA);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue