<div dir="ltr">Tested-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 19, 2017 at 4:55 PM, Rafael Antognolli <span dir="ltr"><<a href="mailto:rafael.antognolli@intel.com" target="_blank">rafael.antognolli@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Before this commit, when a group with count="0" is found, only one field<br>
is added to the struct representing the instruction. This causes only<br>
one entry to be printed by aubinator, for variable length groups.<br>
<br>
With this commit we "detect" that there's a variable length group<br>
(count="0") and store the offset of the last entry added to the struct<br>
when reading the xml. When finally reading the aubdump file, we check<br>
the size of the group and whether we have variable number of elements,<br>
and in that case, reuse the last field to add the remaining elements.<br>
<br>
Signed-off-by: Rafael Antognolli <<a href="mailto:rafael.antognolli@intel.com">rafael.antognolli@intel.com</a>><br>
---<br>
src/intel/common/gen_decoder.c | 35 +++++++++++++++++++++++++++++-<wbr>-----<br>
src/intel/common/gen_decoder.h | 6 ++++++-<br>
src/intel/tools/aubinator.c | 19 +++++++++++++++++++-<br>
3 files changed, 54 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/intel/common/gen_<wbr>decoder.c b/src/intel/common/gen_<wbr>decoder.c<br>
index e3327d3..15bba32 100644<br>
--- a/src/intel/common/gen_<wbr>decoder.c<br>
+++ b/src/intel/common/gen_<wbr>decoder.c<br>
@@ -190,6 +190,8 @@ create_group(struct parser_context *ctx, const char *name, const char **atts)<br>
group->spec = ctx->spec;<br>
group->group_offset = 0;<br>
group->group_count = 0;<br>
+ group->variable_offset = 0;<br>
+ group->variable = false;<br>
<br>
return group;<br>
}<br>
@@ -210,16 +212,22 @@ create_enum(struct parser_context *ctx, const char *name, const char **atts)<br>
<br>
static void<br>
get_group_offset_count(struct parser_context *ctx, const char *name,<br>
- const char **atts, uint32_t *offset, uint32_t *count)<br>
+ const char **atts, uint32_t *offset, uint32_t *count,<br>
+ uint32_t *elem_size, bool *variable)<br>
{<br>
char *p;<br>
int i;<br>
<br>
for (i = 0; atts[i]; i += 2) {<br>
- if (strcmp(atts[i], "count") == 0)<br>
+ if (strcmp(atts[i], "count") == 0) {<br>
*count = strtoul(atts[i + 1], &p, 0);<br>
- else if (strcmp(atts[i], "start") == 0)<br>
+ if (*count == 0)<br>
+ *variable = true;<br>
+ } else if (strcmp(atts[i], "start") == 0) {<br>
*offset = strtoul(atts[i + 1], &p, 0);<br>
+ } else if (strcmp(atts[i], "size") == 0) {<br>
+ *elem_size = strtoul(atts[i + 1], &p, 0);<br>
+ }<br>
}<br>
return;<br>
}<br>
@@ -331,8 +339,11 @@ create_field(struct parser_context *ctx, const char **atts)<br>
field->start = ctx->group->group_offset+<wbr>strtoul(atts[i + 1], &p, 0);<br>
else if (strcmp(atts[i], "end") == 0) {<br>
field->end = ctx->group->group_offset+<wbr>strtoul(atts[i + 1], &p, 0);<br>
- if (ctx->group->group_offset)<br>
+ if (ctx->group->group_offset) {<br>
ctx->group->group_offset = field->end+1;<br>
+ if (ctx->group->variable)<br>
+ ctx->group->variable_offset = ctx->group->group_offset;<br>
+ }<br>
} else if (strcmp(atts[i], "type") == 0)<br>
field->type = string_to_type(ctx, atts[i + 1]);<br>
else if (strcmp(atts[i], "default") == 0 &&<br>
@@ -400,7 +411,8 @@ start_element(void *data, const char *element_name, const char **atts)<br>
get_register_offset(atts, &ctx->group->register_offset);<br>
} else if (strcmp(element_name, "group") == 0) {<br>
get_group_offset_count(ctx, name, atts, &ctx->group->group_offset,<br>
- &ctx->group->group_count);<br>
+ &ctx->group->group_count, &ctx->group->elem_size,<br>
+ &ctx->group->variable);<br>
} else if (strcmp(element_name, "field") == 0) {<br>
do {<br>
ctx->fields[ctx->nfields++] = create_field(ctx, atts);<br>
@@ -734,6 +746,8 @@ gen_field_iterator_init(struct gen_field_iterator *iter,<br>
iter->p = p;<br>
iter->i = 0;<br>
iter->print_colors = print_colors;<br>
+ iter->repeat = false;<br>
+ iter->addr_inc = 0;<br>
}<br>
<br>
static const char *<br>
@@ -755,8 +769,17 @@ gen_field_iterator_next(struct gen_field_iterator *iter)<br>
float f;<br>
} v;<br>
<br>
- if (iter->i == iter->group->nfields)<br>
+ if (iter->i == iter->group->nfields) {<br>
+ if (iter->group->group_size > 0) {<br>
+ int iter_length = iter->group->elem_size;<br>
+<br>
+ iter->group->group_size -= iter_length / 32;<br>
+ iter->addr_inc += iter_length;<br>
+ iter->dword = (iter->field->start + iter->addr_inc) / 32;<br>
+ return true;<br>
+ }<br>
return false;<br>
+ }<br>
<br>
iter->field = iter->group->fields[iter->i++]<wbr>;<br>
iter->name = iter->field->name;<br>
diff --git a/src/intel/common/gen_<wbr>decoder.h b/src/intel/common/gen_<wbr>decoder.h<br>
index 870bd7f..4f4295f 100644<br>
--- a/src/intel/common/gen_<wbr>decoder.h<br>
+++ b/src/intel/common/gen_<wbr>decoder.h<br>
@@ -61,6 +61,8 @@ struct gen_field_iterator {<br>
int i;<br>
struct gen_field *field;<br>
bool print_colors;<br>
+ bool repeat;<br>
+ uint32_t addr_inc;<br>
};<br>
<br>
struct gen_group {<br>
@@ -69,6 +71,10 @@ struct gen_group {<br>
int nfields;<br>
struct gen_field **fields;<br>
uint32_t group_offset, group_count;<br>
+ uint32_t elem_size;<br>
+ uint32_t variable_offset;<br>
+ bool variable;<br>
+ uint32_t group_size;<br>
<br>
uint32_t opcode_mask;<br>
uint32_t opcode;<br>
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c<br>
index f1bedd2..53b2a27 100644<br>
--- a/src/intel/tools/aubinator.c<br>
+++ b/src/intel/tools/aubinator.c<br>
@@ -95,10 +95,28 @@ valid_offset(uint32_t offset)<br>
return offset < gtt_end;<br>
}<br>
<br>
+/**<br>
+ * Set group variable size for groups with count="0".<br>
+ *<br>
+ * By default the group size is fixed and not needed because the struct<br>
+ * describing a group knows the number of elements. However, for groups with<br>
+ * count="0" we have a variable number of elements, and the struct describing<br>
+ * the group only includes one of them. So we calculate the remaining size of<br>
+ * the group based on the size we get here, and the offset after the last<br>
+ * element added to the group.<br>
+ */<br>
+static void<br>
+group_set_size(struct gen_group *strct, uint32_t size)<br>
+{<br>
+ if (strct->variable && strct->elem_size)<br>
+ strct->group_size = size - (strct->variable_offset / 32);<br>
+}<br>
+<br>
static void<br>
decode_group(struct gen_group *strct, const uint32_t *p, int starting_dword)<br>
{<br>
uint64_t offset = option_print_offsets ? (void *) p - gtt : 0;<br>
+<br>
gen_print_group(outfile, strct, offset, p, option_color == COLOR_ALWAYS);<br>
}<br>
<br>
@@ -722,6 +740,7 @@ parse_commands(struct gen_spec *spec, uint32_t *cmds, int size, int engine)<br>
gen_group_get_name(inst), reset_color);<br>
<br>
if (option_full_decode) {<br>
+ group_set_size(inst, length);<br>
decode_group(inst, p, 0);<br>
<br>
for (i = 0; i < ARRAY_LENGTH(custom_handlers); i++) {<br>
<span class="HOEnZb"><font color="#888888">--<br>
git-series 0.9.1<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>