From d298121f5d753b21c62709ae33ac08ddb053c719 Mon Sep 17 00:00:00 2001 From: senorblanco Date: Thu, 30 Apr 2015 12:06:10 -0700 Subject: Fix gpu memory accounting for auto-resolving MSAA. BUG=skia: Review URL: https://codereview.chromium.org/1115233002 --- src/gpu/gl/GrGLRenderTarget.cpp | 18 +++++++++++------- src/gpu/gl/GrGLRenderTarget.h | 7 +++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp index 3eb2ae09fe..c9e65d4fab 100644 --- a/src/gpu/gl/GrGLRenderTarget.cpp +++ b/src/gpu/gl/GrGLRenderTarget.cpp @@ -39,19 +39,23 @@ void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) { fViewport.fHeight = desc.fHeight; // We own one color value for each MSAA sample. - fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt); + int colorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt); if (fTexFBOID != fRTFBOID) { // If we own the resolve buffer then that is one more sample per pixel. - fColorValuesPerPixel += 1; - } -} - -size_t GrGLRenderTarget::onGpuMemorySize() const { + colorValuesPerPixel += 1; + } else if (fTexFBOID != 0) { + // For auto-resolving FBOs, the MSAA buffer is free. + colorValuesPerPixel = 1; + } SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig); SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig)); size_t colorBytes = GrBytesPerPixel(fDesc.fConfig); SkASSERT(colorBytes > 0); - return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes; + fGpuMemorySize = colorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes; +} + +size_t GrGLRenderTarget::onGpuMemorySize() const { + return fGpuMemorySize; } void GrGLRenderTarget::onRelease() { diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h index 4d3061c4e4..7c0c08cdf6 100644 --- a/src/gpu/gl/GrGLRenderTarget.h +++ b/src/gpu/gl/GrGLRenderTarget.h @@ -86,10 +86,9 @@ private: // we want the rendering to be at top left (GL has origin in bottom left) GrGLIRect fViewport; - // onGpuMemorySize() needs to know what how many color values are owned per pixel. However, - // abandon and release zero out the IDs and the cache needs to know the size even after those - // actions. - uint8_t fColorValuesPerPixel; + // onGpuMemorySize() needs to know the VRAM footprint of the FBO(s). However, abandon and + // release zero out the IDs and the cache needs to know the size even after those actions. + size_t fGpuMemorySize; typedef GrRenderTarget INHERITED; }; -- cgit v1.2.3