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