mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 738189: Add memory reporting for Azure VRAM usage. r=jrmuizel
This commit is contained in:
parent
1e8a485b9b
commit
fecc69df4f
@ -852,6 +852,9 @@ public:
|
||||
static TemporaryRef<GlyphRenderingOptions>
|
||||
CreateDWriteGlyphRenderingOptions(IDWriteRenderingParams *aParams);
|
||||
|
||||
static uint64_t GetD2DVRAMUsageDrawTarget();
|
||||
static uint64_t GetD2DVRAMUsageSourceSurface();
|
||||
|
||||
private:
|
||||
static ID3D10Device1 *mD3D10Device;
|
||||
#endif
|
||||
|
@ -55,6 +55,8 @@ struct Vertex {
|
||||
|
||||
ID2D1Factory *DrawTargetD2D::mFactory;
|
||||
IDWriteFactory *DrawTargetD2D::mDWriteFactory;
|
||||
uint64_t DrawTargetD2D::mVRAMUsageDT;
|
||||
uint64_t DrawTargetD2D::mVRAMUsageSS;
|
||||
|
||||
// Helper class to restore surface contents that was clipped out but may have
|
||||
// been altered by a drawing call.
|
||||
@ -161,20 +163,24 @@ DrawTargetD2D::~DrawTargetD2D()
|
||||
PopAllClips();
|
||||
|
||||
mRT->EndDraw();
|
||||
|
||||
mVRAMUsageDT -= GetByteSize();
|
||||
}
|
||||
if (mTempRT) {
|
||||
mTempRT->EndDraw();
|
||||
|
||||
mVRAMUsageDT -= GetByteSize();
|
||||
}
|
||||
|
||||
if (mSnapshot) {
|
||||
// We may hold the only reference. MarkIndependent will clear mSnapshot;
|
||||
// keep the snapshot object alive so it doesn't get destroyed while
|
||||
// MarkIndependent is running.
|
||||
// keep the snapshot object alive so it doesn't get destroyed while
|
||||
// MarkIndependent is running.
|
||||
RefPtr<SourceSurfaceD2DTarget> deathGrip = mSnapshot;
|
||||
// mSnapshot can be treated as independent of this DrawTarget since we know
|
||||
// this DrawTarget won't change again.
|
||||
deathGrip->MarkIndependent();
|
||||
// mSnapshot will be cleared now.
|
||||
// mSnapshot can be treated as independent of this DrawTarget since we know
|
||||
// this DrawTarget won't change again.
|
||||
deathGrip->MarkIndependent();
|
||||
// mSnapshot will be cleared now.
|
||||
}
|
||||
|
||||
// Targets depending on us can break that dependency, since we're obviously not going to
|
||||
@ -1274,6 +1280,12 @@ DrawTargetD2D::InitD3D10Data()
|
||||
/*
|
||||
* Private helpers
|
||||
*/
|
||||
uint32_t
|
||||
DrawTargetD2D::GetByteSize() const
|
||||
{
|
||||
return mSize.width * mSize.height * BytesPerPixel(mFormat);
|
||||
}
|
||||
|
||||
bool
|
||||
DrawTargetD2D::InitD2DRenderTarget()
|
||||
{
|
||||
@ -1293,6 +1305,8 @@ DrawTargetD2D::InitD2DRenderTarget()
|
||||
mRT->SetTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE);
|
||||
}
|
||||
|
||||
mVRAMUsageDT += GetByteSize();
|
||||
|
||||
return InitD3D10Data();
|
||||
}
|
||||
|
||||
@ -1441,6 +1455,8 @@ DrawTargetD2D::GetRTForOperation(CompositionOp aOperator, const Pattern &aPatter
|
||||
return mRT;
|
||||
}
|
||||
|
||||
mVRAMUsageDT += GetByteSize();
|
||||
|
||||
mTempRT->BeginDraw();
|
||||
|
||||
mTempRT->Clear(D2D1::ColorF(0, 0));
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
bool Init(const IntSize &aSize, SurfaceFormat aFormat);
|
||||
bool Init(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
|
||||
bool InitD3D10Data();
|
||||
uint32_t GetByteSize() const;
|
||||
|
||||
static ID2D1Factory *factory();
|
||||
static TemporaryRef<ID2D1StrokeStyle> CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions);
|
||||
@ -131,6 +132,10 @@ public:
|
||||
stream << "DrawTargetD2D(" << this << ")";
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
static uint64_t mVRAMUsageDT;
|
||||
static uint64_t mVRAMUsageSS;
|
||||
|
||||
private:
|
||||
friend class AutoSaveRestoreClippedOut;
|
||||
friend class SourceSurfaceD2DTarget;
|
||||
|
@ -381,5 +381,17 @@ Factory::CreateWrappingDataSourceSurface(uint8_t *aData, int32_t aStride,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Factory::GetD2DVRAMUsageDrawTarget()
|
||||
{
|
||||
return DrawTargetD2D::mVRAMUsageDT;
|
||||
}
|
||||
|
||||
uint64_t
|
||||
Factory::GetD2DVRAMUsageSourceSurface()
|
||||
{
|
||||
return DrawTargetD2D::mVRAMUsageSS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,9 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SourceSurfaceD2D.h"
|
||||
#include "DrawTargetD2D.h"
|
||||
#include "Logging.h"
|
||||
#include "Tools.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace gfx {
|
||||
@ -15,6 +17,9 @@ SourceSurfaceD2D::SourceSurfaceD2D()
|
||||
|
||||
SourceSurfaceD2D::~SourceSurfaceD2D()
|
||||
{
|
||||
if (mBitmap) {
|
||||
DrawTargetD2D::mVRAMUsageSS -= GetByteSize();
|
||||
}
|
||||
}
|
||||
|
||||
IntSize
|
||||
@ -62,6 +67,8 @@ SourceSurfaceD2D::InitFromData(unsigned char *aData,
|
||||
return false;
|
||||
}
|
||||
|
||||
DrawTargetD2D::mVRAMUsageSS += GetByteSize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -96,8 +103,16 @@ SourceSurfaceD2D::InitFromTexture(ID3D10Texture2D *aTexture,
|
||||
return false;
|
||||
}
|
||||
|
||||
DrawTargetD2D::mVRAMUsageSS += GetByteSize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SourceSurfaceD2D::GetByteSize() const
|
||||
{
|
||||
return mSize.width * mSize.height * BytesPerPixel(mFormat);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ public:
|
||||
private:
|
||||
friend class DrawTargetD2D;
|
||||
|
||||
uint32_t GetByteSize() const;
|
||||
|
||||
RefPtr<ID2D1Bitmap> mBitmap;
|
||||
SurfaceFormat mFormat;
|
||||
IntSize mSize;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "SourceSurfaceD2DTarget.h"
|
||||
#include "Logging.h"
|
||||
#include "DrawTargetD2D.h"
|
||||
#include "Tools.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -18,6 +19,7 @@ SourceSurfaceD2DTarget::SourceSurfaceD2DTarget(DrawTargetD2D* aDrawTarget,
|
||||
: mDrawTarget(aDrawTarget)
|
||||
, mTexture(aTexture)
|
||||
, mFormat(aFormat)
|
||||
, mOwnsCopy(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -26,6 +28,11 @@ SourceSurfaceD2DTarget::~SourceSurfaceD2DTarget()
|
||||
// We don't need to do anything special here to notify our mDrawTarget. It must
|
||||
// already have cleared its mSnapshot field, otherwise this object would
|
||||
// be kept alive.
|
||||
if (mOwnsCopy) {
|
||||
IntSize size = GetSize();
|
||||
|
||||
DrawTargetD2D::mVRAMUsageSS -= size.width * size.height * BytesPerPixel(mFormat);
|
||||
}
|
||||
}
|
||||
|
||||
IntSize
|
||||
@ -98,6 +105,9 @@ SourceSurfaceD2DTarget::DrawTargetWillChange()
|
||||
|
||||
mBitmap = NULL;
|
||||
|
||||
DrawTargetD2D::mVRAMUsageSS += desc.Width * desc.Height * BytesPerPixel(mFormat);
|
||||
mOwnsCopy = true;
|
||||
|
||||
// We now no longer depend on the source surface content remaining the same.
|
||||
MarkIndependent();
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
DrawTargetD2D* mDrawTarget;
|
||||
mutable RefPtr<ID3D10Texture2D> mTexture;
|
||||
SurfaceFormat mFormat;
|
||||
bool mOwnsCopy;
|
||||
};
|
||||
|
||||
class DataSourceSurfaceD2DTarget : public DataSourceSurface
|
||||
|
@ -118,6 +118,35 @@ NS_MEMORY_REPORTER_IMPLEMENT(
|
||||
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
PRInt64 GetD2DVRAMUsageDrawTarget() {
|
||||
return mozilla::gfx::Factory::GetD2DVRAMUsageDrawTarget();
|
||||
}
|
||||
|
||||
PRInt64 GetD2DVRAMUsageSourceSurface() {
|
||||
return mozilla::gfx::Factory::GetD2DVRAMUsageSourceSurface();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(
|
||||
D2DVRAMDT,
|
||||
"gfx-d2d-vram-drawtarget",
|
||||
KIND_OTHER,
|
||||
UNITS_BYTES,
|
||||
GetD2DVRAMUsageDrawTarget,
|
||||
"Video memory used by D2D DrawTargets.")
|
||||
|
||||
NS_MEMORY_REPORTER_IMPLEMENT(
|
||||
D2DVRAMSS,
|
||||
"gfx-d2d-vram-sourcesurface",
|
||||
KIND_OTHER,
|
||||
UNITS_BYTES,
|
||||
GetD2DVRAMUsageSourceSurface,
|
||||
"Video memory used by D2D SourceSurfaces.")
|
||||
|
||||
#define GFX_USE_CLEARTYPE_ALWAYS "gfx.font_rendering.cleartype.always_use_for_content"
|
||||
#define GFX_DOWNLOADABLE_FONTS_USE_CLEARTYPE "gfx.font_rendering.cleartype.use_for_downloadable_fonts"
|
||||
|
||||
@ -330,6 +359,8 @@ gfxWindowsPlatform::gfxWindowsPlatform()
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVram));
|
||||
mD2DDevice = nsnull;
|
||||
#endif
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVRAMDT));
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(D2DVRAMSS));
|
||||
|
||||
UpdateRenderMode();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user