mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-04 00:49:02 -06:00 
			
		
		
		
	texture_cache: use two-pass collection for costly load resources (#13096)
This commit is contained in:
		@@ -72,11 +72,18 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
template <class P>
 | 
					template <class P>
 | 
				
			||||||
void TextureCache<P>::RunGarbageCollector() {
 | 
					void TextureCache<P>::RunGarbageCollector() {
 | 
				
			||||||
    bool high_priority_mode = total_used_memory >= expected_memory;
 | 
					    bool high_priority_mode = false;
 | 
				
			||||||
    bool aggressive_mode = total_used_memory >= critical_memory;
 | 
					    bool aggressive_mode = false;
 | 
				
			||||||
    const u64 ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL;
 | 
					    u64 ticks_to_destroy = 0;
 | 
				
			||||||
    size_t num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10);
 | 
					    size_t num_iterations = 0;
 | 
				
			||||||
    const auto clean_up = [this, &num_iterations, &high_priority_mode,
 | 
					
 | 
				
			||||||
 | 
					    const auto Configure = [&](bool allow_aggressive) {
 | 
				
			||||||
 | 
					        high_priority_mode = total_used_memory >= expected_memory;
 | 
				
			||||||
 | 
					        aggressive_mode = allow_aggressive && total_used_memory >= critical_memory;
 | 
				
			||||||
 | 
					        ticks_to_destroy = aggressive_mode ? 10ULL : high_priority_mode ? 25ULL : 50ULL;
 | 
				
			||||||
 | 
					        num_iterations = aggressive_mode ? 40 : (high_priority_mode ? 20 : 10);
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const auto Cleanup = [this, &num_iterations, &high_priority_mode,
 | 
				
			||||||
                          &aggressive_mode](ImageId image_id) {
 | 
					                          &aggressive_mode](ImageId image_id) {
 | 
				
			||||||
        if (num_iterations == 0) {
 | 
					        if (num_iterations == 0) {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
@@ -123,7 +130,16 @@ void TextureCache<P>::RunGarbageCollector() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, clean_up);
 | 
					
 | 
				
			||||||
 | 
					    // Try to remove anything old enough and not high priority.
 | 
				
			||||||
 | 
					    Configure(false);
 | 
				
			||||||
 | 
					    lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // If pressure is still too high, prune aggressively.
 | 
				
			||||||
 | 
					    if (total_used_memory >= critical_memory) {
 | 
				
			||||||
 | 
					        Configure(true);
 | 
				
			||||||
 | 
					        lru_cache.ForEachItemBelow(frame_tick - ticks_to_destroy, Cleanup);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <class P>
 | 
					template <class P>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user