mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-01-10 18:50:22 +01:00
vk: Guard against concurrent access of storage pool under high pressure and MTRSX.
This commit is contained in:
parent
3ee626ce3c
commit
87677cfc85
|
|
@ -558,18 +558,22 @@ namespace vk
|
|||
fmt::throw_exception("Unexpected descriptor structure at index %u", idx);
|
||||
};
|
||||
|
||||
const bool cache_is_valid = m_descriptor_template_cache_id == m_descriptor_set.cache_id();
|
||||
for (unsigned i = 0; i < m_descriptor_slots.size(); ++i)
|
||||
{
|
||||
m_descriptor_template[i].dstSet = m_descriptor_set.value();
|
||||
if (!m_descriptors_dirty[i] && cache_is_valid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
std::lock_guard lock(m_descriptor_set);
|
||||
const bool cache_is_valid = m_descriptor_template_cache_id == m_descriptor_set.cache_id();
|
||||
|
||||
// Update
|
||||
update_descriptor_slot(i);
|
||||
m_descriptors_dirty[i] = false;
|
||||
for (unsigned i = 0; i < m_descriptor_slots.size(); ++i)
|
||||
{
|
||||
m_descriptor_template[i].dstSet = m_descriptor_set.value();
|
||||
if (!m_descriptors_dirty[i] && cache_is_valid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update
|
||||
update_descriptor_slot(i);
|
||||
m_descriptors_dirty[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Push
|
||||
|
|
|
|||
|
|
@ -437,7 +437,8 @@ namespace vk
|
|||
|
||||
// We have queued writes
|
||||
if ((m_push_type_mask & ~m_update_after_bind_mask) ||
|
||||
(m_pending_writes.size() >= max_cache_size))
|
||||
(m_pending_writes.size() >= max_cache_size) ||
|
||||
storage_cache_pressure())
|
||||
{
|
||||
flush();
|
||||
return;
|
||||
|
|
@ -464,11 +465,14 @@ namespace vk
|
|||
return;
|
||||
}
|
||||
|
||||
std::lock_guard lock(m_storage_lock);
|
||||
|
||||
const auto num_writes = ::size32(m_pending_writes);
|
||||
const auto num_copies = ::size32(m_pending_copies);
|
||||
vkUpdateDescriptorSets(*g_render_device, num_writes, m_pending_writes.data(), num_copies, m_pending_copies.data());
|
||||
|
||||
m_storage_cache_id++;
|
||||
|
||||
m_push_type_mask = 0;
|
||||
m_pending_writes.clear();
|
||||
m_pending_copies.clear();
|
||||
|
|
|
|||
|
|
@ -183,13 +183,19 @@ namespace vk
|
|||
const rsx::simple_array<WriteDescriptorSetT> peek() const { return m_pending_writes; }
|
||||
u64 cache_id() const { return m_storage_cache_id; }
|
||||
|
||||
// Basic lockable for storage coherence
|
||||
void lock() { m_storage_lock.lock(); }
|
||||
void unlock() { m_storage_lock.unlock(); }
|
||||
|
||||
private:
|
||||
VkDescriptorSet m_handle = VK_NULL_HANDLE;
|
||||
u64 m_update_after_bind_mask = 0;
|
||||
u64 m_push_type_mask = 0;
|
||||
u64 m_storage_cache_id = 0;
|
||||
bool m_in_use = false;
|
||||
|
||||
shared_mutex m_storage_lock;
|
||||
atomic_t<u64> m_storage_cache_id = 0;
|
||||
|
||||
rsx::simple_array<VkBufferView> m_buffer_view_pool;
|
||||
rsx::simple_array<VkDescriptorBufferInfo> m_buffer_info_pool;
|
||||
rsx::simple_array<VkDescriptorImageInfo> m_image_info_pool;
|
||||
|
|
|
|||
Loading…
Reference in a new issue