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

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

Issue 939093002: Recycle stencil buffers across render targets. (Closed) Base URL: https://skia.googlesource.com/skia.git@keychange
Patch Set: minor Created 5 years, 10 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/GrGLGpu.h ('k') | src/gpu/gl/GrGLStencilBuffer.h » ('j') | 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 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 GrSurfaceDesc desc; 434 GrSurfaceDesc desc;
435 desc.fConfig = wrapDesc.fConfig; 435 desc.fConfig = wrapDesc.fConfig;
436 desc.fFlags = kCheckAllocation_GrSurfaceFlag; 436 desc.fFlags = kCheckAllocation_GrSurfaceFlag;
437 desc.fWidth = wrapDesc.fWidth; 437 desc.fWidth = wrapDesc.fWidth;
438 desc.fHeight = wrapDesc.fHeight; 438 desc.fHeight = wrapDesc.fHeight;
439 desc.fSampleCnt = wrapDesc.fSampleCnt; 439 desc.fSampleCnt = wrapDesc.fSampleCnt;
440 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true); 440 desc.fOrigin = resolve_origin(wrapDesc.fOrigin, true);
441 441
442 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc)); 442 GrRenderTarget* tgt = SkNEW_ARGS(GrGLRenderTarget, (this, desc, idDesc));
443 if (wrapDesc.fStencilBits) { 443 if (wrapDesc.fStencilBits) {
444 GrGLStencilBuffer::IDDesc sbDesc; 444 GrGLStencilBuffer::IDDesc sbDesc;
robertphillips 2015/02/19 16:39:26 Is this next line needed anymore ?
bsalomon 2015/02/19 16:54:55 Acknowledged.
445 sbDesc.fRenderbufferID = 0; 445 sbDesc.fRenderbufferID = 0;
446 sbDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle;
447 GrGLStencilBuffer::Format format; 446 GrGLStencilBuffer::Format format;
448 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat; 447 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat;
449 format.fPacked = false; 448 format.fPacked = false;
450 format.fStencilBits = wrapDesc.fStencilBits; 449 format.fStencilBits = wrapDesc.fStencilBits;
451 format.fTotalBits = wrapDesc.fStencilBits; 450 format.fTotalBits = wrapDesc.fStencilBits;
452 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer, 451 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer,
453 (this, 452 (this,
454 sbDesc, 453 sbDesc,
455 desc.fWidth, 454 desc.fWidth,
456 desc.fHeight, 455 desc.fHeight,
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 GR_GL_RENDERBUFFER_DEPTH_SIZE, 1120 GR_GL_RENDERBUFFER_DEPTH_SIZE,
1122 (GrGLint*)&format->fTotalBits); 1121 (GrGLint*)&format->fTotalBits);
1123 format->fTotalBits += format->fStencilBits; 1122 format->fTotalBits += format->fStencilBits;
1124 } else { 1123 } else {
1125 format->fTotalBits = format->fStencilBits; 1124 format->fTotalBits = format->fStencilBits;
1126 } 1125 }
1127 } 1126 }
1128 } 1127 }
1129 } 1128 }
1130 1129
1131 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, bool budget ed, int width, 1130 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) {
1132 int height) {
1133 // All internally created RTs are also textures. We don't create 1131 // All internally created RTs are also textures. We don't create
1134 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . 1132 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1135 SkASSERT(rt->asTexture()); 1133 SkASSERT(rt->asTexture());
1136 SkASSERT(width >= rt->width()); 1134 SkASSERT(width >= rt->width());
1137 SkASSERT(height >= rt->height()); 1135 SkASSERT(height >= rt->height());
1138 1136
1139 int samples = rt->numSamples(); 1137 int samples = rt->numSamples();
1140 GrGLStencilBuffer::IDDesc sbDesc; 1138 GrGLStencilBuffer::IDDesc sbDesc;
robertphillips 2015/02/19 16:39:26 same here ?
bsalomon 2015/02/19 16:54:55 Acknowledged.
1141 sbDesc.fRenderbufferID = 0; 1139 sbDesc.fRenderbufferID = 0;
1142 sbDesc.fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle
1143 : GrGpuResource::kUncached_LifeCycle;
1144 1140
1145 int stencilFmtCnt = this->glCaps().stencilFormats().count(); 1141 int stencilFmtCnt = this->glCaps().stencilFormats().count();
1146 for (int i = 0; i < stencilFmtCnt; ++i) { 1142 for (int i = 0; i < stencilFmtCnt; ++i) {
1147 if (!sbDesc.fRenderbufferID) { 1143 if (!sbDesc.fRenderbufferID) {
1148 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1144 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1149 } 1145 }
1150 if (!sbDesc.fRenderbufferID) { 1146 if (!sbDesc.fRenderbufferID) {
1151 return false; 1147 return false;
1152 } 1148 }
1153 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)); 1149 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID));
(...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 this->setVertexArrayID(gpu, 0); 2759 this->setVertexArrayID(gpu, 0);
2764 } 2760 }
2765 int attrCount = gpu->glCaps().maxVertexAttributes(); 2761 int attrCount = gpu->glCaps().maxVertexAttributes();
2766 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2762 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2767 fDefaultVertexArrayAttribState.resize(attrCount); 2763 fDefaultVertexArrayAttribState.resize(attrCount);
2768 } 2764 }
2769 attribState = &fDefaultVertexArrayAttribState; 2765 attribState = &fDefaultVertexArrayAttribState;
2770 } 2766 }
2771 return attribState; 2767 return attribState;
2772 } 2768 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLStencilBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698