[Mesa-dev] [PATCH 1/2] intel: decoder: handle 0 sized structs
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Tue Aug 14 00:21:47 UTC 2018
Gen7.5 has a BLEND_STATE of size 0 which includes a variable length
group. We did not deal with that very well, leading to an endless
loop.
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107544
---
src/intel/common/gen_decoder.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c
index ec0a486b101..daaf772a59f 100644
--- a/src/intel/common/gen_decoder.c
+++ b/src/intel/common/gen_decoder.c
@@ -991,7 +991,7 @@ gen_field_iterator_init(struct gen_field_iterator *iter,
iter->p_bit = p_bit;
int length = gen_group_get_length(iter->group, iter->p);
- iter->p_end = length > 0 ? &p[length] : NULL;
+ iter->p_end = length >= 0 ? &p[length] : NULL;
iter->print_colors = print_colors;
}
@@ -1000,16 +1000,32 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
{
/* Initial condition */
if (!iter->field) {
- if (iter->group->fields)
+ if (iter->group->fields) {
+ /* We have an instruction/struct with at least one field. */
iter->field = iter->group->fields;
- else
+ } else if (iter->group->next) {
+ /* We have an instruction/struct with no fields but at least a
+ * group.
+ */
iter->field = iter->group->next->fields;
+ iter->struct_desc =
+ gen_spec_find_struct(iter->group->spec,
+ iter->field->type.gen_struct->name);
+ } else {
+ /* Please fix genxml. */
+ unreachable("Empty struct/instruction");
+ return false;
+ }
bool result = iter_decode_field(iter);
- if (iter->p_end)
- assert(result);
+ if (!result && iter->p_end) {
+ /* We're dealing with a non empty struct of length=0 (BLEND_STATE on
+ * Gen 7.5)
+ */
+ assert(iter->group->dw_length == 0);
+ }
- return true;
+ return result;
}
if (!iter_advance_field(iter))
--
2.18.0
More information about the mesa-dev
mailing list