Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Unified Diff: src/gpu/gl/GrGpuGL.cpp

Issue 553583008: Add counting of some GL calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix some indents Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 5d4bd8b7b74f308aa5fbc1e56670884972e622dc..6feb65379540752b972f63a663de411a58118529 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -116,6 +116,11 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
: GrGpu(context)
, fGLContext(ctx) {
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls = 0;
+ fGPUStats.fCompileShaderCalls = 0;
+#endif
+
SkASSERT(ctx.isInitialized());
fCaps.reset(SkRef(ctx.caps()));
@@ -870,6 +875,9 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
width, height)) {
goto FAILED;
}
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fRTFBOID));
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_COLOR_ATTACHMENT0,
@@ -884,6 +892,9 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig);
}
}
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID));
if (this->glCaps().usesImplicitMSAAResolve() && desc->fSampleCnt > 0) {
@@ -1245,6 +1256,9 @@ bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar
GrGLuint rb = glsb->renderbufferID();
fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo));
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
@@ -1438,6 +1452,9 @@ void GrGpuGL::discard(GrRenderTarget* renderTarget) {
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) {
fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
}
switch (this->glCaps().invalidateFBType()) {
@@ -1601,6 +1618,9 @@ bool GrGpuGL::onReadPixels(GrRenderTarget* target,
case GrGLRenderTarget::kCanResolve_ResolveType:
this->onResolveRenderTarget(tgt);
// we don't track the state of the READ FBO ID.
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER,
tgt->textureFBOID()));
break;
@@ -1698,6 +1718,9 @@ void GrGpuGL::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
uint32_t rtID = target->getUniqueID();
if (fHWBoundRenderTargetUniqueID != rtID) {
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID()));
#ifdef SK_DEBUG
// don't do this check in Chromium -- this is causing
@@ -1800,6 +1823,9 @@ void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) {
// Some extensions automatically resolves the texture when it is read.
if (this->glCaps().usesMSAARenderBuffers()) {
SkASSERT(rt->textureFBOID() != rt->renderFBOID());
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls += 2;
+#endif
GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID()));
GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()));
// make sure we go through flushRenderTarget() since we've modified
@@ -2363,38 +2389,41 @@ inline bool can_copy_texsubimage(const GrSurface* dst,
}
}
+}
+
// If a temporary FBO was created, its non-zero ID is returned. The viewport that the copy rect is
// relative to is output.
-inline GrGLuint bind_surface_as_fbo(const GrGLInterface* gl,
- GrSurface* surface,
- GrGLenum fboTarget,
- GrGLIRect* viewport) {
+GrGLuint GrGpuGL::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLIRect* viewport) {
GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarget());
GrGLuint tempFBOID;
if (NULL == rt) {
SkASSERT(surface->asTexture());
GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textureID();
- GR_GL_CALL(gl, GenFramebuffers(1, &tempFBOID));
- GR_GL_CALL(gl, BindFramebuffer(fboTarget, tempFBOID));
- GR_GL_CALL(gl, FramebufferTexture2D(fboTarget,
- GR_GL_COLOR_ATTACHMENT0,
- GR_GL_TEXTURE_2D,
- texID,
- 0));
+ GR_GL_CALL(this->glInterface(), GenFramebuffers(1, &tempFBOID));
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
+ GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, tempFBOID));
+ GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget,
+ GR_GL_COLOR_ATTACHMENT0,
+ GR_GL_TEXTURE_2D,
+ texID,
+ 0));
viewport->fLeft = 0;
viewport->fBottom = 0;
viewport->fWidth = surface->width();
viewport->fHeight = surface->height();
} else {
tempFBOID = 0;
- GR_GL_CALL(gl, BindFramebuffer(fboTarget, rt->renderFBOID()));
+#if GR_GPU_STATS
+ fGPUStats.fBindFrameBufferCalls++;
+#endif
+ GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBOID()));
*viewport = rt->getViewport();
}
return tempFBOID;
}
-}
-
void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc) {
// Check for format issues with glCopyTexSubImage2D
if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInternalFormat() &&
@@ -2432,7 +2461,7 @@ bool GrGpuGL::onCopySurface(GrSurface* dst,
(!wouldNeedTempFBO || !inheritedCouldCopy)) {
GrGLuint srcFBO;
GrGLIRect srcVP;
- srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER, &srcVP);
+ srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP);
GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture());
SkASSERT(dstTex);
// We modified the bound FBO
@@ -2475,8 +2504,8 @@ bool GrGpuGL::onCopySurface(GrSurface* dst,
GrGLuint srcFBO;
GrGLIRect dstVP;
GrGLIRect srcVP;
- dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP);
- srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FRAMEBUFFER, &srcVP);
+ dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP);
+ srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP);
// We modified the bound FBO
fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
GrGLIRect srcGLRect;

Powered by Google App Engine
This is Rietveld 408576698