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

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

Issue 1420033005: Create swizzle table inside of glsl caps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | 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 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();
21 fMSFBOType = kNone_MSFBOType; 22 fMSFBOType = kNone_MSFBOType;
22 fInvalidateFBType = kNone_InvalidateFBType; 23 fInvalidateFBType = kNone_InvalidateFBType;
23 fLATCAlias = kLATC_LATCAlias; 24 fLATCAlias = kLATC_LATCAlias;
24 fMapBufferType = kNone_MapBufferType; 25 fMapBufferType = kNone_MapBufferType;
25 fMaxFragmentUniformVectors = 0; 26 fMaxFragmentUniformVectors = 0;
26 fMaxVertexAttributes = 0; 27 fMaxVertexAttributes = 0;
27 fMaxFragmentTextureUnits = 0; 28 fMaxFragmentTextureUnits = 0;
28 fRGBA8RenderbufferSupport = false; 29 fRGBA8RenderbufferSupport = false;
29 fBGRAIsInternalFormat = false; 30 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
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) {
104 fUnpackRowLengthSupport = true; 97 fUnpackRowLengthSupport = true;
105 fUnpackFlipYSupport = false; 98 fUnpackFlipYSupport = false;
106 fPackRowLengthSupport = true; 99 fPackRowLengthSupport = true;
107 fPackFlipYSupport = false; 100 fPackFlipYSupport = false;
108 } else { 101 } else {
109 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || 102 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) ||
110 ctxInfo.hasExtension("GL_EXT_unpack_subimage") ; 103 ctxInfo.hasExtension("GL_EXT_unpack_subimage") ;
111 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); 104 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
112 fPackRowLengthSupport = version >= GR_GL_VER(3,0) || 105 fPackRowLengthSupport = version >= GR_GL_VER(3,0) ||
113 ctxInfo.hasExtension("GL_NV_pack_subimage"); 106 ctxInfo.hasExtension("GL_NV_pack_subimage");
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } else { 477 } else {
485 fSupportsInstancedDraws = 478 fSupportsInstancedDraws =
486 version >= GR_GL_VER(3, 0) || 479 version >= GR_GL_VER(3, 0) ||
487 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && 480 (ctxInfo.hasExtension("GL_EXT_draw_instanced") &&
488 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); 481 ctxInfo.hasExtension("GL_EXT_instanced_arrays"));
489 } 482 }
490 483
491 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); 484 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport);
492 this->initConfigRenderableTable(ctxInfo, srgbSupport); 485 this->initConfigRenderableTable(ctxInfo, srgbSupport);
493 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); 486 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
487 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t his point.
488 this->initConfigSwizzleTable(ctxInfo, glslCaps);
494 489
495 this->applyOptionsOverrides(contextOptions); 490 this->applyOptionsOverrides(contextOptions);
496 glslCaps->applyOptionsOverrides(contextOptions); 491 glslCaps->applyOptionsOverrides(contextOptions);
497 } 492 }
498 493
499 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation, 494 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation,
500 bool isCoreProfile) { 495 bool isCoreProfile) {
501 switch (generation) { 496 switch (generation) {
502 case k110_GrGLSLGeneration: 497 case k110_GrGLSLGeneration:
503 if (kGLES_GrGLStandard == standard) { 498 if (kGLES_GrGLStandard == standard) {
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 1157
1163 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); 1158 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
1164 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); 1159 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
1165 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType ]); 1160 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType ]);
1166 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); 1161 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
1167 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); 1162 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
1168 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); 1163 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
1169 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); 1164 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
1170 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); 1165 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
1171 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES" : "NO")); 1166 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES" : "NO"));
1172 r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO"));
1173 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES ": "NO")); 1167 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES ": "NO"));
1174 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO") ); 1168 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO") );
1175 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": " NO")); 1169 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": " NO"));
1176 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); 1170 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
1177 1171
1178 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO" )); 1172 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO" ));
1179 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO" )); 1173 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO" ));
1180 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); 1174 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
1181 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); 1175 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
1182 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); 1176 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that 1267 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
1274 // are recommended against. 1268 // are recommended against.
1275 if (glslCaps->fGeometryShaderSupport) { 1269 if (glslCaps->fGeometryShaderSupport) {
1276 for (int p = 0; p < kGrSLPrecisionCount; ++p) { 1270 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
1277 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = 1271 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
1278 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p]; 1272 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p];
1279 } 1273 }
1280 } 1274 }
1281 } 1275 }
1282 1276
1277 void GrGLCaps::initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps * glslCaps) {
1278 GrGLStandard standard = ctxInfo.standard();
1279 GrGLVersion version = ctxInfo.version();
1280
1281 glslCaps->fMustSwizzleInShader = true;
1282 if (kGL_GrGLStandard == standard) {
1283 if (version >= GR_GL_VER(3,3) || ctxInfo.hasExtension("GL_ARB_texture_sw izzle")) {
1284 glslCaps->fMustSwizzleInShader = false;
1285 }
1286 } else {
1287 if (version >= GR_GL_VER(3,0)) {
1288 glslCaps->fMustSwizzleInShader = false;
1289 }
1290 }
1291
1292 glslCaps->fConfigSwizzle[kUnknown_GrPixelConfig] = nullptr;
1293 if (fTextureRedSupport) {
1294 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "rrrr";
1295 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "rrrr";
1296 } else {
1297 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "aaaa";
1298 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "aaaa";
1299 }
1300 glslCaps->fConfigSwizzle[kIndex_8_GrPixelConfig] = "rgba";
1301 glslCaps->fConfigSwizzle[kRGB_565_GrPixelConfig] = "rgba";
1302 glslCaps->fConfigSwizzle[kRGBA_4444_GrPixelConfig] = "rgba";
1303 glslCaps->fConfigSwizzle[kRGBA_8888_GrPixelConfig] = "rgba";
1304 glslCaps->fConfigSwizzle[kBGRA_8888_GrPixelConfig] = "rgba";
1305 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba";
1306 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba";
1307 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr";
1308 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr";
1309 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba";
1310 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba";
1311 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba";
1312
1313 }
1314
1315 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
1283 1316
1284 1317
1285
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698