pan/bit: Add log2 helper interp
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 14 Apr 2020 19:25:17 +0000 (15:25 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 17 Apr 2020 20:25:36 +0000 (16:25 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4615>

src/panfrost/bifrost/test/bi_interpret.c

index 92f5865e48bbf884aec72903dc1adc4e59040973..eca42292c609ddd7f4b29ecacbb929f638fd2d3e 100644 (file)
@@ -509,6 +509,19 @@ bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
                 break;
         }
 
+        case BI_TABLE: {
+                if (ins->op.table == BI_TABLE_LOG2_U_OVER_U_1_LOW) {
+                        assert(ins->dest_type == nir_type_float32);
+                        int _nop = 0;
+                        float f = frexp_log(srcs[0].f32, &_nop);
+                        dest.f32 = log2f(f) / (f - 1.0);
+                        dest.u32++; /* Sorry. */
+                } else {
+                        unreachable("Unknown table op");
+                }
+                break;
+       }
+
         case BI_SHIFT:
         case BI_SWIZZLE:
         case BI_ROUND: