mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
vulkan: Workaround to avoid lockup due to double fault
- TODO: Ensure no page faults occur within a page-fault handler!
This commit is contained in:
parent
17c399d4e8
commit
fb7ccbd7b4
1 changed files with 23 additions and 5 deletions
|
@ -315,6 +315,7 @@ namespace vk
|
|||
};
|
||||
|
||||
private:
|
||||
std::atomic_bool in_access_violation_handler = { false };
|
||||
shared_mutex m_cache_mutex;
|
||||
std::unordered_map<u32, ranged_storage> m_cache;
|
||||
|
||||
|
@ -766,7 +767,11 @@ namespace vk
|
|||
std::pair<u32, u32> trampled_range = std::make_pair(0xffffffff, 0x0);
|
||||
std::unordered_map<u32, bool> processed_ranges;
|
||||
|
||||
reader_lock lock(m_cache_mutex);
|
||||
const bool _false = false;
|
||||
const bool acquire_lock = in_access_violation_handler.compare_exchange_weak(const_cast<bool&>(_false), true);
|
||||
|
||||
if (acquire_lock)
|
||||
m_cache_mutex.lock_shared();
|
||||
|
||||
for (auto It = m_cache.begin(); It != m_cache.end(); It++)
|
||||
{
|
||||
|
@ -829,6 +834,12 @@ namespace vk
|
|||
processed_ranges[base] = true;
|
||||
}
|
||||
|
||||
if (acquire_lock)
|
||||
{
|
||||
in_access_violation_handler = false;
|
||||
m_cache_mutex.unlock_shared();
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -847,7 +858,11 @@ namespace vk
|
|||
std::pair<u32, u32> trampled_range = std::make_pair(0xffffffff, 0x0);
|
||||
std::unordered_map<u32, bool> processed_ranges;
|
||||
|
||||
reader_lock lock(m_cache_mutex);
|
||||
const bool _false = false;
|
||||
const bool acquire_lock = in_access_violation_handler.compare_exchange_weak(const_cast<bool&>(_false), true);
|
||||
|
||||
if (acquire_lock)
|
||||
m_cache_mutex.lock_shared();
|
||||
|
||||
for (auto It = m_cache.begin(); It != m_cache.end(); It++)
|
||||
{
|
||||
|
@ -889,9 +904,6 @@ namespace vk
|
|||
range_reset = true;
|
||||
}
|
||||
|
||||
// Upgrade to writer lock
|
||||
lock.upgrade();
|
||||
|
||||
tex.set_dirty(true);
|
||||
tex.unprotect();
|
||||
|
||||
|
@ -909,6 +921,12 @@ namespace vk
|
|||
processed_ranges[base] = true;
|
||||
}
|
||||
|
||||
if (acquire_lock)
|
||||
{
|
||||
in_access_violation_handler = false;
|
||||
m_cache_mutex.unlock_shared();
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue