From 8421be7ebfbf278e3175652c6e28c8dbaf6dd981 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Mon, 14 Aug 2023 02:14:52 +0300 Subject: [PATCH] rasterizer_cache: Proper surface unregister --- .../rasterizer_cache/rasterizer_cache.h | 17 ++++++++++------- .../renderer_opengl/gl_texture_runtime.h | 3 +++ .../renderer_vulkan/vk_texture_runtime.cpp | 4 ++++ .../renderer_vulkan/vk_texture_runtime.h | 3 +++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.h b/src/video_core/rasterizer_cache/rasterizer_cache.h index c981d08d7..2fbc9a671 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache.h @@ -1300,11 +1300,6 @@ void RasterizerCache::InvalidateRegion(PAddr addr, u32 size, SurfaceId region for (const SurfaceId surface_id : remove_surfaces) { UnregisterSurface(surface_id); - if (slot_surfaces[surface_id].type != SurfaceType::Fill) { - sentenced.emplace_back(surface_id, frame_tick); - } else { - slot_surfaces.erase(surface_id); - } } } @@ -1365,7 +1360,13 @@ void RasterizerCache::UnregisterSurface(SurfaceId surface_id) { surfaces.erase(vector_it); }); - RemoveTextureCubeFace(surface_id); + if (surface.type != SurfaceType::Fill) { + RemoveTextureCubeFace(surface_id); + sentenced.emplace_back(surface_id, frame_tick); + return; + } + + slot_surfaces.erase(surface_id); } template @@ -1376,7 +1377,9 @@ void RasterizerCache::UnregisterAll() { UnregisterSurface(surfaces.back()); } } - texture_cube_cache.clear(); + runtime.Finish(); + frame_tick += runtime.RemoveThreshold(); + RunGarbageCollector(); } template diff --git a/src/video_core/renderer_opengl/gl_texture_runtime.h b/src/video_core/renderer_opengl/gl_texture_runtime.h index b9a971c2d..39da1cac7 100644 --- a/src/video_core/renderer_opengl/gl_texture_runtime.h +++ b/src/video_core/renderer_opengl/gl_texture_runtime.h @@ -45,6 +45,9 @@ public: /// Returns the removal threshold ticks for the garbage collector u32 RemoveThreshold(); + /// Submits and waits for current GPU work. + void Finish() {} + /// Returns true if the provided pixel format cannot be used natively by the runtime. bool NeedsConversion(VideoCore::PixelFormat pixel_format) const; diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp index abc6aec87..5dd46609f 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp @@ -278,6 +278,10 @@ u32 TextureRuntime::RemoveThreshold() { return num_swapchain_images + 2; } +void TextureRuntime::Finish() { + scheduler.Finish(); +} + bool TextureRuntime::Reinterpret(Surface& source, Surface& dest, const VideoCore::TextureBlit& blit) { const PixelFormat src_format = source.pixel_format; diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.h b/src/video_core/renderer_vulkan/vk_texture_runtime.h index 6694a98ef..fd9b299e9 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.h +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.h @@ -61,6 +61,9 @@ public: /// Returns the removal threshold ticks for the garbage collector u32 RemoveThreshold(); + /// Submits and waits for current GPU work. + void Finish(); + /// Maps an internal staging buffer of the provided size for pixel uploads/downloads VideoCore::StagingData FindStaging(u32 size, bool upload);