The Drawing fully immersive content using Metal guide describes how to use Metal for visionOS immersive experiences, but seemingly requires swift to bring up the required CompositorLayer
.
@main
struct MyApp: App {
var body: some Scene {
ImmersiveSpace(id: "MyContent") {
CompositorLayer { layerRenderer in
let renderThread = Thread {
let engine = myEngineCreate(layerRenderer)
myEngineRenderLoop(engine)
}
renderThread.name = "Render Thread"
renderThread.start()
}
}
}
The ImmersiveSpace
scene can presumably be replaced with a call to
[UIApplication.sharedApplication activateSceneSessionForRequest:[UISceneSessionActivationRequest requestWithRole:UISceneSessionRoleImmersiveSpaceApplication] errorHandler:nil]
But is there a replacement for CompositorLayer
? Or some other way to produce a cp_layer_renderer
?
Perhaps it would be possible to write a small swift helper for this, but given the swift interface for CompositorLayer
how would that be tied to an existing UIScene
as created above?
@available(visionOS 1.0, *)
public struct CompositorLayer : SwiftUI.ImmersiveSpaceContent {
public init(configuration: any _CompositorServices_SwiftUI.CompositorLayerConfiguration = .default, renderer: @escaping (CompositorServices.LayerRenderer) -> Swift.Void)
public var body: Swift.Never {
get
}
public typealias Body = Swift.Never
}