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

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: Unused variable 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
« no previous file with comments | « 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 supported with the
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 = this->caps()->minTextureSize();
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 this->setScratchTextureUnit();
1192 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID));
1193 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1194 GR_GL_TEXTURE_MAG_FILTER,
1195 GR_GL_NEAREST));
1196 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1197 GR_GL_TEXTURE_MIN_FILTER,
1198 GR_GL_NEAREST));
1199 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1200 GR_GL_TEXTURE_WRAP_S,
1201 GR_GL_CLAMP_TO_EDGE));
1202 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1203 GR_GL_TEXTURE_WRAP_T,
1204 GR_GL_CLAMP_TO_EDGE));
1205
1206 GrGLenum internalFormat = 0x0; // suppress warning
1207 GrGLenum externalFormat = 0x0; // suppress warning
1208 GrGLenum externalType = 0x0; // suppress warning
1209 if (!this->configToGLFormats(config, false, &internalFormat,
1210 &externalFormat, &externalType)) {
1211 GL_CALL(DeleteTextures(1, &colorID));
1212 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1213 return kUnsupportedStencilIndex;
1214 }
1215
1216 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1217 GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
1218 0, internalFormat,
1219 size,
1220 size,
1221 0,
1222 externalFormat,
1223 externalType,
1224 NULL));
1225 if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) {
1226 GL_CALL(DeleteTextures(1, &colorID));
1227 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex;
1228 return kUnsupportedStencilIndex;
1229 }
1230
1231 // unbind the texture from the texture unit before binding it to the fra me buffer
1232 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0));
1233
1234 // Create Framebuffer
1235 GrGLuint fb;
1236 GL_CALL(GenFramebuffers(1, &fb));
1237 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb));
1238 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1239 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER,
1240 GR_GL_COLOR_ATTACHMENT0,
1241 GR_GL_TEXTURE_2D,
1242 colorID,
1243 0));
1244
1245 // look over formats till I find a compatible one
1246 int stencilFmtCnt = this->glCaps().stencilFormats().count();
1247 GrGLuint sbRBID = 0;
1248 for (int i = 0; i < stencilFmtCnt; ++i) {
1249 const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats( )[i];
1250
1251 GL_CALL(GenRenderbuffers(1, &sbRBID));
1252 if (!sbRBID) {
1253 break;
1254 }
1255 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbRBID));
1256 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1257 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERB UFFER,
1258 sFmt.fInterna lFormat,
1259 size, size));
1260 if (GR_GL_NO_ERROR == GR_GL_GET_ERROR(this->glInterface())) {
1261 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1262 GR_GL_STENCIL_ATTACHMENT,
1263 GR_GL_RENDERBUFFER, sbRBID));
1264 if (sFmt.fPacked) {
1265 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1266 GR_GL_DEPTH_ATTACHMENT,
1267 GR_GL_RENDERBUFFER, sbRBID)) ;
1268 } else {
1269 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1270 GR_GL_DEPTH_ATTACHMENT,
1271 GR_GL_RENDERBUFFER, 0));
1272 }
1273 GrGLenum status;
1274 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1275 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
1276 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1277 GR_GL_STENCIL_ATTACHMENT,
1278 GR_GL_RENDERBUFFER, 0));
1279 if (sFmt.fPacked) {
1280 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1281 GR_GL_DEPTH_ATTACHMENT,
1282 GR_GL_RENDERBUFFER, 0));
1283 }
1284 } else {
1285 fPixelConfigToStencilIndex[config] = i;
1286 break;
1287 }
1288 }
1289 sbRBID = 0;
1290 }
1291 GL_CALL(DeleteTextures(1, &colorID));
1292 GL_CALL(DeleteRenderbuffers(1, &sbRBID));
1293 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0));
1294 GL_CALL(DeleteFramebuffers(1, &fb));
1295 }
1296 SkASSERT(kUnknownStencilIndex != fPixelConfigToStencilIndex[config]);
1297 return fPixelConfigToStencilIndex[config];
1298 }
1299
1172 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) { 1300 bool GrGLGpu::createStencilAttachmentForRenderTarget(GrRenderTarget* rt, int wid th, int height) {
1173 // All internally created RTs are also textures. We don't create 1301 // 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) . 1302 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1175 SkASSERT(rt->asTexture()); 1303 SkASSERT(rt->asTexture());
1176 SkASSERT(width >= rt->width()); 1304 SkASSERT(width >= rt->width());
1177 SkASSERT(height >= rt->height()); 1305 SkASSERT(height >= rt->height());
1178 1306
1179 int samples = rt->numStencilSamples(); 1307 int samples = rt->numStencilSamples();
1180 GrGLStencilAttachment::IDDesc sbDesc; 1308 GrGLStencilAttachment::IDDesc sbDesc;
1181 1309
1182 int stencilFmtCnt = this->glCaps().stencilFormats().count(); 1310 int sIdx = this->getCompatibleStencilIndex(rt->config());
1183 for (int i = 0; i < stencilFmtCnt; ++i) { 1311 if (sIdx == kUnsupportedStencilIndex) {
1184 if (!sbDesc.fRenderbufferID) { 1312 return false;
1185 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1313 }
1186 } 1314
1187 if (!sbDesc.fRenderbufferID) { 1315 if (!sbDesc.fRenderbufferID) {
1188 return false; 1316 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1189 } 1317 }
1190 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)); 1318 if (!sbDesc.fRenderbufferID) {
1191 // we start with the last stencil format that succeeded in hopes 1319 return false;
1192 // that we won't go through this loop more than once after the 1320 }
1193 // first (painful) stencil creation. 1321 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID));
1194 int sIdx = (i + fLastSuccessfulStencilFmtIdx) % stencilFmtCnt; 1322 const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[sIdx];
1195 const GrGLCaps::StencilFormat& sFmt = this->glCaps().stencilFormats()[sI dx]; 1323 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1196 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1324 // 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 1325 // version on a GL that doesn't have an MSAA extension.
1198 // version on a GL that doesn't have an MSAA extension. 1326 if (samples > 0) {
1199 bool created; 1327 SkAssertResult(renderbuffer_storage_msaa(*fGLContext,
1200 if (samples > 0) { 1328 samples,
1201 created = renderbuffer_storage_msaa(*fGLContext, 1329 sFmt.fInternalFormat,
1202 samples, 1330 width, height));
1203 sFmt.fInternalFormat, 1331 } else {
1204 width, height); 1332 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERBUFFE R,
1205 } else { 1333 sFmt.fInternalFor mat,
1206 GL_ALLOC_CALL(this->glInterface(), RenderbufferStorage(GR_GL_RENDERB UFFER, 1334 width, height));
1207 sFmt.fInterna lFormat, 1335 SkASSERT(GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glInterfa ce()));
1208 width, height )); 1336 }
1209 created = (GR_GL_NO_ERROR == check_alloc_error(rt->desc(), this->glI nterface())); 1337 fStats.incStencilAttachmentCreates();
1210 } 1338 // After sized formats we attempt an unsized format and take
1211 if (created) { 1339 // whatever sizes GL gives us. In that case we query for the size.
1212 fStats.incStencilAttachmentCreates(); 1340 GrGLStencilAttachment::Format format = sFmt;
1213 // After sized formats we attempt an unsized format and take 1341 get_stencil_rb_sizes(this->glInterface(), &format);
1214 // whatever sizes GL gives us. In that case we query for the size. 1342 SkAutoTUnref<GrGLStencilAttachment> sb(
1215 GrGLStencilAttachment::Format format = sFmt; 1343 new GrGLStencilAttachment(this, sbDesc, width, height, samples, format)) ;
1216 get_stencil_rb_sizes(this->glInterface(), &format); 1344 SkAssertResult(this->attachStencilAttachmentToRenderTarget(sb, rt));
1217 SkAutoTUnref<GrGLStencilAttachment> sb( 1345 rt->renderTargetPriv().didAttachStencilAttachment(sb);
1218 new GrGLStencilAttachment(this, sbDesc, width, height, sampl es, format)); 1346 // This work around is currently breaking on windows 7 hd2000 bot when we bi nd a color buffer
1219 if (this->attachStencilAttachmentToRenderTarget(sb, rt)) {
1220 fLastSuccessfulStencilFmtIdx = sIdx;
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 1347 #if 0
1224 // Clear the stencil buffer. We use a special purpose FBO for th is so that the 1348 // 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 1349 // entire stencil buffer is cleared, even if it is attached to an FBO with a
1226 // smaller color target. 1350 // smaller color target.
1227 if (0 == fStencilClearFBOID) { 1351 if (0 == fStencilClearFBOID) {
1228 GL_CALL(GenFramebuffers(1, &fStencilClearFBOID)); 1352 GL_CALL(GenFramebuffers(1, &fStencilClearFBOID));
1229 } 1353 }
1230 1354
1231 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fStencilClearFBOID)); 1355 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fStencilClearFBOID));
1232 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 1356 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
1233 fStats.incRenderTargetBinds(); 1357 fStats.incRenderTargetBinds();
1234 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1358 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1235 GR_GL_STENCIL_ATTACHMENT, 1359 GR_GL_STENCIL_ATTACHMENT,
1236 GR_GL_RENDERBUFFER, sbDesc.fRend erbufferID)); 1360 GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)) ;
1237 if (sFmt.fPacked) { 1361 if (sFmt.fPacked) {
1238 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1362 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1239 GR_GL_DEPTH_ATTACHMENT, 1363 GR_GL_DEPTH_ATTACHMENT,
1240 GR_GL_RENDERBUFFER, sbDesc.f RenderbufferID)); 1364 GR_GL_RENDERBUFFER, sbDesc.fRenderbuffer ID));
1241 } 1365 }
1242 1366
1243 GL_CALL(ClearStencil(0)); 1367 GL_CALL(ClearStencil(0));
1244 // Many GL implementations seem to have trouble with clearing an FBO with only 1368 // Many GL implementations seem to have trouble with clearing an FBO with on ly
1245 // a stencil buffer. 1369 // a stencil buffer.
1246 GrGLuint tempRB; 1370 GrGLuint tempRB;
1247 GL_CALL(GenRenderbuffers(1, &tempRB)); 1371 GL_CALL(GenRenderbuffers(1, &tempRB));
1248 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, tempRB)); 1372 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, tempRB));
1249 if (samples > 0) { 1373 if (samples > 0) {
1250 renderbuffer_storage_msaa(fGLContext, samples, GR_GL_RGBA8, width, height); 1374 renderbuffer_storage_msaa(fGLContext, samples, GR_GL_RGBA8, width, heigh t);
1251 } else { 1375 } else {
1252 GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, GR_GL_RGBA8, width, height)); 1376 GL_CALL(RenderbufferStorage(GR_GL_RENDERBUFFER, GR_GL_RGBA8, width, heig ht));
1253 } 1377 }
1254 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1378 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1255 GR_GL_COLOR_ATTACHMENT0, 1379 GR_GL_COLOR_ATTACHMENT0,
1256 GR_GL_RENDERBUFFER, tempRB)); 1380 GR_GL_RENDERBUFFER, tempRB));
1257 1381
1258 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT)); 1382 GL_CALL(Clear(GR_GL_STENCIL_BUFFER_BIT));
1259 1383
1260 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1384 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1261 GR_GL_COLOR_ATTACHMENT0, 1385 GR_GL_COLOR_ATTACHMENT0,
1262 GR_GL_RENDERBUFFER, 0)); 1386 GR_GL_RENDERBUFFER, 0));
1263 GL_CALL(DeleteRenderbuffers(1, &tempRB)); 1387 GL_CALL(DeleteRenderbuffers(1, &tempRB));
1264 1388
1265 // Unbind the SB from the FBO so that we don't keep it alive. 1389 // Unbind the SB from the FBO so that we don't keep it alive.
1266 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1390 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1267 GR_GL_STENCIL_ATTACHMENT, 1391 GR_GL_STENCIL_ATTACHMENT,
1268 GR_GL_RENDERBUFFER, 0)); 1392 GR_GL_RENDERBUFFER, 0));
1269 if (sFmt.fPacked) { 1393 if (sFmt.fPacked) {
1270 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1394 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1271 GR_GL_DEPTH_ATTACHMENT, 1395 GR_GL_DEPTH_ATTACHMENT,
1272 GR_GL_RENDERBUFFER, 0)); 1396 GR_GL_RENDERBUFFER, 0));
1273 } 1397 }
1274 #endif 1398 #endif
1275 return true; 1399 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 } 1400 }
1287 1401
1288 bool GrGLGpu::attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, GrR enderTarget* rt) { 1402 bool GrGLGpu::attachStencilAttachmentToRenderTarget(GrStencilAttachment* sb, GrR enderTarget* rt) {
1289 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt); 1403 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(rt);
1290 1404
1291 GrGLuint fbo = glrt->renderFBOID(); 1405 GrGLuint fbo = glrt->renderFBOID();
1292 1406
1293 if (nullptr == sb) { 1407 if (nullptr == sb) {
1294 if (rt->renderTargetPriv().getStencilAttachment()) { 1408 if (rt->renderTargetPriv().getStencilAttachment()) {
1295 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1409 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
(...skipping 22 matching lines...) Expand all
1318 if (glsb->format().fPacked) { 1432 if (glsb->format().fPacked) {
1319 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1433 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1320 GR_GL_DEPTH_ATTACHMENT, 1434 GR_GL_DEPTH_ATTACHMENT,
1321 GR_GL_RENDERBUFFER, rb)); 1435 GR_GL_RENDERBUFFER, rb));
1322 } else { 1436 } else {
1323 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1437 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1324 GR_GL_DEPTH_ATTACHMENT, 1438 GR_GL_DEPTH_ATTACHMENT,
1325 GR_GL_RENDERBUFFER, 0)); 1439 GR_GL_RENDERBUFFER, 0));
1326 } 1440 }
1327 1441
1442 #ifdef SK_DEBUG
1328 GrGLenum status; 1443 GrGLenum status;
1329 if (!this->glCaps().isColorConfigAndStencilFormatVerified(rt->config(), glsb->format())) { 1444 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1330 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1445 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status);
1331 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 1446 #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; 1447 return true;
1348 } 1448 }
1349 } 1449 }
1350 1450
1351 //////////////////////////////////////////////////////////////////////////////// 1451 ////////////////////////////////////////////////////////////////////////////////
1352 1452
1353 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) { 1453 GrVertexBuffer* GrGLGpu::onCreateVertexBuffer(size_t size, bool dynamic) {
1354 GrGLVertexBuffer::Desc desc; 1454 GrGLVertexBuffer::Desc desc;
1355 desc.fDynamic = dynamic; 1455 desc.fDynamic = dynamic;
1356 desc.fSizeInBytes = size; 1456 desc.fSizeInBytes = size;
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3165 this->setVertexArrayID(gpu, 0); 3265 this->setVertexArrayID(gpu, 0);
3166 } 3266 }
3167 int attrCount = gpu->glCaps().maxVertexAttributes(); 3267 int attrCount = gpu->glCaps().maxVertexAttributes();
3168 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3268 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3169 fDefaultVertexArrayAttribState.resize(attrCount); 3269 fDefaultVertexArrayAttribState.resize(attrCount);
3170 } 3270 }
3171 attribState = &fDefaultVertexArrayAttribState; 3271 attribState = &fDefaultVertexArrayAttribState;
3172 } 3272 }
3173 return attribState; 3273 return attribState;
3174 } 3274 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698