Auto merge of #23945 - Manishearth:hl-xr-immersive, r=asajeffrey

Immersive WebXR on Hololens

This PR adds support to the OpenXR backend (https://github.com/servo/webxr/pull/37) for Hololens. We support _entering_ immersive mode, but currently do nothing in immersive mode (https://github.com/servo/webxr/issues/38, applying https://github.com/servo/webxr/tree/d3d11-draw should render some red).

This should be ready to land as-is aside from its dependency on https://github.com/servo/servo/pull/23922. It can be tested on https://manishearth.github.io/webgl-to-webxr/webxr-ar.html (make sure to click through the alerts).

This is based on https://github.com/servo/servo/pull/23922 .

This builds off of @paulrouget's work.

r? @jdm @paulrouget

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23945)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-08-13 00:38:57 -04:00 committed by GitHub
commit 9b24798390
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 154 additions and 19 deletions

45
Cargo.lock generated
View file

@ -3307,6 +3307,26 @@ dependencies = [
"vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "openxr"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
"openxr-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "openxr-sys"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ordered-float"
version = "1.0.0"
@ -3331,7 +3351,7 @@ name = "osmesa-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -4558,7 +4578,7 @@ dependencies = [
[[package]]
name = "shared_library"
version = "0.1.8"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -4594,6 +4614,7 @@ dependencies = [
"libservo 0.0.1",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"servo-media 0.1.0 (git+https://github.com/servo/media)",
"webxr 0.0.1 (git+https://github.com/servo/webxr)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -5671,7 +5692,7 @@ dependencies = [
[[package]]
name = "webxr"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#f67b762424af7c75c0bbce817d0e55ff51baf4cc"
source = "git+https://github.com/servo/webxr#affa222d3c187f40ed3f6e91752f1f2e3f583dc6"
dependencies = [
"bindgen 0.49.2 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5679,13 +5700,16 @@ dependencies = [
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
"glutin 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"openxr 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "webxr-api"
version = "0.0.1"
source = "git+https://github.com/servo/webxr#f67b762424af7c75c0bbce817d0e55ff51baf4cc"
source = "git+https://github.com/servo/webxr#affa222d3c187f40ed3f6e91752f1f2e3f583dc6"
dependencies = [
"euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)",
"gleam 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5778,6 +5802,14 @@ dependencies = [
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wio"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wr_malloc_size_of"
version = "0.0.1"
@ -6150,6 +6182,8 @@ dependencies = [
"checksum opaque-debug 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "51ecbcb821e1bd256d456fe858aaa7f380b63863eab2eb86eee1bd9f33dd6682"
"checksum openssl 0.10.11 (registry+https://github.com/rust-lang/crates.io-index)" = "6c24d3508b4fb6da175c10baac54c578b33f09c89ae90c6fe9788b3b4768efdc"
"checksum openssl-sys 0.9.35 (registry+https://github.com/rust-lang/crates.io-index)" = "912f301a749394e1025d9dcddef6106ddee9252620e6d0a0e5f8d0681de9b129"
"checksum openxr 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bd30879fa0a4815c204a199a06f08826c892208e6d93617194bd5a9e0b12e9e0"
"checksum openxr-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "875181a679f13b1b7c6b37b7f221c11a9cabc67a51399bc8051165d2c03a17a0"
"checksum ordered-float 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e9a3c8db0fca1fdb34404f0b1286db252f23930b9f7a481e376c16c0d5c309d4"
"checksum ordermap 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063"
"checksum osmesa-src 0.1.0 (git+https://github.com/servo/osmesa-src)" = "<none>"
@ -6241,7 +6275,7 @@ dependencies = [
"checksum servo_media_derive 0.1.0 (git+https://github.com/servo/media)" = "<none>"
"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68"
"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d"
"checksum shared_library 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8254bf098ce4d8d7cc7cc6de438c5488adc5297e5b7ffef88816c0a91bd289c1"
"checksum shared_library 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5a9e7e0f2bfae24d8a5b5a66c5b257a83c7412304311512a0c054cd5e619da11"
"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
"checksum sig 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6567e29578f9bfade6a5d94a32b9a4256348358d2a3f448cab0021f9a02614a2"
"checksum signpost 0.1.0 (git+https://github.com/pcwalton/signpost.git)" = "<none>"
@ -6343,6 +6377,7 @@ dependencies = [
"checksum wincolor 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "561ed901ae465d6185fa7864d63fbd5720d0ef718366c9a4dc83cf6170d7e9ba"
"checksum winit 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d233301129ddd33260b47f76900b50e154b7254546e2edba0e5468a1a5fe4de3"
"checksum winres 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "27d9192d6356d7efe8405dec6c5506b67543cf64b6049968f39f4c4623b4f25d"
"checksum wio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
"checksum wr_malloc_size_of 0.0.1 (git+https://github.com/servo/webrender)" = "<none>"
"checksum ws 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ec91ea61b83ce033c43c06c52ddc7532f465c0153281610d44c58b74083aee1a"
"checksum x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5c4ac579b5d324dc4add02312b5d0e3e0218521e2d5779d526ac39ee4bb171"

View file

@ -156,10 +156,6 @@ impl XRMethods for XR {
comp: InCompartment,
) -> Rc<Promise> {
let promise = Promise::new_in_current_compartment(&self.global(), comp);
if mode != XRSessionMode::Immersive_vr {
promise.reject_error(Error::NotSupported);
return promise;
}
if self.pending_or_active_session() {
promise.reject_error(Error::InvalidState);

View file

@ -10,7 +10,9 @@ publish = false
libservo = { path = "../../../components/servo" }
log = "0.4"
servo-media = { git = "https://github.com/servo/media" }
webxr-api = { git = "https://github.com/servo/webxr" }
webxr-api = { git = "https://github.com/servo/webxr", features = ["ipc"] }
webxr = { git = "https://github.com/servo/webxr" , optional = true}
[target.'cfg(not(target_os = "macos"))'.dependencies]
libc = "0.2"
@ -44,5 +46,5 @@ no_static_freetype = ["libservo/no_static_freetype"]
no_wgl = ["libservo/no_wgl"]
oculusvr = ["libservo/oculusvr"]
webdriver = ["libservo/webdriver"]
uwp = ["libservo/uwp"]
uwp = ["libservo/uwp", "webxr", "webxr/openxr-api"]
webgl_backtrace = ["libservo/webgl_backtrace"]

View file

@ -189,8 +189,8 @@ pub fn init(
gl.finish();
let window_callbacks = Rc::new(ServoWindowCallbacks {
gl: gl.clone(),
host_callbacks: callbacks,
gl: gl.clone(),
coordinates: RefCell::new(init_opts.coordinates),
density: init_opts.density,
gl_context_pointer: init_opts.gl_context_pointer,
@ -201,6 +201,7 @@ pub fn init(
vr_init: init_opts.vr_init,
xr_discovery: init_opts.xr_discovery,
waker,
gl: gl.clone(),
});
let servo = Servo::new(embedder_callbacks, window_callbacks.clone());
@ -581,6 +582,8 @@ struct ServoEmbedderCallbacks {
waker: Box<dyn EventLoopWaker>,
xr_discovery: Option<Box<dyn webxr_api::Discovery>>,
vr_init: VRInitOptions,
#[allow(unused)]
gl: Rc<dyn gl::Gl>,
}
struct ServoWindowCallbacks {
@ -611,6 +614,19 @@ impl EmbedderMethods for ServoEmbedderCallbacks {
}
}
#[cfg(feature = "uwp")]
fn register_webxr(&mut self, registry: &mut webxr_api::MainThreadRegistry) {
debug!("EmbedderMethods::register_xr");
assert!(
self.xr_discovery.is_none(),
"UWP builds should not be initialized with a WebXR Discovery object"
);
let gl = self.gl.clone();
let discovery = webxr::openxr::OpenXrDiscovery::new(gl);
registry.register(discovery);
}
#[cfg(not(feature = "uwp"))]
fn register_webxr(&mut self, registry: &mut webxr_api::MainThreadRegistry) {
debug!("EmbedderMethods::register_xr");
if let Some(discovery) = self.xr_discovery.take() {

View file

@ -696,6 +696,12 @@ class MachCommands(CommandBase):
if not package_gstreamer_dlls(env, servo_exe_dir, target_triple, uwp):
status = 1
if uwp:
# copy needed openxr DLLs in to servo.exe dir
print("Packaging openxr DLLs")
if not self.package_openxr_dlls(env, servo_exe_dir, target_triple):
status = 1
# UWP app packaging already bundles all required DLLs for us.
print("Packaging MSVC DLLs")
if not package_msvc_dlls(servo_exe_dir, target_triple, vcinstalldir, vs_version):
@ -746,6 +752,29 @@ class MachCommands(CommandBase):
opts += params
return check_call(["cargo", "clean"] + opts, env=self.build_env(), verbose=verbose)
def package_openxr_dlls(self, env, servo_exe_dir, target):
target_arch = target.split('-')[0]
if target_arch == "aarch64":
arch = "arm64"
elif target_arch == "x64":
arch = "x64"
else:
print("ERROR: We do not have openxr_loader DLLs for %s" % target_arch)
return False
# The package on S3 contains both debug and release DLLs, but
# by default we only use release DLLs. If you need to debug OpenXR itself,
# change this to Debug.
dll_path = os.path.join(self.msvc_package_dir("openxr-loader-uwp"), arch, "Release", "openxr_loader.dll")
try:
shutil.copy(dll_path, servo_exe_dir)
except:
print("ERROR: Could not find %s" % dll_path)
return False
return True
def gstreamer_root(target, env):
arch = {

View file

@ -9,4 +9,5 @@ WINDOWS_MSVC = {
"ninja": "1.7.1",
"openssl": "111.3.0+1.1.1c-vs2017",
"gstreamer-uwp": "1.16.0.3",
"openxr-loader-uwp": "1.0",
}

4
support/hololens/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/Generated Files
ServoApp.vcxproj.user
bin
obj

View file

@ -173,6 +173,9 @@
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\debug\openxr_loader.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\debug\libcrypto.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
</None>
@ -188,6 +191,9 @@
<None Include="..\..\..\target\aarch64-pc-windows-msvc\debug\vcruntime140.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\release\openxr_loader.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\release\libcrypto.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
</None>
@ -221,6 +227,13 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</DeploymentContent>
</None>
<None Include="..\..\..\target\debug\openxr_loader.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">false</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</DeploymentContent>
</None>
<None Include="..\..\..\target\debug\libcrypto.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</DeploymentContent>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
@ -236,6 +249,9 @@
</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
</None>
<None Include="..\..\..\target\release\openxr_loader.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
</None>
<None Include="..\..\..\target\release\libcrypto.dll">
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</DeploymentContent>
</None>

View file

@ -90,6 +90,9 @@
<None Include="Content\VertexShaderShared.hlsl">
<Filter>Content</Filter>
</None>
<None Include="..\..\..\target\debug\openxr_loader.dll">
<Filter>DebugServoDLLs</Filter>
</None>
<None Include="..\..\..\target\debug\libcrypto.dll">
<Filter>DebugServoDLLs</Filter>
</None>
@ -102,12 +105,18 @@
<None Include="..\..\..\target\debug\simpleservo.dll">
<Filter>DebugServoDLLs</Filter>
</None>
<None Include="..\..\..\target\release\openxr_loader.dll">
<Filter>ReleaseServoDLLs</Filter>
</None>
<None Include="..\..\..\target\release\libcrypto.dll">
<Filter>ReleaseServoDLLs</Filter>
</None>
<None Include="..\..\..\target\release\libssl.dll">
<Filter>ReleaseServoDLLs</Filter>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\debug\openxr_loader.dll">
<Filter>DebugARM64ServoDLLs</Filter>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\debug\libcrypto.dll">
<Filter>DebugARM64ServoDLLs</Filter>
</None>
@ -117,6 +126,9 @@
<None Include="..\..\..\target\aarch64-pc-windows-msvc\debug\simpleservo.dll">
<Filter>DebugARM64ServoDLLs</Filter>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\release\openxr_loader.dll">
<Filter>ReleaseARM64ServoDLLs</Filter>
</None>
<None Include="..\..\..\target\aarch64-pc-windows-msvc\release\libcrypto.dll">
<Filter>ReleaseARM64ServoDLLs</Filter>
</None>

View file

@ -0,0 +1,29 @@
REM USAGE
REM Clone https://github.com/microsoft/OpenXR-SDK-VisualStudio, open the openxr_loader_uwp project
REM Change the project output type to a dynamic library
REM Build it for Debug/Release x64/ARM64
REM create-openxr-package path\to\outputdir path\to\OpenXR-SDK-VisualStudio
REM name the outputdir openxr-loader-uwp-versionnumber and zip it
cd %1
mkdir arm64
mkdir arm64\Debug
cd arm64\Debug
copy %2\bin\Debug\ARM64\openxr_loader_uwp\* .
ren *.* openxr_loader.*
cd ..
mkdir Release
cd Release
copy %2\bin\Release\ARM64\openxr_loader_uwp\* .
ren *.* openxr_loader.*
cd ..\..
mkdir x64
mkdir x64\Debug
cd x64\Debug
copy %2\bin\Debug\x64\openxr_loader_uwp\* .
ren *.* openxr_loader.*
cd ..
mkdir Release
cd Release
copy %2\bin\Release\x64\openxr_loader_uwp\* .
ren *.* openxr_loader.*

View file

@ -26,9 +26,6 @@
[Non-immersive session supports local space when required]
expected: FAIL
[Non-immersive session supports viewer space by default]
expected: FAIL
[Non-immersive session rejects local space if not requested]
expected: FAIL

View file

@ -2,6 +2,3 @@
[Identity reference space provides correct poses for immersive sessions]
expected: FAIL
[Identity reference space provides correct poses for inline sessions]
expected: FAIL

View file

@ -1,4 +1,5 @@
[xrWebGLLayer_constructor.https.html]
expected: ERROR
[Ensure that XRWebGLLayer's constructor throws appropriate errors]
expected: FAIL
expected: TIMEOUT