Bug 1595036 - Put GPU debug markers behind a pref r=kvark
authorMiko Mynttinen <mikokm@gmail.com>
Fri, 08 Nov 2019 15:59:27 +0000
changeset 501310 093ad83d0ab40951603cb3df46dc29877d51ca75
parent 501309 f414b9e6d85710f92649566c1c6511265dadd476
child 501311 efc82f89a7c74dc8efe498342f78a4b379acabd4
push id114168
push userdluca@mozilla.com
push dateSun, 10 Nov 2019 03:08:55 +0000
treeherdermozilla-inbound@33f64c1ef3e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskvark
bugs1595036
milestone72.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 1595036 - Put GPU debug markers behind a pref r=kvark Differential Revision: https://phabricator.services.mozilla.com/D52339
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/src/bindings.rs
gfx/wr/webrender/src/renderer.rs
modules/libpref/init/StaticPrefList.yaml
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -93,17 +93,18 @@ class NewRenderer : public RendererEvent
                 ? aRenderThread.GetShaders()->RawShaders()
                 : nullptr,
             aRenderThread.ThreadPool().Raw(), &WebRenderMallocSizeOf,
             &WebRenderMallocEnclosingSizeOf, (uint32_t)wr::RenderRoot::Default,
             compositor->ShouldUseNativeCompositor() ? compositor.get()
                                                     : nullptr,
             compositor->GetMaxUpdateRects(),
             compositor->GetMaxPartialPresentRects(), mDocHandle, &wrRenderer,
-            mMaxTextureSize)) {
+            mMaxTextureSize,
+            StaticPrefs::gfx_webrender_enable_gpu_markers_AtStartup())) {
       // wr_window_new puts a message into gfxCriticalNote if it returns false
       return;
     }
     MOZ_ASSERT(wrRenderer);
 
     RefPtr<RenderThread> thread = &aRenderThread;
     auto renderer =
         MakeUnique<RendererOGL>(std::move(thread), std::move(compositor),
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1302,17 +1302,18 @@ pub extern "C" fn wr_window_new(window_i
                                 size_of_op: VoidPtrToSizeFn,
                                 enclosing_size_of_op: VoidPtrToSizeFn,
                                 document_id: u32,
                                 compositor: *mut c_void,
                                 max_update_rects: usize,
                                 max_partial_present_rects: usize,
                                 out_handle: &mut *mut DocumentHandle,
                                 out_renderer: &mut *mut Renderer,
-                                out_max_texture_size: *mut i32)
+                                out_max_texture_size: *mut i32,
+                                enable_gpu_markers: bool)
                                 -> bool {
     assert!(unsafe { is_in_render_thread() });
 
     let recorder: Option<Box<dyn ApiRecordingReceiver>> = if unsafe { gfx_use_wrench() } {
         let name = format!("wr-record-{}.bin", window_id.0);
         Some(Box::new(BinaryRecorder::new(&PathBuf::from(name))))
     } else {
         None
@@ -1400,16 +1401,17 @@ pub extern "C" fn wr_window_new(window_i
         clear_color: Some(color),
         precache_flags,
         namespace_alloc_by_client: true,
         enable_picture_caching,
         allow_pixel_local_storage_support: false,
         start_debug_server,
         surface_origin_is_top_left,
         compositor_config,
+        enable_gpu_markers,
         ..Default::default()
     };
 
     // Ensure the WR profiler callbacks are hooked up to the Gecko profiler.
     set_profiler_hooks(Some(&PROFILER_HOOKS));
 
     let window_size = DeviceIntSize::new(window_width, window_height);
     let notifier = Box::new(CppNotifier {
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -2301,27 +2301,30 @@ impl Renderer {
                 namespace_alloc_by_client,
             );
             backend.run(backend_profile_counters);
             if let Some(ref thread_listener) = *thread_listener_for_render_backend {
                 thread_listener.thread_stopped(&rb_thread_name);
             }
         })?;
 
-        let debug_support = if device.supports_extension("GL_KHR_debug") {
+        let debug_method = if !options.enable_gpu_markers {
+            // The GPU markers are disabled.
+            GpuDebugMethod::None
+        } else if device.supports_extension("GL_KHR_debug") {
             GpuDebugMethod::KHR
         } else if device.supports_extension("GL_EXT_debug_marker") {
             GpuDebugMethod::MarkerEXT
         } else {
             GpuDebugMethod::None
         };
 
-        info!("using {:?}", debug_support);
-
-        let gpu_profile = GpuProfiler::new(Rc::clone(device.rc_gl()), debug_support);
+        info!("using {:?}", debug_method);
+
+        let gpu_profile = GpuProfiler::new(Rc::clone(device.rc_gl()), debug_method);
         #[cfg(feature = "capture")]
         let read_fbo = device.create_fbo();
 
         let mut renderer = Renderer {
             result_rx,
             debug_server,
             device,
             active_documents: Vec::new(),
@@ -6159,16 +6162,17 @@ pub struct RendererOptions {
     pub batch_lookback_count: usize,
     /// Start the debug server for this renderer.
     pub start_debug_server: bool,
     /// Output the source of the shader with the given name.
     pub dump_shader_source: Option<String>,
     pub surface_origin_is_top_left: bool,
     /// The configuration options defining how WR composites the final scene.
     pub compositor_config: CompositorConfig,
+    pub enable_gpu_markers: bool,
 }
 
 impl Default for RendererOptions {
     fn default() -> Self {
         RendererOptions {
             device_pixel_ratio: 1.0,
             resource_override_path: None,
             enable_aa: true,
@@ -6213,16 +6217,17 @@ impl Default for RendererOptions {
             // For backwards compatibility we set this to true by default, so
             // that if the debugger feature is enabled, the debug server will
             // be started automatically. Users can explicitly disable this as
             // needed.
             start_debug_server: true,
             dump_shader_source: None,
             surface_origin_is_top_left: false,
             compositor_config: CompositorConfig::default(),
+            enable_gpu_markers: true,
         }
     }
 }
 
 pub trait DebugServer {
     fn send(&mut self, _message: String);
 }
 
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -3627,16 +3627,25 @@
 #endif
   mirror: once
 
 - name: gfx.webrender.max-partial-present-rects
   type: uint32_t
   value: 0
   mirror: once
 
+- name: gfx.webrender.enable-gpu-markers
+  type: bool
+#ifdef DEBUG
+  value: true
+#else
+  value: false
+#endif
+  mirror: once
+
 #ifdef NIGHTLY_BUILD
   # Keep this pref hidden on non-nightly builds to avoid people accidentally
   # turning it on.
 -   name: gfx.webrender.start-debug-server
     type: RelaxedAtomicBool
     value: false
     mirror: always
 #endif