From 4a8579b292442311d1f194b4d66490044b3dc0d6 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 27 Jun 2024 13:44:34 -0700 Subject: [PATCH 01/10] track in destructor. --- impeller/core/allocator.h | 5 +- impeller/playground/playground_test.h | 2 +- impeller/renderer/backend/metal/BUILD.gn | 6 +- .../renderer/backend/metal/allocator_mtl.h | 30 +++++++++ .../renderer/backend/metal/allocator_mtl.mm | 50 ++++++++++++++- .../backend/metal/allocator_mtl_unittests.mm | 62 +++++++++++++++++++ .../renderer/backend/metal/surface_mtl.mm | 4 ++ impeller/renderer/backend/metal/texture_mtl.h | 10 +++ .../renderer/backend/metal/texture_mtl.mm | 20 +++++- .../renderer/backend/vulkan/allocator_vk.h | 4 +- 10 files changed, 186 insertions(+), 7 deletions(-) create mode 100644 impeller/renderer/backend/metal/allocator_mtl_unittests.mm diff --git a/impeller/core/allocator.h b/impeller/core/allocator.h index 38ac054d36423..921fb64a9edda 100644 --- a/impeller/core/allocator.h +++ b/impeller/core/allocator.h @@ -47,9 +47,12 @@ class Allocator { /// @brief Write debug memory usage information to the dart timeline in debug /// and profile modes. /// - /// This is only supported on the Vulkan backend. + /// This is supported on both the Metal and Vulkan backends. virtual void DebugTraceMemoryStatistics() const {}; + // Visible for testing. + virtual size_t DebugGetHeapUsage() const { return 0; } + protected: Allocator(); diff --git a/impeller/playground/playground_test.h b/impeller/playground/playground_test.h index d3f241b6d4df6..26b8d611a4a29 100644 --- a/impeller/playground/playground_test.h +++ b/impeller/playground/playground_test.h @@ -42,7 +42,7 @@ class PlaygroundTest : public Playground, private: // |Playground| - bool ShouldKeepRendering() const; + bool ShouldKeepRendering() const override; #if FML_OS_MACOSX fml::ScopedNSAutoreleasePool autorelease_pool_; diff --git a/impeller/renderer/backend/metal/BUILD.gn b/impeller/renderer/backend/metal/BUILD.gn index e681b7bfee415..343330fc2ad23 100644 --- a/impeller/renderer/backend/metal/BUILD.gn +++ b/impeller/renderer/backend/metal/BUILD.gn @@ -65,10 +65,14 @@ impeller_component("metal") { impeller_component("metal_unittests") { testonly = true - sources = [ "texture_mtl_unittests.mm" ] + sources = [ + "allocator_mtl_unittests.mm", + "texture_mtl_unittests.mm", + ] deps = [ ":metal", + "//flutter/impeller/playground:playground_test", "//flutter/testing:testing_lib", ] diff --git a/impeller/renderer/backend/metal/allocator_mtl.h b/impeller/renderer/backend/metal/allocator_mtl.h index 057f2a078a081..3067bcf2e3c18 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.h +++ b/impeller/renderer/backend/metal/allocator_mtl.h @@ -7,10 +7,28 @@ #include +#include "impeller/base/thread.h" #include "impeller/core/allocator.h" namespace impeller { +class DebugAllocatorStats { + public: + DebugAllocatorStats() {} + + ~DebugAllocatorStats() {} + + void Increment(size_t size); + + void Decrement(size_t size); + + size_t GetAllocationSizeMB(); + + private: + mutable Mutex mutex_ = {}; + size_t size_ IPLR_GUARDED_BY(mutex_) = 0; +}; + class AllocatorMTL final : public Allocator { public: AllocatorMTL(); @@ -18,6 +36,9 @@ class AllocatorMTL final : public Allocator { // |Allocator| ~AllocatorMTL() override; + // |Allocator| + size_t DebugGetHeapUsage() const override; + private: friend class ContextMTL; @@ -26,6 +47,12 @@ class AllocatorMTL final : public Allocator { bool supports_memoryless_targets_ = false; bool supports_uma_ = false; bool is_valid_ = false; + +#ifdef IMPELLER_DEBUG + std::shared_ptr debug_allocater_ = + std::make_shared(); +#endif // IMPELLER_DEBUG + ISize max_texture_supported_; AllocatorMTL(id device, std::string label); @@ -47,6 +74,9 @@ class AllocatorMTL final : public Allocator { // |Allocator| ISize GetMaxTextureSizeSupported() const override; + // |Allocator| + void DebugTraceMemoryStatistics() const override; + AllocatorMTL(const AllocatorMTL&) = delete; AllocatorMTL& operator=(const AllocatorMTL&) = delete; diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index dfae2502ea9fe..5ba964042c87c 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -6,7 +6,9 @@ #include "flutter/fml/build_config.h" #include "flutter/fml/logging.h" +#include "fml/trace_event.h" #include "impeller/base/validation.h" +#include "impeller/core/formats.h" #include "impeller/renderer/backend/metal/device_buffer_mtl.h" #include "impeller/renderer/backend/metal/formats_mtl.h" #include "impeller/renderer/backend/metal/texture_mtl.h" @@ -88,6 +90,27 @@ static bool SupportsLossyTextureCompression(id device) { #endif } +void DebugAllocatorStats::Increment(size_t size) { + Lock lock(mutex_); + size_ += size; +} + +void DebugAllocatorStats::Decrement(size_t size) { + Lock lock(mutex_); + if (size > size_) { + size_ = 0; + } else { + size_ -= size; + } +} + +size_t DebugAllocatorStats::GetAllocationSizeMB() { + size_t current_size = 0; + Lock lock(mutex_); + current_size = size_ * 1e-6; + return current_size; +} + AllocatorMTL::AllocatorMTL(id device, std::string label) : device_(device), allocator_label_(std::move(label)) { if (!device_) { @@ -212,11 +235,23 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode, } } +#ifdef IMPELLER_DEBUG + if (desc.storage_mode != StorageMode::kDeviceTransient) { + debug_allocater_->Increment(desc.GetByteSizeOfBaseMipLevel()); + } +#endif // IMPELLER_DEBUG + auto texture = [device_ newTextureWithDescriptor:mtl_texture_desc]; if (!texture) { return nullptr; } - return TextureMTL::Create(desc, texture); + std::shared_ptr result_texture = + TextureMTL::Create(desc, texture); +#ifdef IMPELLER_DEBUG + result_texture->SetDebugAllocator(debug_allocater_); +#endif // IMPELLER_DEBUG + + return result_texture; } uint16_t AllocatorMTL::MinimumBytesPerRow(PixelFormat format) const { @@ -228,4 +263,17 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode, return max_texture_supported_; } +size_t AllocatorMTL::DebugGetHeapUsage() const { + return debug_allocater_->GetAllocationSizeMB(); +} + +void AllocatorMTL::DebugTraceMemoryStatistics() const { +#ifdef IMPELLER_DEBUG + size_t allocated_size = DebugGetHeapUsage(); + FML_TRACE_COUNTER("flutter", "AllocatorVK", + reinterpret_cast(this), // Trace Counter ID + "MemoryBudgetUsageMB", allocated_size); +#endif // IMPELLER_DEBUG +} + } // namespace impeller diff --git a/impeller/renderer/backend/metal/allocator_mtl_unittests.mm b/impeller/renderer/backend/metal/allocator_mtl_unittests.mm new file mode 100644 index 0000000000000..16139a7fff00a --- /dev/null +++ b/impeller/renderer/backend/metal/allocator_mtl_unittests.mm @@ -0,0 +1,62 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "flutter/testing/testing.h" +#include "impeller/core/formats.h" +#include "impeller/core/texture_descriptor.h" +#include "impeller/playground/playground_test.h" +#include "impeller/renderer/backend/metal/allocator_mtl.h" +#include "impeller/renderer/backend/metal/context_mtl.h" +#include "impeller/renderer/backend/metal/formats_mtl.h" +#include "impeller/renderer/backend/metal/lazy_drawable_holder.h" +#include "impeller/renderer/backend/metal/texture_mtl.h" +#include "impeller/renderer/capabilities.h" + +#include +#include +#include + +#include "gtest/gtest.h" + +namespace impeller { +namespace testing { + +using AllocatorMTLTest = PlaygroundTest; +INSTANTIATE_METAL_PLAYGROUND_SUITE(AllocatorMTLTest); + +TEST_P(AllocatorMTLTest, DebugTraceMemoryStatistics) { + auto& context_mtl = ContextMTL::Cast(*GetContext()); + const auto& allocator = context_mtl.GetResourceAllocator(); + + EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u); + + // Memoryless texture does not increase allocated size. + { + TextureDescriptor desc; + desc.format = PixelFormat::kR8G8B8A8UNormInt; + desc.storage_mode = StorageMode::kDeviceTransient; + desc.size = {1000, 1000}; + auto texture_1 = allocator->CreateTexture(desc); + + EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u); + + // Private storage texture increases allocated size. + desc.storage_mode = StorageMode::kDevicePrivate; + auto texture_2 = allocator->CreateTexture(desc); + + EXPECT_EQ(allocator->DebugGetHeapUsage(), 4u); + + // Host storage texture increases allocated size. + desc.storage_mode = StorageMode::kHostVisible; + auto texture_3 = allocator->CreateTexture(desc); + + EXPECT_EQ(allocator->DebugGetHeapUsage(), 8u); + } + + // After all textures are out of scope, memory has been decremented. + EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u); +} + +} // namespace testing +} // namespace impeller diff --git a/impeller/renderer/backend/metal/surface_mtl.mm b/impeller/renderer/backend/metal/surface_mtl.mm index b84f3a144058d..9219aca941278 100644 --- a/impeller/renderer/backend/metal/surface_mtl.mm +++ b/impeller/renderer/backend/metal/surface_mtl.mm @@ -229,6 +229,10 @@ - (void)flutterPrepareForPresent:(nonnull id)commandBuffer; return false; } +#ifdef IMPELLER_DEBUG + context->GetResourceAllocator()->DebugTraceMemoryStatistics(); +#endif // IMPELLER_DEBUG + if (requires_blit_) { if (!(source_texture_ && destination_texture_)) { return false; diff --git a/impeller/renderer/backend/metal/texture_mtl.h b/impeller/renderer/backend/metal/texture_mtl.h index b0aa1c8b6f1d4..6fedd97d0d837 100644 --- a/impeller/renderer/backend/metal/texture_mtl.h +++ b/impeller/renderer/backend/metal/texture_mtl.h @@ -9,6 +9,7 @@ #include "impeller/base/backend_cast.h" #include "impeller/core/texture.h" +#include "impeller/renderer/backend/metal/allocator_mtl.h" namespace impeller { @@ -47,7 +48,16 @@ class TextureMTL final : public Texture, bool GenerateMipmap(id encoder); +#ifdef IMPELLER_DEBUG + void SetDebugAllocator( + const std::shared_ptr& debug_allocator); +#endif // IMPELLER_DEBUG + private: +#ifdef IMPELLER_DEBUG + std::shared_ptr debug_allocator_ = nullptr; +#endif // IMPELLER_DEBUG + AcquireTextureProc aquire_proc_ = {}; bool is_valid_ = false; bool is_wrapped_ = false; diff --git a/impeller/renderer/backend/metal/texture_mtl.mm b/impeller/renderer/backend/metal/texture_mtl.mm index d65937e8b9f09..2f21c324b5eeb 100644 --- a/impeller/renderer/backend/metal/texture_mtl.mm +++ b/impeller/renderer/backend/metal/texture_mtl.mm @@ -6,6 +6,7 @@ #include #include "impeller/base/validation.h" +#include "impeller/core/formats.h" #include "impeller/core/texture_descriptor.h" namespace impeller { @@ -59,7 +60,17 @@ new TextureMTL( return std::make_shared(desc, [texture]() { return texture; }); } -TextureMTL::~TextureMTL() = default; +TextureMTL::~TextureMTL() { +#ifdef IMPELLER_DEBUG + if (debug_allocator_) { + auto desc = GetTextureDescriptor(); + if (desc.storage_mode == StorageMode::kDeviceTransient) { + return; + } + debug_allocator_->Decrement(desc.GetByteSizeOfBaseMipLevel()); + } +#endif // IMPELLER_DEBUG +} void TextureMTL::SetLabel(std::string_view label) { if (is_drawable_) { @@ -76,6 +87,13 @@ new TextureMTL( return OnSetContents(mapping->GetMapping(), mapping->GetSize(), slice); } +#ifdef IMPELLER_DEBUG +void TextureMTL::SetDebugAllocator( + const std::shared_ptr& debug_allocator) { + debug_allocator_ = debug_allocator; +} +#endif // IMPELLER_DEBUG + // |Texture| bool TextureMTL::OnSetContents(const uint8_t* contents, size_t length, diff --git a/impeller/renderer/backend/vulkan/allocator_vk.h b/impeller/renderer/backend/vulkan/allocator_vk.h index a664c84f4a9af..f1a3201e8f676 100644 --- a/impeller/renderer/backend/vulkan/allocator_vk.h +++ b/impeller/renderer/backend/vulkan/allocator_vk.h @@ -21,8 +21,8 @@ class AllocatorVK final : public Allocator { // |Allocator| ~AllocatorVK() override; - // Visible for testing - size_t DebugGetHeapUsage() const; + // |Allocator| + size_t DebugGetHeapUsage() const override; /// @brief Select a matching memory type for the given /// [memory_type_bits_requirement], or -1 if none is found. From 90c68ef169a4b15404268dc9bf7ba3247b434e89 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 27 Jun 2024 18:57:34 -0700 Subject: [PATCH 02/10] ++ --- impeller/renderer/backend/metal/allocator_mtl.h | 4 ++-- impeller/renderer/backend/metal/allocator_mtl.mm | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.h b/impeller/renderer/backend/metal/allocator_mtl.h index 3067bcf2e3c18..46f59a5ed9427 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.h +++ b/impeller/renderer/backend/metal/allocator_mtl.h @@ -6,6 +6,7 @@ #define FLUTTER_IMPELLER_RENDERER_BACKEND_METAL_ALLOCATOR_MTL_H_ #include +#include #include "impeller/base/thread.h" #include "impeller/core/allocator.h" @@ -25,8 +26,7 @@ class DebugAllocatorStats { size_t GetAllocationSizeMB(); private: - mutable Mutex mutex_ = {}; - size_t size_ IPLR_GUARDED_BY(mutex_) = 0; + std::atomic size_ = 0; }; class AllocatorMTL final : public Allocator { diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 5ba964042c87c..6f37df947059a 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -91,12 +91,10 @@ static bool SupportsLossyTextureCompression(id device) { } void DebugAllocatorStats::Increment(size_t size) { - Lock lock(mutex_); size_ += size; } void DebugAllocatorStats::Decrement(size_t size) { - Lock lock(mutex_); if (size > size_) { size_ = 0; } else { @@ -105,10 +103,7 @@ static bool SupportsLossyTextureCompression(id device) { } size_t DebugAllocatorStats::GetAllocationSizeMB() { - size_t current_size = 0; - Lock lock(mutex_); - current_size = size_ * 1e-6; - return current_size; + return size_ * 1e-6; } AllocatorMTL::AllocatorMTL(id device, std::string label) @@ -264,13 +259,17 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode, } size_t AllocatorMTL::DebugGetHeapUsage() const { +#ifdef IMPELLER_DEBUG return debug_allocater_->GetAllocationSizeMB(); +#else + return 0u; +#endif // IMPELLER_DEBUG } void AllocatorMTL::DebugTraceMemoryStatistics() const { #ifdef IMPELLER_DEBUG size_t allocated_size = DebugGetHeapUsage(); - FML_TRACE_COUNTER("flutter", "AllocatorVK", + FML_TRACE_COUNTER("flutter", "AllocatorMTL", reinterpret_cast(this), // Trace Counter ID "MemoryBudgetUsageMB", allocated_size); #endif // IMPELLER_DEBUG From eb7342013999cb88cb4a48fb0b9e43867e30fc4e Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Thu, 27 Jun 2024 18:59:17 -0700 Subject: [PATCH 03/10] license --- ci/licenses_golden/excluded_files | 1 + impeller/renderer/backend/metal/allocator_mtl.mm | 6 +----- .../renderer/backend/metal/allocator_mtl_unittests.mm | 8 ++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ci/licenses_golden/excluded_files b/ci/licenses_golden/excluded_files index bec99eef744ad..6420aa3a94f74 100644 --- a/ci/licenses_golden/excluded_files +++ b/ci/licenses_golden/excluded_files @@ -176,6 +176,7 @@ ../../../flutter/impeller/golden_tests/README.md ../../../flutter/impeller/playground ../../../flutter/impeller/renderer/backend/gles/test +../../../flutter/impeller/renderer/backend/metal/allocator_mtl_unittests.mm ../../../flutter/impeller/renderer/backend/metal/texture_mtl_unittests.mm ../../../flutter/impeller/renderer/backend/vulkan/allocator_vk_unittests.cc ../../../flutter/impeller/renderer/backend/vulkan/command_encoder_vk_unittests.cc diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 6f37df947059a..9f7a0dac54134 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -95,11 +95,7 @@ static bool SupportsLossyTextureCompression(id device) { } void DebugAllocatorStats::Decrement(size_t size) { - if (size > size_) { - size_ = 0; - } else { - size_ -= size; - } + size_ -= size; } size_t DebugAllocatorStats::GetAllocationSizeMB() { diff --git a/impeller/renderer/backend/metal/allocator_mtl_unittests.mm b/impeller/renderer/backend/metal/allocator_mtl_unittests.mm index 16139a7fff00a..4150caf20ce9d 100644 --- a/impeller/renderer/backend/metal/allocator_mtl_unittests.mm +++ b/impeller/renderer/backend/metal/allocator_mtl_unittests.mm @@ -45,13 +45,21 @@ desc.storage_mode = StorageMode::kDevicePrivate; auto texture_2 = allocator->CreateTexture(desc); +#ifdef IMPELLER_DEBUG EXPECT_EQ(allocator->DebugGetHeapUsage(), 4u); +#else + EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u); +#endif // IMPELLER_DEBUG // Host storage texture increases allocated size. desc.storage_mode = StorageMode::kHostVisible; auto texture_3 = allocator->CreateTexture(desc); +#ifdef IMPELLER_DEBUG EXPECT_EQ(allocator->DebugGetHeapUsage(), 8u); +#else + EXPECT_EQ(allocator->DebugGetHeapUsage(), 0u); +#endif // IMPELLER_DEBUG } // After all textures are out of scope, memory has been decremented. From 5bbf312890687417b12f17b50438211fec0c3ac3 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 28 Jun 2024 09:53:02 -0700 Subject: [PATCH 04/10] Update allocator_mtl.mm --- impeller/renderer/backend/metal/allocator_mtl.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 9f7a0dac54134..9387dcc3ab297 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -91,11 +91,11 @@ static bool SupportsLossyTextureCompression(id device) { } void DebugAllocatorStats::Increment(size_t size) { - size_ += size; + size_.fetch_add(size, std::memory_order_relaxed); } void DebugAllocatorStats::Decrement(size_t size) { - size_ -= size; + size_.fetch_sub(size, std::memory_order_relaxed); } size_t DebugAllocatorStats::GetAllocationSizeMB() { From 0599098a318cbea3a3a514711be1f15476894ef4 Mon Sep 17 00:00:00 2001 From: jonahwilliams Date: Fri, 28 Jun 2024 10:47:53 -0700 Subject: [PATCH 05/10] ++ --- impeller/core/texture_descriptor.h | 17 +++++++++++++++++ impeller/renderer/backend/metal/allocator_mtl.h | 3 +++ .../renderer/backend/metal/allocator_mtl.mm | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/impeller/core/texture_descriptor.h b/impeller/core/texture_descriptor.h index 66a293d0ca8e0..851ffde902e25 100644 --- a/impeller/core/texture_descriptor.h +++ b/impeller/core/texture_descriptor.h @@ -5,6 +5,7 @@ #ifndef FLUTTER_IMPELLER_CORE_TEXTURE_DESCRIPTOR_H_ #define FLUTTER_IMPELLER_CORE_TEXTURE_DESCRIPTOR_H_ +#include #include "impeller/core/formats.h" #include "impeller/geometry/size.h" @@ -51,6 +52,22 @@ struct TextureDescriptor { return size.Area() * BytesPerPixelForPixelFormat(format); } + constexpr size_t GetByteSizeOfAllMipLevels() const { + if (!IsValid()) { + return 0u; + } + size_t result = 0u; + int64_t width = size.width; + int64_t height = size.height; + for (auto i = 0u; i < mip_count; i++) { + result += + ISize(width, height).Area() * BytesPerPixelForPixelFormat(format); + width /= 2; + height /= 2; + } + return result; + } + constexpr size_t GetBytesPerRow() const { if (!IsValid()) { return 0u; diff --git a/impeller/renderer/backend/metal/allocator_mtl.h b/impeller/renderer/backend/metal/allocator_mtl.h index 46f59a5ed9427..82fd870190a0f 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.h +++ b/impeller/renderer/backend/metal/allocator_mtl.h @@ -19,10 +19,13 @@ class DebugAllocatorStats { ~DebugAllocatorStats() {} + /// Increment the tracked allocation size in bytes. void Increment(size_t size); + /// Decrement the tracked allocation size in bytes. void Decrement(size_t size); + /// Get the current tracked allocation size in MB. size_t GetAllocationSizeMB(); private: diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 9f7a0dac54134..4e8c95bf45865 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -228,7 +228,7 @@ static MTLStorageMode ToMTLStorageMode(StorageMode mode, #ifdef IMPELLER_DEBUG if (desc.storage_mode != StorageMode::kDeviceTransient) { - debug_allocater_->Increment(desc.GetByteSizeOfBaseMipLevel()); + debug_allocater_->Increment(desc.GetByteSizeOfAllMipLevels()); } #endif // IMPELLER_DEBUG From ebe3c03464612de66df34f08443477288891e5a1 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Sat, 29 Jun 2024 09:35:45 -0700 Subject: [PATCH 06/10] Update allocator_mtl.mm --- impeller/renderer/backend/metal/allocator_mtl.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 8f44f94393da1..1fa60754cdabd 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -99,7 +99,7 @@ static bool SupportsLossyTextureCompression(id device) { } size_t DebugAllocatorStats::GetAllocationSizeMB() { - return size_ * 1e-6; + return size_ / 1_000_000; } AllocatorMTL::AllocatorMTL(id device, std::string label) From d3d1366a468fa084dffc874e3cc23ae7cd589e26 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Sat, 29 Jun 2024 10:07:40 -0700 Subject: [PATCH 07/10] Update allocator_mtl.mm --- impeller/renderer/backend/metal/allocator_mtl.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 1fa60754cdabd..57504b641f451 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -99,7 +99,7 @@ static bool SupportsLossyTextureCompression(id device) { } size_t DebugAllocatorStats::GetAllocationSizeMB() { - return size_ / 1_000_000; + return size_ / 1_000_000u; } AllocatorMTL::AllocatorMTL(id device, std::string label) From 1af8e93ca6c8ac105a64a47c1f7c08a46b81e420 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Sat, 29 Jun 2024 12:47:28 -0700 Subject: [PATCH 08/10] Update allocator_mtl.mm --- impeller/renderer/backend/metal/allocator_mtl.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 57504b641f451..8513c644ce304 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -99,7 +99,7 @@ static bool SupportsLossyTextureCompression(id device) { } size_t DebugAllocatorStats::GetAllocationSizeMB() { - return size_ / 1_000_000u; + return size_ / 1_000_000ll; } AllocatorMTL::AllocatorMTL(id device, std::string label) From e3b4bcd73a5ef169946f1da624ca23fd7118ee20 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 1 Jul 2024 08:53:39 -0700 Subject: [PATCH 09/10] Update allocator_mtl.mm --- impeller/renderer/backend/metal/allocator_mtl.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 8513c644ce304..6ba9659a961a9 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -99,7 +99,8 @@ static bool SupportsLossyTextureCompression(id device) { } size_t DebugAllocatorStats::GetAllocationSizeMB() { - return size_ / 1_000_000ll; + size_t new_value = size_ / 1_000_000; + return new_value; } AllocatorMTL::AllocatorMTL(id device, std::string label) From 51ed874eca485db6f684490a1deca5d8f130f46f Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 1 Jul 2024 09:59:44 -0700 Subject: [PATCH 10/10] Update allocator_mtl.mm --- impeller/renderer/backend/metal/allocator_mtl.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/impeller/renderer/backend/metal/allocator_mtl.mm b/impeller/renderer/backend/metal/allocator_mtl.mm index 6ba9659a961a9..913f7333205a8 100644 --- a/impeller/renderer/backend/metal/allocator_mtl.mm +++ b/impeller/renderer/backend/metal/allocator_mtl.mm @@ -99,7 +99,7 @@ static bool SupportsLossyTextureCompression(id device) { } size_t DebugAllocatorStats::GetAllocationSizeMB() { - size_t new_value = size_ / 1_000_000; + size_t new_value = size_ / 1000000; return new_value; }