Bug 1589119 - Add profile counters for rendered and total number of picture cache tiles. r=gw
authorNicolas Silva <nsilva@mozilla.com>
Fri, 18 Oct 2019 01:03:07 +0000
changeset 559436 8f6ab1486f9fe658ad688fea54f6779c43063a11
parent 559435 19a2899c8f21a0b0062b4bc203533669ac6d2d22
child 559437 5979a213200682d5eef021820f88cd3a2ef2f936
push id12177
push usercsabou@mozilla.com
push dateMon, 21 Oct 2019 14:52:16 +0000
treeherdermozilla-beta@1918a9cd33bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1589119
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1589119 - Add profile counters for rendered and total number of picture cache tiles. r=gw Differential Revision: https://phabricator.services.mozilla.com/D49438
gfx/wr/webrender/src/profiler.rs
gfx/wr/webrender/src/renderer.rs
--- a/gfx/wr/webrender/src/profiler.rs
+++ b/gfx/wr/webrender/src/profiler.rs
@@ -29,16 +29,18 @@ pub mod expected {
     pub const MAX_GPU_TIME: Range<f64> =            0.0..15.0;
     pub const DRAW_CALLS: Range<u64> =              1..100;
     pub const VERTICES: Range<u64> =                10..25_000;
     pub const TOTAL_PRIMITIVES: Range<u64> =        1..5000;
     pub const VISIBLE_PRIMITIVES: Range<u64> =      1..5000;
     pub const USED_TARGETS: Range<u64> =            1..4;
     pub const COLOR_TARGETS: Range<u64> =           1..4;
     pub const ALPHA_TARGETS: Range<u64> =           0..2;
+    pub const RENDERED_PICTURE_CACHE_TILES: Range<u64> = 0..5;
+    pub const TOTAL_PICTURE_CACHE_TILES: Range<u64> = 0..15;
     pub const CREATED_TARGETS: Range<u64> =         0..3;
     pub const CHANGED_TARGETS: Range<u64> =         0..3;
     pub const TEXTURE_DATA_UPLOADED: Range<u64> =   0..10;
     pub const GPU_CACHE_ROWS_TOTAL: Range<u64> =    1..50;
     pub const GPU_CACHE_ROWS_UPDATED: Range<u64> =  0..25;
     pub const GPU_CACHE_BLOCKS_TOTAL: Range<u64> =  1..1000;
     pub const GPU_CACHE_BLOCKS_UPDATED: Range<u64> = 0..1000;
     pub const GPU_CACHE_BLOCKS_SAVED: Range<u64> =  0..1000;
@@ -783,16 +785,18 @@ pub struct RendererProfileCounters {
     pub frame_counter: IntProfileCounter,
     pub frame_time: AverageTimeProfileCounter,
     pub draw_calls: AverageIntProfileCounter,
     pub vertices: AverageIntProfileCounter,
     pub vao_count_and_size: ResourceProfileCounter,
     pub color_targets: AverageIntProfileCounter,
     pub alpha_targets: AverageIntProfileCounter,
     pub texture_data_uploaded: AverageIntProfileCounter,
+    pub rendered_picture_cache_tiles: AverageIntProfileCounter,
+    pub total_picture_cache_tiles: AverageIntProfileCounter,
 }
 
 pub struct RendererProfileTimers {
     pub cpu_time: TimeProfileCounter,
     pub gpu_graph: TimeProfileCounter,
     pub gpu_samples: Vec<GpuTimer<GpuProfileTag>>,
 }
 
@@ -821,25 +825,35 @@ impl RendererProfileCounters {
             alpha_targets: AverageIntProfileCounter::new(
                 "Alpha Targets",
                 None, Some(expected::ALPHA_TARGETS),
             ),
             texture_data_uploaded: AverageIntProfileCounter::new(
                 "Texture data, kb",
                 None, Some(expected::TEXTURE_DATA_UPLOADED),
             ),
+            rendered_picture_cache_tiles: AverageIntProfileCounter::new(
+                "Rendered tiles",
+                None, Some(expected::RENDERED_PICTURE_CACHE_TILES),
+            ),
+            total_picture_cache_tiles: AverageIntProfileCounter::new(
+                "Total tiles",
+                None, Some(expected::TOTAL_PICTURE_CACHE_TILES),
+            ),
         }
     }
 
     pub fn reset(&mut self) {
         self.draw_calls.reset();
         self.vertices.reset();
         self.color_targets.reset();
         self.alpha_targets.reset();
         self.texture_data_uploaded.reset();
+        self.rendered_picture_cache_tiles.reset();
+        self.total_picture_cache_tiles.reset();
     }
 }
 
 impl RendererProfileTimers {
     pub fn new() -> Self {
         RendererProfileTimers {
             cpu_time: TimeProfileCounter::new("Renderer CPU Time", false, None),
             gpu_samples: Vec::new(),
@@ -1416,16 +1430,17 @@ impl Profiler {
     ) {
         Profiler::draw_counters(
             &[
                 &renderer_profile.frame_time as &dyn ProfileCounter,
                 &renderer_profile.color_targets,
                 &renderer_profile.alpha_targets,
                 &renderer_profile.draw_calls,
                 &renderer_profile.vertices,
+                &renderer_profile.rendered_picture_cache_tiles,
                 &renderer_profile.texture_data_uploaded,
                 &self.ipc_time,
                 &self.backend_time,
                 &self.renderer_time,
                 &self.gpu_time,
             ],
             None,
             debug_renderer,
@@ -1445,16 +1460,18 @@ impl Profiler {
         debug_renderer: &mut DebugRenderer,
     ) {
         Profiler::draw_counters(
             &[
                 &renderer_profile.frame_time as &dyn ProfileCounter,
                 &renderer_profile.frame_counter,
                 &renderer_profile.color_targets,
                 &renderer_profile.alpha_targets,
+                &renderer_profile.rendered_picture_cache_tiles,
+                &renderer_profile.total_picture_cache_tiles,
                 &renderer_profile.texture_data_uploaded,
             ],
             None,
             debug_renderer,
             true,
             &mut self.draw_state
         );
 
@@ -1616,16 +1633,18 @@ impl Profiler {
                 &self.renderer_time,
                 &self.gpu_time,
             ],
             &[
                 &renderer_profile.color_targets,
                 &renderer_profile.alpha_targets,
                 &renderer_profile.draw_calls,
                 &renderer_profile.vertices,
+                &renderer_profile.rendered_picture_cache_tiles,
+                &renderer_profile.total_picture_cache_tiles,
             ],
             &[
                 &backend_profile.resources.gpu_cache.allocated_rows,
                 &backend_profile.resources.gpu_cache.updated_rows,
                 &backend_profile.resources.gpu_cache.allocated_blocks,
                 &backend_profile.resources.gpu_cache.updated_blocks,
                 &backend_profile.resources.gpu_cache.saved_blocks,
             ],
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -3635,16 +3635,17 @@ impl Renderer {
         &mut self,
         target: &PictureCacheTarget,
         draw_target: DrawTarget,
         content_origin: DeviceIntPoint,
         projection: &default::Transform3D<f32>,
         render_tasks: &RenderTaskGraph,
         stats: &mut RendererStats,
     ) {
+        self.profile_counters.rendered_picture_cache_tiles.inc();
         self.profile_counters.color_targets.inc();
         let _gm = self.gpu_profile.start_marker("picture cache target");
         let framebuffer_kind = FramebufferKind::Other;
 
         {
             let _timer = self.gpu_profile.start_timer(GPU_TAG_SETUP_TARGET);
             self.device.bind_draw_target(draw_target);
             self.device.disable_depth();
@@ -4060,16 +4061,22 @@ impl Renderer {
         }
 
         self.shaders.borrow_mut().composite.bind(
             &mut self.device,
             &projection,
             &mut self.renderer_errors
         );
 
+        // We are only interested in tiles backed with actual cached pixels so we don't
+        // count clear tiles here.
+        let num_tiles = composite_state.opaque_tiles.len()
+            + composite_state.alpha_tiles.len();
+        self.profile_counters.total_picture_cache_tiles.set(num_tiles);
+
         // Draw opaque tiles first, front-to-back to get maxmum
         // z-reject efficiency.
         if !composite_state.opaque_tiles.is_empty() {
             let opaque_sampler = self.gpu_profile.start_sampler(GPU_SAMPLER_TAG_OPAQUE);
             self.device.enable_depth_write();
             self.set_blend(false, FramebufferKind::Main);
             self.draw_tile_list(
                 composite_state.opaque_tiles.iter().rev(),