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

Side by Side Diff: src/gpu/gl/GrGLRenderTarget.cpp

Issue 1115233002: Fix gpu memory accounting for auto-resolving MSAA. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cache the total computed vram size, not the color values per pixel Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrGLRenderTarget.h" 8 #include "GrGLRenderTarget.h"
9 9
10 #include "GrGLGpu.h" 10 #include "GrGLGpu.h"
(...skipping 21 matching lines...) Expand all
32 fTexFBOID = idDesc.fTexFBOID; 32 fTexFBOID = idDesc.fTexFBOID;
33 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID; 33 fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
34 fIsWrapped = kWrapped_LifeCycle == idDesc.fLifeCycle; 34 fIsWrapped = kWrapped_LifeCycle == idDesc.fLifeCycle;
35 35
36 fViewport.fLeft = 0; 36 fViewport.fLeft = 0;
37 fViewport.fBottom = 0; 37 fViewport.fBottom = 0;
38 fViewport.fWidth = desc.fWidth; 38 fViewport.fWidth = desc.fWidth;
39 fViewport.fHeight = desc.fHeight; 39 fViewport.fHeight = desc.fHeight;
40 40
41 // We own one color value for each MSAA sample. 41 // We own one color value for each MSAA sample.
42 fColorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt); 42 int colorValuesPerPixel = SkTMax(1, fDesc.fSampleCnt);
43 if (fTexFBOID != fRTFBOID) { 43 if (fTexFBOID != fRTFBOID) {
44 // If we own the resolve buffer then that is one more sample per pixel. 44 // If we own the resolve buffer then that is one more sample per pixel.
45 fColorValuesPerPixel += 1; 45 colorValuesPerPixel += 1;
46 } 46 } else if (fTexFBOID != 0) {
47 } 47 // For auto-resolving FBOs, the MSAA buffer is free.
48 48 colorValuesPerPixel = 1;
49 size_t GrGLRenderTarget::onGpuMemorySize() const { 49 }
50 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig); 50 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig);
51 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig)); 51 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig));
52 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig); 52 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig);
53 SkASSERT(colorBytes > 0); 53 SkASSERT(colorBytes > 0);
54 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes; 54 fGpuMemorySize = colorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorB ytes;
55 }
56
57 size_t GrGLRenderTarget::onGpuMemorySize() const {
58 return fGpuMemorySize;
55 } 59 }
56 60
57 void GrGLRenderTarget::onRelease() { 61 void GrGLRenderTarget::onRelease() {
58 if (!fIsWrapped) { 62 if (!fIsWrapped) {
59 if (fTexFBOID) { 63 if (fTexFBOID) {
60 GL_CALL(DeleteFramebuffers(1, &fTexFBOID)); 64 GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
61 } 65 }
62 if (fRTFBOID && fRTFBOID != fTexFBOID) { 66 if (fRTFBOID && fRTFBOID != fTexFBOID) {
63 GL_CALL(DeleteFramebuffers(1, &fRTFBOID)); 67 GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
64 } 68 }
65 if (fMSColorRenderbufferID) { 69 if (fMSColorRenderbufferID) {
66 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID)); 70 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
67 } 71 }
68 } 72 }
69 fRTFBOID = 0; 73 fRTFBOID = 0;
70 fTexFBOID = 0; 74 fTexFBOID = 0;
71 fMSColorRenderbufferID = 0; 75 fMSColorRenderbufferID = 0;
72 fIsWrapped = false; 76 fIsWrapped = false;
73 INHERITED::onRelease(); 77 INHERITED::onRelease();
74 } 78 }
75 79
76 void GrGLRenderTarget::onAbandon() { 80 void GrGLRenderTarget::onAbandon() {
77 fRTFBOID = 0; 81 fRTFBOID = 0;
78 fTexFBOID = 0; 82 fTexFBOID = 0;
79 fMSColorRenderbufferID = 0; 83 fMSColorRenderbufferID = 0;
80 fIsWrapped = false; 84 fIsWrapped = false;
81 INHERITED::onAbandon(); 85 INHERITED::onAbandon();
82 } 86 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLRenderTarget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698