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

8
Cargo.lock generated
View file

@ -5554,7 +5554,7 @@ dependencies = [
[[package]]
name = "surfman"
version = "0.2.0"
source = "git+https://github.com/servo/surfman#41ac1ee64bc2d1978aeed0f8bf549c57f20ec7c8"
source = "git+https://github.com/servo/surfman#bc084411664b04dba777659e5ce16b5f95b7371a"
dependencies = [
"bitflags",
"cfg_aliases",
@ -5570,6 +5570,7 @@ dependencies = [
"libc",
"log",
"mach",
"metal",
"objc",
"parking_lot",
"wayland-sys 0.24.0",
@ -6446,7 +6447,7 @@ dependencies = [
[[package]]
name = "webxr"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#755a872672c80d71651a305600b97526952d5293"
source = "git+https://github.com/servo/webxr#e30ebd848c4deb95833c2fea91d7d8d34f6d8ed8"
dependencies = [
"android_injected_glue",
"bindgen",
@ -6469,7 +6470,7 @@ dependencies = [
[[package]]
name = "webxr-api"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#755a872672c80d71651a305600b97526952d5293"
source = "git+https://github.com/servo/webxr#e30ebd848c4deb95833c2fea91d7d8d34f6d8ed8"
dependencies = [
"euclid",
"ipc-channel",
@ -6477,7 +6478,6 @@ dependencies = [
"serde",
"surfman-chains-api",
"time",
"winit",
]
[[package]]

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
}