Dump additional MSAA textures' info in ComputeEstimatedMemoryUsage()
ComputeEstimatedMemoryUsageInfo() will return additional info:
- Total number of MSAA textures.
- Biggest MSAA texture's memory usage.
Bug: chromium:402138745
Change-Id: I7266966cbf2e6220746f3c2a6b2585387a297fde
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/240294
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@chromium.org>
Auto-Submit: Quyen Le <lehoangquyen@chromium.org>
diff --git a/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h
index da345ba..28f6c125 100644
--- a/include/dawn/native/DawnNative.h
+++ b/include/dawn/native/DawnNative.h
@@ -315,16 +315,21 @@
};
DAWN_NATIVE_EXPORT void DumpMemoryStatistics(WGPUDevice device, MemoryDump* dump);
-// 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.
+// Intended for background tracing for UMA that returns the estimated memory usage.
struct DAWN_NATIVE_EXPORT MemoryUsageInfo {
+ // Total memory usage.
uint64_t totalUsage;
+ // Total depth stencil textures' memory.
uint64_t depthStencilTexturesUsage;
+ // Total MSAA textures' memory.
uint64_t msaaTexturesUsage;
+ // Number of MSAA textures.
+ uint64_t msaaTexturesCount;
+ // Largest MSAA texture's memory.
+ uint64_t largestMsaaTextureUsage;
+ // Total textures' memory.
uint64_t texturesUsage;
+ // Total buffers' memory.
uint64_t buffersUsage;
};
DAWN_NATIVE_EXPORT MemoryUsageInfo ComputeEstimatedMemoryUsageInfo(WGPUDevice device);
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp
index 242e900..01b951f 100644
--- a/src/dawn/native/Device.cpp
+++ b/src/dawn/native/Device.cpp
@@ -2439,6 +2439,8 @@
info.texturesUsage += size;
if (texture->GetSampleCount() > 1) {
info.msaaTexturesUsage += size;
+ info.msaaTexturesCount++;
+ info.largestMsaaTextureUsage = std::max(info.largestMsaaTextureUsage, size);
}
if (texture->GetFormat().HasDepthOrStencil()) {
info.depthStencilTexturesUsage += size;
diff --git a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
index 7377174..10adeba 100644
--- a/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
+++ b/src/dawn/tests/unittests/native/MemoryInstrumentationTests.cpp
@@ -277,8 +277,8 @@
constexpr uint64_t kMipmappedTextureSize =
(((30 * 20) + (15 * 10) + (7 * 5) + (3 * 2) + (1 * 1)) * 2) * 10; // 15840
- // Create a multi-sampled texture.
- const wgpu::TextureDescriptor kMultisampleTextureDesc = {
+ // Create multi-sampled textures.
+ const wgpu::TextureDescriptor kMultisampleTextureDesc1 = {
.usage = wgpu::TextureUsage::RenderAttachment,
.size = {.width = 30, .height = 20},
.format = kRG8UnormTextureFormat,
@@ -286,9 +286,15 @@
.viewFormatCount = 1,
.viewFormats = &kRG8UnormTextureFormat,
};
- wgpu::Texture multisampleTexture = device.CreateTexture(&kMultisampleTextureDesc);
+ wgpu::Texture multisampleTexture1 = device.CreateTexture(&kMultisampleTextureDesc1);
// Expected size = width(30) * height(20) * bytes per pixel(2) * sample count(4).
- constexpr uint64_t kMultisampleTextureSize = 30 * 20 * 2 * 4;
+ constexpr uint64_t kMultisampleTextureSize1 = 30 * 20 * 2 * 4;
+
+ wgpu::TextureDescriptor kMultisampleTextureDesc2 = kMultisampleTextureDesc1;
+ kMultisampleTextureDesc2.size = {.width = 60, .height = 40};
+ wgpu::Texture multisampleTexture2 = device.CreateTexture(&kMultisampleTextureDesc2);
+ // Expected size = width(60) * height(40) * bytes per pixel(2) * sample count(4).
+ constexpr uint64_t kMultisampleTextureSize2 = 60 * 40 * 2 * 4;
// Create a depth texture.
const wgpu::TextureDescriptor kDepthTextureDesc = {
@@ -314,13 +320,17 @@
MemoryUsageInfo memInfo = ComputeEstimatedMemoryUsageInfo(device.Get());
- EXPECT_EQ(memInfo.totalUsage, kBufferSize + kMipmappedTextureSize + kMultisampleTextureSize +
- kDepthTextureSize + kStencilTextureSize);
+ EXPECT_EQ(memInfo.totalUsage, kBufferSize + kMipmappedTextureSize + kMultisampleTextureSize1 +
+ kMultisampleTextureSize2 + kDepthTextureSize +
+ kStencilTextureSize);
EXPECT_EQ(memInfo.buffersUsage, kBufferSize);
- EXPECT_EQ(memInfo.texturesUsage, kMipmappedTextureSize + kMultisampleTextureSize +
- kDepthTextureSize + kStencilTextureSize);
+ EXPECT_EQ(memInfo.texturesUsage, kMipmappedTextureSize + kMultisampleTextureSize1 +
+ kMultisampleTextureSize2 + kDepthTextureSize +
+ kStencilTextureSize);
EXPECT_EQ(memInfo.depthStencilTexturesUsage, kDepthTextureSize + kStencilTextureSize);
- EXPECT_EQ(memInfo.msaaTexturesUsage, kMultisampleTextureSize);
+ EXPECT_EQ(memInfo.msaaTexturesUsage, kMultisampleTextureSize1 + kMultisampleTextureSize2);
+ EXPECT_EQ(memInfo.msaaTexturesCount, 2u);
+ EXPECT_EQ(memInfo.largestMsaaTextureUsage, kMultisampleTextureSize2);
}
} // namespace