Bug 1542826 - Add more debug flags to disable various things. r=gw
☠☠ backed out by cffeafe28a45 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 23 Apr 2019 19:56:23 +0000
changeset 470552 a02e469be7b353670593dc7ca2db4595cb01b30a
parent 470551 5118d628ec890f6dada7e16c1ac60d0d56a43483
child 470553 1dba743761b70dcf224def15834f5d32559ea72e
push id35908
push useraciure@mozilla.com
push dateWed, 24 Apr 2019 04:28:40 +0000
treeherdermozilla-central@c9f0730a57a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgw
bugs1542826
milestone68.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 1542826 - Add more debug flags to disable various things. r=gw Differential Revision: https://phabricator.services.mozilla.com/D28356
gfx/thebes/gfxPlatform.cpp
gfx/wr/debugger/src/components/OptionsPage.vue
gfx/wr/webrender/src/debug_server.rs
gfx/wr/webrender/src/renderer.rs
gfx/wr/webrender_api/src/api.rs
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -566,16 +566,21 @@ static void WebRenderDebugPrefChangeCall
                       wr::DebugFlags_SLOW_FRAME_INDICATOR)
   GFX_WEBRENDER_DEBUG(".texture-cache.clear-evicted",
                       wr::DebugFlags_TEXTURE_CACHE_DBG_CLEAR_EVICTED)
   GFX_WEBRENDER_DEBUG(".picture-caching", wr::DebugFlags_PICTURE_CACHING_DBG)
   GFX_WEBRENDER_DEBUG(".primitives", wr::DebugFlags_PRIMITIVE_DBG)
   // Bit 18 is for the zoom display, which requires the mouse position and thus
   // currently only works in wrench.
   GFX_WEBRENDER_DEBUG(".small-screen", wr::DebugFlags_SMALL_SCREEN)
+  GFX_WEBRENDER_DEBUG(".disable-opaque-pass", wr::DebugFlags_DISABLE_OPAQUE_PASS)
+  GFX_WEBRENDER_DEBUG(".disable-alpha-pass", wr::DebugFlags_DISABLE_ALPHA_PASS)
+  GFX_WEBRENDER_DEBUG(".disable-clip-masks", wr::DebugFlags_DISABLE_CLIP_MASKS)
+  GFX_WEBRENDER_DEBUG(".disable-text-prims", wr::DebugFlags_DISABLE_TEXT_PRIMS)
+  GFX_WEBRENDER_DEBUG(".disable-gradient-prims", wr::DebugFlags_DISABLE_GRADIENT_PRIMS)
 #undef GFX_WEBRENDER_DEBUG
 
   gfx::gfxVars::SetWebRenderDebugFlags(flags.bits);
 }
 
 #if defined(USE_SKIA)
 static uint32_t GetSkiaGlyphCacheSize() {
   // Only increase font cache size on non-android to save memory.
--- a/gfx/wr/debugger/src/components/OptionsPage.vue
+++ b/gfx/wr/debugger/src/components/OptionsPage.vue
@@ -31,16 +31,46 @@
             </label>
         </div>
         <div class="field">
             <label class="checkbox">
                 <input type="checkbox" :disabled="disabled" v-on:click="setGpuSampleQueries($event.target.checked)">
                 Enable GPU sample queries
             </label>
         </div>
+        <div class="field">
+            <label class="checkbox">
+                <input type="checkbox" :disabled="disabled" v-on:click="setOpaquePass(!$event.target.checked)">
+                Disable opaque pass
+            </label>
+        </div>
+        <div class="field">
+            <label class="checkbox">
+                <input type="checkbox" :disabled="disabled" v-on:click="setAlphaPass(!$event.target.checked)">
+                Disable alpha pass
+            </label>
+        </div>
+        <div class="field">
+            <label class="checkbox">
+                <input type="checkbox" :disabled="disabled" v-on:click="setClipMasks(!$event.target.checked)">
+                Disable clip masks
+            </label>
+        </div>
+        <div class="field">
+            <label class="checkbox">
+                <input type="checkbox" :disabled="disabled" v-on:click="setTextPrims(!$event.target.checked)">
+                Disable text primitives
+            </label>
+        </div>
+        <div class="field">
+            <label class="checkbox">
+                <input type="checkbox" :disabled="disabled" v-on:click="setGradientPrims(!$event.target.checked)">
+                Disable gradient primitives
+            </label>
+        </div>
     </div>
 </template>
 
 <script>
 export default {
     computed: {
         disabled() {
             return !this.$store.state.connected
@@ -83,15 +113,50 @@ export default {
             }
         },
         setGpuSampleQueries(enabled) {
             if (enabled) {
                 this.$store.dispatch('sendMessage', "enable_gpu_sample_queries");
             } else {
                 this.$store.dispatch('sendMessage', "disable_gpu_sample_queries");
             }
+        },
+        setOpaquePass(enabled) {
+            if (enabled) {
+                this.$store.dispatch('sendMessage', "enable_opaque_pass");
+            } else {
+                this.$store.dispatch('sendMessage', "disable_opaque_pass");
+            }
+        },
+        setAlphaPass(enabled) {
+            if (enabled) {
+                this.$store.dispatch('sendMessage', "enable_alpha_pass");
+            } else {
+                this.$store.dispatch('sendMessage', "disable_alpha_pass");
+            }
+        },
+        setClipMasks(enabled) {
+            if (enabled) {
+                this.$store.dispatch('sendMessage', "enable_clip_masks");
+            } else {
+                this.$store.dispatch('sendMessage', "disable_clip_masks");
+            }
+        },
+        setTextPrims(enabled) {
+            if (enabled) {
+                this.$store.dispatch('sendMessage', "enable_text_prims");
+            } else {
+                this.$store.dispatch('sendMessage', "disable_text_prims");
+            }
+        },
+        setGradientPrims(enabled) {
+            if (enabled) {
+                this.$store.dispatch('sendMessage', "enable_gradient_prims");
+            } else {
+                this.$store.dispatch('sendMessage', "disable_gradient_prims");
+            }
         }
     },
 }
 </script>
 
 <style>
 </style>
--- a/gfx/wr/webrender/src/debug_server.rs
+++ b/gfx/wr/webrender/src/debug_server.rs
@@ -57,16 +57,26 @@ impl ws::Handler for Server {
                     "enable_texture_cache_debug" => self.debug_flags.insert(DebugFlags::TEXTURE_CACHE_DBG),
                     "disable_texture_cache_debug" => self.debug_flags.remove(DebugFlags::TEXTURE_CACHE_DBG),
                     "enable_render_target_debug" => self.debug_flags.insert(DebugFlags::RENDER_TARGET_DBG),
                     "disable_render_target_debug" => self.debug_flags.remove(DebugFlags::RENDER_TARGET_DBG),
                     "enable_gpu_time_queries" => self.debug_flags.insert(DebugFlags::GPU_TIME_QUERIES),
                     "disable_gpu_time_queries" => self.debug_flags.remove(DebugFlags::GPU_TIME_QUERIES),
                     "enable_gpu_sample_queries" => self.debug_flags.insert(DebugFlags::GPU_SAMPLE_QUERIES),
                     "disable_gpu_sample_queries" => self.debug_flags.remove(DebugFlags::GPU_SAMPLE_QUERIES),
+                    "disable_opaque_pass" => self.debug_flags.insert(DebugFlags::DISABLE_OPAQUE_PASS),
+                    "enable_opaque_pass" => self.debug_flags.remove(DebugFlags::DISABLE_OPAQUE_PASS),
+                    "disable_alpha_pass" => self.debug_flags.insert(DebugFlags::DISABLE_ALPHA_PASS),
+                    "enable_alpha_pass" => self.debug_flags.remove(DebugFlags::DISABLE_ALPHA_PASS),
+                    "disable_clip_masks" => self.debug_flags.insert(DebugFlags::DISABLE_CLIP_MASKS),
+                    "enable_clip_masks" => self.debug_flags.remove(DebugFlags::DISABLE_CLIP_MASKS),
+                    "disable_text_prims" => self.debug_flags.insert(DebugFlags::DISABLE_TEXT_PRIMS),
+                    "enable_text_prims" => self.debug_flags.remove(DebugFlags::DISABLE_TEXT_PRIMS),
+                    "disable_gradient_prims" => self.debug_flags.insert(DebugFlags::DISABLE_GRADIENT_PRIMS),
+                    "enable_gradient_prims" => self.debug_flags.remove(DebugFlags::DISABLE_GRADIENT_PRIMS),
                     _ => set_flags = false,
                 };
 
                 let cmd = if set_flags {
                     DebugCommand::SetFlags(self.debug_flags)
                 } else {
                     match string.as_str() {
                         "fetch_passes" => DebugCommand::FetchPasses,
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -3740,45 +3740,63 @@ impl Renderer {
                 f(None)
             } else {
                 for region in regions {
                     f(Some(*region))
                 }
             }
         }
 
+        fn should_skip_batch(kind: &BatchKind, flags: &DebugFlags) -> bool {
+            match kind {
+                BatchKind::TextRun(_) => {
+                    flags.contains(DebugFlags::DISABLE_TEXT_PRIMS)
+                }
+                BatchKind::Brush(BrushBatchKind::RadialGradient) |
+                BatchKind::Brush(BrushBatchKind::LinearGradient) => {
+                    flags.contains(DebugFlags::DISABLE_GRADIENT_PRIMS)
+                }
+                _ => false,
+            }
+        }
+
         for alpha_batch_container in &target.alpha_batch_containers {
             let uses_scissor = alpha_batch_container.task_scissor_rect.is_some() ||
                                !alpha_batch_container.regions.is_empty();
 
             if uses_scissor {
                 self.device.enable_scissor();
                 let scissor_rect = draw_target.build_scissor_rect(
                     alpha_batch_container.task_scissor_rect,
                     content_origin,
                 );
                 self.device.set_scissor_rect(scissor_rect)
             }
 
-            if !alpha_batch_container.opaque_batches.is_empty() {
+            if !alpha_batch_container.opaque_batches.is_empty()
+                    && !self.debug_flags.contains(DebugFlags::DISABLE_OPAQUE_PASS) {
                 let _gl = self.gpu_profile.start_marker("opaque batches");
                 let opaque_sampler = self.gpu_profile.start_sampler(GPU_SAMPLER_TAG_OPAQUE);
                 self.set_blend(false, framebuffer_kind);
                 //Note: depth equality is needed for split planes
                 self.device.set_depth_func(DepthFunction::LessEqual);
                 self.device.enable_depth();
                 self.device.enable_depth_write();
 
                 // Draw opaque batches front-to-back for maximum
                 // z-buffer efficiency!
                 for batch in alpha_batch_container
                     .opaque_batches
                     .iter()
                     .rev()
                 {
+                    if should_skip_batch(&batch.key.kind, &self.debug_flags) {
+                        continue;
+                    }
+
                     self.shaders.borrow_mut()
                         .get(&batch.key, self.debug_flags)
                         .bind(
                             &mut self.device, projection,
                             &mut self.renderer_errors,
                         );
 
                     let _timer = self.gpu_profile.start_timer(batch.key.kind.sampler_tag());
@@ -3803,17 +3821,18 @@ impl Renderer {
                         }
                     );
                 }
 
                 self.device.disable_depth_write();
                 self.gpu_profile.finish_sampler(opaque_sampler);
             }
 
-            if !alpha_batch_container.alpha_batches.is_empty() {
+            if !alpha_batch_container.alpha_batches.is_empty()
+                    && !self.debug_flags.contains(DebugFlags::DISABLE_ALPHA_PASS) {
                 let _gl = self.gpu_profile.start_marker("alpha batches");
                 let transparent_sampler = self.gpu_profile.start_sampler(GPU_SAMPLER_TAG_TRANSPARENT);
                 self.set_blend(true, framebuffer_kind);
                 let mut prev_blend_mode = BlendMode::None;
 
                 // If the device supports pixel local storage, initialize the PLS buffer for
                 // the transparent pass. This involves reading the current framebuffer value
                 // and storing that in PLS.
@@ -3827,16 +3846,20 @@ impl Renderer {
                     self.init_pixel_local_storage(
                         alpha_batch_container.task_rect,
                         projection,
                         stats,
                     );
                 }
 
                 for batch in &alpha_batch_container.alpha_batches {
+                    if should_skip_batch(&batch.key.kind, &self.debug_flags) {
+                        continue;
+                    }
+
                     self.shaders.borrow_mut()
                         .get(&batch.key, self.debug_flags)
                         .bind(
                             &mut self.device, projection,
                             &mut self.renderer_errors,
                         );
 
                     if batch.key.blend_mode != prev_blend_mode {
@@ -4031,16 +4054,20 @@ impl Renderer {
 
     /// Draw all the instances in a clip batcher list to the current target.
     fn draw_clip_batch_list(
         &mut self,
         list: &ClipBatchList,
         projection: &Transform3D<f32>,
         stats: &mut RendererStats,
     ) {
+        if self.debug_flags.contains(DebugFlags::DISABLE_CLIP_MASKS) {
+            return;
+        }
+
         // draw rounded cornered rectangles
         if !list.slow_rectangles.is_empty() {
             let _gm2 = self.gpu_profile.start_marker("slow clip rectangles");
             self.shaders.borrow_mut().cs_clip_rectangle_slow.bind(
                 &mut self.device,
                 projection,
                 &mut self.renderer_errors,
             );
--- a/gfx/wr/webrender_api/src/api.rs
+++ b/gfx/wr/webrender_api/src/api.rs
@@ -1054,16 +1054,23 @@ bitflags! {
         /// Highlight all primitives with colors based on kind.
         const PRIMITIVE_DBG = 1 << 16;
         /// Draw a zoom widget showing part of the framebuffer zoomed in.
         const ZOOM_DBG = 1 << 17;
         /// Scale the debug renderer down for a smaller screen. This will disrupt
         /// any mapping between debug display items and page content, so shouldn't
         /// be used with overlays like the picture caching or primitive display.
         const SMALL_SCREEN = 1 << 18;
+        /// Disable various bits of the WebRender pipeline, to help narrow
+        /// down where slowness might be coming from.
+        const DISABLE_OPAQUE_PASS = 1 << 19;
+        const DISABLE_ALPHA_PASS = 1 << 20;
+        const DISABLE_CLIP_MASKS = 1 << 21;
+        const DISABLE_TEXT_PRIMS = 1 << 22;
+        const DISABLE_GRADIENT_PRIMS = 1 << 23;
     }
 }
 
 pub struct RenderApi {
     api_sender: MsgSender<ApiMsg>,
     payload_sender: PayloadSender,
     namespace_id: IdNamespace,
     next_id: Cell<ResourceId>,