From 35b1f1acc5b57e5ef457882f9e0549bc80a0d1c2 Mon Sep 17 00:00:00 2001 From: Csoregi Natalia Date: Tue, 18 May 2021 17:08:37 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1711462, bug 1705024) for failures on svg-paint-rect-changes.html. CLOSED TREE Backed out changeset 40fd0d9fbaa7 (bug 1705024) Backed out changeset 7fe9e5e3e89e (bug 1711462) --- gfx/wr/webrender/src/lru_cache.rs | 10 ------ gfx/wr/webrender/src/render_task_cache.rs | 19 +----------- gfx/wr/webrender/src/resource_cache.rs | 4 ++- gfx/wr/webrender/src/texture_cache.rs | 38 +++++++++-------------- 4 files changed, 19 insertions(+), 52 deletions(-) diff --git a/gfx/wr/webrender/src/lru_cache.rs b/gfx/wr/webrender/src/lru_cache.rs index d53119b77d17..a71302ff0471 100644 --- a/gfx/wr/webrender/src/lru_cache.rs +++ b/gfx/wr/webrender/src/lru_cache.rs @@ -188,16 +188,6 @@ impl LRUCache { } } - /// Manually evict a specific item. - pub fn remove(&mut self, handle: &WeakFreeListHandle) -> Option { - if let Some(entry) = self.entries.get_opt_mut(handle) { - let strong_handle = self.lru[entry.partition_index as usize].remove(entry.lru_index); - return Some(self.entries.free(strong_handle).value); - } - - None - } - /// This is used by the calling code to signal that the element that this handle /// references has been used on this frame. Internally, it updates the links in /// the LRU tracking element to move this item to the end of the LRU list. Returns diff --git a/gfx/wr/webrender/src/render_task_cache.rs b/gfx/wr/webrender/src/render_task_cache.rs index 370897f30b0b..e6413267f10b 100644 --- a/gfx/wr/webrender/src/render_task_cache.rs +++ b/gfx/wr/webrender/src/render_task_cache.rs @@ -69,7 +69,6 @@ pub struct RenderTaskCacheEntry { user_data: Option<[f32; 4]>, target_kind: RenderTargetKind, is_opaque: bool, - frame_id: u64, pub handle: TextureCacheHandle, /// If a render task was generated for this cache entry on _this_ frame, /// we need to track the task id here. This allows us to hook it up as @@ -90,7 +89,6 @@ pub enum RenderTaskCacheMarker {} pub struct RenderTaskCache { map: FastHashMap>, cache_entries: FreeList, - frame_id: u64, } pub type RenderTaskCacheEntryHandle = WeakFreeListHandle; @@ -100,7 +98,6 @@ impl RenderTaskCache { RenderTaskCache { map: FastHashMap::default(), cache_entries: FreeList::new(), - frame_id: 0, } } @@ -113,7 +110,6 @@ impl RenderTaskCache { &mut self, texture_cache: &mut TextureCache, ) { - self.frame_id += 1; profile_scope!("begin_frame"); // Drop any items from the cache that have been // evicted from the texture cache. @@ -129,25 +125,15 @@ impl RenderTaskCache { // from here so that this hash map doesn't // grow indefinitely! let cache_entries = &mut self.cache_entries; - let frame_id = self.frame_id; self.map.retain(|_, handle| { - let mut retain = texture_cache.is_allocated( + let retain = texture_cache.is_allocated( &cache_entries.get(handle).handle, ); - if retain { - let entry = cache_entries.get_mut(&handle); - if frame_id > entry.frame_id + 10 { - texture_cache.evict_handle(&entry.handle); - retain = false; - } - } - if !retain { let handle = mem::replace(handle, FreeListHandle::invalid()); cache_entries.free(handle); } - retain }); @@ -237,7 +223,6 @@ impl RenderTaskCache { where F: FnOnce(&mut RenderTaskGraphBuilder) -> Result, { - let frame_id = self.frame_id; let size = key.size; // Get the texture cache handle for this cache key, // or create one. @@ -248,13 +233,11 @@ impl RenderTaskCache { user_data, target_kind: RenderTargetKind::Color, // will be set below. is_opaque, - frame_id, render_task_id: None, }; cache_entries.insert(entry) }); let cache_entry = cache_entries.get_mut(entry_handle); - cache_entry.frame_id = self.frame_id; // Check if this texture cache handle is valid. if texture_cache.request(&cache_entry.handle, gpu_cache) { diff --git a/gfx/wr/webrender/src/resource_cache.rs b/gfx/wr/webrender/src/resource_cache.rs index 0c5d106bb1c3..8809357436a4 100644 --- a/gfx/wr/webrender/src/resource_cache.rs +++ b/gfx/wr/webrender/src/resource_cache.rs @@ -228,7 +228,9 @@ struct CachedImageInfo { impl CachedImageInfo { fn mark_unused(&mut self, texture_cache: &mut TextureCache) { - texture_cache.evict_handle(&self.texture_cache_handle); + if self.manual_eviction { + texture_cache.evict_manual_handle(&self.texture_cache_handle); + } self.manual_eviction = false; } } diff --git a/gfx/wr/webrender/src/texture_cache.rs b/gfx/wr/webrender/src/texture_cache.rs index f2ca3213dbbe..8554ec29e40c 100644 --- a/gfx/wr/webrender/src/texture_cache.rs +++ b/gfx/wr/webrender/src/texture_cache.rs @@ -1217,29 +1217,21 @@ impl TextureCache { /// Evict a texture cache handle that was previously set to be in manual /// eviction mode. - pub fn evict_handle(&mut self, handle: &TextureCacheHandle) { - match handle { - TextureCacheHandle::Manual(handle) => { - // Find the strong handle that matches this weak handle. If this - // ever shows up in profiles, we can make it a hash (but the number - // of manual eviction handles is typically small). - // Alternatively, we could make a more forgiving FreeList variant - // which does not differentiate between strong and weak handles. - let index = self.manual_handles.iter().position(|strong_handle| { - strong_handle.matches(handle) - }); - if let Some(index) = index { - let handle = self.manual_handles.swap_remove(index); - let entry = self.manual_entries.free(handle); - self.evict_impl(entry); - } + pub fn evict_manual_handle(&mut self, handle: &TextureCacheHandle) { + if let TextureCacheHandle::Manual(handle) = handle { + // Find the strong handle that matches this weak handle. If this + // ever shows up in profiles, we can make it a hash (but the number + // of manual eviction handles is typically small). + // Alternatively, we could make a more forgiving FreeList variant + // which does not differentiate between strong and weak handles. + let index = self.manual_handles.iter().position(|strong_handle| { + strong_handle.matches(handle) + }); + if let Some(index) = index { + let handle = self.manual_handles.swap_remove(index); + let entry = self.manual_entries.free(handle); + self.evict_impl(entry); } - TextureCacheHandle::Auto(handle) => { - if let Some(entry) = self.lru_cache.remove(handle) { - self.evict_impl(entry); - } - } - _ => {} } } @@ -1920,7 +1912,7 @@ mod test_texture_cache { assert!(bytes_after_allocating > bytes_at_start); for handle in handles { - texture_cache.evict_handle(&handle); + texture_cache.evict_manual_handle(&handle); } let bytes_at_end = texture_cache.total_allocated_bytes_for_testing();