aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/vulkan_common
diff options
context:
space:
mode:
authorTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-28 18:36:20 -0400
committerTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-28 18:36:20 -0400
commit5220e4aa539617b83b0b4f2a1666dd068616830e (patch)
treec17d5f1d2be74c0cb17db79fafc038c8be06d9ff /src/video_core/vulkan_common
parent395de452330f717917d5aa468e50ea3b001c12ef (diff)
Texture cache: log VMA blocks per memory type with the periodic memory log
Device memory use is ~3 GB above what the images account for; this shows where. The per-decode log drops to debug level.
Diffstat (limited to 'src/video_core/vulkan_common')
-rw-r--r--src/video_core/vulkan_common/vulkan_memory_allocator.cpp26
-rw-r--r--src/video_core/vulkan_common/vulkan_memory_allocator.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
index aafb3183b6..23f1b0a798 100644
--- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
+++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp
@@ -5,6 +5,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <algorithm>
+#include <array>
#include <bit>
#include <limits>
#include <optional>
@@ -451,4 +452,29 @@ MemoryCommit MemoryAllocator::Commit(const vk::Buffer &buffer, MemoryUsage usage
return MemoryCommit(allocator, a, info);
}
+void LogMemoryStatistics(const Device& device) {
+ const VmaAllocator allocator = device.GetAllocator();
+ const VkPhysicalDeviceMemoryProperties* properties{};
+ vmaGetMemoryProperties(allocator, &properties);
+ VmaTotalStatistics stats{};
+ vmaCalculateStatistics(allocator, &stats);
+ for (u32 type = 0; type < properties->memoryTypeCount; ++type) {
+ const VmaStatistics& s = stats.memoryType[type].statistics;
+ if (s.blockCount == 0) {
+ continue;
+ }
+ LOG_INFO(Render_Vulkan, "VMA type {} (heap {}, flags {:#x}): {} blocks {} MiB, {} allocations {} MiB",
+ type, properties->memoryTypes[type].heapIndex,
+ static_cast<u32>(properties->memoryTypes[type].propertyFlags), s.blockCount,
+ s.blockBytes >> 20, s.allocationCount, s.allocationBytes >> 20);
+ }
+ std::array<VmaBudget, VK_MAX_MEMORY_HEAPS> budgets{};
+ vmaGetHeapBudgets(allocator, budgets.data());
+ for (u32 heap = 0; heap < properties->memoryHeapCount; ++heap) {
+ LOG_INFO(Render_Vulkan, "VMA heap {}: usage {} MiB of budget {} MiB, VMA blocks {} MiB",
+ heap, budgets[heap].usage >> 20, budgets[heap].budget >> 20,
+ budgets[heap].statistics.blockBytes >> 20);
+ }
+}
+
} // namespace Vulkan
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.h b/src/video_core/vulkan_common/vulkan_memory_allocator.h
index a0f9081fc0..7467e929d3 100644
--- a/src/video_core/vulkan_common/vulkan_memory_allocator.h
+++ b/src/video_core/vulkan_common/vulkan_memory_allocator.h
@@ -142,4 +142,7 @@ namespace Vulkan {
u32 valid_memory_types{~0u};
};
+ /// Logs VMA's blocks and allocations per memory type, and each heap's budget.
+ void LogMemoryStatistics(const Device& device);
+
} // namespace Vulkan