Use an appropriate graphics adapter when openxr is present.

This commit is contained in:
Josh Matthews 2020-05-08 17:30:50 -04:00
parent 50e05a83b4
commit cacefbad17
2 changed files with 21 additions and 7 deletions

View file

@ -40,6 +40,7 @@ use std::mem;
use std::os::raw::c_void;
use std::path::PathBuf;
use std::rc::Rc;
use surfman::Adapter;
use surfman::Connection;
use surfman::SurfaceType;
@ -211,9 +212,12 @@ pub fn init(
// Initialize surfman
let connection = Connection::new().or(Err("Failed to create connection"))?;
let adapter = connection
.create_adapter()
.or(Err("Failed to create adapter"))?;
let adapter = match create_adapter() {
Some(adapter) => adapter,
None => connection
.create_adapter()
.or(Err("Failed to create adapter"))?,
};
let native_widget = unsafe {
connection.create_native_widget_from_ptr(
init_opts.native_widget,
@ -950,3 +954,13 @@ impl ResourceReaderMethods for ResourceReaderInstance {
vec![]
}
}
#[cfg(feature = "uwp")]
fn create_adapter() -> Option<Adapter> {
webxr::openxr::create_surfman_adapter()
}
#[cfg(not(feature = "uwp"))]
fn create_adapter() -> Option<Adapter> {
None
}