[Mesa-dev] [PATCH] intel/decoder: Use 'DWord Length' and 'bias' fields for packet length.

Toni Lönnberg toni.lonnberg at intel.com
Fri Oct 26 13:07:27 UTC 2018


Use the 'DWord Length' and 'bias' fields from the instruction definition to
parse the packet length from the command stream when possible. The hardcoded
mechanism is used whenever an instruction doesn't have this field.
---
 src/intel/common/gen_decoder.c | 16 ++++++++++++++--
 src/intel/common/gen_decoder.h |  1 +
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index 5f6e7a0b808..2d58708f5dd 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -163,11 +163,15 @@ create_group(struct parser_context *ctx,
    group->spec = ctx->spec;
    group->variable = false;
    group->fixed_length = fixed_length;
+   group->dw_length = 0;
+   group->bias = 1;
 
    for (int i = 0; atts[i]; i += 2) {
       char *p;
       if (strcmp(atts[i], "length") == 0) {
          group->dw_length = strtoul(atts[i + 1], &p, 0);
+      } else if (strcmp(atts[i], "bias") == 0) {
+         group->bias = strtoul(atts[i + 1], &p, 0);
       }
    }
 
@@ -743,8 +747,16 @@ gen_group_find_field(struct gen_group *group, const char *name)
 int
 gen_group_get_length(struct gen_group *group, const uint32_t *p)
 {
-   if (group && group->fixed_length)
-      return group->dw_length;
+   if (group) {
+      if (group->fixed_length)
+         return group->dw_length;
+      else {
+         struct gen_field *field = gen_group_find_field(group, "DWord Length");
+         if (field) {
+            return field_value(p[0], field->start, field->end) + group->bias;
+         }
+      }
+   }
 
    uint32_t h = p[0];
    uint32_t type = field_value(h, 29, 31);
diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h
index a80c50b6647..0b33eb32cfc 100644
--- a/src/intel/common/gen_decoder.h
+++ b/src/intel/common/gen_decoder.h
@@ -101,6 +101,7 @@ struct gen_group {
    struct gen_field *fields; /* linked list of fields */
 
    uint32_t dw_length;
+   uint32_t bias; /* <instruction> specific */
    uint32_t group_offset, group_count;
    uint32_t group_size;
    bool variable; /* <group> specific */
-- 
2.17.1



More information about the mesa-dev mailing list