+ whandle->stride = rsc->slices[0].stride;
+
+ /* If we're passing some reference to our BO out to some other part of
+ * the system, then we can't do any optimizations about only us being
+ * the ones seeing it (like BO caching or shadow update avoidance).
+ */
+ rsc->bo->private = false;
+
+ switch (whandle->type) {
+ case DRM_API_HANDLE_TYPE_SHARED:
+ if (screen->ro) {
+ /* This could probably be supported, assuming that a
+ * control node was used for pl111.
+ */
+ fprintf(stderr, "flink unsupported with pl111\n");
+ return FALSE;
+ }
+
+ return vc4_bo_flink(rsc->bo, &whandle->handle);
+ case DRM_API_HANDLE_TYPE_KMS:
+ if (screen->ro && renderonly_get_handle(rsc->scanout, whandle))
+ return TRUE;
+ whandle->handle = rsc->bo->handle;
+ return TRUE;
+ case DRM_API_HANDLE_TYPE_FD:
+ /* FDs are cross-device, so we can export directly from vc4.
+ */
+ whandle->handle = vc4_bo_get_dmabuf(rsc->bo);
+ return whandle->handle != -1;
+ }