[Mesa-dev] [PATCH 2/2] broadcom/genxml: Fix decoding of groups with small fields.

Kenneth Graunke kenneth at whitecape.org
Thu Oct 26 04:17:14 UTC 2017

Groups containing fields smaller than a byte probably not being decoded
correctly.  For example:

    <group count="32" start="32" size="4">
      <field name="Vertex Element Enables" start="0" end="3" type="uint"/>

gen_field_iterator_next would properly walk over each element of the
array, incrementing group_iter.  However, the code to print the actual
values only considered iter->field->start/end, which are 0 and 3 in the
above example.  So it would always fetch bits 3:0 of the current byte,
printing the same value over and over.

Cc: Eric Anholt <eric at anholt.net>
 src/broadcom/cle/v3d_decoder.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Hey Eric,

This patch is totally untested...I assume I need to build vc5, and
I can't do that because I don't have a simulator.  Not even compile
tested.  I figured you had the same bug though, so I'd try and fix it.


diff --git a/src/broadcom/cle/v3d_decoder.c b/src/broadcom/cle/v3d_decoder.c
index 4ac40af05e8..9c457b76068 100644
--- a/src/broadcom/cle/v3d_decoder.c
+++ b/src/broadcom/cle/v3d_decoder.c
@@ -781,8 +781,10 @@ v3d_field_iterator_next(struct v3d_field_iterator *iter)
         const char *enum_name = NULL;
-        int s = iter->field->start;
-        int e = iter->field->end;
+        int group_member_offset =
+                iter_group_offset_bits(iter, iter->group_iter);
+        int s = group_member_offset + iter->field->start;
+        int e = group_member_offset + iter->field->end;
         switch (iter->field->type.kind) {
         case V3D_TYPE_UNKNOWN:

More information about the mesa-dev mailing list