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/GrGLGpu.cpp

Issue 1317443004: Calculate pixel config and stencil fmt pairs once per pixel config. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 3 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
« src/gpu/gl/GrGLGpu.h ('K') | « src/gpu/gl/GrGLGpu.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 8
9 #include "GrGLGpu.h" 9 #include "GrGLGpu.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); 152 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff);
153 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); 153 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff);
154 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); 154 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff);
155 155
156 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope 156 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope
157 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); 157 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
158 } 158 }
159 159
160 /////////////////////////////////////////////////////////////////////////////// 160 ///////////////////////////////////////////////////////////////////////////////
161 161
162 // Used in the map of pixel configs to stencil format indices. This value is use d to
163 // indicate that a stencil format has not yet been set for the given config.
164 static const int kUnknownStencilIndex = -1;
165 // This value is used as the stencil index when no stencil configs are support w ith the
jvanverth1 2015/09/10 13:35:03 Nit: support -> supported
egdaniel 2015/09/10 13:59:10 Done.
166 // given pixel config.
167 static const int kUnsupportedStencilIndex = -2;
168
169 ///////////////////////////////////////////////////////////////////////////////
170
162 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options, 171 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
163 GrContext* context) { 172 GrContext* context) {
164 SkAutoTUnref<const GrGLInterface> glInterface( 173 SkAutoTUnref<const GrGLInterface> glInterface(
165 reinterpret_cast<const GrGLInterface*>(backendContext)); 174 reinterpret_cast<const GrGLInterface*>(backendContext));
166 if (!glInterface) { 175 if (!glInterface) {
167 glInterface.reset(GrGLDefaultInterface()); 176 glInterface.reset(GrGLDefaultInterface());
168 } else { 177 } else {
169 glInterface->ref(); 178 glInterface->ref();
170 } 179 }
171 if (!glInterface) { 180 if (!glInterface) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 SkDebugf("------ EXTENSIONS\n"); 213 SkDebugf("------ EXTENSIONS\n");
205 this->glContext().extensions().print(); 214 this->glContext().extensions().print();
206 SkDebugf("\n"); 215 SkDebugf("\n");
207 SkDebugf("%s", this->glCaps().dump().c_str()); 216 SkDebugf("%s", this->glCaps().dump().c_str());
208 } 217 }
209 218
210 fProgramCache = new ProgramCache(this); 219 fProgramCache = new ProgramCache(this);
211 220
212 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs); 221 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs);
213 222
214 fLastSuccessfulStencilFmtIdx = 0; 223 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
224 fPixelConfigToStencilIndex[i] = kUnknownStencilIndex;
225 }
215 fHWProgramID = 0; 226 fHWProgramID = 0;
216 fTempSrcFBOID = 0; 227 fTempSrcFBOID = 0;
217 fTempDstFBOID = 0; 228 fTempDstFBOID = 0;
218 fStencilClearFBOID = 0; 229 fStencilClearFBOID = 0;
219 230
220 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { 231 if (this->glCaps().shaderCaps()->pathRenderingSupport()) {
221 fPathRendering.reset(new GrGLPathRendering(this)); 232 fPathRendering.reset(new GrGLPathRendering(this));
222 } 233 }
223 234
224 this->createCopyProgram(); 235 this->createCopyProgram();
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 GR_GL_RENDERBUFFER_DEPTH_SIZE, 1173 GR_GL_RENDERBUFFER_DEPTH_SIZE,
1163 (GrGLint*)&format->fTotalBits); 1174 (GrGLint*)&format->fTotalBits);
1164 format->fTotalBits += format->fStencilBits; 1175 format->fTotalBits += format->fStencilBits;
1165 } else { 1176 } else {
1166 format->fTotalBits = format->fStencilBits; 1177 format->fTotalBits = format->fStencilBits;
1167 } 1178 }
1168 } 1179 }
1169 } 1180 }
1170 } 1181 }
1171 1182
1183 int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
1184 int size = 16;
bsalomon 2015/09/09 22:02:29 maybe use caps()->minTextureSize()?
egdaniel 2015/09/10 13:59:10 Done, but still need some default value for cases
1185 if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) {
1186 // Default to unsupported
1187 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1188 // Create color texture
1189 GrGLuint colorID;
1190 GL_CALL(GenTextures(1, &colorID));
1191 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID));
bsalomon 2015/09/09 22:02:29 need to invalidate bound texture tracking
egdaniel 2015/09/10 13:59:10 Done.
1192 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1193 GR_GL_TEXTURE_MAG_FILTER,
1194 GR_GL_NEAREST));
1195 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1196 GR_GL_TEXTURE_MIN_FILTER,
1197 GR_GL_NEAREST));
1198 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1199 GR_GL_TEXTURE_WRAP_S,
1200 GR_GL_CLAMP_TO_EDGE));
1201 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1202 GR_GL_TEXTURE_WRAP_T,
1203 GR_GL_CLAMP_TO_EDGE));
1204
1205 GrGLenum internalFormat = 0x0; // suppress warning
1206 GrGLenum externalFormat = 0x0; // suppress warning
1207 GrGLenum externalType = 0x0; // suppress warning
1208 if (!this->configToGLFormats(config, false, &internalFormat,
1209 &externalFormat, &externalType)) {
1210 GL_CALL(DeleteTextures(1, &colorID));
1211 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1212 return kUnsupportedStencilIndex;
1213 }
1214
1215 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1216 GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
1217 0, internalFormat,
1218 size,
1219 size,
1220 0,
1221 externalFormat,
1222 externalType,
1223 NULL));
1224 if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) {
1225 GL_CALL(DeleteTextures(1, &colorID));
1226 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1227 return kUnsupportedStencilIndex;
1228 }
1229
1230 // unbind the texture from the texture unit before binding it to the fra me buffer
1231 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0));
1232
1233 // Create Framebuffer
1234 GrGLuint fb;
1235 GL_CALL(GenFramebuffers(1, &fb));
1236 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb));
1237 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1238 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
1239 GR_GL_COLOR_ATTACHMENT0,
1240 GR_GL_TEXTURE_2D,
1241 colorID,
1242 0));
1243
1244 // look over formats till I find a compatible one
1245 int stencilFmtCnt = this->glCaps().stencilFormats().count();
1246 GrGLuint sbRBID = 0;
1247 for (int i = 0; i < stencilFmtCnt; ++i) {
1248 const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats( )[i];
1249
1250 GL_CALL(GenRenderbuffers(1, &sbRBID));
1251 if (!sbRBID) {
1252 break;
1253 }
1254 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbRBID));
1255 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1256 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERB UFFER,
1257 sFmt.fInterna lFormat,
1258 size, size));
1259 if (GR_GL_NO_ERROR == GR_GL_GET_ERROR(this->glInterface())) {
1260 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1261 GR_GL_STENCIL_ATTACHMENT,
1262 GR_GL_RENDERBUFFER, sbRBID));
1263 if (sFmt.fPacked) {
1264 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1265 GR_GL_DEPTH_ATTACHMENT,
1266 GR_GL_RENDERBUFFER, sbRBID)) ;
1267 } else {
1268 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1269 GR_GL_DEPTH_ATTACHMENT,
1270 GR_GL_RENDERBUFFER, 0));
1271 }
1272 GrGLenum status;
1273 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1274 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
1275 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1276 GR_GL_STENCIL_ATTACHMENT,
1277 GR_GL_RENDERBUFFER, 0));
1278 if (sFmt.fPacked) {
1279 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1280 GR_GL_DEPTH_ATTACHMENT,
1281 GR_GL_RENDERBUFFER, 0));
1282 }
1283 } else {
1284 fPixelConfigToStencilIndex[config] = i;
1285 break;
1286 }
1287 }
1288 sbRBID = 0;
1289 }
1290 GL_CALL(DeleteTextures(1, &colorID));
1291 GL_CALL(DeleteRenderbuffers(1, &sbRBID));
1292 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0));
1293 GL_CALL(DeleteFramebuffers(1, &fb));
1294 }
1295 SkASSERT(kUnknownStencilIndex != fPixelConfigToStencilIndex[config]);
1296 return fPixelConfigToStencilIndex[config];
1297 }
1298
1172 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { 1299 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) {
1173 // All internally created RTs are also textures. We don't create 1300 // All internally created RTs are also textures. We don't create
1174 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . 1301 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1175 SkASSERT(rt->asTexture()); 1302 SkASSERT(rt->asTexture());
1176 SkASSERT(width >= rt->width()); 1303 SkASSERT(width >= rt->width());
1177 SkASSERT(height >= rt->height()); 1304 SkASSERT(height >= rt->height());
1178 1305
1179 int samples = rt->numStencilSamples(); 1306 int samples = rt->numStencilSamples();
1180 GrGLStencilAttachment::IDDesc sbDesc; 1307 GrGLStencilAttachment::IDDesc sbDesc;
1181 1308
1182 int stencilFmtCnt = this->glCaps().stencilFormats().count(); 1309 int sIdx = this->getCompatibleStencilIndex(rt->config());
1183 for (int i = 0; i < stencilFmtCnt; ++i) { 1310 if (sIdx == kUnsupportedStencilIndex) {
1184 if (!sbDesc.fRenderbufferID) { 1311 return false;
1185 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1312 }
1186 } 1313
1187 if (!sbDesc.fRenderbufferID) { 1314 if (!sbDesc.fRenderbufferID) {
1188 return false; 1315 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1189 } 1316 }
1190 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)); 1317 if (!sbDesc.fRenderbufferID) {
1191 // we start with the last stencil format that succeeded in hopes 1318 return false;
1192 // that we won't go through this loop more than once after the 1319 }
1193 // first (painful) stencil creation. 1320 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID));
1194 int sIdx = (i + fLastSuccessfulStencilFmtIdx) % stencilFmtCnt; 1321 const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[sIdx];
1195 const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[sI dx]; 1322 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1196 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1323 // we do this "if" so that we don't call the multisample
1197 // we do this "if" so that we don't call the multisample 1324 // version on a GL that doesn't have an MSAA extension.
1198 // version on a GL that doesn't have an MSAA extension. 1325 bool created;
1199 bool created; 1326 if (samples > 0) {
1200 if (samples > 0) { 1327 created = renderbuffer_storage_msaa(*fGLContext,
1201 created = renderbuffer_storage_msaa(*fGLContext, 1328 samples,
1202 samples, 1329 sFmt.fInternalFormat,
1203 sFmt.fInternalFormat, 1330 width, height);
1204 width, height); 1331 } else {
1205 } else { 1332 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERBUFFE R,
1206 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERB UFFER, 1333 sFmt.fInternalFor mat,
1207 sFmt.fInterna lFormat, 1334 width, height));
1208 width, height )); 1335 created = (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glInter face()));
1209 created = (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glI nterface())); 1336 }
1210 } 1337 SkASSERT(created);
1211 if (created) { 1338 fStats.incStencilAttachmentCreates();
1212 fStats.incStencilAttachmentCreates(); 1339 // After sized formats we attempt an unsized format and take
1213 // After sized formats we attempt an unsized format and take 1340 // whatever sizes GL gives us. In that case we query for the size.
1214 // whatever sizes GL gives us. In that case we query for the size. 1341 GrGLStencilAttachment::Format format = sFmt;
1215 GrGLStencilAttachment::Format format = sFmt; 1342 get_stencil_rb_sizes(this->glInterface(), &format);
1216 get_stencil_rb_sizes(this->glInterface(), &format); 1343 SkAutoTUnref<GrGLStencilAttachment> sb(
1217 SkAutoTUnref<GrGLStencilAttachment> sb( 1344 new GrGLStencilAttachment(this, sbDesc, width, height, samples, format)) ;
1218 new GrGLStencilAttachment(this, sbDesc, width, height, sampl es, format)); 1345 SkAssertResult(this->attachStencilAttachmentToRenderTarget(sb, rt));
1219 if (this->attachStencilAttachmentToRenderTarget(sb, rt)) { 1346 rt->renderTargetPriv().didAttachStencilAttachment(sb);
1220 fLastSuccessfulStencilFmtIdx = sIdx; 1347 // This work around is currently breaking on windows 7 hd2000 bot when we bi nd a color buffer
1221 rt->renderTargetPriv().didAttachStencilAttachment(sb);
1222 // This work around is currently breaking on windows 7 hd2000 bot when we bind a color buffer
1223 #if 0 1348 #if 0
1224 // Clear the stencil buffer. We use a special purpose FBO for th is so that the 1349 // Clear the stencil buffer. We use a special purpose FBO for this so that t he
1225 // entire stencil buffer is cleared, even if it is attached to a n FBO with a 1350 // entire stencil buffer is cleared, even if it is attached to an FBO with a
1226 // smaller color target. 1351 // smaller color target.
1227 if (0 == fStencilClearFBOID) { 1352 if (0 == fStencilClearFBOID) {
1228 GL_CALL(GenFramebuffers(1, &fStencilClearFBOID)); 1353 GL_CALL(GenFramebuffers(1, &fStencilClearFBOID));
1229 } 1354 }
1230 1355
1231 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fStencilClearFBOID)); 1356 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fStencilClearFBOID));
1232 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 1357 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1233 fStats.incRenderTargetBinds(); 1358 fStats.incRenderTargetBinds();
1234 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1359 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1235 GR_GL_STENCIL_ATTACHMENT, 1360 GR_GL_STENCIL_ATTACHMENT,
1236 GR_GL_RENDERBUFFER, sbDesc.fRend erbufferID)); 1361 GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)) ;
1237 if (sFmt.fPacked) { 1362 if (sFmt.fPacked) {
1238 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1363 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1239 GR_GL_DEPTH_ATTACHMENT, 1364 GR_GL_DEPTH_ATTACHMENT,
1240 GR_GL_RENDERBUFFER, sbDesc.f RenderbufferID)); 1365 GR_GL_RENDERBUFFER, sbDesc.fRenderbuffer ID));
1241 } 1366 }
1242 1367
1243 GL_CALL(ClearStencil(0)); 1368 GL_CALL(ClearStencil(0));
1244 // Many GL implementations seem to have trouble with clearing an FBO with only 1369 // Many GL implementations seem to have trouble with clearing an FBO with on ly
1245 // a stencil buffer. 1370 // a stencil buffer.
1246 GrGLuint tempRB; 1371 GrGLuint tempRB;
1247 GL_CALL(GenRenderbuffers(1, &tempRB)); 1372 GL_CALL(GenRenderbuffers(1, &tempRB));
1248 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, tempRB)); 1373 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, tempRB));
1249 if (samples > 0) { 1374 if (samples > 0) {
1250 renderbuffer_storage_msaa(fGLContext, samples, GR_GL_RGBA8, width, height); 1375 renderbuffer_storage_msaa(fGLContext, samples, GR_GL_RGBA8, width, heigh t);
1251 } else { 1376 } else {
1252 GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, GR_GL_RGBA8, width, height)); 1377 GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, GR_GL_RGBA8, width, heig ht));
1253 } 1378 }
1254 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1379 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1255 GR_GL_COLOR_ATTACHMENT0, 1380 GR_GL_COLOR_ATTACHMENT0,
1256 GR_GL_RENDERBUFFER, tempRB)); 1381 GR_GL_RENDERBUFFER, tempRB));
1257 1382
1258 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1383 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1259 1384
1260 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1385 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1261 GR_GL_COLOR_ATTACHMENT0, 1386 GR_GL_COLOR_ATTACHMENT0,
1262 GR_GL_RENDERBUFFER, 0)); 1387 GR_GL_RENDERBUFFER, 0));
1263 GL_CALL(DeleteRenderbuffers(1, &tempRB)); 1388 GL_CALL(DeleteRenderbuffers(1, &tempRB));
1264 1389
1265 // Unbind the SB from the FBO so that we don't keep it alive. 1390 // Unbind the SB from the FBO so that we don't keep it alive.
1266 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1391 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1267 GR_GL_STENCIL_ATTACHMENT, 1392 GR_GL_STENCIL_ATTACHMENT,
1268 GR_GL_RENDERBUFFER, 0)); 1393 GR_GL_RENDERBUFFER, 0));
1269 if (sFmt.fPacked) { 1394 if (sFmt.fPacked) {
1270 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1395 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1271 GR_GL_DEPTH_ATTACHMENT, 1396 GR_GL_DEPTH_ATTACHMENT,
1272 GR_GL_RENDERBUFFER, 0)); 1397 GR_GL_RENDERBUFFER, 0));
1273 } 1398 }
1274 #endif 1399 #endif
1275 return true; 1400 return true;
1276 }
1277 // Remove the scratch key from this resource so we don't grab it fro m the cache ever
1278 // again.
1279 sb->resourcePriv().removeScratchKey();
1280 // Set this to 0 since we handed the valid ID off to the failed sten cil buffer resource.
1281 sbDesc.fRenderbufferID = 0;
1282 }
1283 }
1284 GL_CALL(DeleteRenderbuffers(1, &sbDesc.fRenderbufferID));
1285 return false;
1286 } 1401 }
1287 1402
1288 bool GrGLGpu::attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, GrR enderTarget* rt) { 1403 bool GrGLGpu::attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, GrR enderTarget* rt) {
1289 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); 1404 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt);
1290 1405
1291 GrGLuint fbo = glrt->renderFBOID(); 1406 GrGLuint fbo = glrt->renderFBOID();
1292 1407
1293 if (nullptr == sb) { 1408 if (nullptr == sb) {
1294 if (rt->renderTargetPriv().getStencilAttachment()) { 1409 if (rt->renderTargetPriv().getStencilAttachment()) {
1295 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1410 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
(...skipping 22 matching lines...) Expand all
1318 if (glsb->format().fPacked) { 1433 if (glsb->format().fPacked) {
1319 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1434 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1320 GR_GL_DEPTH_ATTACHMENT, 1435 GR_GL_DEPTH_ATTACHMENT,
1321 GR_GL_RENDERBUFFER, rb)); 1436 GR_GL_RENDERBUFFER, rb));
1322 } else { 1437 } else {
1323 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1438 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1324 GR_GL_DEPTH_ATTACHMENT, 1439 GR_GL_DEPTH_ATTACHMENT,
1325 GR_GL_RENDERBUFFER, 0)); 1440 GR_GL_RENDERBUFFER, 0));
1326 } 1441 }
1327 1442
1443 #ifdef SK_DEBUG
1328 GrGLenum status; 1444 GrGLenum status;
1329 if (!this->glCaps().isColorConfigAndStencilFormatVerified(rt->config(), glsb->format())) { 1445 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1330 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1446 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status);
1331 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 1447 #endif
1332 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1333 GR_GL_STENCIL_ATTACHMENT,
1334 GR_GL_RENDERBUFFER, 0));
1335 if (glsb->format().fPacked) {
1336 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1337 GR_GL_DEPTH_ATTACHMENT,
1338 GR_GL_RENDERBUFFER, 0));
1339 }
1340 return false;
1341 } else {
1342 fGLContext->caps()->markColorConfigAndStencilFormatAsVerified(
1343 rt->config(),
1344 glsb->format());
1345 }
1346 }
1347 return true; 1448 return true;
1348 } 1449 }
1349 } 1450 }
1350 1451
1351 //////////////////////////////////////////////////////////////////////////////// 1452 ////////////////////////////////////////////////////////////////////////////////
1352 1453
1353 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) { 1454 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) {
1354 GrGLVertexBuffer::Desc desc; 1455 GrGLVertexBuffer::Desc desc;
1355 desc.fDynamic = dynamic; 1456 desc.fDynamic = dynamic;
1356 desc.fSizeInBytes = size; 1457 desc.fSizeInBytes = size;
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 this->setVertexArrayID(gpu, 0); 3266 this->setVertexArrayID(gpu, 0);
3166 } 3267 }
3167 int attrCount = gpu->glCaps().maxVertexAttributes(); 3268 int attrCount = gpu->glCaps().maxVertexAttributes();
3168 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3269 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3169 fDefaultVertexArrayAttribState.resize(attrCount); 3270 fDefaultVertexArrayAttribState.resize(attrCount);
3170 } 3271 }
3171 attribState = &fDefaultVertexArrayAttribState; 3272 attribState = &fDefaultVertexArrayAttribState;
3172 } 3273 }
3173 return attribState; 3274 return attribState;
3174 } 3275 }
OLDNEW
« src/gpu/gl/GrGLGpu.h ('K') | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698