Skip to content

Commit 4739d43

Browse files
committed
Synchronously requests current epoch.
Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
1 parent 8c1bfc3 commit 4739d43

9 files changed

Lines changed: 69 additions & 72 deletions

File tree

example-compositor/compositor/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ fn main() {
498498
// as required.
499499
renderer.update();
500500
renderer.render(device_size, 0).unwrap();
501-
let _ = renderer.flush_pipeline_info();
501+
let _ = api.flush_pipeline_info();
502502

503503
// Construct a simple display list that can be drawn and composited by DC.
504504
let mut txn = Transaction::new();

examples/common/boilerplate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub fn main_wrapper<E: Example>(
312312

313313
renderer.update();
314314
renderer.render(device_size, 0).unwrap();
315-
let _ = renderer.flush_pipeline_info();
315+
let _ = api.flush_pipeline_info();
316316
example.draw_custom(&*gl);
317317
windowed_context.swap_buffers().ok();
318318

webrender/src/internal_types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use api::units::*;
99
use crate::render_api::DebugCommand;
1010
use crate::composite::NativeSurfaceOperation;
1111
use crate::device::TextureFilter;
12-
use crate::renderer::{FullFrameStats, PipelineInfo};
12+
use crate::renderer::FullFrameStats;
1313
use crate::gpu_cache::GpuCacheUpdateList;
1414
use crate::gpu_types::BlurEdgeMode;
1515
use crate::frame_builder::Frame;
@@ -1366,7 +1366,6 @@ pub enum ResultMsg {
13661366
resource_updates: ResourceUpdateList,
13671367
memory_pressure: bool,
13681368
},
1369-
PublishPipelineInfo(PipelineInfo),
13701369
PublishDocument(
13711370
FramePublishId,
13721371
DocumentId,

webrender/src/render_api.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::api::DEFAULT_TILE_SIZE;
2525
use crate::api::units::*;
2626
use crate::api_resources::ApiResources;
2727
use glyph_rasterizer::SharedFontResources;
28+
use crate::renderer::PipelineInfo;
2829
use crate::scene_builder_thread::{SceneBuilderRequest, SceneBuilderResult};
2930
use crate::intern::InterningMemoryReport;
3031
use crate::profiler::{self, TransactionProfile};
@@ -1010,6 +1011,8 @@ pub enum ApiMsg {
10101011
DebugCommand(DebugCommand),
10111012
/// Message from the scene builder thread.
10121013
SceneBuilderResult(SceneBuilderResult),
1014+
/// Request pipeline infos.
1015+
RequestPipelineInfo(Sender<PipelineInfo>),
10131016
}
10141017

10151018
impl fmt::Debug for ApiMsg {
@@ -1023,6 +1026,7 @@ impl fmt::Debug for ApiMsg {
10231026
ApiMsg::ReportMemory(..) => "ApiMsg::ReportMemory",
10241027
ApiMsg::DebugCommand(..) => "ApiMsg::DebugCommand",
10251028
ApiMsg::SceneBuilderResult(..) => "ApiMsg::SceneBuilderResult",
1029+
ApiMsg::RequestPipelineInfo(..) => "ApiMsg::RequestPipelineInfo",
10261030
})
10271031
}
10281032
}
@@ -1454,6 +1458,20 @@ impl RenderApi {
14541458
SceneBuilderRequest::SetParameter(parameter)
14551459
);
14561460
}
1461+
1462+
/// Flush and return the current PipelineInfo.
1463+
pub fn flush_pipeline_info(&self) -> PipelineInfo {
1464+
let (tx, rx) = single_msg_channel();
1465+
self.scene_sender.send(SceneBuilderRequest::FlushPipelineInfo(tx)).unwrap();
1466+
rx.recv().unwrap()
1467+
}
1468+
1469+
/// Returns the Epoch of the current frame in a pipeline.
1470+
pub fn current_epoch(&self, document_id: DocumentId, pipeline_id: PipelineId) -> Option<Epoch> {
1471+
let (tx, rx) = single_msg_channel();
1472+
self.scene_sender.send(SceneBuilderRequest::CurrentEpoch(document_id, pipeline_id, tx)).unwrap();
1473+
rx.recv().unwrap()
1474+
}
14571475
}
14581476

14591477
impl Drop for RenderApi {

webrender/src/render_backend.rs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
use api::{DebugFlags, Parameter, BoolParameter, PrimitiveFlags, MinimapData};
1212
use api::{DocumentId, ExternalScrollId, HitTestResult};
13-
use api::{IdNamespace, PipelineId, RenderNotifier, SampledScrollOffset};
13+
use api::{IdNamespace, RenderNotifier, SampledScrollOffset};
1414
use api::{NotificationRequest, Checkpoint, QualitySettings};
1515
use api::{FramePublishId, PrimitiveKeyKind, RenderReasons};
1616
use api::units::*;
@@ -44,7 +44,7 @@ use crate::prim_store::{PrimitiveInstanceKind, PrimTemplateCommonData};
4444
use crate::prim_store::interned::*;
4545
use crate::profiler::{self, TransactionProfile};
4646
use crate::render_task_graph::RenderTaskGraphBuilder;
47-
use crate::renderer::{FullFrameStats, PipelineInfo};
47+
use crate::renderer::{FullFrameStats};
4848
use crate::resource_cache::ResourceCache;
4949
#[cfg(feature = "replay")]
5050
use crate::resource_cache::PlainCacheOwn;
@@ -330,13 +330,10 @@ impl ScratchBuffer {
330330
}
331331

332332
struct Document {
333+
#[allow(dead_code)]
333334
/// The id of this document
334335
id: DocumentId,
335336

336-
/// Temporary list of removed pipelines received from the scene builder
337-
/// thread and forwarded to the renderer.
338-
removed_pipelines: Vec<(PipelineId, DocumentId)>,
339-
340337
view: DocumentView,
341338

342339
/// The id and time of the current frame.
@@ -405,7 +402,6 @@ impl Document {
405402
) -> Self {
406403
Document {
407404
id,
408-
removed_pipelines: Vec::new(),
409405
view: DocumentView {
410406
scene: SceneView {
411407
device_rect: size.into(),
@@ -650,15 +646,6 @@ impl Document {
650646
self.hit_tester_is_valid = true;
651647
}
652648

653-
pub fn updated_pipeline_info(&mut self) -> PipelineInfo {
654-
let removed_pipelines = self.removed_pipelines.take_and_preallocate();
655-
PipelineInfo {
656-
epochs: self.scene.pipeline_epochs.iter()
657-
.map(|(&pipeline_id, &epoch)| ((pipeline_id, self.id), epoch)).collect(),
658-
removed_pipelines,
659-
}
660-
}
661-
662649
/// Returns true if the node actually changed position or false otherwise.
663650
pub fn set_scroll_offsets(
664651
&mut self,
@@ -939,7 +926,6 @@ impl RenderBackend {
939926
let has_built_scene = txn.built_scene.is_some();
940927

941928
if let Some(doc) = self.documents.get_mut(&txn.document_id) {
942-
doc.removed_pipelines.append(&mut txn.removed_pipelines);
943929
doc.view.scene = txn.view;
944930
doc.profile.merge(&mut txn.profile);
945931

@@ -1308,6 +1294,9 @@ impl RenderBackend {
13081294
ApiMsg::SceneBuilderResult(msg) => {
13091295
return self.process_scene_builder_result(msg, frame_counter);
13101296
}
1297+
ApiMsg::RequestPipelineInfo(tx) => {
1298+
self.send_backend_message(SceneBuilderRequest::RequestPipelineInfo(tx));
1299+
}
13111300
}
13121301

13131302
// Now that we are likely out of the critical path, purge a few chunks
@@ -1698,9 +1687,6 @@ impl RenderBackend {
16981687
let update_doc_time = profiler::ns_to_ms(zeitstempel::now() - update_doc_start);
16991688
rendered_document.profile.set(profiler::UPDATE_DOCUMENT_TIME, update_doc_time);
17001689

1701-
let msg = ResultMsg::PublishPipelineInfo(doc.updated_pipeline_info());
1702-
self.result_tx.send(msg).unwrap();
1703-
17041690
// Publish the frame
17051691
self.frame_publish_id.advance();
17061692
let msg = ResultMsg::PublishDocument(
@@ -1710,13 +1696,6 @@ impl RenderBackend {
17101696
pending_update,
17111697
);
17121698
self.result_tx.send(msg).unwrap();
1713-
} else if requested_frame {
1714-
// WR-internal optimization to avoid doing a bunch of render work if
1715-
// there's no pixels. We still want to pretend to render and request
1716-
// a render to make sure that the callbacks (particularly the
1717-
// new_frame_ready callback below) has the right flags.
1718-
let msg = ResultMsg::PublishPipelineInfo(doc.updated_pipeline_info());
1719-
self.result_tx.send(msg).unwrap();
17201699
}
17211700

17221701
drain_filter(

webrender/src/renderer/init.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ pub fn create_webrender_instance(
802802
vaos,
803803
vertex_data_textures,
804804
current_vertex_data_textures: 0,
805-
pipeline_info: PipelineInfo::default(),
806805
dither_matrix_texture,
807806
external_image_handler: None,
808807
size_of_ops: make_size_of_ops(),

webrender/src/renderer/mod.rs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use api::{PipelineId, ImageRendering, Checkpoint, NotificationRequest, ImageBuff
4444
use api::ExternalImage;
4545
use api::FramePublishId;
4646
use api::units::*;
47-
use api::channel::{Sender, Receiver};
47+
use api::channel::{Sender, single_msg_channel, Receiver};
4848
pub use api::DebugFlags;
4949
use core::time::Duration;
5050

@@ -867,8 +867,6 @@ pub struct Renderer {
867867
gpu_cache_frame_id: FrameId,
868868
gpu_cache_overflow: bool,
869869

870-
pipeline_info: PipelineInfo,
871-
872870
// Manages and resolves source textures IDs to real texture IDs.
873871
texture_resolver: TextureResolver,
874872

@@ -1017,15 +1015,6 @@ impl Renderer {
10171015
self.clear_color = color;
10181016
}
10191017

1020-
pub fn flush_pipeline_info(&mut self) -> PipelineInfo {
1021-
mem::replace(&mut self.pipeline_info, PipelineInfo::default())
1022-
}
1023-
1024-
/// Returns the Epoch of the current frame in a pipeline.
1025-
pub fn current_epoch(&self, document_id: DocumentId, pipeline_id: PipelineId) -> Option<Epoch> {
1026-
self.pipeline_info.epochs.get(&(pipeline_id, document_id)).cloned()
1027-
}
1028-
10291018
fn get_next_result_msg(&mut self) -> Option<ResultMsg> {
10301019
if self.pending_result_msg.is_none() {
10311020
if let Ok(msg) = self.result_rx.try_recv() {
@@ -1054,12 +1043,6 @@ impl Renderer {
10541043
// Pull any pending results and return the most recent.
10551044
while let Some(msg) = self.get_next_result_msg() {
10561045
match msg {
1057-
ResultMsg::PublishPipelineInfo(mut pipeline_info) => {
1058-
for ((pipeline_id, document_id), epoch) in pipeline_info.epochs {
1059-
self.pipeline_info.epochs.insert((pipeline_id, document_id), epoch);
1060-
}
1061-
self.pipeline_info.removed_pipelines.extend(pipeline_info.removed_pipelines.drain(..));
1062-
}
10631046
ResultMsg::PublishDocument(
10641047
_,
10651048
document_id,
@@ -5894,7 +5877,12 @@ impl Renderer {
58945877
let y0: f32 = 30.0;
58955878
let mut y = y0;
58965879
let mut text_width = 0.0;
5897-
for ((pipeline, document_id), epoch) in &self.pipeline_info.epochs {
5880+
5881+
let (tx, rx) = single_msg_channel();
5882+
self.api_tx.send(ApiMsg::RequestPipelineInfo(tx)).unwrap();
5883+
let pipeline_info = rx.recv().unwrap();
5884+
5885+
for ((pipeline, document_id), epoch) in pipeline_info.epochs {
58985886
y += dy;
58995887
let w = debug_renderer.add_text(
59005888
x0, y,
@@ -6270,10 +6258,10 @@ impl ExternalImageHandler for DummyExternalImageHandler {
62706258
fn unlock(&mut self, _key: ExternalImageId, _channel_index: u8) {}
62716259
}
62726260

6273-
#[derive(Default)]
6261+
#[derive(Clone, Default)]
62746262
pub struct PipelineInfo {
62756263
pub epochs: FastHashMap<(PipelineId, DocumentId), Epoch>,
6276-
pub removed_pipelines: Vec<(PipelineId, DocumentId)>,
6264+
pub removed_pipelines: FastHashSet<(PipelineId, DocumentId)>,
62776265
}
62786266

62796267
impl Renderer {

0 commit comments

Comments
 (0)