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.
This commit is contained in:
parent
cfb9245911
commit
669dcfacee
5 changed files with 39 additions and 1 deletions
|
|
@ -1895,6 +1895,10 @@ bool TextureCacheRuntime::CanReportMemoryUsage() const {
|
|||
return device.CanReportMemoryUsage();
|
||||
}
|
||||
|
||||
void TextureCacheRuntime::LogMemoryStatistics() const {
|
||||
Vulkan::LogMemoryStatistics(device);
|
||||
}
|
||||
|
||||
void TextureCacheRuntime::FlushDeferredClear() {
|
||||
scheduler.FlushDeferredClear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ public:
|
|||
|
||||
bool CanReportMemoryUsage() const;
|
||||
|
||||
void LogMemoryStatistics() const;
|
||||
|
||||
bool CanDownloadMsaa(const VideoCommon::ImageInfo& info) const;
|
||||
|
||||
[[nodiscard]] VkImage AcquireMsaaScratchImage(const VkImageCreateInfo& image_ci);
|
||||
|
|
|
|||
|
|
@ -212,6 +212,9 @@ void TextureCache<P>::TickFrame() {
|
|||
LOG_INFO(HW_GPU, " format {}: {} MiB in {} images", formats[i].second, formats[i].first >> 20,
|
||||
by_format[formats[i].second].second);
|
||||
}
|
||||
if constexpr (requires { runtime.LogMemoryStatistics(); }) {
|
||||
runtime.LogMemoryStatistics();
|
||||
}
|
||||
}
|
||||
if (total_used_memory > minimum_memory) {
|
||||
RunGarbageCollector();
|
||||
|
|
@ -1451,7 +1454,7 @@ u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) {
|
|||
template <class P>
|
||||
void TextureCache<P>::QueueAsyncDecode(Image& image, ImageId image_id) {
|
||||
UNIMPLEMENTED_IF(False(image.flags & ImageFlagBits::Converted));
|
||||
LOG_INFO(HW_GPU, "Queuing async texture decode");
|
||||
LOG_DEBUG(HW_GPU, "Queuing async texture decode {:#x}", image.gpu_addr);
|
||||
|
||||
image.flags |= ImageFlagBits::IsDecoding;
|
||||
auto decode = std::make_unique<AsyncDecodeContext>();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue