summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-04-01 13:13:50 -0400
committerMarge Bot <[email protected]>2020-04-05 23:26:04 +0000
commit5e3e32e368caabc50b669967b1a81b0f32102194 (patch)
tree5ccd6a957eff23313e5e9b65371c235199f52c37 /src
parentdbb8a564f2661fe8f665ea0f2e277c19259ba968 (diff)
pan/bit: Implement floating source mods
Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4458>
Diffstat (limited to 'src')
-rw-r--r--src/panfrost/bifrost/test/bi_interpret.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/test/bi_interpret.c b/src/panfrost/bifrost/test/bi_interpret.c
index 8a4781b538e..2ad1a21df25 100644
--- a/src/panfrost/bifrost/test/bi_interpret.c
+++ b/src/panfrost/bifrost/test/bi_interpret.c
@@ -24,6 +24,7 @@
* Alyssa Rosenzweig <[email protected]>
*/
+#include <math.h>
#include "bit.h"
#include "util/half_float.h"
@@ -201,6 +202,18 @@ bit_outmod(float raw, enum bifrost_outmod mod)
}
}
+static float
+bit_srcmod(float raw, bool abs, bool neg)
+{
+ if (abs)
+ raw = fabs(raw);
+
+ if (neg)
+ raw = -raw;
+
+ return raw;
+}
+
void
bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
{
@@ -210,6 +223,23 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
bi_foreach_src(ins, src)
srcs[src].u64 = bit_read(s, ins, ins->src[src], ins->src_types[src], FMA);
+ /* Apply source modifiers if we need to */
+ if (bi_has_source_mods(ins)) {
+ bi_foreach_src(ins, src) {
+ if (ins->src_types[src] == nir_type_float16) {
+ for (unsigned c = 0; c < 2; ++c) {
+ srcs[src].f16[c] = bh(bit_srcmod(bf(srcs[src].f16[c]),
+ ins->src_abs[src],
+ ins->src_neg[src]));
+ }
+ } else if (ins->src_types[src] == nir_type_float32) {
+ srcs[src].f32 = bit_srcmod(srcs[src].f32,
+ ins->src_abs[src],
+ ins->src_neg[src]);
+ }
+ }
+ }
+
/* Next, do the action of the instruction */
bit_t dest = { 0 };