- pandecode_msg("size: (%d, %d, %d)\n",
- bits(p->invocation_count, 0, p->size_y_shift) + 1,
- bits(p->invocation_count, p->size_y_shift, p->size_z_shift) + 1,
- bits(p->invocation_count, p->size_z_shift,
- p->workgroups_x_shift) + 1);
- pandecode_msg("workgroups: (%d, %d, %d)\n",
- bits(p->invocation_count, p->workgroups_x_shift,
- p->workgroups_y_shift) + 1,
- bits(p->invocation_count, p->workgroups_y_shift,
- p->workgroups_z_shift) + 1,
- bits(p->invocation_count, p->workgroups_z_shift,
- 32) + 1);
+
+ unsigned size_x = bits(p->invocation_count, 0, p->size_y_shift) + 1;
+ unsigned size_y = bits(p->invocation_count, p->size_y_shift, p->size_z_shift) + 1;
+ unsigned size_z = bits(p->invocation_count, p->size_z_shift, p->workgroups_x_shift) + 1;
+
+ unsigned groups_x = bits(p->invocation_count, p->workgroups_x_shift, p->workgroups_y_shift) + 1;
+ unsigned groups_y = bits(p->invocation_count, p->workgroups_y_shift, p->workgroups_z_shift) + 1;
+ unsigned groups_z = bits(p->invocation_count, p->workgroups_z_shift, 32) + 1;
+
+ /* Even though we have this decoded, we want to ensure that the
+ * representation is "unique" so we don't lose anything by printing only
+ * the final result. More specifically, we need to check that we were
+ * passed something in canonical form, since the definition per the
+ * hardware is inherently not unique. How? Well, take the resulting
+ * decode and pack it ourselves! If it is bit exact with what we
+ * decoded, we're good to go. */
+
+ struct mali_vertex_tiler_prefix ref;
+ panfrost_pack_work_groups_compute(&ref, groups_x, groups_y, groups_z, size_x, size_y, size_z, noninstanced);
+
+ bool canonical =
+ (p->invocation_count == ref.invocation_count) &&
+ (p->size_y_shift == ref.size_y_shift) &&
+ (p->size_z_shift == ref.size_z_shift) &&
+ (p->workgroups_x_shift == ref.workgroups_x_shift) &&
+ (p->workgroups_y_shift == ref.workgroups_y_shift) &&
+ (p->workgroups_z_shift == ref.workgroups_z_shift) &&
+ (p->workgroups_x_shift_2 == ref.workgroups_x_shift_2);
+
+ if (!canonical) {
+ pandecode_msg("XXX: non-canonical workgroups packing\n");
+ pandecode_msg("expected: %X, %d, %d, %d, %d, %d\n",
+ ref.invocation_count,
+ ref.size_y_shift,
+ ref.size_z_shift,
+ ref.workgroups_x_shift,
+ ref.workgroups_y_shift,
+ ref.workgroups_z_shift,
+ ref.workgroups_x_shift_2);
+
+ pandecode_prop("invocation_count = 0x%" PRIx32, p->invocation_count);
+ pandecode_prop("size_y_shift = %d", p->size_y_shift);
+ pandecode_prop("size_z_shift = %d", p->size_z_shift);
+ pandecode_prop("workgroups_x_shift = %d", p->workgroups_x_shift);
+ pandecode_prop("workgroups_y_shift = %d", p->workgroups_y_shift);
+ pandecode_prop("workgroups_z_shift = %d", p->workgroups_z_shift);
+ pandecode_prop("workgroups_x_shift_2 = %d", p->workgroups_x_shift_2);
+ }
+
+ /* Regardless, print the decode */
+ pandecode_msg("size (%d, %d, %d), count (%d, %d, %d)\n",
+ size_x, size_y, size_z,
+ groups_x, groups_y, groups_z);