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

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

Issue 1526253007: Move the GrGLGpu config stencil format index into ConfigTable (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update comments Created 5 years 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff); 153 GR_STATIC_ASSERT(15 == kIS2C_GrBlendCoeff);
154 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff); 154 GR_STATIC_ASSERT(16 == kS2A_GrBlendCoeff);
155 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff); 155 GR_STATIC_ASSERT(17 == kIS2A_GrBlendCoeff);
156 156
157 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope 157 // assertion for gXfermodeCoeff2Blend have to be in GrGpu scope
158 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend)); 158 GR_STATIC_ASSERT(kGrBlendCoeffCnt == SK_ARRAY_COUNT(gXfermodeCoeff2Blend));
159 } 159 }
160 160
161 /////////////////////////////////////////////////////////////////////////////// 161 ///////////////////////////////////////////////////////////////////////////////
162 162
163 // Used in the map of pixel configs to stencil format indices. This value is use d to
164 // indicate that a stencil format has not yet been set for the given config.
165 static const int kUnknownStencilIndex = -1;
166 // This value is used as the stencil index when no stencil configs are supported with the
167 // given pixel config.
168 static const int kUnsupportedStencilIndex = -2;
169
170 ///////////////////////////////////////////////////////////////////////////////
171 163
172 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options, 164 GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
173 GrContext* context) { 165 GrContext* context) {
174 SkAutoTUnref<const GrGLInterface> glInterface( 166 SkAutoTUnref<const GrGLInterface> glInterface(
175 reinterpret_cast<const GrGLInterface*>(backendContext)); 167 reinterpret_cast<const GrGLInterface*>(backendContext));
176 if (!glInterface) { 168 if (!glInterface) {
177 glInterface.reset(GrGLDefaultInterface()); 169 glInterface.reset(GrGLDefaultInterface());
178 } else { 170 } else {
179 glInterface->ref(); 171 glInterface->ref();
180 } 172 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 SkDebugf("------ EXTENSIONS\n"); 207 SkDebugf("------ EXTENSIONS\n");
216 this->glContext().extensions().print(); 208 this->glContext().extensions().print();
217 SkDebugf("\n"); 209 SkDebugf("\n");
218 SkDebugf("%s", this->glCaps().dump().c_str()); 210 SkDebugf("%s", this->glCaps().dump().c_str());
219 } 211 }
220 212
221 fProgramCache = new ProgramCache(this); 213 fProgramCache = new ProgramCache(this);
222 214
223 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs); 215 SkASSERT(this->glCaps().maxVertexAttributes() >= GrGeometryProcessor::kMaxVe rtexAttribs);
224 216
225 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
226 fPixelConfigToStencilIndex[i] = kUnknownStencilIndex;
227 }
228 fHWProgramID = 0; 217 fHWProgramID = 0;
229 fTempSrcFBOID = 0; 218 fTempSrcFBOID = 0;
230 fTempDstFBOID = 0; 219 fTempDstFBOID = 0;
231 fStencilClearFBOID = 0; 220 fStencilClearFBOID = 0;
232 221
233 if (this->glCaps().shaderCaps()->pathRenderingSupport()) { 222 if (this->glCaps().shaderCaps()->pathRenderingSupport()) {
234 fPathRendering.reset(new GrGLPathRendering(this)); 223 fPathRendering.reset(new GrGLPathRendering(this));
235 } 224 }
236 this->createCopyPrograms(); 225 this->createCopyPrograms();
237 fWireRectProgram.fProgram = 0; 226 fWireRectProgram.fProgram = 0;
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 format->fTotalBits += format->fStencilBits; 1261 format->fTotalBits += format->fStencilBits;
1273 } else { 1262 } else {
1274 format->fTotalBits = format->fStencilBits; 1263 format->fTotalBits = format->fStencilBits;
1275 } 1264 }
1276 } 1265 }
1277 } 1266 }
1278 } 1267 }
1279 1268
1280 int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { 1269 int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
1281 static const int kSize = 16; 1270 static const int kSize = 16;
1282 if (kUnknownStencilIndex == fPixelConfigToStencilIndex[config]) { 1271 if (ConfigEntry::kUnknown_StencilIndex == fConfigTable[config].fStencilForma tIndex) {
1283 // Default to unsupported 1272 // Default to unsupported
1284 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex; 1273 fConfigTable[config].fStencilFormatIndex = ConfigEntry::kUnsupported_Ste ncilFormatIndex;
1285 // Create color texture 1274 // Create color texture
1286 GrGLuint colorID = 0; 1275 GrGLuint colorID = 0;
1287 GL_CALL(GenTextures(1, &colorID)); 1276 GL_CALL(GenTextures(1, &colorID));
1288 this->setScratchTextureUnit(); 1277 this->setScratchTextureUnit();
1289 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID)); 1278 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, colorID));
1290 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1279 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1291 GR_GL_TEXTURE_MAG_FILTER, 1280 GR_GL_TEXTURE_MAG_FILTER,
1292 GR_GL_NEAREST)); 1281 GR_GL_NEAREST));
1293 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1282 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1294 GR_GL_TEXTURE_MIN_FILTER, 1283 GR_GL_TEXTURE_MIN_FILTER,
1295 GR_GL_NEAREST)); 1284 GR_GL_NEAREST));
1296 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1285 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1297 GR_GL_TEXTURE_WRAP_S, 1286 GR_GL_TEXTURE_WRAP_S,
1298 GR_GL_CLAMP_TO_EDGE)); 1287 GR_GL_CLAMP_TO_EDGE));
1299 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, 1288 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D,
1300 GR_GL_TEXTURE_WRAP_T, 1289 GR_GL_TEXTURE_WRAP_T,
1301 GR_GL_CLAMP_TO_EDGE)); 1290 GR_GL_CLAMP_TO_EDGE));
1302 1291
1303 GrGLenum internalFormat = 0x0; // suppress warning 1292 GrGLenum internalFormat = 0x0; // suppress warning
1304 GrGLenum externalFormat = 0x0; // suppress warning 1293 GrGLenum externalFormat = 0x0; // suppress warning
1305 GrGLenum externalType = 0x0; // suppress warning 1294 GrGLenum externalType = 0x0; // suppress warning
1306 bool useSizedFormat = use_sized_format_for_texture(false, this->ctxInfo( ), config); 1295 bool useSizedFormat = use_sized_format_for_texture(false, this->ctxInfo( ), config);
1307 if (!this->configToGLFormats(config, useSizedFormat, &internalFormat, 1296 if (!this->configToGLFormats(config, useSizedFormat, &internalFormat,
1308 &externalFormat, &externalType)) { 1297 &externalFormat, &externalType)) {
1309 GL_CALL(DeleteTextures(1, &colorID)); 1298 GL_CALL(DeleteTextures(1, &colorID));
1310 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex; 1299 return ConfigEntry::kUnsupported_StencilFormatIndex;
1311 return kUnsupportedStencilIndex;
1312 } 1300 }
1313 1301
1314 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); 1302 CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
1315 GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D, 1303 GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
1316 0, internalFormat, 1304 0, internalFormat,
1317 kSize, 1305 kSize,
1318 kSize, 1306 kSize,
1319 0, 1307 0,
1320 externalFormat, 1308 externalFormat,
1321 externalType, 1309 externalType,
1322 NULL)); 1310 NULL));
1323 if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) { 1311 if (GR_GL_NO_ERROR != GR_GL_GET_ERROR(this->glInterface())) {
1324 GL_CALL(DeleteTextures(1, &colorID)); 1312 GL_CALL(DeleteTextures(1, &colorID));
1325 fPixelConfigToStencilIndex[config] = kUnsupportedStencilIndex; 1313 return ConfigEntry::kUnsupported_StencilFormatIndex;
1326 return kUnsupportedStencilIndex;
1327 } 1314 }
1328 1315
1329 // unbind the texture from the texture unit before binding it to the fra me buffer 1316 // unbind the texture from the texture unit before binding it to the fra me buffer
1330 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0)); 1317 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, 0));
1331 1318
1332 // Create Framebuffer 1319 // Create Framebuffer
1333 GrGLuint fb = 0; 1320 GrGLuint fb = 0;
1334 GL_CALL(GenFramebuffers(1, &fb)); 1321 GL_CALL(GenFramebuffers(1, &fb));
1335 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb)); 1322 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fb));
1336 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; 1323 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 1360 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
1374 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1361 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1375 GR_GL_STENCIL_ATTACHMENT, 1362 GR_GL_STENCIL_ATTACHMENT,
1376 GR_GL_RENDERBUFFER, 0)); 1363 GR_GL_RENDERBUFFER, 0));
1377 if (sFmt.fPacked) { 1364 if (sFmt.fPacked) {
1378 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, 1365 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
1379 GR_GL_DEPTH_ATTACHMENT, 1366 GR_GL_DEPTH_ATTACHMENT,
1380 GR_GL_RENDERBUFFER, 0)); 1367 GR_GL_RENDERBUFFER, 0));
1381 } 1368 }
1382 } else { 1369 } else {
1383 fPixelConfigToStencilIndex[config] = i; 1370 fConfigTable[config].fStencilFormatIndex = i;
1384 break; 1371 break;
1385 } 1372 }
1386 } 1373 }
1387 sbRBID = 0; 1374 sbRBID = 0;
1388 } 1375 }
1389 GL_CALL(DeleteTextures(1, &colorID)); 1376 GL_CALL(DeleteTextures(1, &colorID));
1390 GL_CALL(DeleteRenderbuffers(1, &sbRBID)); 1377 GL_CALL(DeleteRenderbuffers(1, &sbRBID));
1391 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0)); 1378 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, 0));
1392 GL_CALL(DeleteFramebuffers(1, &fb)); 1379 GL_CALL(DeleteFramebuffers(1, &fb));
1393 } 1380 }
1394 SkASSERT(kUnknownStencilIndex != fPixelConfigToStencilIndex[config]); 1381 SkASSERT(ConfigEntry::kUnknown_StencilIndex != fConfigTable[config].fStencil FormatIndex);
1395 return fPixelConfigToStencilIndex[config]; 1382 return fConfigTable[config].fStencilFormatIndex;
1396 } 1383 }
1397 1384
1398 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen derTarget* rt, 1385 GrStencilAttachment* GrGLGpu::createStencilAttachmentForRenderTarget(const GrRen derTarget* rt,
1399 int width, 1386 int width,
1400 int height) { 1387 int height) {
1401 // All internally created RTs are also textures. We don't create 1388 // All internally created RTs are also textures. We don't create
1402 // SBs for a client's standalone RT (that is a RT that isn't also a texture) . 1389 // SBs for a client's standalone RT (that is a RT that isn't also a texture) .
1403 SkASSERT(rt->asTexture()); 1390 SkASSERT(rt->asTexture());
1404 SkASSERT(width >= rt->width()); 1391 SkASSERT(width >= rt->width());
1405 SkASSERT(height >= rt->height()); 1392 SkASSERT(height >= rt->height());
1406 1393
1407 int samples = rt->numStencilSamples(); 1394 int samples = rt->numStencilSamples();
1408 GrGLStencilAttachment::IDDesc sbDesc; 1395 GrGLStencilAttachment::IDDesc sbDesc;
1409 1396
1410 int sIdx = this->getCompatibleStencilIndex(rt->config()); 1397 int sIdx = this->getCompatibleStencilIndex(rt->config());
1411 if (sIdx == kUnsupportedStencilIndex) { 1398 if (sIdx < 0) {
1412 return nullptr; 1399 return nullptr;
1413 } 1400 }
1414 1401
1415 if (!sbDesc.fRenderbufferID) { 1402 if (!sbDesc.fRenderbufferID) {
1416 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID)); 1403 GL_CALL(GenRenderbuffers(1, &sbDesc.fRenderbufferID));
1417 } 1404 }
1418 if (!sbDesc.fRenderbufferID) { 1405 if (!sbDesc.fRenderbufferID) {
1419 return nullptr; 1406 return nullptr;
1420 } 1407 }
1421 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID)); 1408 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, sbDesc.fRenderbufferID));
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 this->setVertexArrayID(gpu, 0); 3642 this->setVertexArrayID(gpu, 0);
3656 } 3643 }
3657 int attrCount = gpu->glCaps().maxVertexAttributes(); 3644 int attrCount = gpu->glCaps().maxVertexAttributes();
3658 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3645 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3659 fDefaultVertexArrayAttribState.resize(attrCount); 3646 fDefaultVertexArrayAttribState.resize(attrCount);
3660 } 3647 }
3661 attribState = &fDefaultVertexArrayAttribState; 3648 attribState = &fDefaultVertexArrayAttribState;
3662 } 3649 }
3663 return attribState; 3650 return attribState;
3664 } 3651 }
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