+ bo->meta.num_planes = num_planes;
+
+ for (i = 0; i < num_planes; ++i) {
+ int prime_fd, stride, offset;
+ plane_image = dri->image_extension->fromPlanar(bo->priv, i, NULL);
+ __DRIimage *image = plane_image ? plane_image : bo->priv;
+
+ if (i)
+ bo->meta.format_modifiers[i] = bo->meta.format_modifiers[0];
+
+ if (!dri->image_extension->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride) ||
+ !dri->image_extension->queryImage(image, __DRI_IMAGE_ATTRIB_OFFSET, &offset)) {
+ ret = -errno;
+ goto cleanup;
+ }
+
+ if (!dri->image_extension->queryImage(image, __DRI_IMAGE_ATTRIB_FD, &prime_fd)) {
+ ret = -errno;
+ goto cleanup;
+ }
+
+ dmabuf_sizes[i] = lseek(prime_fd, 0, SEEK_END);
+ if (dmabuf_sizes[i] == (off_t)-1) {
+ ret = -errno;
+ close(prime_fd);
+ goto cleanup;
+ }
+
+ lseek(prime_fd, 0, SEEK_SET);
+
+ ret = drmPrimeFDToHandle(bo->drv->fd, prime_fd, &handle);
+
+ close(prime_fd);
+
+ if (ret) {
+ drv_log("drmPrimeFDToHandle failed with %s\n", strerror(errno));
+ goto cleanup;
+ }
+
+ bo->handles[i].u32 = handle;
+
+ bo->meta.strides[i] = stride;
+ bo->meta.offsets[i] = offset;
+
+ if (plane_image)
+ dri->image_extension->destroyImage(plane_image);