| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
| 10 | 10 |
| 11 #include "GrContextOptions.h" |
| 11 #include "GrGLContext.h" | 12 #include "GrGLContext.h" |
| 12 #include "glsl/GrGLSLCaps.h" | 13 #include "glsl/GrGLSLCaps.h" |
| 13 #include "SkTSearch.h" | 14 #include "SkTSearch.h" |
| 14 #include "SkTSort.h" | 15 #include "SkTSort.h" |
| 15 | 16 |
| 16 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, | 17 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, |
| 17 const GrGLContextInfo& ctxInfo, | 18 const GrGLContextInfo& ctxInfo, |
| 18 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ | 19 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ |
| 19 fVerifiedColorConfigs.reset(); | 20 fVerifiedColorConfigs.reset(); |
| 20 fStencilFormats.reset(); | 21 fStencilFormats.reset(); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } else { | 485 } else { |
| 485 fSupportsInstancedDraws = | 486 fSupportsInstancedDraws = |
| 486 version >= GR_GL_VER(3, 0) || | 487 version >= GR_GL_VER(3, 0) || |
| 487 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && | 488 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && |
| 488 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); | 489 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); |
| 489 } | 490 } |
| 490 | 491 |
| 491 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); | 492 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); |
| 492 this->initConfigRenderableTable(ctxInfo, srgbSupport); | 493 this->initConfigRenderableTable(ctxInfo, srgbSupport); |
| 493 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); | 494 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); |
| 495 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t
his point. |
| 496 this->initConfigSwizzleTable(glslCaps); |
| 494 | 497 |
| 495 this->applyOptionsOverrides(contextOptions); | 498 this->applyOptionsOverrides(contextOptions); |
| 496 glslCaps->applyOptionsOverrides(contextOptions); | 499 glslCaps->applyOptionsOverrides(contextOptions); |
| 497 } | 500 } |
| 498 | 501 |
| 499 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, | 502 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, |
| 500 bool isCoreProfile) { | 503 bool isCoreProfile) { |
| 501 switch (generation) { | 504 switch (generation) { |
| 502 case k110_GrGLSLGeneration: | 505 case k110_GrGLSLGeneration: |
| 503 if (kGLES_GrGLStandard == standard) { | 506 if (kGLES_GrGLStandard == standard) { |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 // highp. GS was added after GetShaderPrecisionFormat was added to the list
of features that | 1276 // highp. GS was added after GetShaderPrecisionFormat was added to the list
of features that |
| 1274 // are recommended against. | 1277 // are recommended against. |
| 1275 if (glslCaps->fGeometryShaderSupport) { | 1278 if (glslCaps->fGeometryShaderSupport) { |
| 1276 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | 1279 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
| 1277 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = | 1280 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = |
| 1278 glslCaps->fFloatPrecisions[kVerte
x_GrShaderType][p]; | 1281 glslCaps->fFloatPrecisions[kVerte
x_GrShaderType][p]; |
| 1279 } | 1282 } |
| 1280 } | 1283 } |
| 1281 } | 1284 } |
| 1282 | 1285 |
| 1286 void GrGLCaps::initConfigSwizzleTable(GrGLSLCaps* glslCaps) { |
| 1287 glslCaps->fMustSwizzleInShader = !this->textureSwizzleSupport(); |
| 1288 |
| 1289 glslCaps->fConfigSwizzle[kUnknown_GrPixelConfig] = nullptr; |
| 1290 if (fTextureRedSupport) { |
| 1291 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "rrrr"; |
| 1292 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "rrrr"; |
| 1293 } else { |
| 1294 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "aaaa"; |
| 1295 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "aaaa"; |
| 1296 } |
| 1297 glslCaps->fConfigSwizzle[kIndex_8_GrPixelConfig] = "rgba"; |
| 1298 glslCaps->fConfigSwizzle[kRGB_565_GrPixelConfig] = "rgba"; |
| 1299 glslCaps->fConfigSwizzle[kRGBA_4444_GrPixelConfig] = "rgba"; |
| 1300 glslCaps->fConfigSwizzle[kRGBA_8888_GrPixelConfig] = "rgba"; |
| 1301 glslCaps->fConfigSwizzle[kBGRA_8888_GrPixelConfig] = "rgba"; |
| 1302 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba"; |
| 1303 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba"; |
| 1304 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr"; |
| 1305 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr"; |
| 1306 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba"; |
| 1307 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; |
| 1308 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; |
| 1309 |
| 1310 } |
| 1311 |
| 1312 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) { |
| 1313 if (options.fUseShaderSwizzling) { |
| 1314 fTextureSwizzleSupport = false; |
| 1315 } |
| 1316 } |
| 1317 |
| 1283 | 1318 |
| 1284 | |
| 1285 | |
| OLD | NEW |