From 523dd220d28d0cbae49b1da24eed6c9640dcc2c6 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 5 Feb 2015 16:20:14 +1300 Subject: [PATCH] Bug 1128765 - Add more more reporters to break down D3D9 texture usage. r=jrmuizel --- gfx/layers/D3D9SurfaceImage.cpp | 9 +++++++- gfx/layers/d3d9/TextureD3D9.cpp | 3 +++ gfx/layers/d3d9/TextureD3D9.h | 1 + gfx/thebes/gfxWindowsPlatform.cpp | 38 +++++++++++++++++++++++++++++++ gfx/thebes/gfxWindowsPlatform.h | 2 ++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp index 09437af5cf3f..392a2a5b30bd 100644 --- a/gfx/layers/D3D9SurfaceImage.cpp +++ b/gfx/layers/D3D9SurfaceImage.cpp @@ -19,7 +19,12 @@ D3D9SurfaceImage::D3D9SurfaceImage() , mSize(0, 0) {} -D3D9SurfaceImage::~D3D9SurfaceImage() {} +D3D9SurfaceImage::~D3D9SurfaceImage() +{ + if (mTexture) { + gfxWindowsPlatform::sD3D9SurfaceImageUsed -= mSize.width * mSize.height * 4; + } +} static const GUID sD3D9TextureUsage = { 0x631e1338, 0xdc22, 0x497f, { 0xa1, 0xa8, 0xb4, 0xfe, 0x3a, 0xf4, 0x13, 0x4d } }; @@ -117,6 +122,8 @@ D3D9SurfaceImage::SetData(const Data& aData) // Track the lifetime of this memory texture->SetPrivateData(sD3D9TextureUsage, new TextureMemoryMeasurer9(region.width * region.height * 4), sizeof(IUnknown *), D3DSPD_IUNKNOWN); + gfxWindowsPlatform::sD3D9SurfaceImageUsed += region.width * region.height * 4; + // Copy the image onto the texture, preforming YUV -> RGB conversion if necessary. RefPtr textureSurface; hr = texture->GetSurfaceLevel(0, byRef(textureSurface)); diff --git a/gfx/layers/d3d9/TextureD3D9.cpp b/gfx/layers/d3d9/TextureD3D9.cpp index 30d8f2e4aef9..1db07aefa0f0 100644 --- a/gfx/layers/d3d9/TextureD3D9.cpp +++ b/gfx/layers/d3d9/TextureD3D9.cpp @@ -741,6 +741,9 @@ SharedTextureClientD3D9::~SharedTextureClientD3D9() if (mTexture && mActor) { KeepUntilFullDeallocation(new TKeepAlive(mTexture)); } + if (mTexture) { + gfxWindowsPlatform::sD3D9SharedTextureUsed -= mDesc.Width * mDesc.Height * 4; + } MOZ_COUNT_DTOR(SharedTextureClientD3D9); } diff --git a/gfx/layers/d3d9/TextureD3D9.h b/gfx/layers/d3d9/TextureD3D9.h index 19152145edd4..6f4d239c472c 100644 --- a/gfx/layers/d3d9/TextureD3D9.h +++ b/gfx/layers/d3d9/TextureD3D9.h @@ -266,6 +266,7 @@ public: mTexture = aTexture; mHandle = aSharedHandle; mDesc = aDesc; + gfxWindowsPlatform::sD3D9SharedTextureUsed += mDesc.Width * mDesc.Height * 4; } virtual gfx::IntSize GetSize() const diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index 53fdf89e3ea5..49967ae0eaee 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -364,6 +364,42 @@ public: NS_IMPL_ISUPPORTS(D3D9TextureReporter, nsIMemoryReporter) +Atomic gfxWindowsPlatform::sD3D9SurfaceImageUsed; + +class D3D9SurfaceImageReporter MOZ_FINAL : public nsIMemoryReporter +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, + nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE + { + return MOZ_COLLECT_REPORT("d3d9-surface-image", KIND_OTHER, UNITS_BYTES, + gfxWindowsPlatform::sD3D9SurfaceImageUsed, + "Memory used for D3D9 surface images"); + } +}; + +NS_IMPL_ISUPPORTS(D3D9SurfaceImageReporter, nsIMemoryReporter) + +Atomic gfxWindowsPlatform::sD3D9SharedTextureUsed; + +class D3D9SharedTextureReporter MOZ_FINAL : public nsIMemoryReporter +{ +public: + NS_DECL_ISUPPORTS + + NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, + nsISupports* aData, bool aAnonymize) MOZ_OVERRIDE + { + return MOZ_COLLECT_REPORT("d3d9-shared-texture", KIND_OTHER, UNITS_BYTES, + gfxWindowsPlatform::sD3D9SharedTextureUsed, + "Memory used for D3D9 shared textures"); + } +}; + +NS_IMPL_ISUPPORTS(D3D9SharedTextureReporter, nsIMemoryReporter) + gfxWindowsPlatform::gfxWindowsPlatform() : mD3D11DeviceInitialized(false) , mIsWARP(false) @@ -393,6 +429,8 @@ gfxWindowsPlatform::gfxWindowsPlatform() RegisterStrongMemoryReporter(new GPUAdapterReporter()); RegisterStrongMemoryReporter(new D3D11TextureReporter()); RegisterStrongMemoryReporter(new D3D9TextureReporter()); + RegisterStrongMemoryReporter(new D3D9SurfaceImageReporter()); + RegisterStrongMemoryReporter(new D3D9SharedTextureReporter()); } gfxWindowsPlatform::~gfxWindowsPlatform() diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 9e1173de5c9b..81336b816054 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -255,6 +255,8 @@ public: static mozilla::Atomic sD3D11MemoryUsed; static mozilla::Atomic sD3D9MemoryUsed; + static mozilla::Atomic sD3D9SurfaceImageUsed; + static mozilla::Atomic sD3D9SharedTextureUsed; protected: RenderMode mRenderMode;