aboutsummaryrefslogtreecommitdiffstats
path: root/components/constellation
diff options
context:
space:
mode:
authorZakor Gyula <gyula.zakor@h-lab.eu>2019-11-10 14:56:22 +0100
committerZakor Gyula <gyula.zakor@h-lab.eu>2019-11-21 08:30:26 +0100
commit12893aa0102f220f411b273a36ac1b4e25fa0ab7 (patch)
tree37362e455b8a1352fc88d39f8eb87170754c5d06 /components/constellation
parent47e39af0f36227e8e98b3dc3511c225192bf3736 (diff)
downloadservo-12893aa0102f220f411b273a36ac1b4e25fa0ab7.tar.gz
servo-12893aa0102f220f411b273a36ac1b4e25fa0ab7.zip
Initial implementation of WebGPU API
Diffstat (limited to 'components/constellation')
-rw-r--r--components/constellation/Cargo.toml1
-rw-r--r--components/constellation/constellation.rs21
-rw-r--r--components/constellation/pipeline.rs7
3 files changed, 29 insertions, 0 deletions
diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml
index ec360006aad..893930c701a 100644
--- a/components/constellation/Cargo.toml
+++ b/components/constellation/Cargo.toml
@@ -47,6 +47,7 @@ servo_geometry = {path = "../geometry"}
servo_rand = {path = "../rand"}
servo_remutex = {path = "../remutex"}
servo_url = {path = "../url"}
+webgpu = {path = "../webgpu"}
webvr_traits = {path = "../webvr_traits"}
webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]}
webxr-api = {git = "https://github.com/servo/webxr", features = ["ipc"]}
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 82b99938f3b..3bd77ebf137 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -172,6 +172,7 @@ use std::sync::Arc;
use std::thread;
use style_traits::viewport::ViewportConstraints;
use style_traits::CSSPixel;
+use webgpu::WebGPU;
use webvr_traits::{WebVREvent, WebVRMsg};
type PendingApprovalNavigations = HashMap<PipelineId, (LoadData, HistoryEntryReplacement)>;
@@ -440,6 +441,10 @@ pub struct Constellation<Message, LTF, STF> {
/// Entry point to create and get channels to a WebGLThread.
webgl_threads: Option<WebGLThreads>,
+ /// An IPC channel for the constellation to send messages to the
+ /// WebGPU threads.
+ webgpu: Option<WebGPU>,
+
/// A channel through which messages can be sent to the webvr thread.
webvr_chan: Option<IpcSender<WebVRMsg>>,
@@ -521,6 +526,9 @@ pub struct InitialConstellationState {
/// Entry point to create and get channels to a WebGLThread.
pub webgl_threads: Option<WebGLThreads>,
+ /// A channel to the WebGPU threads.
+ pub webgpu: Option<WebGPU>,
+
/// A channel to the webgl thread.
pub webvr_chan: Option<IpcSender<WebVRMsg>>,
@@ -836,6 +844,7 @@ where
(rng, prob)
}),
webgl_threads: state.webgl_threads,
+ webgpu: state.webgpu,
webvr_chan: state.webvr_chan,
webxr_registry: state.webxr_registry,
canvas_chan: CanvasPaintThread::start(),
@@ -1090,6 +1099,7 @@ where
.webgl_threads
.as_ref()
.map(|threads| threads.pipeline()),
+ webgpu: self.webgpu.clone(),
webvr_chan: self.webvr_chan.clone(),
webxr_registry: self.webxr_registry.clone(),
player_context: self.player_context.clone(),
@@ -2355,6 +2365,17 @@ where
}
}
+ if let Some(webgpu) = self.webgpu.as_ref() {
+ debug!("Exiting WebGPU thread.");
+ let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!");
+ if let Err(e) = webgpu.exit(sender) {
+ warn!("Exit WebGPU Thread failed ({})", e);
+ }
+ if let Err(e) = receiver.recv() {
+ warn!("Failed to receive exit response from WebGPU ({})", e);
+ }
+ }
+
if let Some(chan) = self.webvr_chan.as_ref() {
debug!("Exiting WebVR thread.");
if let Err(e) = chan.send(WebVRMsg::Exit) {
diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs
index 3ac5ded15ed..fd7202aa9ec 100644
--- a/components/constellation/pipeline.rs
+++ b/components/constellation/pipeline.rs
@@ -46,6 +46,7 @@ use std::process;
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
+use webgpu::WebGPU;
use webvr_traits::WebVRMsg;
/// A `Pipeline` is the constellation's view of a `Document`. Each pipeline has an
@@ -188,6 +189,9 @@ pub struct InitialPipelineState {
/// A channel to the WebGL thread.
pub webgl_chan: Option<WebGLPipeline>,
+ /// A channel to the WebGPU threads.
+ pub webgpu: Option<WebGPU>,
+
/// A channel to the webvr thread.
pub webvr_chan: Option<IpcSender<WebVRMsg>>,
@@ -299,6 +303,7 @@ impl Pipeline {
webrender_document: state.webrender_document,
webgl_chan: state.webgl_chan,
webvr_chan: state.webvr_chan,
+ webgpu: state.webgpu,
webxr_registry: state.webxr_registry,
player_context: state.player_context,
};
@@ -504,6 +509,7 @@ pub struct UnprivilegedPipelineContent {
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
webgl_chan: Option<WebGLPipeline>,
+ webgpu: Option<WebGPU>,
webvr_chan: Option<IpcSender<WebVRMsg>>,
webxr_registry: webxr_api::Registry,
player_context: WindowGLContext,
@@ -556,6 +562,7 @@ impl UnprivilegedPipelineContent {
pipeline_namespace_id: self.pipeline_namespace_id,
content_process_shutdown_chan: content_process_shutdown_chan,
webgl_chan: self.webgl_chan,
+ webgpu: self.webgpu,
webvr_chan: self.webvr_chan,
webxr_registry: self.webxr_registry,
webrender_document: self.webrender_document,