Bug 1367919 - Add tracking for data allocation calls in WebGL. r=jgilbert

This commit is contained in:
Samuel Vargas 2017-06-22 14:32:00 -04:00
parent 05f9138c12
commit f36d75726e
7 changed files with 38 additions and 0 deletions

View File

@ -153,6 +153,8 @@ WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usa
gl->fBufferData(target, size, uploadData, usage);
}
mContext->OnDataAllocCall();
mUsage = usage;
mByteLength = size;
mIndexCache = Move(newIndexCache);

View File

@ -118,6 +118,7 @@ WebGLContext::WebGLContext()
, mMaxPerfWarnings(gfxPrefs::WebGLMaxPerfWarnings())
, mNumPerfWarnings(0)
, mMaxAcceptableFBStatusInvals(gfxPrefs::WebGLMaxAcceptableFBStatusInvals())
, mDataAllocGLCallCount(0)
, mBufferFetchingIsVerified(false)
, mBufferFetchingHasPerVertex(false)
, mMaxFetchedVertices(0)
@ -1588,6 +1589,16 @@ WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield clearBits,
}
}
void
WebGLContext::OnEndOfFrame() const
{
if (gfxPrefs::WebGLSpewFrameAllocs()) {
GeneratePerfWarning("[webgl.perf.spew-frame-allocs] %" PRIu64 " data allocations this frame.",
mDataAllocGLCallCount);
}
mDataAllocGLCallCount = 0;
}
// For an overview of how WebGL compositing works, see:
// https://wiki.mozilla.org/Platform/GFX/WebGL/Compositing
bool
@ -1617,6 +1628,7 @@ WebGLContext::PresentScreenBuffer()
}
mShouldPresent = false;
OnEndOfFrame();
return true;
}

View File

@ -1029,6 +1029,19 @@ private:
bool ValidateCapabilityEnum(GLenum cap, const char* info);
realGLboolean* GetStateTrackingSlot(GLenum cap);
// Allocation debugging variables
mutable uint64_t mDataAllocGLCallCount;
void OnDataAllocCall() const {
mDataAllocGLCallCount++;
}
uint64_t GetNumGLDataAllocCalls() const {
return mDataAllocGLCallCount;
}
void OnEndOfFrame() const;
// -----------------------------------------------------------------------------
// Texture funcions (WebGLContextTextures.cpp)
public:

View File

@ -218,6 +218,8 @@ WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples,
return;
}
mContext->OnDataAllocCall();
mSamples = samples;
mFormat = usage;
mWidth = width;

View File

@ -1165,6 +1165,8 @@ WebGLTexture::TexStorage(const char* funcName, TexTarget target, GLsizei levels,
GLenum error = DoTexStorage(mContext->gl, target.get(), levels, sizedFormat, width,
height, depth);
mContext->OnDataAllocCall();
if (error == LOCAL_GL_OUT_OF_MEMORY) {
mContext->ErrorOutOfMemory("%s: Ran out of memory during texture allocation.",
funcName);
@ -1297,6 +1299,8 @@ WebGLTexture::TexImage(const char* funcName, TexImageTarget target, GLint level,
return;
}
mContext->OnDataAllocCall();
if (glError == LOCAL_GL_OUT_OF_MEMORY) {
mContext->ErrorOutOfMemory("%s: Driver ran out of memory during upload.",
funcName);
@ -1502,6 +1506,7 @@ WebGLTexture::CompressedTexImage(const char* funcName, TexImageTarget target, GL
GLenum error = DoCompressedTexImage(mContext->gl, target, level, internalFormat,
blob->mWidth, blob->mHeight, blob->mDepth,
blob->mAvailBytes, blob->mPtr);
mContext->OnDataAllocCall();
if (error == LOCAL_GL_OUT_OF_MEMORY) {
mContext->ErrorOutOfMemory("%s: Ran out of memory during upload.", funcName);
return;
@ -2167,6 +2172,8 @@ WebGLTexture::CopyTexImage2D(TexImageTarget target, GLint level, GLenum internal
return;
}
mContext->OnDataAllocCall();
////////////////////////////////////
// Update our specification data.

View File

@ -724,6 +724,7 @@ private:
DECL_GFX_PREF(Live, "webgl.perf.max-warnings", WebGLMaxPerfWarnings, int32_t, 0);
DECL_GFX_PREF(Live, "webgl.perf.max-acceptable-fb-status-invals", WebGLMaxAcceptableFBStatusInvals, int32_t, 0);
DECL_GFX_PREF(Live, "webgl.perf.spew-frame-allocs", WebGLSpewFrameAllocs, bool, true);
DECL_GFX_PREF(Live, "webgl.webgl2-compat-mode", WebGL2CompatMode, bool, false);
DECL_GFX_PREF(Live, "webrender.blob-images", WebRenderBlobImages, bool, false);

View File

@ -4675,6 +4675,7 @@ pref("webgl.webgl2-compat-mode", false);
pref("webgl.perf.max-warnings", 0);
pref("webgl.perf.max-acceptable-fb-status-invals", 0);
pref("webgl.perf.spew-frame-allocs", true);
pref("webgl.enable-webgl2", true);