- /* Add the usage flags in, since they can change across the CSO
- * lifetime due to layout switches */
-
- view->hw.format.layout = panfrost_layout_for_texture(rsrc);
- view->hw.format.manual_stride = has_manual_stride;
-
- /* Inject the addresses in, interleaving array indices, mip levels,
- * cube faces, and strides in that order */
-
- unsigned idx = 0;
- unsigned levels = 1 + last_level - first_level;
- unsigned layers = 1 + last_layer - first_layer;
- unsigned faces = 1 + last_face - first_face;
- unsigned num_elements = levels * layers * faces;
- if (has_manual_stride)
- num_elements *= 2;
-
- descriptor = malloc(sizeof(struct mali_texture_descriptor) +
- sizeof(mali_ptr) * num_elements);
- memcpy(descriptor, &view->hw, sizeof(struct mali_texture_descriptor));
-
- mali_ptr *pointers_and_strides = descriptor +
- sizeof(struct mali_texture_descriptor);
-
- for (unsigned w = first_layer; w <= last_layer; ++w) {
- for (unsigned l = first_level; l <= last_level; ++l) {
- for (unsigned f = first_face; f <= last_face; ++f) {
- pointers_and_strides[idx++] =
- panfrost_get_texture_address(rsrc, l, w * face_mult + f)
- + afbc_bit + view->astc_stretch;
- if (has_manual_stride) {
- pointers_and_strides[idx++] =
- rsrc->slices[l].stride;
- }
- }
- }
- }
-
- descriptor_gpu = panfrost_upload_transient(batch, descriptor,
- sizeof(struct mali_texture_descriptor) +
- num_elements * sizeof(*pointers_and_strides));
- free(descriptor);