diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 7a8f78cde1..b80af2b480 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -113,6 +113,54 @@ TextureCache
::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
}
}
+template ::RunAllocationGarbageCollector(size_t requested_bytes) {
+ if (requested_bytes == 0) {
+ return;
+ }
+
+ if (allocation_gc_frame != frame_tick) {
+ allocation_gc_frame = frame_tick;
+ allocation_gc_passes = 0;
+ }
+ if (allocation_gc_passes >= MAX_ALLOCATION_GC_PASSES_PER_FRAME) {
+ return;
+ }
+
+ if (runtime.CanReportMemoryUsage()) {
+ total_used_memory = runtime.GetDeviceMemoryUsage();
+ }
+
+ const u64 request = static_cast ::RunGarbageCollector() {
bool high_priority_mode = total_used_memory >= expected_memory;
@@ -1606,18 +1654,20 @@ bool TextureCache ::ScaleDown(Image& image) {
template ::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr,
RelaxedOptions options) {
+ const size_t requested_size = CalculateGuestSizeInBytes(info);
std::optional ::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DA
ImageInfo new_info = info;
const size_t size_bytes = CalculateGuestSizeInBytes(new_info);
+ RunAllocationGarbageCollector(size_bytes);
+
const bool broken_views = runtime.HasBrokenTextureViewFormats();
const bool native_bgr = runtime.HasNativeBgr();
join_overlap_ids.clear();
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index 0cdeb9fdc5..e2c2c5d7d9 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -120,7 +120,7 @@ class TextureCache : public VideoCommon::ChannelSetupCaches