diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 51652814c4..e0c97de3c4 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -269,6 +269,7 @@ namespace rsx shared_mutex m_cache_mutex; ranged_storage m_storage; std::unordered_multimap> m_temporary_subresource_cache; + std::vector m_uncached_subresources; predictor_type m_predictor; std::atomic m_cache_update_tag = {0}; @@ -1322,7 +1323,7 @@ namespace rsx image_view_type create_temporary_subresource(commandbuffer_type &cmd, deferred_subresource& desc) { - if (!desc.do_not_cache) + if (LIKELY(!desc.do_not_cache)) { const auto found = m_temporary_subresource_cache.equal_range(desc.address); for (auto It = found.first; It != found.second; ++It) @@ -1418,14 +1419,31 @@ namespace rsx } } - if (result && !desc.do_not_cache) + if (LIKELY(result)) { - m_temporary_subresource_cache.insert({ desc.address,{ desc, result } }); + if (LIKELY(!desc.do_not_cache)) + { + m_temporary_subresource_cache.insert({ desc.address,{ desc, result } }); + } + else + { + m_uncached_subresources.push_back(result); + } } return result; } + void release_uncached_temporary_subresources() + { + for (auto& view : m_uncached_subresources) + { + release_temporary_subresource(view); + } + + m_uncached_subresources.clear(); + } + void notify_surface_changed(const utils::address_range& range) { for (auto It = m_temporary_subresource_cache.begin(); It != m_temporary_subresource_cache.end();) diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 82ba8c1630..40d5130f4d 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -387,6 +387,8 @@ void GLGSRender::end() } } + m_gl_texture_cache.release_uncached_temporary_subresources(); + m_frame_stats.textures_upload_time += m_profiler.duration(); // Optionally do memory synchronization if the texture stage has not yet triggered this diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 6c402c9c05..3053d6c6e0 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -1691,6 +1691,8 @@ void VKGSRender::end() } } + m_texture_cache.release_uncached_temporary_subresources(); + m_frame_stats.textures_upload_time += m_profiler.duration(); if (m_current_command_buffer->flags & vk::command_buffer::cb_load_occluson_task)