glBindRenderbuffer(GL_RENDERBUFFER, fGL.fRenderbuffer);
[fGL.fContext presentRenderbuffer:GL_RENDERBUFFER];
-#if GR_COLLECT_STATS
- // static int frame = 0;
- // if (!(frame % 100)) {
- // ctx->printStats();
- // }
- // ctx->resetStats();
- // ++frame;
-#endif
}
- (void)drawInRaster {
#endif
/**
- * GR_COLLECT_STATS controls whether the GrGpu class collects stats.
- * If not already defined then collect in debug build but not release.
- */
-#if !defined(GR_COLLECT_STATS)
- #define GR_COLLECT_STATS GR_DEBUG
-#endif
-
-/**
* GR_STATIC_RECT_VB controls whether rects are drawn by issuing a vertex
* for each corner or using a static vb that is positioned by modifying the
* view / texture matrix.
class GrDrawTarget;
class GrFontCache;
class GrGpu;
-struct GrGpuStats;
class GrIndexBuffer;
class GrIndexBufferAllocPool;
class GrInOrderDrawBuffer;
GrFontCache* getFontCache() { return fFontCache; }
GrDrawTarget* getTextTarget(const GrPaint& paint);
const GrIndexBuffer* getQuadIndexBuffer() const;
- void resetStats();
- const GrGpuStats& getStats() const;
- void printStats() const;
+
/**
* Stencil buffers add themselves to the cache using
* addAndLockStencilBuffer. When a SB's RT-attachment count
return bits;
}
-void GrContext::resetStats() {
- fGpu->resetStats();
-}
-
-const GrGpuStats& GrContext::getStats() const {
- return fGpu->getStats();
-}
-
-void GrContext::printStats() const {
- fGpu->printStats();
-}
-
GrContext::GrContext(GrGpu* gpu) {
fGpu = gpu;
fGpu->ref();
poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER;
poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX;
#endif
- resetStats();
for (int i = 0; i < kGrPixelConfigCount; ++i) {
fConfigRenderSupport[i] = false;
return;
}
-#if GR_COLLECT_STATS
- fStats.fVertexCnt += vertexCount;
- fStats.fIndexCnt += indexCount;
- fStats.fDrawCnt += 1;
-#endif
-
int sVertex = startVertex;
int sIndex = startIndex;
setupGeometry(&sVertex, &sIndex, vertexCount, indexCount);
if (!this->setupClipAndFlushState(type)) {
return;
}
-#if GR_COLLECT_STATS
- fStats.fVertexCnt += vertexCount;
- fStats.fDrawCnt += 1;
-#endif
int sVertex = startVertex;
setupGeometry(&sVertex, NULL, vertexCount, 0);
--fIndexPoolUseCnt;
}
-////////////////////////////////////////////////////////////////////////////////
-
-const GrGpuStats& GrGpu::getStats() const {
- return fStats;
-}
-
-void GrGpu::resetStats() {
- memset(&fStats, 0, sizeof(fStats));
-}
-
-void GrGpu::printStats() const {
- if (GR_COLLECT_STATS) {
- GrPrintf(
- "-v-------------------------GPU STATS----------------------------v-\n"
- "Stats collection is: %s\n"
- "Draws: %04d, Verts: %04d, Indices: %04d\n"
- "ProgChanges: %04d, TexChanges: %04d, RTChanges: %04d\n"
- "TexCreates: %04d, RTCreates:%04d\n"
- "-^--------------------------------------------------------------^-\n",
- (GR_COLLECT_STATS ? "ON" : "OFF"),
- fStats.fDrawCnt, fStats.fVertexCnt, fStats.fIndexCnt,
- fStats.fProgChngCnt, fStats.fTextureChngCnt, fStats.fRenderTargetChngCnt,
- fStats.fTextureCreateCnt, fStats.fRenderTargetCreateCnt);
- }
-}
-
-
class GrStencilBuffer;
class GrVertexBufferAllocPool;
-/**
- * Gpu usage statistics.
- */
-struct GrGpuStats {
- uint32_t fVertexCnt; //<! Number of vertices drawn
- uint32_t fIndexCnt; //<! Number of indices drawn
- uint32_t fDrawCnt; //<! Number of draws
-
- uint32_t fProgChngCnt;//<! Number of program changes
-
- /**
- * Number of times the texture is set in 3D API
- */
- uint32_t fTextureChngCnt;
- /**
- * Number of times the render target is set in 3D API
- */
- uint32_t fRenderTargetChngCnt;
- /**
- * Number of textures created (includes textures that are rendertargets).
- */
- uint32_t fTextureCreateCnt;
- /**
- * Number of rendertargets created.
- */
- uint32_t fRenderTargetCreateCnt;
-};
-
class GrGpu : public GrDrawTarget {
public:
GrPixelConfig config, const void* buffer,
size_t rowBytes);
- const GrGpuStats& getStats() const;
- void resetStats();
- void printStats() const;
-
/**
* Called to tell Gpu object that all GrResources have been lost and should
* be abandoned. Overrides must call INHERITED::abandonResources().
// and the client isn't using the stencil test.
static const GrStencilSettings* GetClipStencilSettings();
- GrGpuStats fStats;
-
GrClipMaskManager fClipMaskManager;
struct GeometryPoolState {
const void* srcData,
size_t rowBytes) {
-#if GR_COLLECT_STATS
- ++fStats.fTextureCreateCnt;
-#endif
-
GrGLTexture::Desc glTexDesc;
GrGLRenderTarget::Desc glRTDesc;
GrGLTexture* tex;
if (renderTarget) {
-#if GR_COLLECT_STATS
- ++fStats.fRenderTargetCreateCnt;
-#endif
// unbind the texture from the texture unit before binding it to the frame buffer
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0));
if (fHWBoundRenderTarget != rt) {
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID()));
- #if GR_COLLECT_STATS
- ++fStats.fRenderTargetChngCnt;
- #endif
#if GR_DEBUG
GrGLenum status;
GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
rt->renderFBOID()));
GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER,
rt->textureFBOID()));
- #if GR_COLLECT_STATS
- ++fStats.fRenderTargetChngCnt;
- #endif
// make sure we go through flushRenderTarget() since we've modified
// the bound DRAW FBO ID.
fHWBoundRenderTarget = NULL;
if (fHWBoundTextures[stage] != nextTexture) {
this->setTextureUnit(stage);
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, nextTexture->textureID()));
- #if GR_COLLECT_STATS
- ++fStats.fTextureChngCnt;
- #endif
//GrPrintf("---- bindtexture %d\n", nextTexture->textureID());
fHWBoundTextures[stage] = nextTexture;
}