| 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 fRGBA8RenderbufferSupport = false; | 29 fRGBA8RenderbufferSupport = false; |
| 30 fBGRAIsInternalFormat = false; | 30 fBGRAIsInternalFormat = 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; | |
| 40 fVertexArrayObjectSupport = false; | 39 fVertexArrayObjectSupport = false; |
| 41 fDirectStateAccessSupport = false; | 40 fDirectStateAccessSupport = false; |
| 42 fDebugSupport = false; | 41 fDebugSupport = false; |
| 43 fES2CompatibilitySupport = false; | 42 fES2CompatibilitySupport = false; |
| 44 fMultisampleDisableSupport = false; | 43 fMultisampleDisableSupport = false; |
| 45 fUseNonVBOVertexAndIndexDynamicData = false; | 44 fUseNonVBOVertexAndIndexDynamicData = false; |
| 46 fIsCoreProfile = false; | 45 fIsCoreProfile = false; |
| 47 fBindFragDataLocationSupport = false; | 46 fBindFragDataLocationSupport = false; |
| 48 fExternalTextureSupport = false; | 47 fExternalTextureSupport = false; |
| 49 fSRGBWriteControl = false; | 48 fSRGBWriteControl = false; |
| 50 fRGBA8888PixelsOpsAreSlow = false; | 49 fRGBA8888PixelsOpsAreSlow = false; |
| 51 fPartialFBOReadIsSlow = false; | 50 fPartialFBOReadIsSlow = false; |
| 52 | 51 |
| 53 fReadPixelsSupportedCache.reset(); | |
| 54 | |
| 55 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); | 52 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); |
| 56 | 53 |
| 57 this->init(contextOptions, ctxInfo, glInterface); | 54 this->init(contextOptions, ctxInfo, glInterface); |
| 58 } | 55 } |
| 59 | 56 |
| 60 void GrGLCaps::init(const GrContextOptions& contextOptions, | 57 void GrGLCaps::init(const GrContextOptions& contextOptions, |
| 61 const GrGLContextInfo& ctxInfo, | 58 const GrGLContextInfo& ctxInfo, |
| 62 const GrGLInterface* gli) { | 59 const GrGLInterface* gli) { |
| 63 GrGLStandard standard = ctxInfo.standard(); | 60 GrGLStandard standard = ctxInfo.standard(); |
| 64 GrGLVersion version = ctxInfo.version(); | 61 GrGLVersion version = ctxInfo.version(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 fTextureRedSupport = version >= GR_GL_VER(3,0) || | 134 fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 138 ctxInfo.hasExtension("GL_ARB_texture_rg"); | 135 ctxInfo.hasExtension("GL_ARB_texture_rg"); |
| 139 } else { | 136 } else { |
| 140 fTextureRedSupport = version >= GR_GL_VER(3,0) || | 137 fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 141 ctxInfo.hasExtension("GL_EXT_texture_rg"); | 138 ctxInfo.hasExtension("GL_EXT_texture_rg"); |
| 142 } | 139 } |
| 143 } | 140 } |
| 144 fImagingSupport = kGL_GrGLStandard == standard && | 141 fImagingSupport = kGL_GrGLStandard == standard && |
| 145 ctxInfo.hasExtension("GL_ARB_imaging"); | 142 ctxInfo.hasExtension("GL_ARB_imaging"); |
| 146 | 143 |
| 147 // ES 2 only guarantees RGBA/uchar + one other format/type combo for | |
| 148 // ReadPixels. The other format has to checked at run-time since it | |
| 149 // can change based on which render target is bound | |
| 150 fTwoFormatLimit = kGLES_GrGLStandard == standard; | |
| 151 | |
| 152 // We only enable srgb support if both textures and FBOs support srgb. | 144 // We only enable srgb support if both textures and FBOs support srgb. |
| 153 bool srgbSupport = false; | 145 bool srgbSupport = false; |
| 154 if (kGL_GrGLStandard == standard) { | 146 if (kGL_GrGLStandard == standard) { |
| 155 if (ctxInfo.version() >= GR_GL_VER(3,0)) { | 147 if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
| 156 srgbSupport = true; | 148 srgbSupport = true; |
| 157 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { | 149 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { |
| 158 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || | 150 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
| 159 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { | 151 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
| 160 srgbSupport = true; | 152 srgbSupport = true; |
| 161 } | 153 } |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1); | 945 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1); |
| 954 if (!hasHalfFPTextures) { | 946 if (!hasHalfFPTextures) { |
| 955 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || | 947 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || |
| 956 (ctxInfo.hasExtension("GL_OES_texture_half_float_lin
ear") && | 948 (ctxInfo.hasExtension("GL_OES_texture_half_float_lin
ear") && |
| 957 ctxInfo.hasExtension("GL_OES_texture_half_float")); | 949 ctxInfo.hasExtension("GL_OES_texture_half_float")); |
| 958 } | 950 } |
| 959 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures; | 951 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures; |
| 960 fConfigTextureSupport[kRGBA_half_GrPixelConfig] = hasHalfFPTextures; | 952 fConfigTextureSupport[kRGBA_half_GrPixelConfig] = hasHalfFPTextures; |
| 961 } | 953 } |
| 962 | 954 |
| 963 bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, | 955 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 964 GrGLenum format, | 956 GrPixelConfig readConfig, |
| 965 GrGLenum type) const { | 957 GrPixelConfig currFBOConfig) const { |
| 966 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { | 958 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); |
| 967 // ES 2 guarantees this format is supported | 959 |
| 960 if (kGL_GrGLStandard == intf->fStandard) { |
| 961 // All of our renderable configs can be converted to each other by glRea
dPixels in OpenGL. |
| 968 return true; | 962 return true; |
| 969 } | 963 } |
| 964 // See Section 16.1.2 in the ES 3.2 specification. |
| 970 | 965 |
| 971 if (!fTwoFormatLimit) { | 966 GrGLenum readFormat = fConfigTable[readConfig].fFormats.fExternalFormat; |
| 972 // not limited by ES 2's constraints | 967 GrGLenum readType = fConfigTable[readConfig].fFormats.fExternalType; |
| 973 return true; | 968 |
| 969 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT
ype) { |
| 970 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { |
| 971 return true; |
| 972 } |
| 973 } else { |
| 974 SkASSERT(kFloat_FormatType == fConfigTable[currFBOConfig].fFormatType); |
| 975 if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) { |
| 976 return true; |
| 977 } |
| 974 } | 978 } |
| 975 | 979 |
| 976 GrGLint otherFormat = GR_GL_RGBA; | 980 if (0 == fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fFormat) { |
| 977 GrGLint otherType = GR_GL_UNSIGNED_BYTE; | 981 ReadPixelsFormat* rpFormat = |
| 982 const_cast<ReadPixelsFormat*>(&fConfigTable[currFBOConfig].fSecondRe
adPixelsFormat); |
| 983 GrGLint format = 0, type = 0; |
| 984 GR_GL_GetIntegerv(intf, GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format)
; |
| 985 GR_GL_GetIntegerv(intf, GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, &type); |
| 986 rpFormat->fFormat = format; |
| 987 rpFormat->fType = type; |
| 988 } |
| 978 | 989 |
| 979 // The other supported format/type combo supported for ReadPixels | 990 return fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fFormat == readFo
rmat && |
| 980 // can change based on which render target is bound | 991 fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fType == readType
; |
| 981 GR_GL_GetIntegerv(intf, | |
| 982 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, | |
| 983 &otherFormat); | |
| 984 | |
| 985 GR_GL_GetIntegerv(intf, | |
| 986 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, | |
| 987 &otherType); | |
| 988 | |
| 989 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; | |
| 990 } | |
| 991 | |
| 992 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, | |
| 993 GrGLenum format, | |
| 994 GrGLenum type, | |
| 995 GrGLenum currFboFormat) const { | |
| 996 ReadPixelsSupportedFormat key = {format, type, currFboFormat}; | |
| 997 if (const bool* supported = fReadPixelsSupportedCache.find(key)) { | |
| 998 return *supported; | |
| 999 } | |
| 1000 bool supported = this->doReadPixelsSupported(intf, format, type); | |
| 1001 fReadPixelsSupportedCache.set(key, supported); | |
| 1002 return supported; | |
| 1003 } | 992 } |
| 1004 | 993 |
| 1005 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { | 994 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { |
| 1006 | 995 |
| 1007 fMSFBOType = kNone_MSFBOType; | 996 fMSFBOType = kNone_MSFBOType; |
| 1008 if (kGL_GrGLStandard != ctxInfo.standard()) { | 997 if (kGL_GrGLStandard != ctxInfo.standard()) { |
| 1009 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed | 998 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
| 1010 // ES3 driver bugs on at least one device with a tiled GPU (N10). | 999 // ES3 driver bugs on at least one device with a tiled GPU (N10). |
| 1011 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { | 1000 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 1012 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; | 1001 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); | 1192 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); |
| 1204 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); | 1193 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); |
| 1205 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); | 1194 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); |
| 1206 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); | 1195 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); |
| 1207 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); | 1196 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
| 1208 | 1197 |
| 1209 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); | 1198 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); |
| 1210 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); | 1199 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); |
| 1211 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); | 1200 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
| 1212 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 1201 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
| 1213 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | |
| 1214 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 1202 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
| 1215 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); | 1203 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); |
| 1216 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); | 1204 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); |
| 1217 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); | 1205 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); |
| 1218 r.appendf("Use non-VBO for dynamic data: %s\n", | 1206 r.appendf("Use non-VBO for dynamic data: %s\n", |
| 1219 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 1207 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 1220 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); | 1208 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); |
| 1221 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ?
"YES" : "NO")); | 1209 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ?
"YES" : "NO")); |
| 1222 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" :
"NO")); | 1210 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" :
"NO")); |
| 1223 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor
t ? "YES" : "NO")); | 1211 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor
t ? "YES" : "NO")); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; | 1332 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; |
| 1345 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; | 1333 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; |
| 1346 | 1334 |
| 1347 } | 1335 } |
| 1348 | 1336 |
| 1349 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo) { | 1337 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo) { |
| 1350 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; | 1338 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; |
| 1351 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; | 1339 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; |
| 1352 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; | 1340 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1353 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; | 1341 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; |
| 1342 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1354 | 1343 |
| 1355 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; | 1344 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; |
| 1356 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA8; | 1345 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA8; |
| 1357 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; | 1346 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; |
| 1358 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_BYTE; | 1347 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_BYTE; |
| 1348 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; |
| 1359 | 1349 |
| 1360 if (this->bgraIsInternalFormat()) { | 1350 if (this->bgraIsInternalFormat()) { |
| 1361 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_BGRA; | 1351 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_BGRA; |
| 1362 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_BGRA8; | 1352 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_BGRA8; |
| 1363 } else { | 1353 } else { |
| 1364 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_RGBA; | 1354 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_RGBA; |
| 1365 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_RGBA8; | 1355 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_RGBA8; |
| 1366 } | 1356 } |
| 1367 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; | 1357 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; |
| 1368 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1358 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
| 1359 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; |
| 1369 | 1360 |
| 1370 | 1361 |
| 1371 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; | 1362 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; |
| 1372 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; | 1363 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; |
| 1373 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the | 1364 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the |
| 1374 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. | 1365 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. |
| 1375 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; | 1366 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; |
| 1376 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1367 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
| 1377 | 1368 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
| 1378 | 1369 |
| 1379 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG
B; | 1370 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG
B; |
| 1380 if (this->ES2CompatibilitySupport()) { | 1371 if (this->ES2CompatibilitySupport()) { |
| 1381 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB565; | 1372 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB565; |
| 1382 } else { | 1373 } else { |
| 1383 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB5; | 1374 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB5; |
| 1384 } | 1375 } |
| 1385 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; | 1376 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; |
| 1386 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_SHORT_5_6_5; | 1377 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_SHORT_5_6_5; |
| 1378 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1387 | 1379 |
| 1388 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; | 1380 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; |
| 1389 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA4; | 1381 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA4; |
| 1390 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; | 1382 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; |
| 1391 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_SHORT_4_4_4_4; | 1383 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_SHORT_4_4_4_4; |
| 1384 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; |
| 1392 | 1385 |
| 1393 | 1386 |
| 1394 if (this->textureRedSupport()) { | 1387 if (this->textureRedSupport()) { |
| 1395 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_RED; | 1388 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_RED; |
| 1396 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_R8; | 1389 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_R8; |
| 1397 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE
D; | 1390 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE
D; |
| 1398 } else { | 1391 } else { |
| 1399 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_ALPHA; | 1392 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_ALPHA; |
| 1400 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_ALPHA8; | 1393 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_ALPHA8; |
| 1401 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL
PHA; | 1394 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL
PHA; |
| 1402 } | 1395 } |
| 1403 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_BYTE; | 1396 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_BYTE; |
| 1397 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1404 | 1398 |
| 1405 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_RGBA; | 1399 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_RGBA; |
| 1406 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_RGBA32F; | 1400 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_RGBA32F; |
| 1407 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; | 1401 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; |
| 1408 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT
; | 1402 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT
; |
| 1403 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; |
| 1409 | 1404 |
| 1410 if (this->textureRedSupport()) { | 1405 if (this->textureRedSupport()) { |
| 1411 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_RED; | 1406 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_RED; |
| 1412 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_R16F; | 1407 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_R16F; |
| 1413 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_RED; | 1408 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_RED; |
| 1414 } else { | 1409 } else { |
| 1415 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_ALPHA; | 1410 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_ALPHA; |
| 1416 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_ALPHA16F; | 1411 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_ALPHA16F; |
| 1417 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_ALPHA; | 1412 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_ALPHA; |
| 1418 } | 1413 } |
| 1419 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { | 1414 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { |
| 1420 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT; | 1415 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT; |
| 1421 } else { | 1416 } else { |
| 1422 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT_OES; | 1417 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT_OES; |
| 1423 } | 1418 } |
| 1419 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; |
| 1424 | 1420 |
| 1425 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; | 1421 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; |
| 1426 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA16F; | 1422 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA16F; |
| 1427 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; | 1423 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; |
| 1428 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { | 1424 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { |
| 1429 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT; | 1425 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT; |
| 1430 } else { | 1426 } else { |
| 1431 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT_OES; | 1427 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT_OES; |
| 1432 } | 1428 } |
| 1429 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; |
| 1433 | 1430 |
| 1434 // No sized/unsized internal format distinction for compressed formats, no e
xternal format. | 1431 // No sized/unsized internal format distinction for compressed formats, no e
xternal format. |
| 1435 | 1432 |
| 1436 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA
LETTE8_RGBA8; | 1433 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA
LETTE8_RGBA8; |
| 1437 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P
ALETTE8_RGBA8; | 1434 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P
ALETTE8_RGBA8; |
| 1438 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; | 1435 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1439 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; | 1436 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; |
| 1437 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1440 | 1438 |
| 1441 switch(this->latcAlias()) { | 1439 switch(this->latcAlias()) { |
| 1442 case GrGLCaps::kLATC_LATCAlias: | 1440 case GrGLCaps::kLATC_LATCAlias: |
| 1443 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = | 1441 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = |
| 1444 GR_GL_COMPRESSED_LUMINANCE_LATC1; | 1442 GR_GL_COMPRESSED_LUMINANCE_LATC1; |
| 1445 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = | 1443 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1446 GR_GL_COMPRESSED_LUMINANCE_LATC1; | 1444 GR_GL_COMPRESSED_LUMINANCE_LATC1; |
| 1447 break; | 1445 break; |
| 1448 case GrGLCaps::kRGTC_LATCAlias: | 1446 case GrGLCaps::kRGTC_LATCAlias: |
| 1449 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = | 1447 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = |
| 1450 GR_GL_COMPRESSED_RED_RGTC1; | 1448 GR_GL_COMPRESSED_RED_RGTC1; |
| 1451 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = | 1449 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1452 GR_GL_COMPRESSED_RED_RGTC1; | 1450 GR_GL_COMPRESSED_RED_RGTC1; |
| 1453 break; | 1451 break; |
| 1454 case GrGLCaps::k3DC_LATCAlias: | 1452 case GrGLCaps::k3DC_LATCAlias: |
| 1455 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_
GL_COMPRESSED_3DC_X; | 1453 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_
GL_COMPRESSED_3DC_X; |
| 1456 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = | 1454 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1457 GR_GL_COMPRESSED_3DC_X; | 1455 GR_GL_COMPRESSED_3DC_X; |
| 1458 break; | 1456 break; |
| 1459 } | 1457 } |
| 1460 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; | 1458 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1461 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; | 1459 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; |
| 1460 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format
Type; |
| 1462 | 1461 |
| 1463 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR
ESSED_ETC1_RGB8; | 1462 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR
ESSED_ETC1_RGB8; |
| 1464 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP
RESSED_ETC1_RGB8; | 1463 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP
RESSED_ETC1_RGB8; |
| 1465 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; | 1464 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1466 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; | 1465 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; |
| 1466 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format
Type; |
| 1467 | 1467 |
| 1468 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO
MPRESSED_R11_EAC; | 1468 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO
MPRESSED_R11_EAC; |
| 1469 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C
OMPRESSED_R11_EAC; | 1469 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C
OMPRESSED_R11_EAC; |
| 1470 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; | 1470 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1471 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; | 1471 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; |
| 1472 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1472 | 1473 |
| 1473 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = | 1474 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = |
| 1474 GR_GL_COMPRESSED_RGBA_ASTC_12x12; | 1475 GR_GL_COMPRESSED_RGBA_ASTC_12x12; |
| 1475 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = | 1476 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1476 GR_GL_COMPRESSED_RGBA_ASTC_12x12; | 1477 GR_GL_COMPRESSED_RGBA_ASTC_12x12; |
| 1477 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; | 1478 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1478 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; | 1479 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; |
| 1480 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
| 1479 | 1481 |
| 1480 // Bulk populate the texture internal/external formats here and then deal wi
th exceptions below. | 1482 // Bulk populate the texture internal/external formats here and then deal wi
th exceptions below. |
| 1481 | 1483 |
| 1482 // ES 2.0 requires that the internal/external formats match. | 1484 // ES 2.0 requires that the internal/external formats match. |
| 1483 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || | 1485 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || |
| 1484 ctxInfo.version() >= GR_GL_VER(3,0)); | 1486 ctxInfo.version() >= GR_GL_VER(3,0)); |
| 1485 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 1487 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 1486 // Almost always we want to pass fExternalFormat as the <format> param t
o glTex[Sub]Image. | 1488 // Almost always we want to pass fExternalFormat as the <format> param t
o glTex[Sub]Image. |
| 1487 fConfigTable[i].fFormats.fExternalFormatForTexImage = | 1489 fConfigTable[i].fFormats.fExternalFormatForTexImage = |
| 1488 fConfigTable[i].fFormats.fExternalFormat; | 1490 fConfigTable[i].fFormats.fExternalFormat; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 fConfigTable[i].fFormats.fSizedInternalFormat); | 1524 fConfigTable[i].fFormats.fSizedInternalFormat); |
| 1523 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter
nalFormat); | 1525 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter
nalFormat); |
| 1524 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna
lType); | 1526 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna
lType); |
| 1525 } | 1527 } |
| 1526 #endif | 1528 #endif |
| 1527 } | 1529 } |
| 1528 | 1530 |
| 1529 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} | 1531 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} |
| 1530 | 1532 |
| 1531 | 1533 |
| OLD | NEW |