Get XR sessions to track the draw texture, so we render the XR framebuffer rather than the default canvas framebuffer

This commit is contained in:
Alan Jeffrey 2019-07-25 18:09:53 -05:00 committed by Josh Matthews
parent b9b01764fb
commit c757a9c009
9 changed files with 47 additions and 34 deletions

30
Cargo.lock generated
View file

@ -411,7 +411,7 @@ dependencies = [
"webrender 0.60.0 (git+https://github.com/servo/webrender)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -432,7 +432,7 @@ dependencies = [
"typetag 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -622,7 +622,7 @@ dependencies = [
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr 0.0.1",
"webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -665,7 +665,7 @@ dependencies = [
"style_traits 0.0.1",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -1088,7 +1088,7 @@ dependencies = [
"servo_url 0.0.1",
"style_traits 0.0.1",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -2538,7 +2538,7 @@ dependencies = [
"webrender_traits 0.0.1",
"webvr 0.0.1",
"webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -3913,7 +3913,7 @@ dependencies = [
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
"xml5ever 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -4005,7 +4005,7 @@ dependencies = [
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.60.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
@ -4102,8 +4102,8 @@ dependencies = [
"servo-media 0.1.0 (git+https://github.com/servo/media)",
"sig 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tinyfiledialogs 3.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"webxr 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"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)",
"winres 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"x11 2.17.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -5496,19 +5496,19 @@ dependencies = [
[[package]]
name = "webxr"
version = "0.0.1"
source = "git+https://github.com/asajeffrey/webxr?branch=optional-glsync#da820a3ab266fce07c9a8abee3e6e9231cb93ec5"
source = "git+https://github.com/servo/webxr#96c964c8939ca3ee8425fb8b29dd6fa6096a0bdd"
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)",
"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)",
"webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)",
"webxr-api 0.0.1 (git+https://github.com/servo/webxr)",
]
[[package]]
name = "webxr-api"
version = "0.0.1"
source = "git+https://github.com/asajeffrey/webxr?branch=optional-glsync#da820a3ab266fce07c9a8abee3e6e9231cb93ec5"
source = "git+https://github.com/servo/webxr#96c964c8939ca3ee8425fb8b29dd6fa6096a0bdd"
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)",
@ -6142,8 +6142,8 @@ dependencies = [
"checksum webrender 0.60.0 (git+https://github.com/servo/webrender)" = "<none>"
"checksum webrender_api 0.60.0 (git+https://github.com/servo/webrender)" = "<none>"
"checksum webrender_build 0.0.1 (git+https://github.com/servo/webrender)" = "<none>"
"checksum webxr 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)" = "<none>"
"checksum webxr-api 0.0.1 (git+https://github.com/asajeffrey/webxr?branch=optional-glsync)" = "<none>"
"checksum webxr 0.0.1 (git+https://github.com/servo/webxr)" = "<none>"
"checksum webxr-api 0.0.1 (git+https://github.com/servo/webxr)" = "<none>"
"checksum weedle 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3bb43f70885151e629e2a19ce9e50bd730fd436cfd4b666894c9ce4de9141164"
"checksum which 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b57acb10231b9493c8472b20cb57317d0679a49e0bdbee44b3b803a6473af164"
"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770"

View file

@ -29,7 +29,3 @@ opt-level = 3
mio = { git = "https://github.com/servo/mio.git", branch = "servo" }
iovec = { git = "https://github.com/servo/iovec.git", branch = "servo" }
cmake = { git = "https://github.com/alexcrichton/cmake-rs" }
[patch."https://github.com/servo/webxr"]
webxr = { git = "https://github.com/asajeffrey/webxr", branch = "optional-glsync" }
webxr-api = { git = "https://github.com/asajeffrey/webxr", branch = "optional-glsync" }

View file

@ -117,8 +117,8 @@ impl SendableWebGLExternalImages {
}
}
impl webxr_api::WebGLExternalImageApi for SendableWebGLExternalImages {
fn lock(&self, id: usize) -> (u32, Size2D<i32>, Option<gl::GLsync>) {
impl SendableWebGLExternalImages {
fn lock_and_get_current_texture(&self, id: usize) -> (u32, Size2D<i32>, Option<gl::GLsync>) {
if let Some(main_thread) = WebGLMainThread::on_current_thread() {
// If we're on the same thread as WebGL, we can get the data directly
let (image_id, size) = main_thread
@ -141,6 +141,13 @@ impl webxr_api::WebGLExternalImageApi for SendableWebGLExternalImages {
(image_id, size, Some(gl_sync as gl::GLsync))
}
}
}
impl webxr_api::WebGLExternalImageApi for SendableWebGLExternalImages {
fn lock(&self, id: usize) -> Option<gl::GLsync> {
let (_, _, gl_sync) = self.lock_and_get_current_texture(id);
gl_sync
}
fn unlock(&self, id: usize) {
if let Some(main_thread) = WebGLMainThread::on_current_thread() {
@ -178,7 +185,7 @@ impl WebGLExternalImages {
impl WebrenderExternalImageApi for WebGLExternalImages {
fn lock(&mut self, id: u64) -> (u32, Size2D<i32>) {
let (image_id, size, gl_sync) = self.sendable.lock(id as usize);
let (image_id, size, gl_sync) = self.sendable.lock_and_get_current_texture(id as usize);
// The next glWaitSync call is run on the WR thread and it's used to synchronize the two
// flows of OpenGL commands in order to avoid WR using a semi-ready WebGL texture.
// glWaitSync doesn't block WR thread, it affects only internal OpenGL subsystem.

View file

@ -6,6 +6,7 @@ use crate::compartments::InCompartment;
use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::NavigatorBinding::NavigatorBinding::NavigatorMethods;
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextMethods;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods;
use crate::dom::bindings::codegen::Bindings::XRBinding::XRSessionMode;
@ -29,6 +30,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::node::Node;
use crate::dom::node::NodeDamage;
use crate::dom::promise::Promise;
use crate::dom::webglframebuffer::WebGLFramebufferAttachmentRoot;
use crate::dom::xrframe::XRFrame;
use crate::dom::xrinputsource::XRInputSource;
use crate::dom::xrreferencespace::XRReferenceSpace;
@ -38,6 +40,7 @@ use crate::dom::xrspace::XRSpace;
use crate::dom::xrwebgllayer::XRWebGLLayer;
use crate::task_source::TaskSource;
use dom_struct::dom_struct;
use euclid::default::Size2D;
use euclid::RigidTransform3D;
use ipc_channel::ipc::IpcSender;
use ipc_channel::router::ROUTER;
@ -182,10 +185,19 @@ impl XRSession {
// Step 6-7: XXXManishearth handle inlineVerticalFieldOfView
// XXXManishearth handle inline sessions and composition disabled flag
let context = pending
.GetBaseLayer()
.map(|layer| layer.Context().context_id().0);
self.session.borrow_mut().set_webgl_context(context);
if let Some(layer) = pending.GetBaseLayer() {
let attachment = layer.framebuffer().attachment(constants::COLOR_ATTACHMENT0);
if let Some(WebGLFramebufferAttachmentRoot::Texture(texture)) = attachment {
let context = layer.Context().context_id().0;
let texture_id = texture.id().get();
if let Some((width, height)) = layer.framebuffer().size() {
let size = Size2D::new(width, height);
self.session
.borrow_mut()
.set_texture(context, texture_id, size);
}
}
}
}
// Step 2

View file

@ -149,6 +149,10 @@ impl XRWebGLLayer {
pub fn session(&self) -> &XRSession {
&self.session
}
pub fn framebuffer(&self) -> &WebGLFramebuffer {
&self.framebuffer
}
}
impl XRWebGLLayerMethods for XRWebGLLayer {

View file

@ -1,5 +1,5 @@
[xrBoundedReferenceSpace_updates.https.html]
expected: TIMEOUT
expected: ERROR
['XRBoundedReferenceSpace updates properly when the changes are applied]
expected: TIMEOUT

View file

@ -1,5 +1,4 @@
[xrSession_end.https.html]
expected: ERROR
[end event fires when non-immersive session ends]
expected: NOTRUN
expected: FAIL

View file

@ -1,5 +1,4 @@
[xrSession_input_events_end.https.html]
expected: ERROR
[Calling end during an input callback stops processing at the right time]
expected: FAIL

View file

@ -1,4 +0,0 @@
[xrSession_prevent_multiple_exclusive.https.html]
[Test prevention of multiple simultaneous immersive sessions]
expected: FAIL