Skip to content
Permalink
Browse files

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

Immersive WebXR on Hololens

This PR adds support to the OpenXR backend (servo/webxr#37) for Hololens. We support _entering_ immersive mode, but currently do nothing in immersive mode (servo/webxr#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 #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 #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 -->
  • Loading branch information...
bors-servo committed Aug 13, 2019
2 parents 9b4b022 + c879ce0 commit 9b247983902d1fca945a0caff029c42d13c846e7

Some generated files are not rendered by default. Learn more.

@@ -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);
@@ -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"]
@@ -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() {
@@ -696,6 +696,12 @@ def package_generated_shared_libraries(libs, build_path, servo_exe_dir):
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 @@ def clean(self, manifest_path=None, params=[], verbose=False):
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 = {
@@ -9,4 +9,5 @@
"ninja": "1.7.1",
"openssl": "111.3.0+1.1.1c-vs2017",
"gstreamer-uwp": "1.16.0.3",
"openxr-loader-uwp": "1.0",
}
@@ -0,0 +1,4 @@
/Generated Files
ServoApp.vcxproj.user
bin
obj
@@ -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>
@@ -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>
@@ -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.*
@@ -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

@@ -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

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

0 comments on commit 9b24798

Please sign in to comment.
You can’t perform that action at this time.