@@ -11,8 +11,8 @@ use openxr::{
1111 ExtensionSet , FormFactor , FrameStream , FrameWaiter , Graphics , Instance , Session , SystemId ,
1212} ;
1313use surfman:: {
14- Adapter as SurfmanAdapter , Connection as SurfmanConnection , Context as SurfmanContext ,
15- Device as SurfmanDevice , Error as SurfmanError , SurfaceTexture ,
14+ Adapter as SurfmanAdapter , Context as SurfmanContext , Device as SurfmanDevice ,
15+ Error as SurfmanError , SurfaceTexture ,
1616} ;
1717use webxr_api:: Error ;
1818use winapi:: Interface ;
@@ -50,20 +50,23 @@ impl GraphicsProviderMethods<D3D11> for GraphicsProvider {
5050 }
5151
5252 fn create_session (
53+ device : & SurfmanDevice ,
5354 instance : & Instance ,
5455 system : SystemId ,
5556 ) -> Result < ( Session < D3D11 > , FrameWaiter , FrameStream < D3D11 > ) , Error > {
56- // FIXME: We should ensure that the OpenXR runtime's texture will be shareable with
57- // surfman's surfaces by validating the requirements of the XR runtime and ensuring that
58- // the WebGL context can use the same device when `makeXRCompatible` is called.
59- let adapter = create_surfman_adapter ( instance) . ok_or ( Error :: NoMatchingDevice ) ?;
60- let connection = SurfmanConnection :: new ( ) . map_err ( |_| Error :: NoMatchingDevice ) ?;
61- let device = connection
62- . create_device ( & adapter)
63- . map_err ( |_| Error :: NoMatchingDevice ) ?;
57+ // Get the current surfman device and extract its D3D device. This will ensure
58+ // that the OpenXR runtime's texture will be shareable with surfman's surfaces.
6459 let native_device = device. native_device ( ) ;
6560 let d3d_device = native_device. d3d11_device ;
6661
62+ // FIXME: we should be using these graphics requirements to drive the actual
63+ // d3d device creation, rather than assuming the device that surfman
64+ // already created is appropriate. OpenXR returns a validation error
65+ // unless we call this method, so we call it and ignore the results
66+ // in the short term.
67+ let _requirements = D3D11 :: requirements ( instance, system)
68+ . map_err ( |e| Error :: BackendSpecific ( format ! ( "D3D11::requirements {:?}" , e) ) ) ?;
69+
6770 unsafe {
6871 instance
6972 . create_session :: < D3D11 > (
0 commit comments