bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | |
| 9 | #include "GrGLCaps.h" |
joshualitt | b4384b9 | 2014-10-21 12:53:15 -0700 | [diff] [blame] | 10 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 11 | #include "GrGLContext.h" |
bsalomon@google.com | c9668ec | 2012-04-11 18:16:41 +0000 | [diff] [blame] | 12 | #include "SkTSearch.h" |
bsalomon@google.com | 20f7f17 | 2013-05-17 19:05:03 +0000 | [diff] [blame] | 13 | #include "SkTSort.h" |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 14 | |
| 15 | GrGLCaps::GrGLCaps() { |
| 16 | this->reset(); |
| 17 | } |
| 18 | |
| 19 | void GrGLCaps::reset() { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 20 | INHERITED::reset(); |
| 21 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 22 | fVerifiedColorConfigs.reset(); |
| 23 | fStencilFormats.reset(); |
| 24 | fStencilVerifiedColorConfigs.reset(); |
| 25 | fMSFBOType = kNone_MSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 26 | fInvalidateFBType = kNone_InvalidateFBType; |
krajcevski | 3217c4a | 2014-06-09 09:10:04 -0700 | [diff] [blame] | 27 | fLATCAlias = kLATC_LATCAlias; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 28 | fMapBufferType = kNone_MapBufferType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 29 | fMaxFragmentUniformVectors = 0; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 30 | fMaxVertexAttributes = 0; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 31 | fMaxFragmentTextureUnits = 0; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 32 | fMaxFixedFunctionTextureCoords = 0; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 33 | fRGBA8RenderbufferSupport = false; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 34 | fBGRAIsInternalFormat = false; |
| 35 | fTextureSwizzleSupport = false; |
| 36 | fUnpackRowLengthSupport = false; |
| 37 | fUnpackFlipYSupport = false; |
| 38 | fPackRowLengthSupport = false; |
| 39 | fPackFlipYSupport = false; |
| 40 | fTextureUsageSupport = false; |
| 41 | fTexStorageSupport = false; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 42 | fTextureRedSupport = false; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 43 | fImagingSupport = false; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 44 | fTwoFormatLimit = false; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 45 | fFragCoordsConventionSupport = false; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 46 | fVertexArrayObjectSupport = false; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 47 | fUseNonVBOVertexAndIndexDynamicData = false; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 48 | fIsCoreProfile = false; |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 49 | fFullClearIsFree = false; |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 50 | fDropsTileOnZeroDivide = false; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 51 | fFBFetchSupport = false; |
| 52 | fFBFetchColorName = NULL; |
| 53 | fFBFetchExtensionString = NULL; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 54 | |
| 55 | fReadPixelsSupportedCache.reset(); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 56 | } |
| 57 | |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 58 | GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 59 | *this = caps; |
| 60 | } |
| 61 | |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 62 | GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 63 | INHERITED::operator=(caps); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 64 | fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
| 65 | fStencilFormats = caps.fStencilFormats; |
| 66 | fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; |
krajcevski | 3217c4a | 2014-06-09 09:10:04 -0700 | [diff] [blame] | 67 | fLATCAlias = caps.fLATCAlias; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 68 | fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 69 | fMaxVertexAttributes = caps.fMaxVertexAttributes; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 70 | fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 71 | fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 72 | fMSFBOType = caps.fMSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 73 | fInvalidateFBType = caps.fInvalidateFBType; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 74 | fMapBufferType = caps.fMapBufferType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 75 | fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 76 | fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; |
| 77 | fTextureSwizzleSupport = caps.fTextureSwizzleSupport; |
| 78 | fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; |
| 79 | fUnpackFlipYSupport = caps.fUnpackFlipYSupport; |
| 80 | fPackRowLengthSupport = caps.fPackRowLengthSupport; |
| 81 | fPackFlipYSupport = caps.fPackFlipYSupport; |
| 82 | fTextureUsageSupport = caps.fTextureUsageSupport; |
| 83 | fTexStorageSupport = caps.fTexStorageSupport; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 84 | fTextureRedSupport = caps.fTextureRedSupport; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 85 | fImagingSupport = caps.fImagingSupport; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 86 | fTwoFormatLimit = caps.fTwoFormatLimit; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 87 | fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 88 | fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 89 | fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicData; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 90 | fIsCoreProfile = caps.fIsCoreProfile; |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 91 | fFullClearIsFree = caps.fFullClearIsFree; |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 92 | fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 93 | fFBFetchSupport = caps.fFBFetchSupport; |
| 94 | fFBFetchColorName = caps.fFBFetchColorName; |
| 95 | fFBFetchExtensionString = caps.fFBFetchExtensionString; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 96 | |
| 97 | return *this; |
| 98 | } |
| 99 | |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 100 | bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 101 | |
| 102 | this->reset(); |
| 103 | if (!ctxInfo.isInitialized()) { |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 104 | return false; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 105 | } |
| 106 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 107 | GrGLStandard standard = ctxInfo.standard(); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 108 | GrGLVersion version = ctxInfo.version(); |
| 109 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 110 | /************************************************************************** |
| 111 | * Caps specific to GrGLCaps |
| 112 | **************************************************************************/ |
| 113 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 114 | if (kGLES_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 115 | GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, |
| 116 | &fMaxFragmentUniformVectors); |
| 117 | } else { |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 118 | SkASSERT(kGL_GrGLStandard == standard); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 119 | GrGLint max; |
| 120 | GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &max); |
| 121 | fMaxFragmentUniformVectors = max / 4; |
commit-bot@chromium.org | 46fbfe0 | 2013-08-30 15:52:12 +0000 | [diff] [blame] | 122 | if (version >= GR_GL_VER(3, 2)) { |
| 123 | GrGLint profileMask; |
| 124 | GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); |
| 125 | fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_BIT); |
| 126 | } |
| 127 | if (!fIsCoreProfile) { |
| 128 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_COORDS, &fMaxFixedFunctionTextureCoords); |
| 129 | // Sanity check |
| 130 | SkASSERT(fMaxFixedFunctionTextureCoords > 0 && fMaxFixedFunctionTextureCoords < 128); |
| 131 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 132 | } |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 133 | GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 134 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUnits); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 135 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 136 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 137 | fRGBA8RenderbufferSupport = true; |
| 138 | } else { |
commit-bot@chromium.org | c5dffe4 | 2013-08-20 15:25:21 +0000 | [diff] [blame] | 139 | fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) || |
| 140 | ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 141 | ctxInfo.hasExtension("GL_ARM_rgba8"); |
| 142 | } |
| 143 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 144 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 145 | fTextureSwizzleSupport = version >= GR_GL_VER(3,3) || |
| 146 | ctxInfo.hasExtension("GL_ARB_texture_swizzle"); |
| 147 | } else { |
commit-bot@chromium.org | 6364b5e | 2013-08-20 20:22:52 +0000 | [diff] [blame] | 148 | fTextureSwizzleSupport = version >= GR_GL_VER(3,0); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 149 | } |
| 150 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 151 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 152 | fUnpackRowLengthSupport = true; |
| 153 | fUnpackFlipYSupport = false; |
| 154 | fPackRowLengthSupport = true; |
| 155 | fPackFlipYSupport = false; |
| 156 | } else { |
commit-bot@chromium.org | dc3134c | 2013-08-16 16:12:23 +0000 | [diff] [blame] | 157 | fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 158 | ctxInfo.hasExtension("GL_EXT_unpack_subimage"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 159 | fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); |
commit-bot@chromium.org | dc3134c | 2013-08-16 16:12:23 +0000 | [diff] [blame] | 160 | fPackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 161 | ctxInfo.hasExtension("GL_NV_pack_subimage"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 162 | fPackFlipYSupport = |
| 163 | ctxInfo.hasExtension("GL_ANGLE_pack_reverse_row_order"); |
| 164 | } |
| 165 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 166 | fTextureUsageSupport = (kGLES_GrGLStandard == standard) && |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 167 | ctxInfo.hasExtension("GL_ANGLE_texture_usage"); |
| 168 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 169 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 7a434a2 | 2013-08-21 14:01:56 +0000 | [diff] [blame] | 170 | // The EXT version can apply to either GL or GLES. |
| 171 | fTexStorageSupport = version >= GR_GL_VER(4,2) || |
| 172 | ctxInfo.hasExtension("GL_ARB_texture_storage") || |
| 173 | ctxInfo.hasExtension("GL_EXT_texture_storage"); |
| 174 | } else { |
| 175 | // Qualcomm Adreno drivers appear to have issues with texture storage. |
| 176 | fTexStorageSupport = (version >= GR_GL_VER(3,0) && |
| 177 | kQualcomm_GrGLVendor != ctxInfo.vendor()) || |
| 178 | ctxInfo.hasExtension("GL_EXT_texture_storage"); |
| 179 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 180 | |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 181 | // ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support it if |
| 182 | // it doesn't have ARB_texture_rg extension. |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 183 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 459104c | 2013-06-14 14:42:56 +0000 | [diff] [blame] | 184 | if (ctxInfo.isMesa()) { |
| 185 | fTextureRedSupport = ctxInfo.hasExtension("GL_ARB_texture_rg"); |
| 186 | } else { |
| 187 | fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 188 | ctxInfo.hasExtension("GL_ARB_texture_rg"); |
| 189 | } |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 190 | } else { |
commit-bot@chromium.org | c5dffe4 | 2013-08-20 15:25:21 +0000 | [diff] [blame] | 191 | fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 192 | ctxInfo.hasExtension("GL_EXT_texture_rg"); |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 193 | } |
| 194 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 195 | fImagingSupport = kGL_GrGLStandard == standard && |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 196 | ctxInfo.hasExtension("GL_ARB_imaging"); |
| 197 | |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 198 | // ES 2 only guarantees RGBA/uchar + one other format/type combo for |
| 199 | // ReadPixels. The other format has to checked at run-time since it |
| 200 | // can change based on which render target is bound |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 201 | fTwoFormatLimit = kGLES_GrGLStandard == standard; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 202 | |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 203 | // Frag Coords Convention support is not part of ES |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 204 | // Known issue on at least some Intel platforms: |
| 205 | // http://code.google.com/p/skia/issues/detail?id=946 |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 206 | if (kIntel_GrGLVendor != ctxInfo.vendor() && kGLES_GrGLStandard != standard) { |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 207 | fFragCoordsConventionSupport = ctxInfo.glslGeneration() >= k150_GrGLSLGeneration || |
| 208 | ctxInfo.hasExtension("GL_ARB_fragment_coord_conventions"); |
| 209 | } |
| 210 | |
bsalomon@google.com | 3012ded | 2013-02-22 16:44:04 +0000 | [diff] [blame] | 211 | // SGX and Mali GPUs that are based on a tiled-deferred architecture that have trouble with |
| 212 | // frequently changing VBOs. We've measured a performance increase using non-VBO vertex |
| 213 | // data for dynamic content on these GPUs. Perhaps we should read the renderer string and |
| 214 | // limit this decision to specific GPU families rather than basing it on the vendor alone. |
| 215 | if (!GR_GL_MUST_USE_VBO && |
bsalomon | ed82c4e | 2014-09-02 07:54:47 -0700 | [diff] [blame] | 216 | (kARM_GrGLVendor == ctxInfo.vendor() || |
| 217 | kImagination_GrGLVendor == ctxInfo.vendor() || |
| 218 | kQualcomm_GrGLVendor == ctxInfo.vendor())) { |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 219 | fUseNonVBOVertexAndIndexDynamicData = true; |
| 220 | } |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 221 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 222 | if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) || |
skia.committer@gmail.com | a915772 | 2014-04-03 03:04:26 +0000 | [diff] [blame] | 223 | (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) || |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 224 | ctxInfo.hasExtension("GL_ARB_invalidate_subdata")) { |
| 225 | fDiscardRenderTargetSupport = true; |
| 226 | fInvalidateFBType = kInvalidate_InvalidateFBType; |
| 227 | } else if (ctxInfo.hasExtension("GL_EXT_discard_framebuffer")) { |
| 228 | fDiscardRenderTargetSupport = true; |
| 229 | fInvalidateFBType = kDiscard_InvalidateFBType; |
| 230 | } |
robertphillips@google.com | a6ffb58 | 2013-04-29 16:50:17 +0000 | [diff] [blame] | 231 | |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 232 | if (kARM_GrGLVendor == ctxInfo.vendor() || kImagination_GrGLVendor == ctxInfo.vendor()) { |
| 233 | fFullClearIsFree = true; |
| 234 | } |
| 235 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 236 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 237 | fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
tomhudson | 612e926 | 2014-11-24 11:22:36 -0800 | [diff] [blame^] | 238 | ctxInfo.hasExtension("GL_ARB_vertex_array_object") || |
| 239 | ctxInfo.hasExtension("GL_APPLE_vertex_array_object"); |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 240 | } else { |
commit-bot@chromium.org | 2276c01 | 2013-08-16 15:53:33 +0000 | [diff] [blame] | 241 | fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
| 242 | ctxInfo.hasExtension("GL_OES_vertex_array_object"); |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 243 | } |
| 244 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 245 | if (kGLES_GrGLStandard == standard) { |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 246 | if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 247 | fFBFetchSupport = true; |
| 248 | fFBFetchColorName = "gl_LastFragData[0]"; |
| 249 | fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch"; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 250 | } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) { |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 251 | fFBFetchSupport = true; |
| 252 | fFBFetchColorName = "gl_LastFragData[0]"; |
| 253 | fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch"; |
| 254 | } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) { |
| 255 | // The arm extension also requires an additional flag which we will set onResetContext |
| 256 | // This is all temporary. |
| 257 | fFBFetchSupport = true; |
| 258 | fFBFetchColorName = "gl_LastFragColorARM"; |
| 259 | fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch"; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 260 | } |
| 261 | } |
| 262 | |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 263 | // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader |
| 264 | fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); |
| 265 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 266 | this->initFSAASupport(ctxInfo, gli); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 267 | this->initStencilFormats(ctxInfo); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 268 | |
| 269 | /************************************************************************** |
bsalomon@google.com | c26d94f | 2013-03-25 18:19:00 +0000 | [diff] [blame] | 270 | * GrDrawTargetCaps fields |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 271 | **************************************************************************/ |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 272 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 273 | // we could also look for GL_ATI_separate_stencil extension or |
| 274 | // GL_EXT_stencil_two_side but they use different function signatures |
| 275 | // than GL2.0+ (and than each other). |
| 276 | fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); |
| 277 | // supported on GL 1.4 and higher or by extension |
| 278 | fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || |
| 279 | ctxInfo.hasExtension("GL_EXT_stencil_wrap"); |
| 280 | } else { |
| 281 | // ES 2 has two sided stencil and stencil wrap |
| 282 | fTwoSidedStencilSupport = true; |
| 283 | fStencilWrapOpsSupport = true; |
| 284 | } |
| 285 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 286 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 287 | fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the desktop VBO |
| 288 | // extension includes glMapBuffer. |
| 289 | if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffer_range")) { |
| 290 | fMapBufferFlags |= kSubset_MapFlag; |
| 291 | fMapBufferType = kMapBufferRange_MapBufferType; |
| 292 | } else { |
| 293 | fMapBufferType = kMapBuffer_MapBufferType; |
| 294 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 295 | } else { |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 296 | // Unextended GLES2 doesn't have any buffer mapping. |
| 297 | fMapBufferFlags = kNone_MapBufferType; |
| 298 | if (ctxInfo.hasExtension("GL_CHROMIUM_map_sub")) { |
| 299 | fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 300 | fMapBufferType = kChromium_MapBufferType; |
| 301 | } else if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_EXT_map_buffer_range")) { |
| 302 | fMapBufferFlags = kCanMap_MapFlag | kSubset_MapFlag; |
| 303 | fMapBufferType = kMapBufferRange_MapBufferType; |
| 304 | } else if (ctxInfo.hasExtension("GL_OES_mapbuffer")) { |
| 305 | fMapBufferFlags = kCanMap_MapFlag; |
| 306 | fMapBufferType = kMapBuffer_MapBufferType; |
| 307 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 308 | } |
| 309 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 310 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 311 | SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || |
| 312 | ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); |
| 313 | fNPOTTextureTileSupport = true; |
| 314 | fMipMapSupport = true; |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 315 | } else { |
| 316 | // Unextended ES2 supports NPOT textures with clamp_to_edge and non-mip filters only |
commit-bot@chromium.org | 22dd6b9 | 2013-08-16 18:13:48 +0000 | [diff] [blame] | 317 | // ES3 has no limitations. |
| 318 | fNPOTTextureTileSupport = ctxInfo.version() >= GR_GL_VER(3,0) || |
| 319 | ctxInfo.hasExtension("GL_OES_texture_npot"); |
commit-bot@chromium.org | 4744231 | 2013-12-19 16:18:01 +0000 | [diff] [blame] | 320 | // ES2 supports MIP mapping for POT textures but our caps don't allow for limited MIP |
| 321 | // support. The OES extension or ES 3.0 allow for MIPS on NPOT textures. So, apparently, |
| 322 | // does the undocumented GL_IMG_texture_npot extension. This extension does not seem to |
| 323 | // to alllow arbitrary wrap modes, however. |
| 324 | fMipMapSupport = fNPOTTextureTileSupport || ctxInfo.hasExtension("GL_IMG_texture_npot"); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 325 | } |
| 326 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 327 | fHWAALineSupport = (kGL_GrGLStandard == standard); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 328 | |
| 329 | GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_SIZE, &fMaxTextureSize); |
| 330 | GR_GL_GetIntegerv(gli, GR_GL_MAX_RENDERBUFFER_SIZE, &fMaxRenderTargetSize); |
| 331 | // Our render targets are always created with textures as the color |
| 332 | // attachment, hence this min: |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 333 | fMaxRenderTargetSize = SkTMin(fMaxTextureSize, fMaxRenderTargetSize); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 334 | |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 335 | fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering"); |
| 336 | |
| 337 | if (fPathRenderingSupport) { |
| 338 | if (kGL_GrGLStandard == standard) { |
| 339 | // We need one of the two possible texturing methods: using fixed function pipeline |
| 340 | // (PathTexGen, texcoords, ...) or using the newer NVPR API additions that support |
| 341 | // setting individual fragment inputs with ProgramPathFragmentInputGen. The API |
| 342 | // additions are detected by checking the existence of the function. Eventually we may |
| 343 | // choose to remove the fixed function codepath. |
| 344 | // Set fMaxFixedFunctionTextureCoords = 0 here if you want to force |
| 345 | // ProgramPathFragmentInputGen usage on desktop. |
| 346 | fPathRenderingSupport = ctxInfo.hasExtension("GL_EXT_direct_state_access") && |
| 347 | (fMaxFixedFunctionTextureCoords > 0 || |
| 348 | ((ctxInfo.version() >= GR_GL_VER(4,3) || |
| 349 | ctxInfo.hasExtension("GL_ARB_program_interface_query")) && |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 350 | gli->fFunctions.fProgramPathFragmentInputGen)); |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 351 | } else { |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 352 | fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1); |
kkinnunen | 32b9a3b | 2014-07-02 22:56:35 -0700 | [diff] [blame] | 353 | } |
| 354 | } |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 355 | |
commit-bot@chromium.org | a3baf3b | 2014-02-21 18:45:30 +0000 | [diff] [blame] | 356 | fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker"); |
| 357 | |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 358 | // For now these two are equivalent but we could have dst read in shader via some other method |
| 359 | fDstReadInShaderSupport = fFBFetchSupport; |
robertphillips@google.com | 8995b7b | 2013-11-01 15:03:34 +0000 | [diff] [blame] | 360 | |
| 361 | // Disable scratch texture reuse on Mali and Adreno devices |
| 362 | fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() && |
| 363 | kQualcomm_GrGLVendor != ctxInfo.vendor(); |
commit-bot@chromium.org | b835652 | 2013-07-18 22:26:39 +0000 | [diff] [blame] | 364 | |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 365 | // Enable supported shader-related caps |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 366 | if (kGL_GrGLStandard == standard) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 367 | fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) || |
| 368 | ctxInfo.hasExtension("GL_ARB_blend_func_extended"); |
| 369 | fShaderDerivativeSupport = true; |
| 370 | // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS |
| 371 | fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3,2) && |
| 372 | ctxInfo.glslGeneration() >= k150_GrGLSLGeneration; |
| 373 | } else { |
rmistry | 63a9f84 | 2014-10-17 06:07:08 -0700 | [diff] [blame] | 374 | fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) || |
| 375 | ctxInfo.hasExtension("GL_OES_standard_derivatives"); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 376 | } |
| 377 | |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 378 | if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 379 | GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); |
| 380 | } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { |
| 381 | GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); |
| 382 | } |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 383 | |
bsalomon | 63b2196 | 2014-11-05 07:05:34 -0800 | [diff] [blame] | 384 | if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() || |
| 385 | kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) { |
| 386 | fUseDrawInsteadOfClear = true; |
| 387 | } |
| 388 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 389 | this->initConfigTexturableTable(ctxInfo, gli); |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 390 | this->initConfigRenderableTable(ctxInfo); |
commit-bot@chromium.org | f4e67e3 | 2014-04-30 01:26:04 +0000 | [diff] [blame] | 391 | |
| 392 | return true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { |
| 396 | |
| 397 | // OpenGL < 3.0 |
| 398 | // no support for render targets unless the GL_ARB_framebuffer_object |
| 399 | // extension is supported (in which case we get ALPHA, RED, RG, RGB, |
| 400 | // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we |
| 401 | // probably don't get R8 in this case. |
| 402 | |
| 403 | // OpenGL 3.0 |
| 404 | // base color renderable: ALPHA, RED, RG, RGB, and RGBA |
| 405 | // sized derivatives: ALPHA8, R8, RGBA4, RGBA8 |
| 406 | |
| 407 | // >= OpenGL 3.1 |
| 408 | // base color renderable: RED, RG, RGB, and RGBA |
| 409 | // sized derivatives: R8, RGBA4, RGBA8 |
| 410 | // if the GL_ARB_compatibility extension is supported then we get back |
| 411 | // support for GL_ALPHA and ALPHA8 |
| 412 | |
| 413 | // GL_EXT_bgra adds BGRA render targets to any version |
| 414 | |
| 415 | // ES 2.0 |
| 416 | // color renderable: RGBA4, RGB5_A1, RGB565 |
| 417 | // GL_EXT_texture_rg adds support for R8 as a color render target |
| 418 | // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 |
| 419 | // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 added BGRA support |
| 420 | |
| 421 | // ES 3.0 |
| 422 | // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the functions called |
| 423 | // below already account for this). |
| 424 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 425 | GrGLStandard standard = ctxInfo.standard(); |
| 426 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 427 | enum { |
| 428 | kNo_MSAA = 0, |
| 429 | kYes_MSAA = 1, |
| 430 | }; |
| 431 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 432 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 433 | // Post 3.0 we will get R8 |
| 434 | // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) |
| 435 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 436 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 437 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true; |
| 438 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 439 | } |
| 440 | } else { |
| 441 | // On ES we can only hope for R8 |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 442 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupport; |
| 443 | fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSupport; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 444 | } |
| 445 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 446 | if (kGL_GrGLStandard != standard) { |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 447 | // only available in ES |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 448 | fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true; |
| 449 | fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | // we no longer support 444 as a render target |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 453 | fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false; |
| 454 | fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 455 | |
| 456 | if (this->fRGBA8RenderbufferSupport) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 457 | fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true; |
commit-bot@chromium.org | da3d69c | 2013-10-28 15:09:13 +0000 | [diff] [blame] | 458 | fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true; |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 459 | } |
| 460 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 461 | if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) { |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 462 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true; |
| 463 | // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to the list of |
| 464 | // configs that are color-renderable and can be passed to glRenderBufferStorageMultisample. |
commit-bot@chromium.org | 4256d24 | 2013-10-17 16:29:41 +0000 | [diff] [blame] | 465 | // Chromium may have an extension to allow BGRA renderbuffers to work on desktop platforms. |
commit-bot@chromium.org | 90313cc | 2014-01-17 15:05:38 +0000 | [diff] [blame] | 466 | if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")) { |
commit-bot@chromium.org | 4256d24 | 2013-10-17 16:29:41 +0000 | [diff] [blame] | 467 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true; |
| 468 | } else { |
| 469 | fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = |
| 470 | !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers(); |
| 471 | } |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 472 | } |
| 473 | |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 474 | if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) { |
| 475 | fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true; |
| 476 | } |
| 477 | |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 478 | // If we don't support MSAA then undo any places above where we set a config as renderable with |
| 479 | // msaa. |
| 480 | if (kNone_MSFBOType == fMSFBOType) { |
| 481 | for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 482 | fConfigRenderSupport[i][kYes_MSAA] = false; |
| 483 | } |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 484 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 485 | } |
| 486 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 487 | void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 488 | GrGLStandard standard = ctxInfo.standard(); |
| 489 | GrGLVersion version = ctxInfo.version(); |
| 490 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 491 | // Base texture support |
| 492 | fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true; |
| 493 | fConfigTextureSupport[kRGB_565_GrPixelConfig] = true; |
| 494 | fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true; |
| 495 | fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true; |
| 496 | |
| 497 | // Check for 8-bit palette.. |
| 498 | GrGLint numFormats; |
| 499 | GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats); |
| 500 | if (numFormats) { |
| 501 | SkAutoSTMalloc<10, GrGLint> formats(numFormats); |
| 502 | GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); |
| 503 | for (int i = 0; i < numFormats; ++i) { |
| 504 | if (GR_GL_PALETTE8_RGBA8 == formats[i]) { |
| 505 | fConfigTextureSupport[kIndex_8_GrPixelConfig] = true; |
| 506 | break; |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | // Check for BGRA |
| 512 | if (kGL_GrGLStandard == standard) { |
| 513 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = |
| 514 | version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra"); |
| 515 | } else { |
| 516 | if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { |
| 517 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; |
| 518 | } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { |
| 519 | fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; |
| 520 | fBGRAIsInternalFormat = true; |
| 521 | } |
| 522 | SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] || |
| 523 | kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); |
| 524 | } |
| 525 | |
| 526 | // Compressed texture support |
| 527 | |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 528 | // glCompressedTexImage2D is available on all OpenGL ES devices... |
| 529 | // however, it is only available on standard OpenGL after version 1.3 |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 530 | bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VER(1, 3)); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 531 | |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 532 | fCompressedTexSubImageSupport = |
bsalomon | 49f085d | 2014-09-05 13:34:00 -0700 | [diff] [blame] | 533 | hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D); |
krajcevski | 78697816 | 2014-07-30 11:25:44 -0700 | [diff] [blame] | 534 | |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 535 | // Check for ETC1 |
| 536 | bool hasETC1 = false; |
| 537 | |
| 538 | // First check version for support |
| 539 | if (kGL_GrGLStandard == standard) { |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 540 | hasETC1 = hasCompressTex2D && |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 541 | (version >= GR_GL_VER(4, 3) || |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 542 | ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 543 | } else { |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 544 | hasETC1 = hasCompressTex2D && |
| 545 | (version >= GR_GL_VER(3, 0) || |
| 546 | ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 547 | // ETC2 is a superset of ETC1, so we can just check for that, too. |
| 548 | (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
| 549 | ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 550 | } |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 551 | fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 552 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 553 | // Check for LATC under its various forms |
| 554 | LATCAlias alias = kLATC_LATCAlias; |
| 555 | bool hasLATC = hasCompressTex2D && |
| 556 | (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || |
| 557 | ctxInfo.hasExtension("GL_NV_texture_compression_latc")); |
| 558 | |
| 559 | // Check for RGTC |
| 560 | if (!hasLATC) { |
| 561 | // If we're using OpenGL 3.0 or later, then we have RGTC, an identical compression format. |
| 562 | if (kGL_GrGLStandard == standard) { |
| 563 | hasLATC = version >= GR_GL_VER(3, 0); |
| 564 | } |
| 565 | |
| 566 | if (!hasLATC) { |
| 567 | hasLATC = |
| 568 | ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || |
| 569 | ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc"); |
| 570 | } |
| 571 | |
| 572 | if (hasLATC) { |
| 573 | alias = kRGTC_LATCAlias; |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | // Check for 3DC |
| 578 | if (!hasLATC) { |
| 579 | hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture"); |
| 580 | if (hasLATC) { |
| 581 | alias = k3DC_LATCAlias; |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC; |
| 586 | fLATCAlias = alias; |
krajcevski | 238b456 | 2014-06-30 09:09:22 -0700 | [diff] [blame] | 587 | |
krajcevski | b3abe90 | 2014-07-30 13:08:11 -0700 | [diff] [blame] | 588 | // Check for R11_EAC ... We don't support R11_EAC on desktop, as most |
| 589 | // cards default to decompressing the textures in the driver, and is |
| 590 | // generally slower. |
| 591 | if (kGL_GrGLStandard != standard) { |
krajcevski | 238b456 | 2014-06-30 09:09:22 -0700 | [diff] [blame] | 592 | fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0); |
| 593 | } |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 594 | |
krajcevski | 7ef2162 | 2014-07-16 15:21:13 -0700 | [diff] [blame] | 595 | // Check for ASTC |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 596 | fConfigTextureSupport[kASTC_12x12_GrPixelConfig] = |
krajcevski | 7ef2162 | 2014-07-16 15:21:13 -0700 | [diff] [blame] | 597 | ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || |
| 598 | ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || |
| 599 | ctxInfo.hasExtension("GL_OES_texture_compression_astc"); |
| 600 | |
joshualitt | ee5da55 | 2014-07-16 13:32:56 -0700 | [diff] [blame] | 601 | // Check for floating point texture support |
| 602 | // NOTE: We disallow floating point textures on ES devices if linear |
| 603 | // filtering modes are not supported. This is for simplicity, but a more |
| 604 | // granular approach is possible. Coincidentally, floating point textures became part of |
| 605 | // the standard in ES3.1 / OGL 3.1, hence the shorthand |
| 606 | bool hasFPTextures = version >= GR_GL_VER(3, 1); |
| 607 | if (!hasFPTextures) { |
| 608 | hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || |
| 609 | (ctxInfo.hasExtension("OES_texture_float_linear") && |
| 610 | ctxInfo.hasExtension("GL_OES_texture_float")); |
| 611 | } |
| 612 | fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures; |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 613 | } |
| 614 | |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 615 | bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, |
| 616 | GrGLenum format, |
| 617 | GrGLenum type) const { |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 618 | if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
| 619 | // ES 2 guarantees this format is supported |
robertphillips@google.com | eca2dfb | 2012-06-27 20:13:49 +0000 | [diff] [blame] | 620 | return true; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | if (!fTwoFormatLimit) { |
| 624 | // not limited by ES 2's constraints |
| 625 | return true; |
| 626 | } |
| 627 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 628 | GrGLint otherFormat = GR_GL_RGBA; |
| 629 | GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 630 | |
| 631 | // The other supported format/type combo supported for ReadPixels |
| 632 | // can change based on which render target is bound |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 633 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 634 | GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
| 635 | &otherFormat); |
| 636 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 637 | GR_GL_GetIntegerv(intf, |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 638 | GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 639 | &otherType); |
| 640 | |
bsalomon@google.com | 548a433 | 2012-07-11 19:45:22 +0000 | [diff] [blame] | 641 | return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 642 | } |
| 643 | |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 644 | bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 645 | GrGLenum format, |
| 646 | GrGLenum type, |
| 647 | GrGLenum currFboFormat) const { |
| 648 | |
| 649 | ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat}; |
| 650 | |
| 651 | ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key); |
| 652 | |
| 653 | if (NULL == cachedValue) { |
| 654 | bool value = doReadPixelsSupported(intf, format, type); |
| 655 | ReadPixelsSupportedFormats newValue(key, value); |
| 656 | fReadPixelsSupportedCache.add(newValue); |
| 657 | |
| 658 | return newValue.value(); |
| 659 | } |
| 660 | |
| 661 | return cachedValue->value(); |
| 662 | } |
| 663 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 664 | void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 665 | |
| 666 | fMSFBOType = kNone_MSFBOType; |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 667 | if (kGL_GrGLStandard != ctxInfo.standard()) { |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 668 | // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
| 669 | // ES3 driver bugs on at least one device with a tiled GPU (N10). |
| 670 | if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 671 | fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
| 672 | } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")) { |
| 673 | fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
commit-bot@chromium.org | 92b7884 | 2014-01-16 20:49:46 +0000 | [diff] [blame] | 674 | } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 675 | fMSFBOType = GrGLCaps::kES_3_0_MSFBOType; |
| 676 | } else if (ctxInfo.hasExtension("GL_CHROMIUM_framebuffer_multisample")) { |
| 677 | // chrome's extension is equivalent to the EXT msaa |
| 678 | // and fbo_blit extensions. |
| 679 | fMSFBOType = kDesktop_EXT_MSFBOType; |
| 680 | } else if (ctxInfo.hasExtension("GL_APPLE_framebuffer_multisample")) { |
| 681 | fMSFBOType = kES_Apple_MSFBOType; |
| 682 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 683 | } else { |
| 684 | if ((ctxInfo.version() >= GR_GL_VER(3,0)) || |
| 685 | ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 686 | fMSFBOType = GrGLCaps::kDesktop_ARB_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 687 | } else if (ctxInfo.hasExtension("GL_EXT_framebuffer_multisample") && |
| 688 | ctxInfo.hasExtension("GL_EXT_framebuffer_blit")) { |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 689 | fMSFBOType = GrGLCaps::kDesktop_EXT_MSFBOType; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 690 | } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 691 | } |
| 692 | } |
| 693 | |
| 694 | namespace { |
| 695 | const GrGLuint kUnknownBitCount = GrGLStencilBuffer::kUnknownBitCount; |
| 696 | } |
| 697 | |
| 698 | void GrGLCaps::initStencilFormats(const GrGLContextInfo& ctxInfo) { |
| 699 | |
| 700 | // Build up list of legal stencil formats (though perhaps not supported on |
| 701 | // the particular gpu/driver) from most preferred to least. |
| 702 | |
| 703 | // these consts are in order of most preferred to least preferred |
| 704 | // we don't bother with GL_STENCIL_INDEX1 or GL_DEPTH32F_STENCIL8 |
| 705 | |
| 706 | static const StencilFormat |
| 707 | // internal Format stencil bits total bits packed? |
| 708 | gS8 = {GR_GL_STENCIL_INDEX8, 8, 8, false}, |
| 709 | gS16 = {GR_GL_STENCIL_INDEX16, 16, 16, false}, |
| 710 | gD24S8 = {GR_GL_DEPTH24_STENCIL8, 8, 32, true }, |
| 711 | gS4 = {GR_GL_STENCIL_INDEX4, 4, 4, false}, |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 712 | // gS = {GR_GL_STENCIL_INDEX, kUnknownBitCount, kUnknownBitCount, false}, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 713 | gDS = {GR_GL_DEPTH_STENCIL, kUnknownBitCount, kUnknownBitCount, true }; |
| 714 | |
commit-bot@chromium.org | 9e90aed | 2014-01-16 16:35:09 +0000 | [diff] [blame] | 715 | if (kGL_GrGLStandard == ctxInfo.standard()) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 716 | bool supportsPackedDS = |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 717 | ctxInfo.version() >= GR_GL_VER(3,0) || |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 718 | ctxInfo.hasExtension("GL_EXT_packed_depth_stencil") || |
| 719 | ctxInfo.hasExtension("GL_ARB_framebuffer_object"); |
| 720 | |
| 721 | // S1 thru S16 formats are in GL 3.0+, EXT_FBO, and ARB_FBO since we |
| 722 | // require FBO support we can expect these are legal formats and don't |
| 723 | // check. These also all support the unsized GL_STENCIL_INDEX. |
| 724 | fStencilFormats.push_back() = gS8; |
| 725 | fStencilFormats.push_back() = gS16; |
| 726 | if (supportsPackedDS) { |
| 727 | fStencilFormats.push_back() = gD24S8; |
| 728 | } |
| 729 | fStencilFormats.push_back() = gS4; |
| 730 | if (supportsPackedDS) { |
| 731 | fStencilFormats.push_back() = gDS; |
| 732 | } |
| 733 | } else { |
| 734 | // ES2 has STENCIL_INDEX8 without extensions but requires extensions |
| 735 | // for other formats. |
| 736 | // ES doesn't support using the unsized format. |
| 737 | |
| 738 | fStencilFormats.push_back() = gS8; |
| 739 | //fStencilFormats.push_back() = gS16; |
commit-bot@chromium.org | 04c500f | 2013-09-06 15:28:01 +0000 | [diff] [blame] | 740 | if (ctxInfo.version() >= GR_GL_VER(3,0) || |
| 741 | ctxInfo.hasExtension("GL_OES_packed_depth_stencil")) { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 742 | fStencilFormats.push_back() = gD24S8; |
| 743 | } |
| 744 | if (ctxInfo.hasExtension("GL_OES_stencil4")) { |
| 745 | fStencilFormats.push_back() = gS4; |
| 746 | } |
| 747 | } |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 748 | SkASSERT(0 == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 749 | fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); |
| 750 | } |
| 751 | |
| 752 | void GrGLCaps::markColorConfigAndStencilFormatAsVerified( |
| 753 | GrPixelConfig config, |
| 754 | const GrGLStencilBuffer::Format& format) { |
| 755 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 756 | return; |
| 757 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 758 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
| 759 | SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 760 | int count = fStencilFormats.count(); |
| 761 | // we expect a really small number of possible formats so linear search |
| 762 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 763 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 764 | for (int i = 0; i < count; ++i) { |
| 765 | if (format.fInternalFormat == |
| 766 | fStencilFormats[i].fInternalFormat) { |
| 767 | fStencilVerifiedColorConfigs[i].markVerified(config); |
| 768 | return; |
| 769 | } |
| 770 | } |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 771 | SkFAIL("Why are we seeing a stencil format that " |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 772 | "GrGLCaps doesn't know about."); |
| 773 | } |
| 774 | |
| 775 | bool GrGLCaps::isColorConfigAndStencilFormatVerified( |
| 776 | GrPixelConfig config, |
| 777 | const GrGLStencilBuffer::Format& format) const { |
| 778 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 779 | return false; |
| 780 | #endif |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 781 | SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 782 | int count = fStencilFormats.count(); |
| 783 | // we expect a really small number of possible formats so linear search |
| 784 | // should be OK |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 785 | SkASSERT(count < 16); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 786 | for (int i = 0; i < count; ++i) { |
| 787 | if (format.fInternalFormat == |
| 788 | fStencilFormats[i].fInternalFormat) { |
| 789 | return fStencilVerifiedColorConfigs[i].isVerified(config); |
| 790 | } |
| 791 | } |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 792 | SkFAIL("Why are we seeing a stencil format that " |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 793 | "GLCaps doesn't know about."); |
| 794 | return false; |
| 795 | } |
| 796 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 797 | SkString GrGLCaps::dump() const { |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 798 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 799 | SkString r = INHERITED::dump(); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 800 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 801 | r.appendf("--- GL-Specific ---\n"); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 802 | for (int i = 0; i < fStencilFormats.count(); ++i) { |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 803 | r.appendf("Stencil Format %d, stencil bits: %02d, total bits: %02d\n", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 804 | i, |
| 805 | fStencilFormats[i].fStencilBits, |
| 806 | fStencilFormats[i].fTotalBits); |
| 807 | } |
| 808 | |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 809 | static const char* kMSFBOExtStr[] = { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 810 | "None", |
| 811 | "ARB", |
| 812 | "EXT", |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 813 | "ES 3.0", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 814 | "Apple", |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 815 | "IMG MS To Texture", |
| 816 | "EXT MS To Texture", |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 817 | }; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 818 | GR_STATIC_ASSERT(0 == kNone_MSFBOType); |
| 819 | GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType); |
| 820 | GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType); |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 821 | GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType); |
| 822 | GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType); |
| 823 | GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType); |
| 824 | GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType); |
commit-bot@chromium.org | 972f9cd | 2014-03-28 17:58:28 +0000 | [diff] [blame] | 825 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 826 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 827 | static const char* kInvalidateFBTypeStr[] = { |
| 828 | "None", |
| 829 | "Discard", |
| 830 | "Invalidate", |
| 831 | }; |
| 832 | GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); |
| 833 | GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); |
| 834 | GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); |
| 835 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBType + 1); |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 836 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 837 | static const char* kMapBufferTypeStr[] = { |
| 838 | "None", |
| 839 | "MapBuffer", |
| 840 | "MapBufferRange", |
| 841 | "Chromium", |
| 842 | }; |
| 843 | GR_STATIC_ASSERT(0 == kNone_MapBufferType); |
| 844 | GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType); |
| 845 | GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType); |
| 846 | GR_STATIC_ASSERT(3 == kChromium_MapBufferType); |
| 847 | GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1); |
| 848 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 849 | r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 850 | r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 851 | r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 852 | r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType]); |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 853 | r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 854 | r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
| 855 | r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 856 | if (!fIsCoreProfile) { |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 857 | r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTextureCoords); |
commit-bot@chromium.org | 3628ad9 | 2013-08-30 19:43:47 +0000 | [diff] [blame] | 858 | } |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 859 | r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
| 860 | r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 861 | r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES": "NO")); |
| 862 | r.appendf("Support texture swizzle: %s\n", (fTextureSwizzleSupport ? "YES": "NO")); |
| 863 | r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES": "NO")); |
| 864 | r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")); |
| 865 | r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "NO")); |
| 866 | r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 867 | |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 868 | r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO")); |
| 869 | r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO")); |
| 870 | r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
| 871 | r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
| 872 | r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
| 873 | r.appendf("Fragment coord conventions support: %s\n", |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 874 | (fFragCoordsConventionSupport ? "YES": "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 875 | r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); |
| 876 | r.appendf("Use non-VBO for dynamic data: %s\n", |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 877 | (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 878 | r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO")); |
commit-bot@chromium.org | 4362a38 | 2014-03-26 19:49:03 +0000 | [diff] [blame] | 879 | r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); |
commit-bot@chromium.org | 8b656c6 | 2013-11-21 15:23:15 +0000 | [diff] [blame] | 880 | return r; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 881 | } |