Fix gpu memory accounting for auto-resolving MSAA.
BUG=skia: Review URL: https://codereview.chromium.org/1115233002
This commit is contained in:
parent
af2bd098ee
commit
d298121f5d
@ -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() {
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user