mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-08-09 17:49:45 +00:00
vk: Fix use-after-free hazard by checking if we're faulting from within the texture cache
- If we're using the texture cache, DO NOT delete resources.
This commit is contained in:
parent
69bdbe97a8
commit
6a9d1edee1
2 changed files with 20 additions and 2 deletions
|
@ -1455,8 +1455,16 @@ namespace rsx
|
||||||
|
|
||||||
bool evict_unused(const std::set<u32>& exclusion_list)
|
bool evict_unused(const std::set<u32>& exclusion_list)
|
||||||
{
|
{
|
||||||
// Manage synchronization externally. It is very likely for RSX to call this after failing to create a new texture while already owning the mutex
|
// Some sanity checks. Do not evict if the cache is currently in use.
|
||||||
ensure(rsx::get_current_renderer()->is_current_thread());
|
ensure(rsx::get_current_renderer()->is_current_thread());
|
||||||
|
std::unique_lock lock(m_cache_mutex, std::defer_lock);
|
||||||
|
|
||||||
|
if (!lock.try_lock())
|
||||||
|
{
|
||||||
|
rsx_log.warning("Unable to evict the texture cache because we're faulting from within in the texture cache!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rsx_log.warning("[PERFORMANCE WARNING] Texture cache is running eviction routine. This will affect performance.");
|
rsx_log.warning("[PERFORMANCE WARNING] Texture cache is running eviction routine. This will affect performance.");
|
||||||
|
|
||||||
thrashed_set evicted_set;
|
thrashed_set evicted_set;
|
||||||
|
@ -1523,7 +1531,9 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard lock(m_cache_mutex);
|
||||||
image_view_type result = 0;
|
image_view_type result = 0;
|
||||||
|
|
||||||
switch (desc.op)
|
switch (desc.op)
|
||||||
{
|
{
|
||||||
case deferred_request_command::cubemap_gather:
|
case deferred_request_command::cubemap_gather:
|
||||||
|
|
|
@ -1094,8 +1094,9 @@ namespace vk
|
||||||
|
|
||||||
bool texture_cache::handle_memory_pressure(rsx::problem_severity severity)
|
bool texture_cache::handle_memory_pressure(rsx::problem_severity severity)
|
||||||
{
|
{
|
||||||
bool any_released = baseclass::handle_memory_pressure(severity);
|
auto any_released = baseclass::handle_memory_pressure(severity);
|
||||||
|
|
||||||
|
// TODO: This can cause invalidation of in-flight resources
|
||||||
if (severity <= rsx::problem_severity::low || !m_temporary_memory_size)
|
if (severity <= rsx::problem_severity::low || !m_temporary_memory_size)
|
||||||
{
|
{
|
||||||
// Nothing left to do
|
// Nothing left to do
|
||||||
|
@ -1109,6 +1110,13 @@ namespace vk
|
||||||
return any_released;
|
return any_released;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_lock lock(m_cache_mutex, std::defer_lock);
|
||||||
|
if (!lock.try_lock())
|
||||||
|
{
|
||||||
|
rsx_log.warning("Unable to remove temporary resources because we're already in the texture cache!");
|
||||||
|
return any_released;
|
||||||
|
}
|
||||||
|
|
||||||
// Nuke temporary resources. They will still be visible to the GPU.
|
// Nuke temporary resources. They will still be visible to the GPU.
|
||||||
auto gc = vk::get_resource_manager();
|
auto gc = vk::get_resource_manager();
|
||||||
u64 actual_released_memory = 0;
|
u64 actual_released_memory = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue