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" | |
12 #include "GrGLContext.h" | 11 #include "GrGLContext.h" |
13 #include "glsl/GrGLSLCaps.h" | 12 #include "glsl/GrGLSLCaps.h" |
14 #include "SkTSearch.h" | 13 #include "SkTSearch.h" |
15 #include "SkTSort.h" | 14 #include "SkTSort.h" |
16 | 15 |
17 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, | 16 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, |
18 const GrGLContextInfo& ctxInfo, | 17 const GrGLContextInfo& ctxInfo, |
19 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ | 18 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ |
20 fVerifiedColorConfigs.reset(); | 19 fVerifiedColorConfigs.reset(); |
21 fStencilFormats.reset(); | 20 fStencilFormats.reset(); |
22 fMSFBOType = kNone_MSFBOType; | 21 fMSFBOType = kNone_MSFBOType; |
23 fInvalidateFBType = kNone_InvalidateFBType; | 22 fInvalidateFBType = kNone_InvalidateFBType; |
24 fLATCAlias = kLATC_LATCAlias; | 23 fLATCAlias = kLATC_LATCAlias; |
25 fMapBufferType = kNone_MapBufferType; | 24 fMapBufferType = kNone_MapBufferType; |
26 fMaxFragmentUniformVectors = 0; | 25 fMaxFragmentUniformVectors = 0; |
27 fMaxVertexAttributes = 0; | 26 fMaxVertexAttributes = 0; |
28 fMaxFragmentTextureUnits = 0; | 27 fMaxFragmentTextureUnits = 0; |
29 fRGBA8RenderbufferSupport = false; | 28 fRGBA8RenderbufferSupport = false; |
30 fBGRAIsInternalFormat = false; | 29 fBGRAIsInternalFormat = false; |
| 30 fTextureSwizzleSupport = false; |
31 fUnpackRowLengthSupport = false; | 31 fUnpackRowLengthSupport = false; |
32 fUnpackFlipYSupport = false; | 32 fUnpackFlipYSupport = false; |
33 fPackRowLengthSupport = false; | 33 fPackRowLengthSupport = false; |
34 fPackFlipYSupport = false; | 34 fPackFlipYSupport = false; |
35 fTextureUsageSupport = false; | 35 fTextureUsageSupport = false; |
36 fTexStorageSupport = false; | 36 fTexStorageSupport = false; |
37 fTextureRedSupport = false; | 37 fTextureRedSupport = false; |
38 fImagingSupport = false; | 38 fImagingSupport = false; |
39 fTwoFormatLimit = false; | 39 fTwoFormatLimit = false; |
40 fFragCoordsConventionSupport = false; | 40 fFragCoordsConventionSupport = false; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 if (kGL_GrGLStandard == standard) { | 88 if (kGL_GrGLStandard == standard) { |
89 fRGBA8RenderbufferSupport = true; | 89 fRGBA8RenderbufferSupport = true; |
90 } else { | 90 } else { |
91 fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) || | 91 fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) || |
92 ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || | 92 ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || |
93 ctxInfo.hasExtension("GL_ARM_rgba8"); | 93 ctxInfo.hasExtension("GL_ARM_rgba8"); |
94 } | 94 } |
95 | 95 |
96 if (kGL_GrGLStandard == standard) { | 96 if (kGL_GrGLStandard == standard) { |
| 97 fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || |
| 98 ctxInfo.hasExtension("GL_ARB_texture_swizzle"); |
| 99 } else { |
| 100 fTextureSwizzleSupport = version >= GR_GL_VER(3,0); |
| 101 } |
| 102 |
| 103 if (kGL_GrGLStandard == standard) { |
97 fUnpackRowLengthSupport = true; | 104 fUnpackRowLengthSupport = true; |
98 fUnpackFlipYSupport = false; | 105 fUnpackFlipYSupport = false; |
99 fPackRowLengthSupport = true; | 106 fPackRowLengthSupport = true; |
100 fPackFlipYSupport = false; | 107 fPackFlipYSupport = false; |
101 } else { | 108 } else { |
102 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || | 109 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || |
103 ctxInfo.hasExtension("GL_EXT_unpack_subimage")
; | 110 ctxInfo.hasExtension("GL_EXT_unpack_subimage")
; |
104 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); | 111 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); |
105 fPackRowLengthSupport = version >= GR_GL_VER(3,0) || | 112 fPackRowLengthSupport = version >= GR_GL_VER(3,0) || |
106 ctxInfo.hasExtension("GL_NV_pack_subimage"); | 113 ctxInfo.hasExtension("GL_NV_pack_subimage"); |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 } else { | 484 } else { |
478 fSupportsInstancedDraws = | 485 fSupportsInstancedDraws = |
479 version >= GR_GL_VER(3, 0) || | 486 version >= GR_GL_VER(3, 0) || |
480 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && | 487 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && |
481 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); | 488 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); |
482 } | 489 } |
483 | 490 |
484 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); | 491 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); |
485 this->initConfigRenderableTable(ctxInfo, srgbSupport); | 492 this->initConfigRenderableTable(ctxInfo, srgbSupport); |
486 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); | 493 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); |
487 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t
his point. | |
488 this->initConfigSwizzleTable(ctxInfo, glslCaps); | |
489 | 494 |
490 this->applyOptionsOverrides(contextOptions); | 495 this->applyOptionsOverrides(contextOptions); |
491 glslCaps->applyOptionsOverrides(contextOptions); | 496 glslCaps->applyOptionsOverrides(contextOptions); |
492 } | 497 } |
493 | 498 |
494 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, | 499 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, |
495 bool isCoreProfile) { | 500 bool isCoreProfile) { |
496 switch (generation) { | 501 switch (generation) { |
497 case k110_GrGLSLGeneration: | 502 case k110_GrGLSLGeneration: |
498 if (kGLES_GrGLStandard == standard) { | 503 if (kGLES_GrGLStandard == standard) { |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 | 1162 |
1158 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); | 1163 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
1159 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); | 1164 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
1160 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); | 1165 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); |
1161 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); | 1166 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); |
1162 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); | 1167 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
1163 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); | 1168 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
1164 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); | 1169 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
1165 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); | 1170 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); |
1166 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); | 1171 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); |
| 1172 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES":
"NO")); |
1167 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); | 1173 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); |
1168 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); | 1174 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); |
1169 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); | 1175 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); |
1170 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); | 1176 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
1171 | 1177 |
1172 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); | 1178 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); |
1173 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); | 1179 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); |
1174 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); | 1180 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
1175 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 1181 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
1176 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 1182 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 // highp. GS was added after GetShaderPrecisionFormat was added to the list
of features that | 1273 // highp. GS was added after GetShaderPrecisionFormat was added to the list
of features that |
1268 // are recommended against. | 1274 // are recommended against. |
1269 if (glslCaps->fGeometryShaderSupport) { | 1275 if (glslCaps->fGeometryShaderSupport) { |
1270 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | 1276 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
1271 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = | 1277 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = |
1272 glslCaps->fFloatPrecisions[kVerte
x_GrShaderType][p]; | 1278 glslCaps->fFloatPrecisions[kVerte
x_GrShaderType][p]; |
1273 } | 1279 } |
1274 } | 1280 } |
1275 } | 1281 } |
1276 | 1282 |
1277 void GrGLCaps::initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps
* glslCaps) { | |
1278 GrGLStandard standard = ctxInfo.standard(); | |
1279 GrGLVersion version = ctxInfo.version(); | |
1280 | |
1281 if (kGL_GrGLStandard == standard) { | |
1282 glslCaps->fMustSwizzleInShader = version >= GR_GL_VER(3,3) || | |
1283 ctxInfo.hasExtension("GL_ARB_texture_sw
izzle"); | |
1284 } else { | |
1285 glslCaps->fMustSwizzleInShader = version >= GR_GL_VER(3,0); | |
1286 } | |
1287 | |
1288 glslCaps->fConfigSwizzle[kUnknown_GrPixelConfig] = nullptr; | |
1289 if (fTextureRedSupport) { | |
1290 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "rrrr"; | |
1291 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "rrrr"; | |
1292 } else { | |
1293 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "aaaa"; | |
1294 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "aaaa"; | |
1295 } | |
1296 glslCaps->fConfigSwizzle[kIndex_8_GrPixelConfig] = "rgba"; | |
1297 glslCaps->fConfigSwizzle[kRGB_565_GrPixelConfig] = "rgba"; | |
1298 glslCaps->fConfigSwizzle[kRGBA_4444_GrPixelConfig] = "rgba"; | |
1299 glslCaps->fConfigSwizzle[kRGBA_8888_GrPixelConfig] = "rgba"; | |
1300 glslCaps->fConfigSwizzle[kBGRA_8888_GrPixelConfig] = "rgba"; | |
1301 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba"; | |
1302 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba"; | |
1303 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr"; | |
1304 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr"; | |
1305 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba"; | |
1306 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; | |
1307 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; | |
1308 | |
1309 } | |
1310 | |
1311 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} | |
1312 | 1283 |
1313 | 1284 |
| 1285 |
OLD | NEW |