Auto merge of #26476 - jdm:xr-emulator-surfman, r=Manishearth

Use an appropriate graphics adapter when openxr is present.

The surfman upgrade broke our fragile process of choosing a graphics adapter that is always compatible with openxr. These changes ensure that won't happen in the future.

Depends on https://github.com/servo/webxr/pull/174.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #26474
- [x] These changes do not require tests because we can't test the emulator configuration
This commit is contained in:
bors-servo 2020-05-12 16:40:06 -04:00 committed by GitHub
commit bd6100be03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

8
Cargo.lock generated
View file

@ -5576,7 +5576,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",
@ -5592,6 +5592,7 @@ dependencies = [
"libc",
"log",
"mach",
"metal",
"objc",
"parking_lot",
"wayland-sys 0.24.0",
@ -6470,7 +6471,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",
@ -6493,7 +6494,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",
@ -6501,7 +6502,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
}