diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 42c22cb06440..4440656ebe15 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -31,7 +31,7 @@ public: TextureMemoryMeasurer(size_t aMemoryUsed) { mMemoryUsed = aMemoryUsed; - gfxWindowsPlatform::sD3D11MemoryUsed += mMemoryUsed; + gfxWindowsPlatform::sD3D11SharedTextures += mMemoryUsed; mRefCnt = 0; } STDMETHODIMP_(ULONG) AddRef() { @@ -57,7 +57,7 @@ public: STDMETHODIMP_(ULONG) Release() { int refCnt = --mRefCnt; if (refCnt == 0) { - gfxWindowsPlatform::sD3D11MemoryUsed -= mMemoryUsed; + gfxWindowsPlatform::sD3D11SharedTextures -= mMemoryUsed; delete this; } return refCnt; diff --git a/gfx/layers/d3d9/TextureD3D9.cpp b/gfx/layers/d3d9/TextureD3D9.cpp index 12ad446decca..919886fb2af7 100644 --- a/gfx/layers/d3d9/TextureD3D9.cpp +++ b/gfx/layers/d3d9/TextureD3D9.cpp @@ -750,7 +750,7 @@ DXGID3D9TextureData::DXGID3D9TextureData(gfx::SurfaceFormat aFormat, DXGID3D9TextureData::~DXGID3D9TextureData() { - gfxWindowsPlatform::sD3D9SharedTextureUsed -= mDesc.Width * mDesc.Height * 4; + gfxWindowsPlatform::sD3D9SharedTextures -= mDesc.Width * mDesc.Height * 4; MOZ_COUNT_DTOR(DXGID3D9TextureData); } @@ -787,7 +787,7 @@ DXGID3D9TextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, DXGID3D9TextureData* data = new DXGID3D9TextureData(aFormat, texture, shareHandle, aDevice); data->mDesc = surfaceDesc; - gfxWindowsPlatform::sD3D9SharedTextureUsed += aSize.width * aSize.height * 4; + gfxWindowsPlatform::sD3D9SharedTextures += aSize.width * aSize.height * 4; return data; } diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index bab09a513687..b5867614b180 100755 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -297,12 +297,12 @@ public: NS_IMPL_ISUPPORTS(GPUAdapterReporter, nsIMemoryReporter) +Atomic gfxWindowsPlatform::sD3D11SharedTextures; +Atomic gfxWindowsPlatform::sD3D9SharedTextures; -Atomic gfxWindowsPlatform::sD3D11MemoryUsed; - -class D3D11TextureReporter final : public nsIMemoryReporter +class D3DSharedTexturesReporter final : public nsIMemoryReporter { - ~D3D11TextureReporter() {} + ~D3DSharedTexturesReporter() {} public: NS_DECL_ISUPPORTS @@ -310,53 +310,29 @@ public: NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT("d3d11-shared-textures", KIND_OTHER, UNITS_BYTES, - gfxWindowsPlatform::sD3D11MemoryUsed, - "Memory used for D3D11 shared textures"); + nsresult rv; + + if (gfxWindowsPlatform::sD3D11SharedTextures > 0) { + rv = MOZ_COLLECT_REPORT( + "d3d11-shared-textures", KIND_OTHER, UNITS_BYTES, + gfxWindowsPlatform::sD3D11SharedTextures, + "D3D11 shared textures."); + NS_ENSURE_SUCCESS(rv, rv); + } + + if (gfxWindowsPlatform::sD3D9SharedTextures > 0) { + rv = MOZ_COLLECT_REPORT( + "d3d9-shared-textures", KIND_OTHER, UNITS_BYTES, + gfxWindowsPlatform::sD3D9SharedTextures, + "D3D9 shared textures."); + NS_ENSURE_SUCCESS(rv, rv); + } + + return NS_OK; } }; -NS_IMPL_ISUPPORTS(D3D11TextureReporter, nsIMemoryReporter) - -Atomic gfxWindowsPlatform::sD3D9MemoryUsed; - -class D3D9TextureReporter final : public nsIMemoryReporter -{ - ~D3D9TextureReporter() {} - -public: - NS_DECL_ISUPPORTS - - NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, - nsISupports* aData, bool aAnonymize) override - { - return MOZ_COLLECT_REPORT("d3d9-shared-textures", KIND_OTHER, UNITS_BYTES, - gfxWindowsPlatform::sD3D9MemoryUsed, - "Memory used for D3D9 shared textures"); - } -}; - -NS_IMPL_ISUPPORTS(D3D9TextureReporter, nsIMemoryReporter) - -Atomic gfxWindowsPlatform::sD3D9SharedTextureUsed; - -class D3D9SharedTextureReporter final : public nsIMemoryReporter -{ - ~D3D9SharedTextureReporter() {} - -public: - NS_DECL_ISUPPORTS - - NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, - nsISupports* aData, bool aAnonymize) 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) +NS_IMPL_ISUPPORTS(D3DSharedTexturesReporter, nsIMemoryReporter) gfxWindowsPlatform::gfxWindowsPlatform() : mRenderMode(RENDER_GDI) @@ -376,11 +352,8 @@ gfxWindowsPlatform::gfxWindowsPlatform() CoInitialize(nullptr); RegisterStrongMemoryReporter(new GfxD2DVramReporter()); - RegisterStrongMemoryReporter(new GPUAdapterReporter()); - RegisterStrongMemoryReporter(new D3D11TextureReporter()); - RegisterStrongMemoryReporter(new D3D9TextureReporter()); - RegisterStrongMemoryReporter(new D3D9SharedTextureReporter()); + RegisterStrongMemoryReporter(new D3DSharedTexturesReporter()); } gfxWindowsPlatform::~gfxWindowsPlatform() diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index d9aba70a8b8b..1c2937f4d98d 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -251,9 +251,8 @@ public: void TestDeviceReset(DeviceResetReason aReason); virtual already_AddRefed CreateHardwareVsyncSource() override; - static mozilla::Atomic sD3D11MemoryUsed; - static mozilla::Atomic sD3D9MemoryUsed; - static mozilla::Atomic sD3D9SharedTextureUsed; + static mozilla::Atomic sD3D11SharedTextures; + static mozilla::Atomic sD3D9SharedTextures; void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut) override;