Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example-compositor/compositor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ fn main() {
// as required.
renderer.update();
renderer.render(device_size, 0).unwrap();
let _ = renderer.flush_pipeline_info();
let _ = api.flush_pipeline_info();

// Construct a simple display list that can be drawn and composited by DC.
let mut txn = Transaction::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/common/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ pub fn main_wrapper<E: Example>(

renderer.update();
renderer.render(device_size, 0).unwrap();
let _ = renderer.flush_pipeline_info();
let _ = api.flush_pipeline_info();
example.draw_custom(&*gl);
windowed_context.swap_buffers().ok();

Expand Down
3 changes: 1 addition & 2 deletions webrender/src/internal_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use api::units::*;
use crate::render_api::DebugCommand;
use crate::composite::NativeSurfaceOperation;
use crate::device::TextureFilter;
use crate::renderer::{FullFrameStats, PipelineInfo};
use crate::renderer::FullFrameStats;
use crate::gpu_cache::GpuCacheUpdateList;
use crate::gpu_types::BlurEdgeMode;
use crate::frame_builder::Frame;
Expand Down Expand Up @@ -1366,7 +1366,6 @@ pub enum ResultMsg {
resource_updates: ResourceUpdateList,
memory_pressure: bool,
},
PublishPipelineInfo(PipelineInfo),
PublishDocument(
FramePublishId,
DocumentId,
Expand Down
18 changes: 18 additions & 0 deletions webrender/src/render_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::api::DEFAULT_TILE_SIZE;
use crate::api::units::*;
use crate::api_resources::ApiResources;
use glyph_rasterizer::SharedFontResources;
use crate::renderer::PipelineInfo;
use crate::scene_builder_thread::{SceneBuilderRequest, SceneBuilderResult};
use crate::intern::InterningMemoryReport;
use crate::profiler::{self, TransactionProfile};
Expand Down Expand Up @@ -1010,6 +1011,8 @@ pub enum ApiMsg {
DebugCommand(DebugCommand),
/// Message from the scene builder thread.
SceneBuilderResult(SceneBuilderResult),
/// Request pipeline infos.
RequestPipelineInfo(Sender<PipelineInfo>),
}

impl fmt::Debug for ApiMsg {
Expand All @@ -1023,6 +1026,7 @@ impl fmt::Debug for ApiMsg {
ApiMsg::ReportMemory(..) => "ApiMsg::ReportMemory",
ApiMsg::DebugCommand(..) => "ApiMsg::DebugCommand",
ApiMsg::SceneBuilderResult(..) => "ApiMsg::SceneBuilderResult",
ApiMsg::RequestPipelineInfo(..) => "ApiMsg::RequestPipelineInfo",
})
}
}
Expand Down Expand Up @@ -1454,6 +1458,20 @@ impl RenderApi {
SceneBuilderRequest::SetParameter(parameter)
);
}

/// Flush and return the current PipelineInfo.
pub fn flush_pipeline_info(&self) -> PipelineInfo {
let (tx, rx) = single_msg_channel();
self.scene_sender.send(SceneBuilderRequest::FlushPipelineInfo(tx)).unwrap();
rx.recv().unwrap()
}

/// Returns the Epoch of the current frame in a pipeline.
pub fn current_epoch(&self, document_id: DocumentId, pipeline_id: PipelineId) -> Option<Epoch> {
let (tx, rx) = single_msg_channel();
self.scene_sender.send(SceneBuilderRequest::CurrentEpoch(document_id, pipeline_id, tx)).unwrap();
rx.recv().unwrap()
}
}

impl Drop for RenderApi {
Expand Down
34 changes: 6 additions & 28 deletions webrender/src/render_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use api::{DebugFlags, Parameter, BoolParameter, PrimitiveFlags, MinimapData};
use api::{DocumentId, ExternalScrollId, HitTestResult};
use api::{IdNamespace, PipelineId, RenderNotifier, SampledScrollOffset};
use api::{IdNamespace, RenderNotifier, SampledScrollOffset};
use api::{NotificationRequest, Checkpoint, QualitySettings};
use api::{FramePublishId, PrimitiveKeyKind, RenderReasons};
use api::units::*;
Expand Down Expand Up @@ -44,7 +44,7 @@ use crate::prim_store::{PrimitiveInstanceKind, PrimTemplateCommonData};
use crate::prim_store::interned::*;
use crate::profiler::{self, TransactionProfile};
use crate::render_task_graph::RenderTaskGraphBuilder;
use crate::renderer::{FullFrameStats, PipelineInfo};
use crate::renderer::{FullFrameStats};
use crate::resource_cache::ResourceCache;
#[cfg(feature = "replay")]
use crate::resource_cache::PlainCacheOwn;
Expand Down Expand Up @@ -330,13 +330,10 @@ impl ScratchBuffer {
}

struct Document {
#[allow(dead_code)]
/// The id of this document
id: DocumentId,

/// Temporary list of removed pipelines received from the scene builder
/// thread and forwarded to the renderer.
removed_pipelines: Vec<(PipelineId, DocumentId)>,

view: DocumentView,

/// The id and time of the current frame.
Expand Down Expand Up @@ -405,7 +402,6 @@ impl Document {
) -> Self {
Document {
id,
removed_pipelines: Vec::new(),
view: DocumentView {
scene: SceneView {
device_rect: size.into(),
Expand Down Expand Up @@ -650,15 +646,6 @@ impl Document {
self.hit_tester_is_valid = true;
}

pub fn updated_pipeline_info(&mut self) -> PipelineInfo {
let removed_pipelines = self.removed_pipelines.take_and_preallocate();
PipelineInfo {
epochs: self.scene.pipeline_epochs.iter()
.map(|(&pipeline_id, &epoch)| ((pipeline_id, self.id), epoch)).collect(),
removed_pipelines,
}
}

/// Returns true if the node actually changed position or false otherwise.
pub fn set_scroll_offsets(
&mut self,
Expand Down Expand Up @@ -939,7 +926,6 @@ impl RenderBackend {
let has_built_scene = txn.built_scene.is_some();

if let Some(doc) = self.documents.get_mut(&txn.document_id) {
doc.removed_pipelines.append(&mut txn.removed_pipelines);
doc.view.scene = txn.view;
doc.profile.merge(&mut txn.profile);

Expand Down Expand Up @@ -1308,6 +1294,9 @@ impl RenderBackend {
ApiMsg::SceneBuilderResult(msg) => {
return self.process_scene_builder_result(msg, frame_counter);
}
ApiMsg::RequestPipelineInfo(tx) => {
self.send_backend_message(SceneBuilderRequest::RequestPipelineInfo(tx));
}
}

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

let msg = ResultMsg::PublishPipelineInfo(doc.updated_pipeline_info());
self.result_tx.send(msg).unwrap();

// Publish the frame
self.frame_publish_id.advance();
let msg = ResultMsg::PublishDocument(
Expand All @@ -1710,13 +1696,6 @@ impl RenderBackend {
pending_update,
);
self.result_tx.send(msg).unwrap();
} else if requested_frame {
// WR-internal optimization to avoid doing a bunch of render work if
// there's no pixels. We still want to pretend to render and request
// a render to make sure that the callbacks (particularly the
// new_frame_ready callback below) has the right flags.
let msg = ResultMsg::PublishPipelineInfo(doc.updated_pipeline_info());
self.result_tx.send(msg).unwrap();
}

drain_filter(
Expand Down Expand Up @@ -2079,7 +2058,6 @@ impl RenderBackend {
let doc = Document {
id,
scene: BuiltScene::empty(),
removed_pipelines: Vec::new(),
view,
stamp: FrameStamp::first(id),
frame_builder: FrameBuilder::new(),
Expand Down
1 change: 0 additions & 1 deletion webrender/src/renderer/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,6 @@ pub fn create_webrender_instance(
vaos,
vertex_data_textures,
current_vertex_data_textures: 0,
pipeline_info: PipelineInfo::default(),
dither_matrix_texture,
external_image_handler: None,
size_of_ops: make_size_of_ops(),
Expand Down
30 changes: 9 additions & 21 deletions webrender/src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use api::{PipelineId, ImageRendering, Checkpoint, NotificationRequest, ImageBuff
use api::ExternalImage;
use api::FramePublishId;
use api::units::*;
use api::channel::{Sender, Receiver};
use api::channel::{Sender, single_msg_channel, Receiver};
pub use api::DebugFlags;
use core::time::Duration;

Expand Down Expand Up @@ -867,8 +867,6 @@ pub struct Renderer {
gpu_cache_frame_id: FrameId,
gpu_cache_overflow: bool,

pipeline_info: PipelineInfo,

// Manages and resolves source textures IDs to real texture IDs.
texture_resolver: TextureResolver,

Expand Down Expand Up @@ -1017,15 +1015,6 @@ impl Renderer {
self.clear_color = color;
}

pub fn flush_pipeline_info(&mut self) -> PipelineInfo {
mem::replace(&mut self.pipeline_info, PipelineInfo::default())
}

/// Returns the Epoch of the current frame in a pipeline.
pub fn current_epoch(&self, document_id: DocumentId, pipeline_id: PipelineId) -> Option<Epoch> {
self.pipeline_info.epochs.get(&(pipeline_id, document_id)).cloned()
}

fn get_next_result_msg(&mut self) -> Option<ResultMsg> {
if self.pending_result_msg.is_none() {
if let Ok(msg) = self.result_rx.try_recv() {
Expand Down Expand Up @@ -1054,12 +1043,6 @@ impl Renderer {
// Pull any pending results and return the most recent.
while let Some(msg) = self.get_next_result_msg() {
match msg {
ResultMsg::PublishPipelineInfo(mut pipeline_info) => {
for ((pipeline_id, document_id), epoch) in pipeline_info.epochs {
self.pipeline_info.epochs.insert((pipeline_id, document_id), epoch);
}
self.pipeline_info.removed_pipelines.extend(pipeline_info.removed_pipelines.drain(..));
}
ResultMsg::PublishDocument(
_,
document_id,
Expand Down Expand Up @@ -5894,7 +5877,12 @@ impl Renderer {
let y0: f32 = 30.0;
let mut y = y0;
let mut text_width = 0.0;
for ((pipeline, document_id), epoch) in &self.pipeline_info.epochs {

let (tx, rx) = single_msg_channel();
self.api_tx.send(ApiMsg::RequestPipelineInfo(tx)).unwrap();
let pipeline_info = rx.recv().unwrap();

for ((pipeline, document_id), epoch) in pipeline_info.epochs {
y += dy;
let w = debug_renderer.add_text(
x0, y,
Expand Down Expand Up @@ -6270,10 +6258,10 @@ impl ExternalImageHandler for DummyExternalImageHandler {
fn unlock(&mut self, _key: ExternalImageId, _channel_index: u8) {}
}

#[derive(Default)]
#[derive(Clone, Default)]
pub struct PipelineInfo {
pub epochs: FastHashMap<(PipelineId, DocumentId), Epoch>,
pub removed_pipelines: Vec<(PipelineId, DocumentId)>,
pub removed_pipelines: FastHashSet<(PipelineId, DocumentId)>,
}

impl Renderer {
Expand Down
Loading