Backed out 2 changesets (bug 1554502) for causing build bustages. a=backout
authorOana Pop Rus <opoprus@mozilla.com>
Mon, 10 Jun 2019 15:56:54 +0300
changeset 536783 73ae511ea89559d9c1b848a8d27cfe1fb6b2e034
parent 536782 121bb815438386f3f7b31a39da9aa3f29bc96f18
child 536784 7619b650e72a615fd8681df1d6d945070f547cd2
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1554502
milestone68.0
backs oute4b071df2c1c3359916ca49ad964817ec9e724ff
4ab0defb9012f8377cc29b5ee6da821699f2d16f
Backed out 2 changesets (bug 1554502) for causing build bustages. a=backout Backed out changeset e4b071df2c1c (bug 1554502) Backed out changeset 4ab0defb9012 (bug 1554502)
gfx/wr/webrender/src/batch.rs
gfx/wr/webrender/src/clip.rs
gfx/wr/webrender/src/frame_builder.rs
gfx/wr/webrender/src/picture.rs
gfx/wr/webrender/src/render_task.rs
gfx/wr/webrender/src/renderer.rs
gfx/wr/webrender/src/tiling.rs
--- a/gfx/wr/webrender/src/batch.rs
+++ b/gfx/wr/webrender/src/batch.rs
@@ -134,150 +134,137 @@ fn textures_compatible(t1: TextureSource
 }
 
 pub struct AlphaBatchList {
     pub batches: Vec<PrimitiveBatch>,
     pub item_rects: Vec<Vec<PictureRect>>,
     current_batch_index: usize,
     current_z_id: ZBufferId,
     break_advanced_blend_batches: bool,
-    lookback_count: usize,
 }
 
 impl AlphaBatchList {
-    fn new(break_advanced_blend_batches: bool, lookback_count: usize) -> Self {
+    fn new(break_advanced_blend_batches: bool) -> Self {
         AlphaBatchList {
             batches: Vec::new(),
             item_rects: Vec::new(),
             current_z_id: ZBufferId::invalid(),
             current_batch_index: usize::MAX,
             break_advanced_blend_batches,
-            lookback_count,
         }
     }
 
     pub fn set_params_and_get_batch(
         &mut self,
         key: BatchKey,
-        // The bounding box of everything at this Z plane. We expect potentially
-        // multiple primitive segments coming with the same `z_id`.
-        z_bounding_rect: &PictureRect,
+        bounding_rect: &PictureRect,
         z_id: ZBufferId,
     ) -> &mut Vec<PrimitiveInstanceData> {
         if z_id != self.current_z_id ||
            self.current_batch_index == usize::MAX ||
            !self.batches[self.current_batch_index].key.is_compatible_with(&key)
         {
             let mut selected_batch_index = None;
 
             match key.blend_mode {
                 BlendMode::SubpixelWithBgColor => {
-                    'outer_multipass: for (batch_index, batch) in self.batches.iter().enumerate().rev().take(self.lookback_count) {
+                    'outer_multipass: for (batch_index, batch) in self.batches.iter().enumerate().rev().take(10) {
                         // Some subpixel batches are drawn in two passes. Because of this, we need
                         // to check for overlaps with every batch (which is a bit different
                         // than the normal batching below).
                         for item_rect in &self.item_rects[batch_index] {
-                            if item_rect.intersects(z_bounding_rect) {
+                            if item_rect.intersects(bounding_rect) {
                                 break 'outer_multipass;
                             }
                         }
 
                         if batch.key.is_compatible_with(&key) {
                             selected_batch_index = Some(batch_index);
                             break;
                         }
                     }
                 }
                 BlendMode::Advanced(_) if self.break_advanced_blend_batches => {
                     // don't try to find a batch
                 }
                 _ => {
-                    'outer_default: for (batch_index, batch) in self.batches.iter().enumerate().rev().take(self.lookback_count) {
+                    'outer_default: for (batch_index, batch) in self.batches.iter().enumerate().rev().take(10) {
                         // For normal batches, we only need to check for overlaps for batches
                         // other than the first batch we consider. If the first batch
                         // is compatible, then we know there isn't any potential overlap
                         // issues to worry about.
                         if batch.key.is_compatible_with(&key) {
                             selected_batch_index = Some(batch_index);
                             break;
                         }
 
                         // check for intersections
                         for item_rect in &self.item_rects[batch_index] {
-                            if item_rect.intersects(z_bounding_rect) {
+                            if item_rect.intersects(bounding_rect) {
                                 break 'outer_default;
                             }
                         }
                     }
                 }
             }
 
             if selected_batch_index.is_none() {
                 let new_batch = PrimitiveBatch::new(key);
                 selected_batch_index = Some(self.batches.len());
                 self.batches.push(new_batch);
                 self.item_rects.push(Vec::new());
             }
 
             self.current_batch_index = selected_batch_index.unwrap();
-            self.item_rects[self.current_batch_index].push(*z_bounding_rect);
+            self.item_rects[self.current_batch_index].push(*bounding_rect);
             self.current_z_id = z_id;
-        } else if cfg!(debug_assertions) {
-            // If it's a different segment of the same (larger) primitive, we expect the bounding box
-            // to be the same - coming from the primitive itself, not the segment.
-            assert_eq!(self.item_rects[self.current_batch_index].last(), Some(z_bounding_rect));
         }
 
         &mut self.batches[self.current_batch_index].instances
     }
 }
 
 pub struct OpaqueBatchList {
     pub pixel_area_threshold_for_new_batch: f32,
     pub batches: Vec<PrimitiveBatch>,
     pub current_batch_index: usize,
-    lookback_count: usize,
 }
 
 impl OpaqueBatchList {
-    fn new(pixel_area_threshold_for_new_batch: f32, lookback_count: usize) -> Self {
+    fn new(pixel_area_threshold_for_new_batch: f32) -> Self {
         OpaqueBatchList {
             batches: Vec::new(),
             pixel_area_threshold_for_new_batch,
             current_batch_index: usize::MAX,
-            lookback_count,
         }
     }
 
     pub fn set_params_and_get_batch(
         &mut self,
         key: BatchKey,
-        // The bounding box of everything at the current Z, whatever it is. We expect potentially
-        // multiple primitive segments produced by a primitive, which we allow to check
-        // `current_batch_index` instead of iterating the batches.
-        z_bounding_rect: &PictureRect,
+        bounding_rect: &PictureRect,
     ) -> &mut Vec<PrimitiveInstanceData> {
         if self.current_batch_index == usize::MAX ||
            !self.batches[self.current_batch_index].key.is_compatible_with(&key) {
             let mut selected_batch_index = None;
-            let item_area = z_bounding_rect.size.area();
+            let item_area = bounding_rect.size.area();
 
             // If the area of this primitive is larger than the given threshold,
             // then it is large enough to warrant breaking a batch for. In this
             // case we just see if it can be added to the existing batch or
             // create a new one.
             if item_area > self.pixel_area_threshold_for_new_batch {
                 if let Some(batch) = self.batches.last() {
                     if batch.key.is_compatible_with(&key) {
                         selected_batch_index = Some(self.batches.len() - 1);
                     }
                 }
             } else {
                 // Otherwise, look back through a reasonable number of batches.
-                for (batch_index, batch) in self.batches.iter().enumerate().rev().take(self.lookback_count) {
+                for (batch_index, batch) in self.batches.iter().enumerate().rev().take(10) {
                     if batch.key.is_compatible_with(&key) {
                         selected_batch_index = Some(batch_index);
                         break;
                     }
                 }
             }
 
             if selected_batch_index.is_none() {
@@ -315,25 +302,24 @@ pub struct BatchList {
 }
 
 impl BatchList {
     pub fn new(
         screen_size: DeviceIntSize,
         regions: Vec<DeviceIntRect>,
         tile_blits: Vec<TileBlit>,
         break_advanced_blend_batches: bool,
-        lookback_count: usize,
     ) -> Self {
         // The threshold for creating a new batch is
         // one quarter the screen size.
         let batch_area_threshold = (screen_size.width * screen_size.height) as f32 / 4.0;
 
         BatchList {
-            alpha_batch_list: AlphaBatchList::new(break_advanced_blend_batches, lookback_count),
-            opaque_batch_list: OpaqueBatchList::new(batch_area_threshold, lookback_count),
+            alpha_batch_list: AlphaBatchList::new(break_advanced_blend_batches),
+            opaque_batch_list: OpaqueBatchList::new(batch_area_threshold),
             regions,
             tile_blits,
         }
     }
 
     pub fn push_single_instance(
         &mut self,
         key: BatchKey,
@@ -475,57 +461,52 @@ struct SegmentInstanceData {
     user_data: i32,
 }
 
 /// Encapsulates the logic of building batches for items that are blended.
 pub struct AlphaBatchBuilder {
     pub batch_lists: Vec<BatchList>,
     screen_size: DeviceIntSize,
     break_advanced_blend_batches: bool,
-    lookback_count: usize,
     render_task_id: RenderTaskId,
 }
 
 impl AlphaBatchBuilder {
     pub fn new(
         screen_size: DeviceIntSize,
         break_advanced_blend_batches: bool,
-        lookback_count: usize,
         render_task_id: RenderTaskId,
     ) -> Self {
         let batch_lists = vec![
             BatchList::new(
                 screen_size,
                 Vec::new(),
                 Vec::new(),
                 break_advanced_blend_batches,
-                lookback_count,
             ),
         ];
 
         AlphaBatchBuilder {
             batch_lists,
             screen_size,
             break_advanced_blend_batches,
-            lookback_count,
             render_task_id,
         }
     }
 
     fn push_new_batch_list(
         &mut self,
         regions: Vec<DeviceIntRect>,
         tile_blits: Vec<TileBlit>,
     ) {
         self.batch_lists.push(BatchList::new(
             self.screen_size,
             regions,
             tile_blits,
             self.break_advanced_blend_batches,
-            self.lookback_count,
         ));
     }
 
     fn current_batch_list(&mut self) -> &mut BatchList {
         self.batch_lists.last_mut().unwrap()
     }
 
     fn can_merge(&self) -> bool {
@@ -587,32 +568,30 @@ impl BatchBuilder {
         batcher: &mut AlphaBatchBuilder,
         ctx: &RenderTargetContext,
         gpu_cache: &mut GpuCache,
         render_tasks: &RenderTaskGraph,
         deferred_resolves: &mut Vec<DeferredResolve>,
         prim_headers: &mut PrimitiveHeaders,
         transforms: &mut TransformPalette,
         root_spatial_node_index: SpatialNodeIndex,
-        surface_spatial_node_index: SpatialNodeIndex,
         z_generator: &mut ZBufferIdGenerator,
     ) {
         // Add each run in this picture to the batch.
         for prim_instance in &pic.prim_list.prim_instances {
             self.add_prim_to_batch(
                 prim_instance,
                 batcher,
                 ctx,
                 gpu_cache,
                 render_tasks,
                 deferred_resolves,
                 prim_headers,
                 transforms,
                 root_spatial_node_index,
-                surface_spatial_node_index,
                 z_generator,
             );
         }
     }
 
     // Adds a primitive to a batch.
     // It can recursively call itself in some situations, for
     // example if it encounters a picture where the items
@@ -623,17 +602,16 @@ impl BatchBuilder {
         batcher: &mut AlphaBatchBuilder,
         ctx: &RenderTargetContext,
         gpu_cache: &mut GpuCache,
         render_tasks: &RenderTaskGraph,
         deferred_resolves: &mut Vec<DeferredResolve>,
         prim_headers: &mut PrimitiveHeaders,
         transforms: &mut TransformPalette,
         root_spatial_node_index: SpatialNodeIndex,
-        surface_spatial_node_index: SpatialNodeIndex,
         z_generator: &mut ZBufferIdGenerator,
     ) {
         if prim_instance.visibility_info == PrimitiveVisibilityIndex::INVALID {
             return;
         }
 
         #[cfg(debug_assertions)] //TODO: why is this needed?
         debug_assert_eq!(prim_instance.prepared_frame_id, render_tasks.frame_id());
@@ -664,21 +642,16 @@ impl BatchBuilder {
 
         let snap_offsets = prim_info.snap_offsets;
         let render_task_address = render_tasks.get_task_address(batcher.render_task_id);
 
         if is_chased {
             println!("\tbatch {:?} with bound {:?}", prim_rect, bounding_rect);
         }
 
-        if !bounding_rect.is_empty() {
-            debug_assert_eq!(prim_info.clip_chain.pic_spatial_node_index, surface_spatial_node_index,
-                "The primitive's bounding box is specified in a different coordinate system from the current batch!");
-        }
-
         match prim_instance.kind {
             PrimitiveInstanceKind::Clear { data_handle } => {
                 let prim_data = &ctx.data_stores.prim[data_handle];
                 let prim_cache_address = gpu_cache.get_address(&prim_data.gpu_cache_handle);
 
                 // TODO(gw): We can abstract some of the common code below into
                 //           helper methods, as we port more primitives to make
                 //           use of interning.
@@ -1032,20 +1005,20 @@ impl BatchBuilder {
                     specific_prim_address: prim_cache_address,
                     transform_id,
                 };
 
                 match picture.context_3d {
                     // Convert all children of the 3D hierarchy root into batches.
                     Picture3DContext::In { root_data: Some(ref list), .. } => {
                         for child in list {
-                            let child_prim_instance = &picture.prim_list.prim_instances[child.anchor];
-                            let child_prim_info = &ctx.scratch.prim_info[child_prim_instance.visibility_info.0 as usize];
+                            let prim_instance = &picture.prim_list.prim_instances[child.anchor];
+                            let prim_info = &ctx.scratch.prim_info[prim_instance.visibility_info.0 as usize];
 
-                            let child_pic_index = match child_prim_instance.kind {
+                            let child_pic_index = match prim_instance.kind {
                                 PrimitiveInstanceKind::Picture { pic_index, .. } => pic_index,
                                 PrimitiveInstanceKind::LineDecoration { .. } |
                                 PrimitiveInstanceKind::TextRun { .. } |
                                 PrimitiveInstanceKind::NormalBorder { .. } |
                                 PrimitiveInstanceKind::ImageBorder { .. } |
                                 PrimitiveInstanceKind::Rectangle { .. } |
                                 PrimitiveInstanceKind::YuvImage { .. } |
                                 PrimitiveInstanceKind::Image { .. } |
@@ -1054,23 +1027,23 @@ impl BatchBuilder {
                                 PrimitiveInstanceKind::Clear { .. } => {
                                     unreachable!();
                                 }
                             };
                             let pic = &ctx.prim_store.pictures[child_pic_index.0];
 
                             // Get clip task, if set, for the picture primitive.
                             let clip_task_address = ctx.get_prim_clip_task_address(
-                                child_prim_info.clip_task_index,
+                                prim_info.clip_task_index,
                                 render_tasks,
                             ).unwrap_or(OPAQUE_TASK_ADDRESS);
 
                             let prim_header = PrimitiveHeader {
                                 local_rect: pic.snapped_local_rect,
-                                local_clip_rect: child_prim_info.combined_local_clip_rect,
+                                local_clip_rect: prim_info.combined_local_clip_rect,
                                 snap_offsets,
                                 specific_prim_address: GpuCacheAddress::INVALID,
                                 transform_id: transforms
                                     .get_id(
                                         child.spatial_node_index,
                                         root_spatial_node_index,
                                         ctx.clip_scroll_tree,
                                     ),
@@ -1133,56 +1106,42 @@ impl BatchBuilder {
                             BrushFlags::empty()
                         };
 
                         let clip_task_address = ctx.get_prim_clip_task_address(
                             prim_info.clip_task_index,
                             render_tasks,
                         ).unwrap_or(OPAQUE_TASK_ADDRESS);
 
-                        let surface = &ctx.surfaces[raster_config.surface_index.0];
-                        let surface_task = surface.render_tasks.map(|s| s.root);
+                        let surface = ctx
+                            .surfaces[raster_config.surface_index.0]
+                            .render_tasks
+                            .map(|s| s.root);
 
                         match raster_config.composite_mode {
                             PictureCompositeMode::TileCache { .. } => {
                                 let tile_cache = picture.tile_cache.as_ref().unwrap();
 
                                 // If the tile cache is disabled, just recurse into the
                                 // picture like a normal pass-through picture, adding
                                 // any child primitives into the parent surface batches.
                                 if !tile_cache.is_enabled {
-                                    // Forcefully break the batches if the
-                                    if surface.surface_spatial_node_index != surface_spatial_node_index {
-                                        self.batcher.push_new_batch_list(
-                                            Vec::new(),
-                                            Vec::new(),
-                                        );
-                                    }
-
                                     self.add_pic_to_batch(
                                         picture,
                                         batcher,
                                         ctx,
                                         gpu_cache,
                                         render_tasks,
                                         deferred_resolves,
                                         prim_headers,
                                         transforms,
                                         root_spatial_node_index,
-                                        surface.surface_spatial_node_index,
                                         z_generator,
                                     );
 
-                                    if surface.surface_spatial_node_index != surface_spatial_node_index {
-                                        self.batcher.push_new_batch_list(
-                                            Vec::new(),
-                                            Vec::new(),
-                                        );
-                                    }
-
                                     return;
                                 }
 
                                 // Construct a local clip rect that ensures we only draw pixels where
                                 // the local bounds of the picture extend to within the edge tiles.
                                 let local_clip_rect = prim_info
                                     .combined_local_clip_rect
                                     .intersection(&picture.snapped_local_rect)
@@ -1304,17 +1263,16 @@ impl BatchBuilder {
                                             batcher,
                                             ctx,
                                             gpu_cache,
                                             render_tasks,
                                             deferred_resolves,
                                             prim_headers,
                                             transforms,
                                             root_spatial_node_index,
-                                            surface.surface_spatial_node_index,
                                             z_generator,
                                         );
 
                                         batcher.push_new_batch_list(
                                             Vec::new(),
                                             Vec::new(),
                                         );
                                     }
@@ -1323,17 +1281,17 @@ impl BatchBuilder {
                             PictureCompositeMode::Filter(ref filter) => {
                                 assert!(filter.is_visible());
                                 match filter {
                                     Filter::Blur(..) => {
                                         let kind = BatchKind::Brush(
                                             BrushBatchKind::Image(ImageBufferKind::Texture2DArray)
                                         );
                                         let (uv_rect_address, textures) = render_tasks.resolve_surface(
-                                            surface_task.expect("bug: surface must be allocated by now"),
+                                            surface.expect("bug: surface must be allocated by now"),
                                             gpu_cache,
                                         );
                                         let key = BatchKey::new(
                                             kind,
                                             non_segmented_blend_mode,
                                             textures,
                                         );
                                         let prim_header_index = prim_headers.push(&prim_header, z_id, [
@@ -1384,17 +1342,17 @@ impl BatchBuilder {
                                             ],
                                         };
 
                                         // Build batch keys for shadow/content
                                         let shadow_key = BatchKey::new(kind, non_segmented_blend_mode, shadow_textures);
                                         let content_key = BatchKey::new(kind, non_segmented_blend_mode, content_textures);
 
                                         // Retrieve the UV rect addresses for shadow/content.
-                                        let cache_task_id = surface_task
+                                        let cache_task_id = surface
                                             .expect("bug: surface must be allocated by now");
                                         let shadow_uv_rect_address = render_tasks[cache_task_id]
                                             .get_texture_address(gpu_cache)
                                             .as_int();
                                         let content_uv_rect_address = render_tasks[secondary_id]
                                             .get_texture_address(gpu_cache)
                                             .as_int();
 
@@ -1502,17 +1460,17 @@ impl BatchBuilder {
                                             }
                                             Filter::ColorMatrix(_) => {
                                                 picture.extra_gpu_data_handles[0].as_int(gpu_cache)
                                             }
                                             Filter::ComponentTransfer => unreachable!(),
                                         };
 
                                         let (uv_rect_address, textures) = render_tasks.resolve_surface(
-                                            surface_task.expect("bug: surface must be allocated by now"),
+                                            surface.expect("bug: surface must be allocated by now"),
                                             gpu_cache,
                                         );
 
                                         let key = BatchKey::new(
                                             BatchKind::Brush(BrushBatchKind::Blend),
                                             BlendMode::PremultipliedAlpha,
                                             textures,
                                         );
@@ -1552,17 +1510,17 @@ impl BatchBuilder {
                                     ((filter_data.data.r_func.to_int() << 28 |
                                       filter_data.data.g_func.to_int() << 24 |
                                       filter_data.data.b_func.to_int() << 20 |
                                       filter_data.data.a_func.to_int() << 16) as i32);
 
                                 let user_data = filter_data.gpu_cache_handle.as_int(gpu_cache);
 
                                 let (uv_rect_address, textures) = render_tasks.resolve_surface(
-                                    surface_task.expect("bug: surface must be allocated by now"),
+                                    surface.expect("bug: surface must be allocated by now"),
                                     gpu_cache,
                                 );
 
                                 let key = BatchKey::new(
                                     BatchKind::Brush(BrushBatchKind::Blend),
                                     BlendMode::PremultipliedAlpha,
                                     textures,
                                 );
@@ -1588,17 +1546,17 @@ impl BatchBuilder {
                                     key,
                                     bounding_rect,
                                     z_id,
                                     PrimitiveInstanceData::from(instance),
                                 );
                             }
                             PictureCompositeMode::MixBlend(mode) if ctx.use_advanced_blending => {
                                 let (uv_rect_address, textures) = render_tasks.resolve_surface(
-                                    surface_task.expect("bug: surface must be allocated by now"),
+                                    surface.expect("bug: surface must be allocated by now"),
                                     gpu_cache,
                                 );
                                 let key = BatchKey::new(
                                     BatchKind::Brush(
                                         BrushBatchKind::Image(ImageBufferKind::Texture2DArray),
                                     ),
                                     BlendMode::Advanced(mode),
                                     textures,
@@ -1623,17 +1581,17 @@ impl BatchBuilder {
                                 batcher.current_batch_list().push_single_instance(
                                     key,
                                     bounding_rect,
                                     z_id,
                                     PrimitiveInstanceData::from(instance),
                                 );
                             }
                             PictureCompositeMode::MixBlend(mode) => {
-                                let cache_task_id = surface_task.expect("bug: surface must be allocated by now");
+                                let cache_task_id = surface.expect("bug: surface must be allocated by now");
                                 let backdrop_id = picture.secondary_render_task_id.expect("no backdrop!?");
 
                                 let key = BatchKey::new(
                                     BatchKind::Brush(
                                         BrushBatchKind::MixBlend {
                                             task_id: batcher.render_task_id,
                                             source_id: cache_task_id,
                                             backdrop_id,
@@ -1664,17 +1622,17 @@ impl BatchBuilder {
                                 batcher.current_batch_list().push_single_instance(
                                     key,
                                     bounding_rect,
                                     z_id,
                                     PrimitiveInstanceData::from(instance),
                                 );
                             }
                             PictureCompositeMode::Blit(_) => {
-                                let cache_task_id = surface_task.expect("bug: surface must be allocated by now");
+                                let cache_task_id = surface.expect("bug: surface must be allocated by now");
                                 let uv_rect_address = render_tasks[cache_task_id]
                                     .get_texture_address(gpu_cache)
                                     .as_int();
                                 let batch_params = BrushBatchParameters::shared(
                                     BrushBatchKind::Image(ImageBufferKind::Texture2DArray),
                                     BatchTextures::render_target_cache(),
                                     [
                                         ShaderColorMode::Image as i32 | ((AlphaType::PremultipliedAlpha as i32) << 16),
@@ -1747,17 +1705,16 @@ impl BatchBuilder {
                             batcher,
                             ctx,
                             gpu_cache,
                             render_tasks,
                             deferred_resolves,
                             prim_headers,
                             transforms,
                             root_spatial_node_index,
-                            surface_spatial_node_index,
                             z_generator,
                         );
                     }
                 }
             }
             PrimitiveInstanceKind::ImageBorder { data_handle, .. } => {
                 let prim_data = &ctx.data_stores.image_border[data_handle];
                 let common_data = &prim_data.common;
--- a/gfx/wr/webrender/src/clip.rs
+++ b/gfx/wr/webrender/src/clip.rs
@@ -2,17 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use api::{BorderRadius, ClipIntern, ClipMode, ComplexClipRegion, ImageMask};
 use api::{BoxShadowClipMode, ImageKey, ImageRendering};
 use api::units::*;
 use crate::border::{ensure_no_corner_overlap, BorderRadiusAu};
 use crate::box_shadow::{BLUR_SAMPLE_SCALE, BoxShadowClipSource, BoxShadowCacheKey};
-use crate::clip_scroll_tree::{ROOT_SPATIAL_NODE_INDEX, CoordinateSystemId, ClipScrollTree, SpatialNodeIndex};
+use crate::clip_scroll_tree::{CoordinateSystemId, ClipScrollTree, SpatialNodeIndex};
 use crate::ellipse::Ellipse;
 use crate::gpu_cache::{GpuCache, GpuCacheHandle, ToGpuBlocks};
 use crate::gpu_types::{BoxShadowStretchMode};
 use crate::image::{self, Repetition};
 use crate::intern;
 use crate::prim_store::{ClipData, ImageMaskData, SpaceMapper, VisibleMaskImageTile};
 use crate::prim_store::{PointKey, SizeKey, RectangleKey};
 use crate::render_task::to_cache_size;
@@ -476,32 +476,29 @@ pub struct ClipChainInstance {
     pub local_clip_rect: LayoutRect,
     pub has_non_local_clips: bool,
     // If true, this clip chain requires allocation
     // of a clip mask.
     pub needs_mask: bool,
     // Combined clip rect in picture space (may
     // be more conservative that local_clip_rect).
     pub pic_clip_rect: PictureRect,
-    // Space, in which the `pic_clip_rect` is defined.
-    pub pic_spatial_node_index: SpatialNodeIndex,
 }
 
 impl ClipChainInstance {
     pub fn empty() -> Self {
         ClipChainInstance {
             clips_range: ClipNodeRange {
                 first: 0,
                 count: 0,
             },
             local_clip_rect: LayoutRect::zero(),
             has_non_local_clips: false,
             needs_mask: false,
             pic_clip_rect: PictureRect::zero(),
-            pic_spatial_node_index: ROOT_SPATIAL_NODE_INDEX,
         }
     }
 }
 
 /// Maintains a stack of clip chain ids that are currently active,
 /// when a clip exists on a picture that has no surface, and is passed
 /// on down to the child primitive(s).
 pub struct ClipChainStack {
@@ -728,17 +725,16 @@ impl ClipStore {
         };
 
         // Return a valid clip chain instance
         Some(ClipChainInstance {
             clips_range,
             has_non_local_clips,
             local_clip_rect,
             pic_clip_rect,
-            pic_spatial_node_index: prim_to_pic_mapper.ref_spatial_node_index,
             needs_mask,
         })
     }
 
     pub fn clear_old_instances(&mut self) {
         self.clip_node_instances.clear();
     }
 }
--- a/gfx/wr/webrender/src/frame_builder.rs
+++ b/gfx/wr/webrender/src/frame_builder.rs
@@ -56,17 +56,16 @@ pub struct FrameBuilderConfig {
     pub dual_source_blending_is_enabled: bool,
     pub chase_primitive: ChasePrimitive,
     pub enable_picture_caching: bool,
     /// True if we're running tests (i.e. via wrench).
     pub testing: bool,
     pub gpu_supports_fast_clears: bool,
     pub gpu_supports_advanced_blend: bool,
     pub advanced_blend_is_coherent: bool,
-    pub batch_lookback_count: usize,
 }
 
 /// A set of common / global resources that are retained between
 /// new display lists, such that any GPU cache handles can be
 /// persisted even when a new display list arrives.
 #[cfg_attr(feature = "capture", derive(Serialize))]
 pub struct FrameGlobalResources {
     /// The image shader block for the most common / default
@@ -222,17 +221,16 @@ impl FrameBuilder {
                 dual_source_blending_is_enabled: true,
                 dual_source_blending_is_supported: false,
                 chase_primitive: ChasePrimitive::Nothing,
                 enable_picture_caching: false,
                 testing: false,
                 gpu_supports_fast_clears: false,
                 gpu_supports_advanced_blend: false,
                 advanced_blend_is_coherent: false,
-                batch_lookback_count: 0,
             },
         }
     }
 
     /// Provide any cached surface tiles from the previous frame builder
     /// to a new frame builder. These will be consumed or dropped the
     /// first time a new frame builder creates a frame.
     pub fn set_retained_resources(
@@ -433,17 +431,16 @@ impl FrameBuilder {
 
         let root_render_task = RenderTask::new_picture(
             RenderTaskLocation::Fixed(self.output_rect),
             self.output_rect.size.to_f32(),
             self.root_pic_index,
             DeviceIntPoint::zero(),
             UvRectKind::Rect,
             root_spatial_node_index,
-            root_spatial_node_index,
             global_device_pixel_scale,
         );
 
         let root_render_task_id = frame_state.render_tasks.add(root_render_task);
         frame_state
             .surfaces
             .first_mut()
             .unwrap()
@@ -590,17 +587,16 @@ impl FrameBuilder {
             for pass in &mut passes {
                 let mut ctx = RenderTargetContext {
                     global_device_pixel_scale,
                     prim_store: &self.prim_store,
                     resource_cache,
                     use_dual_source_blending,
                     use_advanced_blending: self.config.gpu_supports_advanced_blend,
                     break_advanced_blend_batches: !self.config.advanced_blend_is_coherent,
-                    batch_lookback_count: self.config.batch_lookback_count,
                     clip_scroll_tree,
                     data_stores,
                     surfaces: &surfaces,
                     scratch,
                     screen_world_rect,
                     globals: &self.globals,
                 };
 
--- a/gfx/wr/webrender/src/picture.rs
+++ b/gfx/wr/webrender/src/picture.rs
@@ -2502,17 +2502,16 @@ impl PicturePrimitive {
 
                         let picture_task = RenderTask::new_picture(
                             RenderTaskLocation::Dynamic(None, device_rect.size),
                             unclipped.size,
                             pic_index,
                             device_rect.origin,
                             uv_rect_kind,
                             raster_spatial_node_index,
-                            surface_spatial_node_index,
                             device_pixel_scale,
                         );
 
                         let picture_task_id = frame_state.render_tasks.add(picture_task);
 
                         let blur_render_task_id = RenderTask::new_blur(
                             blur_std_deviation,
                             picture_task_id,
@@ -2552,17 +2551,16 @@ impl PicturePrimitive {
 
                         let mut picture_task = RenderTask::new_picture(
                             RenderTaskLocation::Dynamic(None, device_rect.size),
                             unclipped.size,
                             pic_index,
                             device_rect.origin,
                             uv_rect_kind,
                             raster_spatial_node_index,
-                            surface_spatial_node_index,
                             device_pixel_scale,
                         );
                         picture_task.mark_for_saving();
 
                         let picture_task_id = frame_state.render_tasks.add(picture_task);
 
                         self.secondary_render_task_id = Some(picture_task_id);
 
@@ -2597,17 +2595,16 @@ impl PicturePrimitive {
 
                         let picture_task = RenderTask::new_picture(
                             RenderTaskLocation::Dynamic(None, clipped.size),
                             unclipped.size,
                             pic_index,
                             clipped.origin,
                             uv_rect_kind,
                             raster_spatial_node_index,
-                            surface_spatial_node_index,
                             device_pixel_scale,
                         );
 
                         let readback_task_id = frame_state.render_tasks.add(
                             RenderTask::new_readback(clipped)
                         );
 
                         frame_state.render_tasks.add_dependency(
@@ -2632,17 +2629,16 @@ impl PicturePrimitive {
 
                         let picture_task = RenderTask::new_picture(
                             RenderTaskLocation::Dynamic(None, clipped.size),
                             unclipped.size,
                             pic_index,
                             clipped.origin,
                             uv_rect_kind,
                             raster_spatial_node_index,
-                            surface_spatial_node_index,
                             device_pixel_scale,
                         );
 
                         let render_task_id = frame_state.render_tasks.add(picture_task);
 
                         (render_task_id, render_task_id)
                     }
                     PictureCompositeMode::ComponentTransferFilter(..) => {
@@ -2656,17 +2652,16 @@ impl PicturePrimitive {
 
                         let picture_task = RenderTask::new_picture(
                             RenderTaskLocation::Dynamic(None, clipped.size),
                             unclipped.size,
                             pic_index,
                             clipped.origin,
                             uv_rect_kind,
                             raster_spatial_node_index,
-                            surface_spatial_node_index,
                             device_pixel_scale,
                         );
 
                         let render_task_id = frame_state.render_tasks.add(picture_task);
 
                         (render_task_id, render_task_id)
                     }
                     PictureCompositeMode::MixBlend(..) |
@@ -2688,17 +2683,16 @@ impl PicturePrimitive {
 
                         let picture_task = RenderTask::new_picture(
                             RenderTaskLocation::Dynamic(None, clipped.size),
                             unclipped.size,
                             pic_index,
                             clipped.origin,
                             uv_rect_kind,
                             raster_spatial_node_index,
-                            surface_spatial_node_index,
                             device_pixel_scale,
                         );
 
                         let render_task_id = frame_state.render_tasks.add(picture_task);
 
                         (render_task_id, render_task_id)
                     }
                 };
--- a/gfx/wr/webrender/src/render_task.rs
+++ b/gfx/wr/webrender/src/render_task.rs
@@ -511,17 +511,16 @@ pub struct TileBlit {
 #[cfg_attr(feature = "capture", derive(Serialize))]
 #[cfg_attr(feature = "replay", derive(Deserialize))]
 pub struct PictureTask {
     pub pic_index: PictureIndex,
     pub can_merge: bool,
     pub content_origin: DeviceIntPoint,
     pub uv_rect_handle: GpuCacheHandle,
     pub root_spatial_node_index: SpatialNodeIndex,
-    pub surface_spatial_node_index: SpatialNodeIndex,
     uv_rect_kind: UvRectKind,
     device_pixel_scale: DevicePixelScale,
 }
 
 #[derive(Debug)]
 #[cfg_attr(feature = "capture", derive(Serialize))]
 #[cfg_attr(feature = "replay", derive(Deserialize))]
 pub struct BlurTask {
@@ -750,17 +749,16 @@ impl RenderTask {
 
     pub fn new_picture(
         location: RenderTaskLocation,
         unclipped_size: DeviceSize,
         pic_index: PictureIndex,
         content_origin: DeviceIntPoint,
         uv_rect_kind: UvRectKind,
         root_spatial_node_index: SpatialNodeIndex,
-        surface_spatial_node_index: SpatialNodeIndex,
         device_pixel_scale: DevicePixelScale,
     ) -> Self {
         let size = match location {
             RenderTaskLocation::Dynamic(_, size) => size,
             RenderTaskLocation::Fixed(rect) => rect.size,
             RenderTaskLocation::TextureCache { rect, .. } => rect.size,
         };
 
@@ -774,17 +772,16 @@ impl RenderTask {
             children: Vec::new(),
             kind: RenderTaskKind::Picture(PictureTask {
                 pic_index,
                 content_origin,
                 can_merge,
                 uv_rect_handle: GpuCacheHandle::new(),
                 uv_rect_kind,
                 root_spatial_node_index,
-                surface_spatial_node_index,
                 device_pixel_scale,
             }),
             clear_mode: ClearMode::Transparent,
             saved_index: None,
         }
     }
 
     pub fn new_gradient(
@@ -2053,17 +2050,17 @@ fn blur_task_graph() {
     // Insert a task that is an even number of passes away from its dependency.
     // This means the source and destination are on the same target and we have to resolve
     // this conflict by automatically inserting a blit task.
     let vblur3 = tasks.add(RenderTask::new_test(color, dyn_location(80, 80), vec![scale3]));
     let hblur3 = tasks.add(RenderTask::new_test(color, dyn_location(80, 80), vec![vblur3]));
 
     // Insert a task that is an odd number > 1 of passes away from its dependency.
     // This should force us to mark the dependency "for saving" to keep its content valid
-    // until the task can access it.
+    // until the task can access it. 
     let vblur4 = tasks.add(RenderTask::new_test(color, dyn_location(160, 160), vec![scale2]));
     let hblur4 = tasks.add(RenderTask::new_test(color, dyn_location(160, 160), vec![vblur4]));
 
     let main_pic = tasks.add(RenderTask::new_test(
         color,
         RenderTaskLocation::Fixed(rect(0, 0, 3200, 1800)),
         vec![hblur1, hblur2, hblur3, hblur4],
     ));
@@ -2104,17 +2101,17 @@ fn blur_task_graph() {
     assert_eq!(passes[6].tasks.len(), 4);
     assert!(passes[6].tasks.contains(&hblur1));
     assert!(passes[6].tasks.contains(&hblur2));
     assert!(passes[6].tasks.contains(&hblur3));
     assert!(passes[6].tasks.contains(&hblur4));
 
     assert_eq!(passes[7].tasks, vec![main_pic]);
 
-    // See vblur4's comment above.
+    // See vblur4's comment above. 
     assert!(tasks[scale2].saved_index.is_some());
 }
 
 #[test]
 fn culled_tasks() {
     // This test checks that tasks that do not contribute to the frame don't appear in the
     // generated passes.
 
--- a/gfx/wr/webrender/src/renderer.rs
+++ b/gfx/wr/webrender/src/renderer.rs
@@ -112,18 +112,16 @@ use time::precise_time_ns;
 
 cfg_if! {
     if #[cfg(feature = "debugger")] {
         use serde_json;
         use crate::debug_server;
     }
 }
 
-const DEFAULT_BATCH_LOOKBACK_COUNT: usize = 10;
-
 /// Is only false if no WR instances have ever been created.
 static HAS_BEEN_INITIALIZED: AtomicBool = AtomicBool::new(false);
 
 /// Returns true if a WR instance has ever been initialized in this process.
 pub fn wr_has_been_initialized() -> bool {
     HAS_BEEN_INITIALIZED.load(Ordering::SeqCst)
 }
 
@@ -2215,17 +2213,16 @@ impl Renderer {
             dual_source_blending_is_enabled: true,
             dual_source_blending_is_supported: use_dual_source_blending,
             chase_primitive: options.chase_primitive,
             enable_picture_caching: options.enable_picture_caching,
             testing: options.testing,
             gpu_supports_fast_clears: options.gpu_supports_fast_clears,
             gpu_supports_advanced_blend: ext_blend_equation_advanced,
             advanced_blend_is_coherent: ext_blend_equation_advanced_coherent,
-            batch_lookback_count: options.batch_lookback_count,
         };
         info!("WR {:?}", config);
 
         let device_pixel_ratio = options.device_pixel_ratio;
         let debug_flags = options.debug_flags;
         let payload_rx_for_backend = payload_rx.to_mpsc_receiver();
         let size_of_op = options.size_of_op;
         let enclosing_size_of_op = options.enclosing_size_of_op;
@@ -5674,19 +5671,16 @@ pub struct RendererOptions {
     pub gpu_supports_fast_clears: bool,
     pub allow_dual_source_blending: bool,
     pub allow_advanced_blend_equation: bool,
     /// If true, allow WR to use pixel local storage if the device supports it.
     /// For now, this defaults to false since the code is still experimental
     /// and not complete. This option will probably be removed once support is
     /// complete, and WR can implicitly choose whether to make use of PLS.
     pub allow_pixel_local_storage_support: bool,
-    /// Number of batches to look back in history for adding the current
-    /// transparent instance into.
-    pub batch_lookback_count: usize,
     /// Start the debug server for this renderer.
     pub start_debug_server: bool,
 }
 
 impl Default for RendererOptions {
     fn default() -> Self {
         RendererOptions {
             device_pixel_ratio: 1.0,
@@ -5720,17 +5714,16 @@ impl Default for RendererOptions {
             support_low_priority_transactions: false,
             namespace_alloc_by_client: false,
             enable_picture_caching: false,
             testing: false,
             gpu_supports_fast_clears: false,
             allow_dual_source_blending: true,
             allow_advanced_blend_equation: false,
             allow_pixel_local_storage_support: false,
-            batch_lookback_count: DEFAULT_BATCH_LOOKBACK_COUNT,
             // 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,
         }
     }
 }
--- a/gfx/wr/webrender/src/tiling.rs
+++ b/gfx/wr/webrender/src/tiling.rs
@@ -53,17 +53,16 @@ pub struct RenderTargetIndex(pub usize);
 
 pub struct RenderTargetContext<'a, 'rc> {
     pub global_device_pixel_scale: DevicePixelScale,
     pub prim_store: &'a PrimitiveStore,
     pub resource_cache: &'rc mut ResourceCache,
     pub use_dual_source_blending: bool,
     pub use_advanced_blending: bool,
     pub break_advanced_blend_batches: bool,
-    pub batch_lookback_count: usize,
     pub clip_scroll_tree: &'a ClipScrollTree,
     pub data_stores: &'a DataStores,
     pub surfaces: &'a [SurfaceInfo],
     pub scratch: &'a PrimitiveScratchBuffer,
     pub screen_world_rect: WorldRect,
     pub globals: &'a FrameGlobalResources,
 }
 
@@ -435,31 +434,29 @@ impl RenderTarget for ColorRenderTarget 
                         None
                     } else {
                         Some(target_rect)
                     };
 
                     let mut alpha_batch_builder = AlphaBatchBuilder::new(
                         self.screen_size,
                         ctx.break_advanced_blend_batches,
-                        ctx.batch_lookback_count,
                         *task_id,
                     );
 
                     self.batch_builder.add_pic_to_batch(
                         pic,
                         &mut alpha_batch_builder,
                         ctx,
                         gpu_cache,
                         render_tasks,
                         deferred_resolves,
                         prim_headers,
                         transforms,
                         pic_task.root_spatial_node_index,
-                        pic_task.surface_spatial_node_index,
                         z_generator,
                     );
 
                     alpha_batch_builder.build(
                         &mut self.alpha_batch_containers,
                         &mut merged_batches,
                         target_rect,
                         scissor_rect,