From 7eee44a5923697f31c807858eb8aac3019718e35 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Mon, 13 Apr 2020 23:26:07 +0000 Subject: [PATCH] Bug 1629693 - Enable GPU cache scatter path when running ANGLE. r=kvark On some (mostly older, integrated) GPUs, the normal GPU texture cache update path doesn't work well when running on ANGLE, causing CPU stalls inside D3D and/or the GPU driver. To reduce the number of code paths we have active that require testing, we will enable the GPU cache scatter update path on all devices running with ANGLE. We want a better solution long-term, but for now this is a significant performance improvement on HD4600 era GPUs, and shouldn't hurt performance in a noticeable way on other systems running under ANGLE. Differential Revision: https://phabricator.services.mozilla.com/D70764 --HG-- extra : moz-landing-system : lando --- gfx/wr/examples/common/boilerplate.rs | 1 - gfx/wr/webrender/src/device/gl.rs | 9 +++++---- gfx/wr/webrender/src/renderer.rs | 15 +++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gfx/wr/examples/common/boilerplate.rs b/gfx/wr/examples/common/boilerplate.rs index b6bf25e68e01..9f70707fa10e 100644 --- a/gfx/wr/examples/common/boilerplate.rs +++ b/gfx/wr/examples/common/boilerplate.rs @@ -164,7 +164,6 @@ pub fn main_wrapper( precache_flags: E::PRECACHE_SHADER_FLAGS, device_pixel_ratio, clear_color: Some(ColorF::new(0.3, 0.0, 0.0, 1.0)), - //scatter_gpu_cache_updates: false, debug_flags, //allow_texture_swizzling: false, ..options.unwrap_or(webrender::RendererOptions::default()) diff --git a/gfx/wr/webrender/src/device/gl.rs b/gfx/wr/webrender/src/device/gl.rs index 1bfad787c158..f77bbe388a66 100644 --- a/gfx/wr/webrender/src/device/gl.rs +++ b/gfx/wr/webrender/src/device/gl.rs @@ -790,7 +790,7 @@ impl ProgramSourceInfo { let source_and_digest = SHADERS.get(&name).expect("Shader not found"); // Hash the renderer name. - hasher.write(device.renderer_name.as_bytes()); + hasher.write(device.capabilities.renderer_name.as_bytes()); // Hash the prefix string. build_shader_prefix_string( @@ -999,6 +999,8 @@ pub struct Capabilities { pub supports_nonzero_pbo_offsets: bool, /// Whether the driver supports specifying the texture usage up front. pub supports_texture_usage: bool, + /// The name of the renderer, as reported by GL + pub renderer_name: String, } #[derive(Clone, Debug)] @@ -1083,7 +1085,6 @@ pub struct Device { max_texture_size: i32, max_texture_layers: u32, - renderer_name: String, cached_programs: Option>, // Frame counter. This is used to map between CPU @@ -1554,6 +1555,7 @@ impl Device { supports_texture_swizzle, supports_nonzero_pbo_offsets, supports_texture_usage, + renderer_name, }, color_formats, @@ -1578,7 +1580,6 @@ impl Device { max_texture_size, max_texture_layers, - renderer_name, cached_programs, frame_id: GpuFrameId(0), extensions, @@ -1998,7 +1999,7 @@ impl Device { error!( "Failed to load a program object with a program binary: {} renderer {}\n{}", &info.base_filename, - self.renderer_name, + self.capabilities.renderer_name, error_log ); if let Some(ref program_cache_handler) = cached_programs.program_cache_handler { diff --git a/gfx/wr/webrender/src/renderer.rs b/gfx/wr/webrender/src/renderer.rs index 49becbd30df1..281b71a2d162 100644 --- a/gfx/wr/webrender/src/renderer.rs +++ b/gfx/wr/webrender/src/renderer.rs @@ -2231,9 +2231,19 @@ impl Renderer { let transforms_texture = VertexDataTexture::new(&mut device, ImageFormat::RGBAF32); let render_task_texture = VertexDataTexture::new(&mut device, ImageFormat::RGBAF32); + // On some (mostly older, integrated) GPUs, the normal GPU texture cache update path + // doesn't work well when running on ANGLE, causing CPU stalls inside D3D and/or the + // GPU driver. See https://bugzilla.mozilla.org/show_bug.cgi?id=1576637 for much + // more detail. To reduce the number of code paths we have active that require testing, + // we will enable the GPU cache scatter update path on all devices running with ANGLE. + // We want a better solution long-term, but for now this is a significant performance + // improvement on HD4600 era GPUs, and shouldn't hurt performance in a noticeable + // way on other systems running under ANGLE. + let is_angle = device.get_capabilities().renderer_name.contains("ANGLE"); + let gpu_cache_texture = GpuCacheTexture::new( &mut device, - options.scatter_gpu_cache_updates, + is_angle, )?; device.end_frame(); @@ -6608,7 +6618,6 @@ pub struct RendererOptions { pub enable_clear_scissor: bool, pub max_texture_size: Option, pub max_glyph_cache_size: Option, - pub scatter_gpu_cache_updates: bool, pub upload_method: UploadMethod, pub workers: Option>, pub enable_multithreading: bool, @@ -6679,8 +6688,6 @@ impl Default for RendererOptions { enable_clear_scissor: true, max_texture_size: None, max_glyph_cache_size: None, - // Scattered GPU cache updates haven't met a test that would show their superiority yet. - scatter_gpu_cache_updates: false, // This is best as `Immediate` on Angle, or `Pixelbuffer(Dynamic)` on GL, // but we are unable to make this decision here, so picking the reasonable medium. upload_method: UploadMethod::PixelBuffer(VertexUsageHint::Stream),