intel/decoder: Decode SFIXED values.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 23 Aug 2018 08:06:53 +0000 (01:06 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 23 Aug 2018 20:04:53 +0000 (13:04 -0700)
This lets us example SAMPLER_STATE's LOD Bias field, among other things.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/common/gen_decoder.c

index c14c23aad1a82bbde4ad78fdbd3f5f648177d286..39da3cadbf8df655e74b08b7602d642e62afc630 100644 (file)
@@ -944,10 +944,14 @@ iter_decode_field(struct gen_field_iterator *iter)
       snprintf(iter->value, sizeof(iter->value), "%f",
                (float) v.qw / (1 << iter->field->type.f));
       break;
-   case GEN_TYPE_SFIXED:
-      /* FIXME: Sign extend extracted field. */
-      snprintf(iter->value, sizeof(iter->value), "%s", "foo");
+   case GEN_TYPE_SFIXED: {
+      /* Sign extend before converting */
+      int bits = iter->field->type.i + iter->field->type.f + 1;
+      int64_t v_sign_extend = ((int64_t)(v.qw << (64 - bits))) >> (64 - bits);
+      snprintf(iter->value, sizeof(iter->value), "%f",
+               (float) v_sign_extend / (1 << iter->field->type.f));
       break;
+   }
    case GEN_TYPE_MBO:
        break;
    case GEN_TYPE_ENUM: {