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

View file

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