From 251929d816ca4be0f803885b0f775bc480a9e2aa Mon Sep 17 00:00:00 2001 From: "Bernhart, Bryan" Date: Thu, 10 Aug 2023 14:06:58 -0700 Subject: [PATCH] Move defaults where used. --- src/gpgmm/common/BUILD.gn | 1 - src/gpgmm/common/CMakeLists.txt | 1 - src/gpgmm/common/Defaults.h | 26 ---------------------- src/gpgmm/common/EventTraceWriter.cpp | 3 ++- src/gpgmm/common/MemoryAllocator.h | 9 ++++++++ src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 1 - src/gpgmm/vk/ResourceAllocatorVk.cpp | 1 - 7 files changed, 11 insertions(+), 31 deletions(-) delete mode 100644 src/gpgmm/common/Defaults.h diff --git a/src/gpgmm/common/BUILD.gn b/src/gpgmm/common/BUILD.gn index 4f893c37..5e0efa72 100644 --- a/src/gpgmm/common/BUILD.gn +++ b/src/gpgmm/common/BUILD.gn @@ -183,7 +183,6 @@ source_set("gpgmm_common_sources") { "ConditionalMemoryAllocator.h", "DedicatedMemoryAllocator.cpp", "DedicatedMemoryAllocator.h", - "Defaults.h", "Error.h", "EventMessage.cpp", "EventMessage.h", diff --git a/src/gpgmm/common/CMakeLists.txt b/src/gpgmm/common/CMakeLists.txt index 80186ed7..5a7a3b85 100644 --- a/src/gpgmm/common/CMakeLists.txt +++ b/src/gpgmm/common/CMakeLists.txt @@ -23,7 +23,6 @@ target_sources(gpgmm_common PRIVATE "ConditionalMemoryAllocator.h" "DedicatedMemoryAllocator.cpp" "DedicatedMemoryAllocator.h" - "Defaults.h" "Error.h" "EventTraceWriter.cpp" "EventTraceWriter.h" diff --git a/src/gpgmm/common/Defaults.h b/src/gpgmm/common/Defaults.h deleted file mode 100644 index d9be1757..00000000 --- a/src/gpgmm/common/Defaults.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2022 The GPGMM Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_GPGMM_COMMON_DEFAULTS_H_ -#define SRC_GPGMM_COMMON_DEFAULTS_H_ - -#include - -namespace gpgmm { - static constexpr const char* kDefaultTraceFile = "gpgmm_event_trace.json"; - static constexpr float kDefaultMemoryFragmentationLimit = 0.125f; // 1/8th or 12.5% - static constexpr float kDefaultMemoryGrowthFactor = 1.25f; // 25% growth -} // namespace gpgmm - -#endif // SRC_GPGMM_COMMON_DEFAULTS_H_ diff --git a/src/gpgmm/common/EventTraceWriter.cpp b/src/gpgmm/common/EventTraceWriter.cpp index 0020d5b4..7c3586b6 100644 --- a/src/gpgmm/common/EventTraceWriter.cpp +++ b/src/gpgmm/common/EventTraceWriter.cpp @@ -14,7 +14,6 @@ #include "gpgmm/common/EventTraceWriter.h" -#include "gpgmm/common/Defaults.h" #include "gpgmm/utils/Assert.h" #include "gpgmm/utils/Log.h" #include "gpgmm/utils/PlatformTime.h" @@ -28,6 +27,8 @@ namespace gpgmm { + static constexpr const char* kDefaultTraceFile = "gpgmm_event_trace.json"; + // Trace buffer that flushes and unlinks itself from the cache once destroyed. class ScopedTraceBufferInTLS { public: diff --git a/src/gpgmm/common/MemoryAllocator.h b/src/gpgmm/common/MemoryAllocator.h index 5f17583a..e3cbe630 100644 --- a/src/gpgmm/common/MemoryAllocator.h +++ b/src/gpgmm/common/MemoryAllocator.h @@ -117,6 +117,15 @@ namespace gpgmm { MemoryAllocatorStats& operator+=(const MemoryAllocatorStats& rhs); }; + // Amount of memory, expressed as a percentage of memory, that is acceptable to waste + // to fragmentation. For example, a 6 byte request may require 8 bytes (eg. power-of-two) or 25% + // fragmentation. + static constexpr float kDefaultMemoryFragmentationLimit = 0.125f; // 1/8th or 12.5% + + // Amount of memory, expressed as a perecentage memory size, that can + // increased per allocation. For example, a 2.0 factor means the memory size can double. + static constexpr float kDefaultMemoryGrowthFactor = 1.25f; // 25% growth + class BlockAllocator; // MemoryAllocatorBase services a fixed or variable sized MemoryAllocationRequest. diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index c638a602..9fcbc768 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -17,7 +17,6 @@ #include "gpgmm/common/BuddyMemoryAllocator.h" #include "gpgmm/common/DedicatedMemoryAllocator.h" -#include "gpgmm/common/Defaults.h" #include "gpgmm/common/EventMessage.h" #include "gpgmm/common/PooledMemoryAllocator.h" #include "gpgmm/common/SegmentedMemoryAllocator.h" diff --git a/src/gpgmm/vk/ResourceAllocatorVk.cpp b/src/gpgmm/vk/ResourceAllocatorVk.cpp index cb30acf1..884c9a05 100644 --- a/src/gpgmm/vk/ResourceAllocatorVk.cpp +++ b/src/gpgmm/vk/ResourceAllocatorVk.cpp @@ -15,7 +15,6 @@ #include "gpgmm/vk/ResourceAllocatorVk.h" #include "gpgmm/common/BuddyMemoryAllocator.h" -#include "gpgmm/common/Defaults.h" #include "gpgmm/common/EventMessage.h" #include "gpgmm/common/Object.h" #include "gpgmm/common/PooledMemoryAllocator.h"