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 | #ifndef GrGLCaps_DEFINED |
| 10 | #define GrGLCaps_DEFINED |
| 11 | |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 12 | #include "GrCaps.h" |
jvanverth | cba99b8 | 2015-06-24 06:59:57 -0700 | [diff] [blame] | 13 | #include "glsl/GrGLSL.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 14 | #include "GrGLStencilAttachment.h" |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 15 | #include "SkChecksum.h" |
mtklein | 2aa1f7e | 2015-02-20 12:35:32 -0800 | [diff] [blame] | 16 | #include "SkTHash.h" |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 17 | #include "SkTArray.h" |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 18 | |
| 19 | class GrGLContextInfo; |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 20 | class GrGLSLCaps; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Stores some capabilities of a GL context. Most are determined by the GL |
| 24 | * version and the extensions string. It also tracks formats that have passed |
| 25 | * the FBO completeness test. |
| 26 | */ |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 27 | class GrGLCaps : public GrCaps { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 28 | public: |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 29 | typedef GrGLStencilAttachment::Format StencilFormat; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * The type of MSAA for FBOs supported. Different extensions have different |
| 33 | * semantics of how / when a resolve is performed. |
| 34 | */ |
| 35 | enum MSFBOType { |
| 36 | /** |
| 37 | * no support for MSAA FBOs |
| 38 | */ |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 39 | kNone_MSFBOType = 0, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 40 | /** |
skia.committer@gmail.com | 6fc1b49 | 2013-09-06 07:01:45 +0000 | [diff] [blame] | 41 | * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object). |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 42 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 43 | kDesktop_ARB_MSFBOType, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 44 | /** |
| 45 | * earlier GL_EXT_framebuffer* extensions |
| 46 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 47 | kDesktop_EXT_MSFBOType, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 48 | /** |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 49 | * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer. |
| 50 | */ |
| 51 | kES_3_0_MSFBOType, |
| 52 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 53 | * GL_APPLE_framebuffer_multisample ES extension |
| 54 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 55 | kES_Apple_MSFBOType, |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 56 | /** |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 57 | * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers. |
| 58 | * Instead the texture is multisampled when bound to the FBO and then resolved automatically |
| 59 | * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call |
| 60 | * GR_GL_MAX_SAMPLES_IMG). |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 61 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 62 | kES_IMG_MsToTexture_MSFBOType, |
| 63 | /** |
| 64 | * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard |
| 65 | * GL_MAX_SAMPLES value. |
| 66 | */ |
| 67 | kES_EXT_MsToTexture_MSFBOType, |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame] | 68 | /** |
| 69 | * GL_NV_framebuffer_mixed_samples. |
| 70 | */ |
| 71 | kMixedSamples_MSFBOType, |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 72 | |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame] | 73 | kLast_MSFBOType = kMixedSamples_MSFBOType |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 76 | enum InvalidateFBType { |
| 77 | kNone_InvalidateFBType, |
| 78 | kDiscard_InvalidateFBType, //<! glDiscardFramebuffer() |
| 79 | kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer() |
| 80 | |
| 81 | kLast_InvalidateFBType = kInvalidate_InvalidateFBType |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 84 | enum MapBufferType { |
| 85 | kNone_MapBufferType, |
| 86 | kMapBuffer_MapBufferType, // glMapBuffer() |
| 87 | kMapBufferRange_MapBufferType, // glMapBufferRange() |
| 88 | kChromium_MapBufferType, // GL_CHROMIUM_map_sub |
| 89 | |
| 90 | kLast_MapBufferType = kChromium_MapBufferType, |
| 91 | }; |
| 92 | |
jvanverth | d7a2c1f | 2015-12-07 07:36:44 -0800 | [diff] [blame^] | 93 | enum TransferBufferType { |
| 94 | kNone_TransferBufferType, |
| 95 | kPBO_TransferBufferType, // ARB_pixel_buffer_object |
| 96 | kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object |
| 97 | |
| 98 | kLast_TransferBufferType = kChromium_TransferBufferType, |
| 99 | }; |
| 100 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 101 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 102 | * Initializes the GrGLCaps to the set of features supported in the current |
| 103 | * OpenGL context accessible via ctxInfo. |
| 104 | */ |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 105 | GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, |
| 106 | const GrGLInterface* glInterface); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Call to note that a color config has been verified as a valid color |
| 110 | * attachment. This may save future calls to glCheckFramebufferStatus |
| 111 | * using isConfigVerifiedColorAttachment(). |
| 112 | */ |
| 113 | void markConfigAsValidColorAttachment(GrPixelConfig config) { |
| 114 | fVerifiedColorConfigs.markVerified(config); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Call to check whether a config has been verified as a valid color |
| 119 | * attachment. |
| 120 | */ |
| 121 | bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { |
| 122 | return fVerifiedColorConfigs.isVerified(config); |
| 123 | } |
| 124 | |
| 125 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 126 | * Reports the type of MSAA FBO support. |
| 127 | */ |
| 128 | MSFBOType msFBOType() const { return fMSFBOType; } |
| 129 | |
| 130 | /** |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 131 | * Does the supported MSAA FBO extension have MSAA renderbuffers? |
| 132 | */ |
| 133 | bool usesMSAARenderBuffers() const { |
| 134 | return kNone_MSFBOType != fMSFBOType && |
| 135 | kES_IMG_MsToTexture_MSFBOType != fMSFBOType && |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame] | 136 | kES_EXT_MsToTexture_MSFBOType != fMSFBOType && |
| 137 | kMixedSamples_MSFBOType != fMSFBOType; |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and |
| 142 | * then implicitly resolved when read. |
| 143 | */ |
| 144 | bool usesImplicitMSAAResolve() const { |
| 145 | return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || |
| 146 | kES_EXT_MsToTexture_MSFBOType == fMSFBOType; |
| 147 | } |
| 148 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 149 | InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } |
| 150 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 151 | /// What type of buffer mapping is supported? |
| 152 | MapBufferType mapBufferType() const { return fMapBufferType; } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 153 | |
jvanverth | d7a2c1f | 2015-12-07 07:36:44 -0800 | [diff] [blame^] | 154 | /// What type of transfer buffer is supported? |
| 155 | TransferBufferType transferBufferType() const { return fTransferBufferType; } |
| 156 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 157 | /** |
| 158 | * Gets an array of legal stencil formats. These formats are not guaranteed |
| 159 | * to be supported by the driver but are legal GLenum names given the GL |
| 160 | * version and extensions supported. |
| 161 | */ |
| 162 | const SkTArray<StencilFormat, true>& stencilFormats() const { |
| 163 | return fStencilFormats; |
| 164 | } |
| 165 | |
| 166 | /// The maximum number of fragment uniform vectors (GLES has min. 16). |
| 167 | int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } |
| 168 | |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 169 | /// maximum number of attribute values per vertex |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 170 | int maxVertexAttributes() const { return fMaxVertexAttributes; } |
| 171 | |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 172 | /// maximum number of texture units accessible in the fragment shader. |
| 173 | int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } |
| 174 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 175 | /// ES requires an extension to support RGBA8 in RenderBufferStorage |
| 176 | bool rgba8RenderbufferSupport() const { return fRGBA8RenderbufferSupport; } |
| 177 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 178 | /** |
| 179 | * Depending on the ES extensions present the BGRA external format may |
| 180 | * correspond either a BGRA or RGBA internalFormat. On desktop GL it is |
| 181 | * RGBA. |
| 182 | */ |
| 183 | bool bgraIsInternalFormat() const { return fBGRAIsInternalFormat; } |
| 184 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 185 | /// Is there support for GL_UNPACK_ROW_LENGTH |
| 186 | bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; } |
| 187 | |
| 188 | /// Is there support for GL_UNPACK_FLIP_Y |
| 189 | bool unpackFlipYSupport() const { return fUnpackFlipYSupport; } |
| 190 | |
| 191 | /// Is there support for GL_PACK_ROW_LENGTH |
| 192 | bool packRowLengthSupport() const { return fPackRowLengthSupport; } |
| 193 | |
| 194 | /// Is there support for GL_PACK_REVERSE_ROW_ORDER |
| 195 | bool packFlipYSupport() const { return fPackFlipYSupport; } |
| 196 | |
| 197 | /// Is there support for texture parameter GL_TEXTURE_USAGE |
| 198 | bool textureUsageSupport() const { return fTextureUsageSupport; } |
| 199 | |
| 200 | /// Is there support for glTexStorage |
| 201 | bool texStorageSupport() const { return fTexStorageSupport; } |
| 202 | |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 203 | /// Is there support for GL_RED and GL_R8 |
| 204 | bool textureRedSupport() const { return fTextureRedSupport; } |
| 205 | |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 206 | /// Is GL_ARB_IMAGING supported |
| 207 | bool imagingSupport() const { return fImagingSupport; } |
| 208 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 209 | /// Is there support for Vertex Array Objects? |
| 210 | bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } |
| 211 | |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 212 | /// Is there support for glDraw*Instanced and glVertexAttribDivisor? |
| 213 | bool instancedDrawingSupport() const { return fInstancedDrawingSupport; } |
| 214 | |
| 215 | /// Is there support for GL_EXT_direct_state_access? |
| 216 | bool directStateAccessSupport() const { return fDirectStateAccessSupport; } |
| 217 | |
| 218 | /// Is there support for GL_KHR_debug? |
| 219 | bool debugSupport() const { return fDebugSupport; } |
| 220 | |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 221 | /// Is there support for ES2 compatability? |
| 222 | bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } |
| 223 | |
cdalton | d472792 | 2015-11-10 12:49:06 -0800 | [diff] [blame] | 224 | /// Can we call glDisable(GL_MULTISAMPLE)? |
| 225 | bool multisampleDisableSupport() const { |
| 226 | return fMultisampleDisableSupport; |
| 227 | } |
| 228 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 229 | /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 230 | bool useNonVBOVertexAndIndexDynamicData() const { |
| 231 | return fUseNonVBOVertexAndIndexDynamicData; |
| 232 | } |
| 233 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 234 | /// Does ReadPixels support the provided format/type combo? |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 235 | bool readPixelsSupported(const GrGLInterface* intf, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 236 | GrGLenum format, |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 237 | GrGLenum type, |
| 238 | GrGLenum currFboFormat) const; |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 239 | |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 240 | bool isCoreProfile() const { return fIsCoreProfile; } |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 241 | |
joshualitt | c1f56b5 | 2015-06-22 12:31:31 -0700 | [diff] [blame] | 242 | bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; } |
| 243 | |
joshualitt | 7bdd70a | 2015-10-01 06:28:11 -0700 | [diff] [blame] | 244 | bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; } |
| 245 | |
bsalomon | 7ea33f5 | 2015-11-22 14:51:00 -0800 | [diff] [blame] | 246 | /// Are textures with GL_TEXTURE_EXTERNAL_OES type supported. |
| 247 | bool externalTextureSupport() const { return fExternalTextureSupport; } |
| 248 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 249 | /** |
bsalomon | 16921ec | 2015-07-30 15:34:56 -0700 | [diff] [blame] | 250 | * Is there support for enabling/disabling sRGB writes for sRGB-capable color attachments? |
| 251 | * If false this does not mean sRGB is not supported but rather that if it is supported |
| 252 | * it cannot be turned off for configs that support it. |
| 253 | */ |
| 254 | bool srgbWriteControl() const { return fSRGBWriteControl; } |
| 255 | |
| 256 | /** |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 257 | * Returns a string containing the caps info. |
| 258 | */ |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 259 | SkString dump() const override; |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 260 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 261 | /** |
| 262 | * LATC can appear under one of three possible names. In order to know |
| 263 | * which GL internal format to use, we need to keep track of which name |
| 264 | * we found LATC under. The default is LATC. |
| 265 | */ |
| 266 | enum LATCAlias { |
| 267 | kLATC_LATCAlias, |
| 268 | kRGTC_LATCAlias, |
| 269 | k3DC_LATCAlias |
| 270 | }; |
| 271 | |
| 272 | LATCAlias latcAlias() const { return fLATCAlias; } |
| 273 | |
bsalomon | 88c7b98 | 2015-07-31 11:20:16 -0700 | [diff] [blame] | 274 | bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } |
| 275 | bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; } |
| 276 | |
egdaniel | f529439 | 2015-10-21 07:14:17 -0700 | [diff] [blame] | 277 | const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); } |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 278 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 279 | private: |
cdalton | 4cd6713 | 2015-06-10 19:23:46 -0700 | [diff] [blame] | 280 | void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*); |
egdaniel | 05ded89 | 2015-10-26 07:38:05 -0700 | [diff] [blame] | 281 | void initGLSL(const GrGLContextInfo&); |
kkinnunen | cfe62e3 | 2015-07-01 02:58:50 -0700 | [diff] [blame] | 282 | bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 283 | |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 284 | void onApplyOptionsOverrides(const GrContextOptions& options) override; |
| 285 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 286 | /** |
| 287 | * Maintains a bit per GrPixelConfig. It is used to avoid redundantly |
| 288 | * performing glCheckFrameBufferStatus for the same config. |
| 289 | */ |
| 290 | struct VerifiedColorConfigs { |
| 291 | VerifiedColorConfigs() { |
| 292 | this->reset(); |
| 293 | } |
| 294 | |
| 295 | void reset() { |
| 296 | for (int i = 0; i < kNumUints; ++i) { |
| 297 | fVerifiedColorConfigs[i] = 0; |
| 298 | } |
| 299 | } |
| 300 | |
bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame] | 301 | static const int kNumUints = (kGrPixelConfigCnt + 31) / 32; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 302 | uint32_t fVerifiedColorConfigs[kNumUints]; |
| 303 | |
| 304 | void markVerified(GrPixelConfig config) { |
| 305 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 306 | return; |
| 307 | #endif |
| 308 | int u32Idx = config / 32; |
| 309 | int bitIdx = config % 32; |
| 310 | fVerifiedColorConfigs[u32Idx] |= 1 << bitIdx; |
| 311 | } |
| 312 | |
| 313 | bool isVerified(GrPixelConfig config) const { |
| 314 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 315 | return false; |
| 316 | #endif |
| 317 | int u32Idx = config / 32; |
| 318 | int bitIdx = config % 32; |
| 319 | return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); |
| 320 | } |
| 321 | }; |
| 322 | |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 323 | void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 324 | void initBlendEqationSupport(const GrGLContextInfo&); |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 325 | void initStencilFormats(const GrGLContextInfo&); |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 326 | // This must be called after initFSAASupport(). |
bsalomon | 16921ec | 2015-07-30 15:34:56 -0700 | [diff] [blame] | 327 | void initConfigRenderableTable(const GrGLContextInfo&, bool srgbSupport); |
| 328 | void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*, bool srgbSupport); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 329 | |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 330 | bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLenum type) const; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 331 | |
jvanverth | cba99b8 | 2015-06-24 06:59:57 -0700 | [diff] [blame] | 332 | void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, |
| 333 | const GrGLInterface* intf, |
| 334 | GrGLSLCaps* glslCaps); |
| 335 | |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 336 | void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glslCaps); |
| 337 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 338 | // tracks configs that have been verified to pass the FBO completeness when |
| 339 | // used as a color attachment |
| 340 | VerifiedColorConfigs fVerifiedColorConfigs; |
| 341 | |
| 342 | SkTArray<StencilFormat, true> fStencilFormats; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 343 | |
| 344 | int fMaxFragmentUniformVectors; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 345 | int fMaxVertexAttributes; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 346 | int fMaxFragmentTextureUnits; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 347 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 348 | MSFBOType fMSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 349 | InvalidateFBType fInvalidateFBType; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 350 | MapBufferType fMapBufferType; |
jvanverth | d7a2c1f | 2015-12-07 07:36:44 -0800 | [diff] [blame^] | 351 | TransferBufferType fTransferBufferType; |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 352 | LATCAlias fLATCAlias; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 353 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 354 | bool fRGBA8RenderbufferSupport : 1; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 355 | bool fBGRAIsInternalFormat : 1; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 356 | bool fUnpackRowLengthSupport : 1; |
| 357 | bool fUnpackFlipYSupport : 1; |
| 358 | bool fPackRowLengthSupport : 1; |
| 359 | bool fPackFlipYSupport : 1; |
| 360 | bool fTextureUsageSupport : 1; |
| 361 | bool fTexStorageSupport : 1; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 362 | bool fTextureRedSupport : 1; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 363 | bool fImagingSupport : 1; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 364 | bool fTwoFormatLimit : 1; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 365 | bool fVertexArrayObjectSupport : 1; |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 366 | bool fInstancedDrawingSupport : 1; |
| 367 | bool fDirectStateAccessSupport : 1; |
| 368 | bool fDebugSupport : 1; |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 369 | bool fES2CompatibilitySupport : 1; |
cdalton | d472792 | 2015-11-10 12:49:06 -0800 | [diff] [blame] | 370 | bool fMultisampleDisableSupport : 1; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 371 | bool fUseNonVBOVertexAndIndexDynamicData : 1; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 372 | bool fIsCoreProfile : 1; |
joshualitt | c1f56b5 | 2015-06-22 12:31:31 -0700 | [diff] [blame] | 373 | bool fBindFragDataLocationSupport : 1; |
bsalomon | 16921ec | 2015-07-30 15:34:56 -0700 | [diff] [blame] | 374 | bool fSRGBWriteControl : 1; |
bsalomon | 88c7b98 | 2015-07-31 11:20:16 -0700 | [diff] [blame] | 375 | bool fRGBA8888PixelsOpsAreSlow : 1; |
| 376 | bool fPartialFBOReadIsSlow : 1; |
joshualitt | 7bdd70a | 2015-10-01 06:28:11 -0700 | [diff] [blame] | 377 | bool fBindUniformLocationSupport : 1; |
bsalomon | 7ea33f5 | 2015-11-22 14:51:00 -0800 | [diff] [blame] | 378 | bool fExternalTextureSupport : 1; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 379 | |
mtklein | 2aa1f7e | 2015-02-20 12:35:32 -0800 | [diff] [blame] | 380 | struct ReadPixelsSupportedFormat { |
| 381 | GrGLenum fFormat; |
| 382 | GrGLenum fType; |
| 383 | GrGLenum fFboFormat; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 384 | |
mtklein | 2aa1f7e | 2015-02-20 12:35:32 -0800 | [diff] [blame] | 385 | bool operator==(const ReadPixelsSupportedFormat& rhs) const { |
| 386 | return fFormat == rhs.fFormat |
| 387 | && fType == rhs.fType |
| 388 | && fFboFormat == rhs.fFboFormat; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 389 | } |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 390 | }; |
mtklein | 02f46cf | 2015-03-20 13:48:42 -0700 | [diff] [blame] | 391 | mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCache; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 392 | |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 393 | typedef GrCaps INHERITED; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 394 | }; |
| 395 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 396 | #endif |