Skip to content

Commit

Permalink
Auto merge of #25855 - jdm:surface-inversion, r=asajeffrey,Manishearth
Browse files Browse the repository at this point in the history
Remove GL->d3d blit in HoloLens immersive mode

Depends on:
* servo/surfman#151
* servo/surfman-chains#7
* servo/webxr#133

These changes add two extra APIs for embedders to use when registering a WebXR device - one to allow running any closure as a task in the webgl thread, and one to register an arbitrary surface provider for a particular webxr session. When an openxr session is started, it can then obtain the webgl thread's d3d device from that thread's surfman device and ensure that openxr uses it.

Surface providers are traits that have their methods invoked by the webgl thread as part of the the normal swapchain operations. This allows the openxr surface provider to return surfaces that wrap the underlying openxr textures, which are valid in the webgl thread and can be used as the target of an opaque framebuffer.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #25735
- [x] These changes do not require tests because there are no windows immersive mode tests
  • Loading branch information
bors-servo authored Mar 6, 2020
2 parents a0f14ce + 24c84d0 commit cb94256
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 112 deletions.
37 changes: 17 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ mio = { git = "https://github.com/servo/mio.git", branch = "servo" }
winapi = { git = "https://github.com/servo/winapi-rs", branch = "patch-1" }
spirv_cross = { git = "https://github.com/servo/spirv_cross", branch = "wgpu-servo" }
backtrace = { git = "https://github.com/MeFisto94/backtrace-rs", branch = "fix-strtab-freeing-crash" }
surfman-chains = { path = "../surfman-chains/surfman-chains" }
surfman-chains-api = { path = "../surfman-chains/surfman-chains-api" }

[patch."https://github.com/servo/mozjs"]
mozjs_sys = { path = "../mozjs" }
2 changes: 1 addition & 1 deletion components/canvas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ webrender_traits = {path = "../webrender_traits"}
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
# NOTE: the sm-angle feature only enables angle on windows, not other platforms!
surfman = { version = "0.1", features = ["sm-angle", "sm-osmesa"] }
surfman-chains = "0.2"
surfman-chains = "0.3"
surfman-chains-api = "0.2"
3 changes: 3 additions & 0 deletions components/canvas/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ extern crate log;
mod raqote_backend;

pub use webgl_mode::WebGLComm;
pub use webgl_thread::SurfaceProvider;
pub use webgl_thread::SurfaceProviders;
pub use webgl_thread::WebGlExecutor;

pub mod canvas_data;
pub mod canvas_paint_thread;
Expand Down
11 changes: 10 additions & 1 deletion components/canvas/webgl_mode/inprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::webgl_thread::{WebGLThread, WebGLThreadInit};
use crate::webgl_thread::{SurfaceProviders, WebGLThread, WebGLThreadInit, WebGlExecutor};
use canvas_traits::webgl::{webgl_channel, WebVRRenderHandler};
use canvas_traits::webgl::{WebGLContextId, WebGLMsg, WebGLThreads};
use euclid::default::Size2D;
Expand All @@ -11,6 +11,7 @@ use gleam;
use servo_config::pref;
use sparkle::gl;
use sparkle::gl::GlType;
use std::collections::HashMap;
use std::default::Default;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
Expand All @@ -27,8 +28,10 @@ use webxr_api::SwapChainId as WebXRSwapChainId;
pub struct WebGLComm {
pub webgl_threads: WebGLThreads,
pub webxr_swap_chains: SwapChains<WebXRSwapChainId>,
pub webxr_surface_providers: SurfaceProviders,
pub image_handler: Box<dyn WebrenderExternalImageApi>,
pub output_handler: Option<Box<dyn webrender_api::OutputImageHandler>>,
pub webgl_executor: WebGlExecutor,
}

impl WebGLComm {
Expand All @@ -46,6 +49,8 @@ impl WebGLComm {
let (sender, receiver) = webgl_channel::<WebGLMsg>().unwrap();
let webrender_swap_chains = SwapChains::new();
let webxr_swap_chains = SwapChains::new();
let webxr_surface_providers = Arc::new(Mutex::new(HashMap::new()));
let (runnable_sender, runnable_receiver) = crossbeam_channel::unbounded();

// This implementation creates a single `WebGLThread` for all the pipelines.
let init = WebGLThreadInit {
Expand All @@ -56,9 +61,11 @@ impl WebGLComm {
receiver,
webrender_swap_chains: webrender_swap_chains.clone(),
webxr_swap_chains: webxr_swap_chains.clone(),
webxr_surface_providers: webxr_surface_providers.clone(),
connection: device.connection(),
adapter: device.adapter(),
api_type,
runnable_receiver,
};

let output_handler = if pref!(dom.webgl.dom_to_texture.enabled) {
Expand All @@ -74,8 +81,10 @@ impl WebGLComm {
WebGLComm {
webgl_threads: WebGLThreads(sender),
webxr_swap_chains,
webxr_surface_providers,
image_handler: Box::new(external),
output_handler: output_handler.map(|b| b as Box<_>),
webgl_executor: runnable_sender,
}
}
}
Expand Down
Loading

0 comments on commit cb94256

Please sign in to comment.