mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-22 07:54:15 +01:00
[dxvk] Sort chunks by allocation time for statistics
This commit is contained in:
parent
69437c2fea
commit
2c8fe59924
@ -1195,6 +1195,7 @@ namespace dxvk {
|
|||||||
pool.chunks.resize(std::max<size_t>(pool.chunks.size(), chunkIndex + 1u));
|
pool.chunks.resize(std::max<size_t>(pool.chunks.size(), chunkIndex + 1u));
|
||||||
pool.chunks[chunkIndex].memory = chunk;
|
pool.chunks[chunkIndex].memory = chunk;
|
||||||
pool.chunks[chunkIndex].unusedTime = high_resolution_clock::time_point();
|
pool.chunks[chunkIndex].unusedTime = high_resolution_clock::time_point();
|
||||||
|
pool.chunks[chunkIndex].chunkCookie = ++pool.nextChunkCookie;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1591,6 +1592,8 @@ namespace dxvk {
|
|||||||
DxvkMemoryAllocationStats& stats) {
|
DxvkMemoryAllocationStats& stats) {
|
||||||
auto& typeStats = stats.memoryTypes[type.index];
|
auto& typeStats = stats.memoryTypes[type.index];
|
||||||
|
|
||||||
|
size_t first = stats.chunks.size();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pool.chunks.size(); i++) {
|
for (uint32_t i = 0; i < pool.chunks.size(); i++) {
|
||||||
if (!pool.chunks[i].memory.memory)
|
if (!pool.chunks[i].memory.memory)
|
||||||
continue;
|
continue;
|
||||||
@ -1604,12 +1607,18 @@ namespace dxvk {
|
|||||||
chunkStats.pageCount = pool.pageAllocator.pageCount(i);
|
chunkStats.pageCount = pool.pageAllocator.pageCount(i);
|
||||||
chunkStats.mapped = &pool == &type.mappedPool;
|
chunkStats.mapped = &pool == &type.mappedPool;
|
||||||
chunkStats.active = pool.pageAllocator.chunkIsAvailable(i);
|
chunkStats.active = pool.pageAllocator.chunkIsAvailable(i);
|
||||||
|
chunkStats.cookie = pool.chunks[i].chunkCookie;
|
||||||
|
|
||||||
size_t maskCount = (chunkStats.pageCount + 31u) / 32u;
|
size_t maskCount = (chunkStats.pageCount + 31u) / 32u;
|
||||||
stats.pageMasks.resize(chunkStats.pageMaskOffset + maskCount);
|
stats.pageMasks.resize(chunkStats.pageMaskOffset + maskCount);
|
||||||
|
|
||||||
pool.pageAllocator.getPageAllocationMask(i, &stats.pageMasks[chunkStats.pageMaskOffset]);
|
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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +82,8 @@ namespace dxvk {
|
|||||||
high_resolution_clock::time_point unusedTime = { };
|
high_resolution_clock::time_point unusedTime = { };
|
||||||
/// Unordered list of resources suballocated from this chunk.
|
/// Unordered list of resources suballocated from this chunk.
|
||||||
DxvkResourceAllocation* allocationList = nullptr;
|
DxvkResourceAllocation* allocationList = nullptr;
|
||||||
|
/// Chunk cookie
|
||||||
|
uint32_t chunkCookie = 0u;
|
||||||
|
|
||||||
void addAllocation(DxvkResourceAllocation* allocation);
|
void addAllocation(DxvkResourceAllocation* allocation);
|
||||||
void removeAllocation(DxvkResourceAllocation* allocation);
|
void removeAllocation(DxvkResourceAllocation* allocation);
|
||||||
@ -109,6 +111,8 @@ namespace dxvk {
|
|||||||
VkDeviceSize nextChunkSize = MinChunkSize;
|
VkDeviceSize nextChunkSize = MinChunkSize;
|
||||||
/// Maximum chunk size for the memory pool. Hard limit.
|
/// Maximum chunk size for the memory pool. Hard limit.
|
||||||
VkDeviceSize maxChunkSize = MaxChunkSize;
|
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) {
|
force_inline int64_t alloc(uint64_t size, uint64_t align) {
|
||||||
if (size <= DxvkPoolAllocator::MaxSize)
|
if (size <= DxvkPoolAllocator::MaxSize)
|
||||||
@ -198,6 +202,8 @@ namespace dxvk {
|
|||||||
bool mapped = false;
|
bool mapped = false;
|
||||||
/// Whether this chunk is active
|
/// Whether this chunk is active
|
||||||
bool active = false;
|
bool active = false;
|
||||||
|
/// Chunk cookie
|
||||||
|
uint32_t cookie = 0u;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user