Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b87e3aa

Browse files
authored
[Impeller] fixed units for memory measurement (#53687)
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 0bb197f commit b87e3aa

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

impeller/renderer/backend/metal/allocator_mtl.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ static bool SupportsLossyTextureCompression(id<MTLDevice> device) {
9999
}
100100

101101
size_t DebugAllocatorStats::GetAllocationSizeMB() {
102-
size_t new_value = size_ / 1000000;
102+
// RAM is measured in MiB, thus a divisor of 2^20 instead of 1,000,000.
103+
size_t new_value = size_ / (1024 * 1024);
103104
return new_value;
104105
}
105106

impeller/renderer/backend/metal/allocator_mtl_unittests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
TextureDescriptor desc;
3737
desc.format = PixelFormat::kR8G8B8A8UNormInt;
3838
desc.storage_mode = StorageMode::kDeviceTransient;
39-
desc.size = {1000, 1000};
39+
desc.size = {1024, 1024};
4040
auto texture_1 = allocator->CreateTexture(desc);
4141

4242
EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u);

impeller/renderer/backend/vulkan/allocator_vk.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ size_t AllocatorVK::DebugGetHeapUsage() const {
519519
total_usage += budget.usage;
520520
}
521521
// Convert bytes to MB.
522-
total_usage *= 1e-6;
522+
total_usage /= (1024 * 1024);
523523
return total_usage;
524524
}
525525

0 commit comments

Comments
 (0)