Skip to content

Commit

Permalink
[dxvk] Limit number of allocations to move per submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
doitsujin committed Oct 18, 2024
1 parent 59b02a2 commit db02988
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/dxvk/dxvk_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 13 additions & 5 deletions src/dxvk/dxvk_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 9 additions & 5 deletions src/dxvk/dxvk_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1221,10 +1223,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:
Expand Down

0 comments on commit db02988

Please sign in to comment.