+static void
+pandecode_texture_payload(mali_ptr payload,
+ enum mali_texture_type type,
+ enum mali_texture_layout layout,
+ bool manual_stride,
+ uint8_t levels,
+ uint16_t depth,
+ uint16_t array_size,
+ struct pandecode_mapped_memory *tmem)
+{
+ pandecode_log(".payload = {\n");
+ pandecode_indent++;
+
+ /* A bunch of bitmap pointers follow.
+ * We work out the correct number,
+ * based on the mipmap/cubemap
+ * properties, but dump extra
+ * possibilities to futureproof */
+
+ int bitmap_count = levels + 1;
+
+ /* Miptree for each face */
+ if (type == MALI_TEX_CUBE)
+ bitmap_count *= 6;
+ else if (type == MALI_TEX_3D && layout == MALI_TEXTURE_LINEAR)
+ bitmap_count *= (depth + 1);
+
+ /* Array of textures */
+ bitmap_count *= (array_size + 1);
+
+ /* Stride for each element */
+ if (manual_stride)
+ bitmap_count *= 2;
+
+ mali_ptr *pointers_and_strides = pandecode_fetch_gpu_mem(tmem,
+ payload, sizeof(mali_ptr) * bitmap_count);
+ for (int i = 0; i < bitmap_count; ++i) {
+ /* How we dump depends if this is a stride or a pointer */
+
+ if (manual_stride && (i & 1)) {
+ /* signed 32-bit snuck in as a 64-bit pointer */
+ uint64_t stride_set = pointers_and_strides[i];
+ uint32_t clamped_stride = stride_set;
+ int32_t stride = clamped_stride;
+ assert(stride_set == clamped_stride);
+ pandecode_log("(mali_ptr) %d /* stride */, \n", stride);
+ } else {
+ char *a = pointer_as_memory_reference(pointers_and_strides[i]);
+ pandecode_log("%s, \n", a);
+ free(a);
+ }
+ }
+
+ pandecode_indent--;
+ pandecode_log("},\n");
+}
+