1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 01:24:11 +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() {
auto resourceList = m_common->memoryManager().pollRelocationList();
constexpr static uint32_t MaxRelocationsPerSubmission = 128u;
auto resourceList = m_common->memoryManager().pollRelocationList(MaxRelocationsPerSubmission);
if (resourceList.empty())
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::vector<DxvkRelocationEntry> result;
result.reserve(m_entries.size());
count = std::min(count, uint32_t(m_entries.size()));
for (const auto& p : m_entries)
result.push_back({ p.first, p.second });
if (!count)
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;
}

View File

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