[native] Remove ComputeEstimateMemoryUsage method
Remove old ComputeEstimateMemoryUsage native method in favor of
ComputeEstimatedMemoryUsageInfo method.
Bug: chromium:402138745
Change-Id: Ie2c8ff950ae8910dd47292b7fecd33d57520684f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/232255
Commit-Queue: Saifuddin Hitawala <hitawala@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h
index 2a22d7e..232d5ae 100644
--- a/include/dawn/native/DawnNative.h
+++ b/include/dawn/native/DawnNative.h
@@ -315,17 +315,11 @@
};
DAWN_NATIVE_EXPORT void DumpMemoryStatistics(WGPUDevice device, MemoryDump* dump);
-// Unlike memory dumps which include detailed information about allocations, this only returns the
-// total estimated memory usage, and is intended for background tracing for UMA.
-DAWN_NATIVE_EXPORT uint64_t ComputeEstimatedMemoryUsage(WGPUDevice device);
-
-// Same as ComputeEstimatedMemoryUsage but with more details:
+// Intended for background tracing for UMA that returns the estimated memory usage with details:
// - total memory usage of textures.
// - total memory usage of buffers.
// - total memory usage of depth/stencil textures.
// - total memory usage of MSAA textures.
-// TODO(chromium:402138745): Remove the old ComputeEstimatedMemoryUsage() once all call sites are
-// updated to use the newer function.
struct DAWN_NATIVE_EXPORT MemoryUsageInfo {
uint64_t totalUsage;
uint64_t depthStencilTexturesUsage;
diff --git a/src/dawn/native/DawnNative.cpp b/src/dawn/native/DawnNative.cpp
index d5da8f4..240e75d 100644
--- a/src/dawn/native/DawnNative.cpp
+++ b/src/dawn/native/DawnNative.cpp
@@ -276,10 +276,6 @@
FromAPI(device)->DumpMemoryStatistics(dump);
}
-uint64_t ComputeEstimatedMemoryUsage(WGPUDevice device) {
- return ComputeEstimatedMemoryUsageInfo(device).totalUsage;
-}
-
MemoryUsageInfo ComputeEstimatedMemoryUsageInfo(WGPUDevice device) {
auto deviceLock(FromAPI(device)->GetScopedLock());
return FromAPI(device)->ComputeEstimatedMemoryUsage();
diff --git a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
index 54517fa..7377174 100644
--- a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
+++ b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
@@ -203,10 +203,10 @@
EXPECT_EQ(memoryDumpMock.GetTotalSize(), kBufferAllocatedSize + kMipmappedTextureSize +
kMultisampleTextureSize + kETC2TextureSize);
- // Check that ComputeEstimatedMemoryUsage() matches the memory dump total size.
- EXPECT_EQ(
- ComputeEstimatedMemoryUsage(device.Get()),
- kBufferAllocatedSize + kMipmappedTextureSize + kMultisampleTextureSize + kETC2TextureSize);
+ // Check that ComputeEstimatedMemoryUsageInfo() matches the memory dump total size.
+ MemoryUsageInfo memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
+ EXPECT_EQ(memInfo.totalUsage, kBufferAllocatedSize + kMipmappedTextureSize +
+ kMultisampleTextureSize + kETC2TextureSize);
}
TEST_F(MemoryInstrumentationTest, ReduceMemoryUsage) {
@@ -227,10 +227,12 @@
mDeviceMock->GetInstance()->APIProcessEvents();
// DynamicUploader buffers will still be alive.
- EXPECT_GT(ComputeEstimatedMemoryUsage(device.Get()), uint64_t(0));
+ MemoryUsageInfo memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
+ EXPECT_GT(memInfo.totalUsage, uint64_t(0));
ReduceMemoryUsage(device.Get());
// But not any more.
- EXPECT_EQ(ComputeEstimatedMemoryUsage(device.Get()), uint64_t(0));
+ memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
+ EXPECT_EQ(memInfo.totalUsage, uint64_t(0));
// Check that DynamicUploader buffer is recreated again.
uniformBuffer = device.CreateBuffer(&kBufferDesc);
@@ -243,10 +245,11 @@
mDeviceMock->GetInstance()->APIProcessEvents();
- EXPECT_GT(ComputeEstimatedMemoryUsage(device.Get()), uint64_t(0));
+ memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
+ EXPECT_GT(memInfo.totalUsage, uint64_t(0));
}
-// Test the detailed memory usage reported by ComputeEstimatedMemoryUsage()
+// Test the detailed memory usage reported by ComputeEstimatedMemoryUsageInfo()
TEST_F(MemoryInstrumentationTest, ComputeEstimatedMemoryUsageInDetails) {
// Create a buffer
constexpr uint64_t kBufferSize = 32;