1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 10:54:16 +01:00

[dxvk] Limit number of allocations to move per submissions

This commit is contained in:
Philip Rebohle 2024-10-18 18:48:43 +02:00
parent db26403839
commit 0ca39e9b8f
3 changed files with 24 additions and 11 deletions

View File

@ -6478,7 +6478,8 @@ namespace dxvk {
void DxvkContext::relocateQueuedResources() { void DxvkContext::relocateQueuedResources() {
auto resourceList = m_common->memoryManager().pollRelocationList(); constexpr static uint32_t MaxRelocationsPerSubmission = 128u;
auto resourceList = m_common->memoryManager().pollRelocationList(MaxRelocationsPerSubmission);
if (resourceList.empty()) if (resourceList.empty())
return; return;

View File

@ -469,16 +469,24 @@ namespace dxvk {
} }
std::vector<DxvkRelocationEntry> DxvkRelocationList::poll() { std::vector<DxvkRelocationEntry> DxvkRelocationList::poll(uint32_t count) {
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
std::vector<DxvkRelocationEntry> result; std::vector<DxvkRelocationEntry> result;
result.reserve(m_entries.size()); count = std::min(count, uint32_t(m_entries.size()));
for (const auto& p : m_entries) if (!count)
result.push_back({ p.first, p.second }); return result;
result.reserve(count);
for (uint32_t i = 0; i < count; i++) {
auto iter = m_entries.begin();
result.push_back({ iter->first, iter->second });
m_entries.erase(iter);
}
m_entries.clear();
return result; return result;
} }

View File

@ -993,11 +993,13 @@ namespace dxvk {
/** /**
* \brief Retrieves list of resources to move * \brief Retrieves list of resources to move
* *
* Clears the internally stored list. Any * Removes items from the internally stored list.
* duplicate entries will be removed. * Any duplicate entries will be removed.
* \param [in] count Number of entries to return
* \returns List of resources to move * \returns List of resources to move
*/ */
std::vector<DxvkRelocationEntry> poll(); std::vector<DxvkRelocationEntry> poll(
uint32_t count);
/** /**
* \brief Adds relocation entry to the list * \brief Adds relocation entry to the list
@ -1238,10 +1240,12 @@ namespace dxvk {
/** /**
* \brief Polls relocation list * \brief Polls relocation list
*
* \param [in] count Desired entry count
* \returns Relocation entries * \returns Relocation entries
*/ */
auto pollRelocationList() { auto pollRelocationList(uint32_t count) {
return m_relocations.poll(); return m_relocations.poll(count);
} }
private: private: