vk: Guard against concurrent access of storage pool under high pressure and MTRSX.
This commit is contained in:
@@ -558,18 +558,22 @@ namespace vk
|
|||||||
fmt::throw_exception("Unexpected descriptor structure at index %u", idx);
|
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();
|
std::lock_guard lock(m_descriptor_set);
|
||||||
if (!m_descriptors_dirty[i] && cache_is_valid)
|
const bool cache_is_valid = m_descriptor_template_cache_id == m_descriptor_set.cache_id();
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update
|
for (unsigned i = 0; i < m_descriptor_slots.size(); ++i)
|
||||||
update_descriptor_slot(i);
|
{
|
||||||
m_descriptors_dirty[i] = false;
|
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
|
// Push
|
||||||
|
|||||||
@@ -437,7 +437,8 @@ namespace vk
|
|||||||
|
|
||||||
// We have queued writes
|
// We have queued writes
|
||||||
if ((m_push_type_mask & ~m_update_after_bind_mask) ||
|
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();
|
flush();
|
||||||
return;
|
return;
|
||||||
@@ -464,11 +465,14 @@ namespace vk
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::lock_guard lock(m_storage_lock);
|
||||||
|
|
||||||
const auto num_writes = ::size32(m_pending_writes);
|
const auto num_writes = ::size32(m_pending_writes);
|
||||||
const auto num_copies = ::size32(m_pending_copies);
|
const auto num_copies = ::size32(m_pending_copies);
|
||||||
vkUpdateDescriptorSets(*g_render_device, num_writes, m_pending_writes.data(), num_copies, m_pending_copies.data());
|
vkUpdateDescriptorSets(*g_render_device, num_writes, m_pending_writes.data(), num_copies, m_pending_copies.data());
|
||||||
|
|
||||||
m_storage_cache_id++;
|
m_storage_cache_id++;
|
||||||
|
|
||||||
m_push_type_mask = 0;
|
m_push_type_mask = 0;
|
||||||
m_pending_writes.clear();
|
m_pending_writes.clear();
|
||||||
m_pending_copies.clear();
|
m_pending_copies.clear();
|
||||||
|
|||||||
@@ -183,13 +183,19 @@ namespace vk
|
|||||||
const rsx::simple_array<WriteDescriptorSetT> peek() const { return m_pending_writes; }
|
const rsx::simple_array<WriteDescriptorSetT> peek() const { return m_pending_writes; }
|
||||||
u64 cache_id() const { return m_storage_cache_id; }
|
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:
|
private:
|
||||||
VkDescriptorSet m_handle = VK_NULL_HANDLE;
|
VkDescriptorSet m_handle = VK_NULL_HANDLE;
|
||||||
u64 m_update_after_bind_mask = 0;
|
u64 m_update_after_bind_mask = 0;
|
||||||
u64 m_push_type_mask = 0;
|
u64 m_push_type_mask = 0;
|
||||||
u64 m_storage_cache_id = 0;
|
|
||||||
bool m_in_use = false;
|
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<VkBufferView> m_buffer_view_pool;
|
||||||
rsx::simple_array<VkDescriptorBufferInfo> m_buffer_info_pool;
|
rsx::simple_array<VkDescriptorBufferInfo> m_buffer_info_pool;
|
||||||
rsx::simple_array<VkDescriptorImageInfo> m_image_info_pool;
|
rsx::simple_array<VkDescriptorImageInfo> m_image_info_pool;
|
||||||
|
|||||||
Reference in New Issue
Block a user