Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print VK_EXT_memory_budget stats on allocation failure #1112

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dxvk/dxvk_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace dxvk {
m_vki->vkGetPhysicalDeviceMemoryProperties2KHR(m_handle, &memProps);

DxvkAdapterMemoryInfo info = { };
info.extMemoryBudget = m_hasMemoryBudget;
info.heapCount = memProps.memoryProperties.memoryHeapCount;

for (uint32_t i = 0; i < info.heapCount; i++) {
Expand Down
1 change: 1 addition & 0 deletions src/dxvk/dxvk_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace dxvk {
* info of each available heap.
*/
struct DxvkAdapterMemoryInfo {
bool extMemoryBudget;
uint32_t heapCount;
DxvkAdapterMemoryHeapInfo heaps[VK_MAX_MEMORY_HEAPS];
};
Expand Down
16 changes: 12 additions & 4 deletions src/dxvk/dxvk_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ namespace dxvk {
result = this->tryAlloc(req, dedAllocPtr, flags & ~optFlags, priority);

if (!result) {
DxvkAdapterMemoryInfo memHeapInfo = m_device->adapter()->getMemoryHeapInfo();
Logger::err(str::format(
"DxvkMemoryAllocator: Memory allocation failed",
"\n Size: ", req->size,
Expand All @@ -214,9 +215,16 @@ namespace dxvk {

for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) {
Logger::err(str::format("Heap ", i, ": ",
(m_memHeaps[i].stats.memoryAllocated >> 20), " MB allocated, ",
(m_memHeaps[i].stats.memoryUsed >> 20), " MB used, ",
(m_memHeaps[i].properties.size >> 20), " MB available"));
(m_memHeaps[i].stats.memoryAllocated >> 20), " MB allocated, ",
(m_memHeaps[i].stats.memoryUsed >> 20), " MB used, ",
memHeapInfo.extMemoryBudget ?
str::format(
(memHeapInfo.heaps[i].memoryAllocated >> 20), " MB allocated (driver), ",
(memHeapInfo.heaps[i].memoryAvailable >> 20), " MB available (driver), ",
(m_memHeaps[i].properties.size >> 20), " MB total")
: str::format(
(m_memHeaps[i].properties.size >> 20), " MB available")
));
}

throw DxvkError("DxvkMemoryAllocator: Memory allocation failed");
Expand Down Expand Up @@ -400,4 +408,4 @@ namespace dxvk {
return std::min(heapSize / MinChunkCount, MaxChunkSize);
}

}
}