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

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: Address comments 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
445 sbDesc.fRenderbufferID = 0;
446 sbDesc.fLifeCycle = GrGpuResource::kWrapped_LifeCycle;
447 GrGLStencilBuffer::Format format; 445 GrGLStencilBuffer::Format format;
448 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat; 446 format.fInternalFormat = GrGLStencilBuffer::kUnknownInternalFormat;
449 format.fPacked = false; 447 format.fPacked = false;
450 format.fStencilBits = wrapDesc.fStencilBits; 448 format.fStencilBits = wrapDesc.fStencilBits;
451 format.fTotalBits = wrapDesc.fStencilBits; 449 format.fTotalBits = wrapDesc.fStencilBits;
452 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer, 450 GrGLStencilBuffer* sb = SkNEW_ARGS(GrGLStencilBuffer,
453 (this, 451 (this,
454 sbDesc, 452 sbDesc,
455 desc.fWidth, 453 desc.fWidth,
456 desc.fHeight, 454 desc.fHeight,
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 GR_GL_RENDERBUFFER_DEPTH_SIZE, 1119 GR_GL_RENDERBUFFER_DEPTH_SIZE,
1122 (GrGLint*)&format->fTotalBits); 1120 (GrGLint*)&format->fTotalBits);
1123 format->fTotalBits += format->fStencilBits; 1121 format->fTotalBits += format->fStencilBits;
1124 } else { 1122 } else {
1125 format->fTotalBits = format->fStencilBits; 1123 format->fTotalBits = format->fStencilBits;
1126 } 1124 }
1127 } 1125 }
1128 } 1126 }
1129 } 1127 }
1130 1128
1131 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, bool budget ed, int width, 1129 bool GrGLGpu::createStencilBufferForRenderTarget(GrRenderTarget* rt, int width, int height) {
1132 int height) {
1133 // All internally created RTs are also textures. We don't create 1130 // 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) . 1131 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1135 SkASSERT(rt->asTexture()); 1132 SkASSERT(rt->asTexture());
1136 SkASSERT(width >= rt->width()); 1133 SkASSERT(width >= rt->width());
1137 SkASSERT(height >= rt->height()); 1134 SkASSERT(height >= rt->height());
1138 1135
1139 int samples = rt->numSamples(); 1136 int samples = rt->numSamples();
1140 GrGLStencilBuffer::IDDesc sbDesc; 1137 GrGLStencilBuffer::IDDesc sbDesc;
1141 sbDesc.fRenderbufferID = 0;
1142 sbDesc.fLifeCycle = budgeted ? GrGpuResource::kCached_LifeCycle
1143 : GrGpuResource::kUncached_LifeCycle;
1144 1138
1145 int stencilFmtCnt = this->glCaps().stencilFormats().count(); 1139 int stencilFmtCnt = this->glCaps().stencilFormats().count();
1146 for (int i = 0; i < stencilFmtCnt; ++i) { 1140 for (int i = 0; i < stencilFmtCnt; ++i) {
1147 if (!sbDesc.fRenderbufferID) { 1141 if (!sbDesc.fRenderbufferID) {
1148 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1142 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1149 } 1143 }
1150 if (!sbDesc.fRenderbufferID) { 1144 if (!sbDesc.fRenderbufferID) {
1151 return false; 1145 return false;
1152 } 1146 }
1153 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)); 1147 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); 2757 this->setVertexArrayID(gpu, 0);
2764 } 2758 }
2765 int attrCount = gpu->glCaps().maxVertexAttributes(); 2759 int attrCount = gpu->glCaps().maxVertexAttributes();
2766 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2760 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2767 fDefaultVertexArrayAttribState.resize(attrCount); 2761 fDefaultVertexArrayAttribState.resize(attrCount);
2768 } 2762 }
2769 attribState = &fDefaultVertexArrayAttribState; 2763 attribState = &fDefaultVertexArrayAttribState;
2770 } 2764 }
2771 return attribState; 2765 return attribState;
2772 } 2766 }
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