Skip to content

Commit

Permalink
[Impeller] fixed units for memory measurement (flutter#53687)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaaclarke authored Jul 2, 2024
1 parent 0bb197f commit b87e3aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion impeller/renderer/backend/metal/allocator_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ static bool SupportsLossyTextureCompression(id<MTLDevice> device) {
}

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

Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/metal/allocator_mtl_unittests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
TextureDescriptor desc;
desc.format = PixelFormat::kR8G8B8A8UNormInt;
desc.storage_mode = StorageMode::kDeviceTransient;
desc.size = {1000, 1000};
desc.size = {1024, 1024};
auto texture_1 = allocator->CreateTexture(desc);

EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u);
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/vulkan/allocator_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ size_t AllocatorVK::DebugGetHeapUsage() const {
total_usage += budget.usage;
}
// Convert bytes to MB.
total_usage *= 1e-6;
total_usage /= (1024 * 1024);
return total_usage;
}

Expand Down

0 comments on commit b87e3aa

Please sign in to comment.