[Mesa-dev] [PATCH 5/7] intel/tools: Support decoding SFIXED items to a float

Jordan Justen jordan.l.justen at intel.com
Tue Jan 10 01:22:16 UTC 2017


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/intel/tools/decoder.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c
index defb0873da0..0e6a139ddaa 100644
--- a/src/intel/tools/decoder.c
+++ b/src/intel/tools/decoder.c
@@ -748,10 +748,16 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
       snprintf(iter->value, sizeof(iter->value),
                "%f", (float) field(v.qw, f->start, f->end) / (1 << f->type.f));
       break;
-   case GEN_TYPE_SFIXED:
+   case GEN_TYPE_SFIXED: {
       /* FIXME: Sign extend extracted field. */
-      snprintf(iter->value, sizeof(iter->value), "%s", "foo");
+      int64_t sign_bit = 1ll << (f->end - f->start);
+      int64_t sign_extend_bits = -1ll - ((sign_bit << 1) - 1);
+      int64_t value = field(v.qw, f->start, f->end);
+      if (value & sign_bit)
+         value += sign_extend_bits;
+      snprintf(iter->value, sizeof(iter->value), "%f", (float)value / (1 << f->type.f));
       break;
+   }
    case GEN_TYPE_MBO:
        break;
    case GEN_TYPE_ENUM: {
-- 
2.11.0



More information about the mesa-dev mailing list