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

[dxvk] Sort chunks by allocation time for statistics

This commit is contained in:
Philip Rebohle 2024-10-18 16:28:31 +02:00 committed by Philip Rebohle
parent 69437c2fea
commit 2c8fe59924
2 changed files with 15 additions and 0 deletions

View File

@ -1195,6 +1195,7 @@ namespace dxvk {
pool.chunks.resize(std::max<size_t>(pool.chunks.size(), chunkIndex + 1u));
pool.chunks[chunkIndex].memory = chunk;
pool.chunks[chunkIndex].unusedTime = high_resolution_clock::time_point();
pool.chunks[chunkIndex].chunkCookie = ++pool.nextChunkCookie;
return true;
}
@ -1591,6 +1592,8 @@ namespace dxvk {
DxvkMemoryAllocationStats& stats) {
auto& typeStats = stats.memoryTypes[type.index];
size_t first = stats.chunks.size();
for (uint32_t i = 0; i < pool.chunks.size(); i++) {
if (!pool.chunks[i].memory.memory)
continue;
@ -1604,12 +1607,18 @@ namespace dxvk {
chunkStats.pageCount = pool.pageAllocator.pageCount(i);
chunkStats.mapped = &pool == &type.mappedPool;
chunkStats.active = pool.pageAllocator.chunkIsAvailable(i);
chunkStats.cookie = pool.chunks[i].chunkCookie;
size_t maskCount = (chunkStats.pageCount + 31u) / 32u;
stats.pageMasks.resize(chunkStats.pageMaskOffset + maskCount);
pool.pageAllocator.getPageAllocationMask(i, &stats.pageMasks[chunkStats.pageMaskOffset]);
}
std::sort(stats.chunks.begin() + first, stats.chunks.end(),
[] (const DxvkMemoryChunkStats& a, const DxvkMemoryChunkStats& b) {
return a.cookie < b.cookie;
});
}

View File

@ -82,6 +82,8 @@ namespace dxvk {
high_resolution_clock::time_point unusedTime = { };
/// Unordered list of resources suballocated from this chunk.
DxvkResourceAllocation* allocationList = nullptr;
/// Chunk cookie
uint32_t chunkCookie = 0u;
void addAllocation(DxvkResourceAllocation* allocation);
void removeAllocation(DxvkResourceAllocation* allocation);
@ -109,6 +111,8 @@ namespace dxvk {
VkDeviceSize nextChunkSize = MinChunkSize;
/// Maximum chunk size for the memory pool. Hard limit.
VkDeviceSize maxChunkSize = MaxChunkSize;
/// Next chunk cookie, used to order chunks in statistics
uint32_t nextChunkCookie = 0u;
force_inline int64_t alloc(uint64_t size, uint64_t align) {
if (size <= DxvkPoolAllocator::MaxSize)
@ -198,6 +202,8 @@ namespace dxvk {
bool mapped = false;
/// Whether this chunk is active
bool active = false;
/// Chunk cookie
uint32_t cookie = 0u;
};