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" |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 13 | #include "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: |
bsalomon@google.com | bcce892 | 2013-03-25 15:38:39 +0000 | [diff] [blame] | 29 | SK_DECLARE_INST_COUNT(GrGLCaps) |
| 30 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 31 | typedef GrGLStencilAttachment::Format StencilFormat; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * The type of MSAA for FBOs supported. Different extensions have different |
| 35 | * semantics of how / when a resolve is performed. |
| 36 | */ |
| 37 | enum MSFBOType { |
| 38 | /** |
| 39 | * no support for MSAA FBOs |
| 40 | */ |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 41 | kNone_MSFBOType = 0, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 42 | /** |
skia.committer@gmail.com | 6fc1b49 | 2013-09-06 07:01:45 +0000 | [diff] [blame] | 43 | * GL3.0-style MSAA FBO (GL_ARB_framebuffer_object). |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 44 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 45 | kDesktop_ARB_MSFBOType, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 46 | /** |
| 47 | * earlier GL_EXT_framebuffer* extensions |
| 48 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 49 | kDesktop_EXT_MSFBOType, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 50 | /** |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 51 | * Similar to kDesktop_ARB but with additional restrictions on glBlitFramebuffer. |
| 52 | */ |
| 53 | kES_3_0_MSFBOType, |
| 54 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 55 | * GL_APPLE_framebuffer_multisample ES extension |
| 56 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 57 | kES_Apple_MSFBOType, |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 58 | /** |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 59 | * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers. |
| 60 | * Instead the texture is multisampled when bound to the FBO and then resolved automatically |
| 61 | * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call |
| 62 | * GR_GL_MAX_SAMPLES_IMG). |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 63 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 64 | kES_IMG_MsToTexture_MSFBOType, |
| 65 | /** |
| 66 | * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard |
| 67 | * GL_MAX_SAMPLES value. |
| 68 | */ |
| 69 | kES_EXT_MsToTexture_MSFBOType, |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame^] | 70 | /** |
| 71 | * GL_NV_framebuffer_mixed_samples. |
| 72 | */ |
| 73 | kMixedSamples_MSFBOType, |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 74 | |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame^] | 75 | kLast_MSFBOType = kMixedSamples_MSFBOType |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 78 | enum InvalidateFBType { |
| 79 | kNone_InvalidateFBType, |
| 80 | kDiscard_InvalidateFBType, //<! glDiscardFramebuffer() |
| 81 | kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer() |
| 82 | |
| 83 | kLast_InvalidateFBType = kInvalidate_InvalidateFBType |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 86 | enum MapBufferType { |
| 87 | kNone_MapBufferType, |
| 88 | kMapBuffer_MapBufferType, // glMapBuffer() |
| 89 | kMapBufferRange_MapBufferType, // glMapBufferRange() |
| 90 | kChromium_MapBufferType, // GL_CHROMIUM_map_sub |
| 91 | |
| 92 | kLast_MapBufferType = kChromium_MapBufferType, |
| 93 | }; |
| 94 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 95 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 96 | * Initializes the GrGLCaps to the set of features supported in the current |
| 97 | * OpenGL context accessible via ctxInfo. |
| 98 | */ |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 99 | GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, |
| 100 | const GrGLInterface* glInterface); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Call to note that a color config has been verified as a valid color |
| 104 | * attachment. This may save future calls to glCheckFramebufferStatus |
| 105 | * using isConfigVerifiedColorAttachment(). |
| 106 | */ |
| 107 | void markConfigAsValidColorAttachment(GrPixelConfig config) { |
| 108 | fVerifiedColorConfigs.markVerified(config); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Call to check whether a config has been verified as a valid color |
| 113 | * attachment. |
| 114 | */ |
| 115 | bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { |
| 116 | return fVerifiedColorConfigs.isVerified(config); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Call to note that a color config / stencil format pair passed |
| 121 | * FBO status check. We may skip calling glCheckFramebufferStatus for |
| 122 | * this combination in the future using |
| 123 | * isColorConfigAndStencilFormatVerified(). |
| 124 | */ |
| 125 | void markColorConfigAndStencilFormatAsVerified( |
| 126 | GrPixelConfig config, |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 127 | const GrGLStencilAttachment::Format& format); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Call to check whether color config / stencil format pair has already |
| 131 | * passed FBO status check. |
| 132 | */ |
| 133 | bool isColorConfigAndStencilFormatVerified( |
| 134 | GrPixelConfig config, |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 135 | const GrGLStencilAttachment::Format& format) const; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 136 | |
| 137 | /** |
| 138 | * Reports the type of MSAA FBO support. |
| 139 | */ |
| 140 | MSFBOType msFBOType() const { return fMSFBOType; } |
| 141 | |
| 142 | /** |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 143 | * Does the supported MSAA FBO extension have MSAA renderbuffers? |
| 144 | */ |
| 145 | bool usesMSAARenderBuffers() const { |
| 146 | return kNone_MSFBOType != fMSFBOType && |
| 147 | kES_IMG_MsToTexture_MSFBOType != fMSFBOType && |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame^] | 148 | kES_EXT_MsToTexture_MSFBOType != fMSFBOType && |
| 149 | kMixedSamples_MSFBOType != fMSFBOType; |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and |
| 154 | * then implicitly resolved when read. |
| 155 | */ |
| 156 | bool usesImplicitMSAAResolve() const { |
| 157 | return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || |
| 158 | kES_EXT_MsToTexture_MSFBOType == fMSFBOType; |
| 159 | } |
| 160 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 161 | InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } |
| 162 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 163 | /// What type of buffer mapping is supported? |
| 164 | MapBufferType mapBufferType() const { return fMapBufferType; } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 165 | |
| 166 | /** |
| 167 | * Gets an array of legal stencil formats. These formats are not guaranteed |
| 168 | * to be supported by the driver but are legal GLenum names given the GL |
| 169 | * version and extensions supported. |
| 170 | */ |
| 171 | const SkTArray<StencilFormat, true>& stencilFormats() const { |
| 172 | return fStencilFormats; |
| 173 | } |
| 174 | |
| 175 | /// The maximum number of fragment uniform vectors (GLES has min. 16). |
| 176 | int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } |
| 177 | |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 178 | /// maximum number of attribute values per vertex |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 179 | int maxVertexAttributes() const { return fMaxVertexAttributes; } |
| 180 | |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 181 | /// maximum number of texture units accessible in the fragment shader. |
| 182 | int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } |
| 183 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 184 | /// ES requires an extension to support RGBA8 in RenderBufferStorage |
| 185 | bool rgba8RenderbufferSupport() const { return fRGBA8RenderbufferSupport; } |
| 186 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 187 | /** |
| 188 | * Depending on the ES extensions present the BGRA external format may |
| 189 | * correspond either a BGRA or RGBA internalFormat. On desktop GL it is |
| 190 | * RGBA. |
| 191 | */ |
| 192 | bool bgraIsInternalFormat() const { return fBGRAIsInternalFormat; } |
| 193 | |
| 194 | /// GL_ARB_texture_swizzle support |
| 195 | bool textureSwizzleSupport() const { return fTextureSwizzleSupport; } |
| 196 | |
| 197 | /// Is there support for GL_UNPACK_ROW_LENGTH |
| 198 | bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; } |
| 199 | |
| 200 | /// Is there support for GL_UNPACK_FLIP_Y |
| 201 | bool unpackFlipYSupport() const { return fUnpackFlipYSupport; } |
| 202 | |
| 203 | /// Is there support for GL_PACK_ROW_LENGTH |
| 204 | bool packRowLengthSupport() const { return fPackRowLengthSupport; } |
| 205 | |
| 206 | /// Is there support for GL_PACK_REVERSE_ROW_ORDER |
| 207 | bool packFlipYSupport() const { return fPackFlipYSupport; } |
| 208 | |
| 209 | /// Is there support for texture parameter GL_TEXTURE_USAGE |
| 210 | bool textureUsageSupport() const { return fTextureUsageSupport; } |
| 211 | |
| 212 | /// Is there support for glTexStorage |
| 213 | bool texStorageSupport() const { return fTexStorageSupport; } |
| 214 | |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 215 | /// Is there support for GL_RED and GL_R8 |
| 216 | bool textureRedSupport() const { return fTextureRedSupport; } |
| 217 | |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 218 | /// Is GL_ARB_IMAGING supported |
| 219 | bool imagingSupport() const { return fImagingSupport; } |
| 220 | |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 221 | /// Is GL_ARB_fragment_coord_conventions supported? |
| 222 | bool fragCoordConventionsSupport() const { return fFragCoordsConventionSupport; } |
| 223 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 224 | /// Is there support for Vertex Array Objects? |
| 225 | bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } |
| 226 | |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 227 | /// Is there support for ES2 compatability? |
| 228 | bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } |
| 229 | |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 230 | /// Can we call glDisable(GL_MULTISAMPLE)? |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame^] | 231 | bool multisampleDisableSupport() const { |
| 232 | return fMultisampleDisableSupport; |
| 233 | } |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 234 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 235 | /// 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] | 236 | bool useNonVBOVertexAndIndexDynamicData() const { |
| 237 | return fUseNonVBOVertexAndIndexDynamicData; |
| 238 | } |
| 239 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 240 | /// Does ReadPixels support the provided format/type combo? |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 241 | bool readPixelsSupported(const GrGLInterface* intf, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 242 | GrGLenum format, |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 243 | GrGLenum type, |
| 244 | GrGLenum currFboFormat) const; |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 245 | |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 246 | bool isCoreProfile() const { return fIsCoreProfile; } |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 247 | |
commit-bot@chromium.org | 3628ad9 | 2013-08-30 19:43:47 +0000 | [diff] [blame] | 248 | |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 249 | bool fullClearIsFree() const { return fFullClearIsFree; } |
| 250 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 251 | /** |
| 252 | * Returns a string containing the caps info. |
| 253 | */ |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 254 | SkString dump() const override; |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 255 | |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 256 | /** |
| 257 | * LATC can appear under one of three possible names. In order to know |
| 258 | * which GL internal format to use, we need to keep track of which name |
| 259 | * we found LATC under. The default is LATC. |
| 260 | */ |
| 261 | enum LATCAlias { |
| 262 | kLATC_LATCAlias, |
| 263 | kRGTC_LATCAlias, |
| 264 | k3DC_LATCAlias |
| 265 | }; |
| 266 | |
| 267 | LATCAlias latcAlias() const { return fLATCAlias; } |
| 268 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 269 | GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); } |
| 270 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 271 | private: |
cdalton | 4cd6713 | 2015-06-10 19:23:46 -0700 | [diff] [blame] | 272 | void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*); |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 273 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 274 | /** |
| 275 | * Maintains a bit per GrPixelConfig. It is used to avoid redundantly |
| 276 | * performing glCheckFrameBufferStatus for the same config. |
| 277 | */ |
| 278 | struct VerifiedColorConfigs { |
| 279 | VerifiedColorConfigs() { |
| 280 | this->reset(); |
| 281 | } |
| 282 | |
| 283 | void reset() { |
| 284 | for (int i = 0; i < kNumUints; ++i) { |
| 285 | fVerifiedColorConfigs[i] = 0; |
| 286 | } |
| 287 | } |
| 288 | |
bsalomon@google.com | b8eb2e8 | 2013-03-28 13:46:42 +0000 | [diff] [blame] | 289 | static const int kNumUints = (kGrPixelConfigCnt + 31) / 32; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 290 | uint32_t fVerifiedColorConfigs[kNumUints]; |
| 291 | |
| 292 | void markVerified(GrPixelConfig config) { |
| 293 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 294 | return; |
| 295 | #endif |
| 296 | int u32Idx = config / 32; |
| 297 | int bitIdx = config % 32; |
| 298 | fVerifiedColorConfigs[u32Idx] |= 1 << bitIdx; |
| 299 | } |
| 300 | |
| 301 | bool isVerified(GrPixelConfig config) const { |
| 302 | #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT |
| 303 | return false; |
| 304 | #endif |
| 305 | int u32Idx = config / 32; |
| 306 | int bitIdx = config % 32; |
| 307 | return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); |
| 308 | } |
| 309 | }; |
| 310 | |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 311 | void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); |
| 312 | void initStencilFormats(const GrGLContextInfo&); |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 313 | // This must be called after initFSAASupport(). |
commit-bot@chromium.org | 7388051 | 2013-10-14 15:33:45 +0000 | [diff] [blame] | 314 | void initConfigRenderableTable(const GrGLContextInfo&); |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 315 | void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 316 | |
bsalomon | 17168df | 2014-12-09 09:00:49 -0800 | [diff] [blame] | 317 | bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLenum type) const; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 318 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 319 | // tracks configs that have been verified to pass the FBO completeness when |
| 320 | // used as a color attachment |
| 321 | VerifiedColorConfigs fVerifiedColorConfigs; |
| 322 | |
| 323 | SkTArray<StencilFormat, true> fStencilFormats; |
| 324 | // tracks configs that have been verified to pass the FBO completeness when |
| 325 | // used as a color attachment when a particular stencil format is used |
| 326 | // as a stencil attachment. |
| 327 | SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs; |
| 328 | |
| 329 | int fMaxFragmentUniformVectors; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 330 | int fMaxVertexAttributes; |
commit-bot@chromium.org | a15f7e5 | 2013-06-05 23:29:25 +0000 | [diff] [blame] | 331 | int fMaxFragmentTextureUnits; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 332 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 333 | MSFBOType fMSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 334 | InvalidateFBType fInvalidateFBType; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 335 | MapBufferType fMapBufferType; |
commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 336 | LATCAlias fLATCAlias; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 337 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 338 | bool fRGBA8RenderbufferSupport : 1; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 339 | bool fBGRAIsInternalFormat : 1; |
| 340 | bool fTextureSwizzleSupport : 1; |
| 341 | bool fUnpackRowLengthSupport : 1; |
| 342 | bool fUnpackFlipYSupport : 1; |
| 343 | bool fPackRowLengthSupport : 1; |
| 344 | bool fPackFlipYSupport : 1; |
| 345 | bool fTextureUsageSupport : 1; |
| 346 | bool fTexStorageSupport : 1; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 347 | bool fTextureRedSupport : 1; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 348 | bool fImagingSupport : 1; |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 349 | bool fTwoFormatLimit : 1; |
bsalomon@google.com | 706f668 | 2012-10-23 14:53:55 +0000 | [diff] [blame] | 350 | bool fFragCoordsConventionSupport : 1; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 351 | bool fVertexArrayObjectSupport : 1; |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 352 | bool fES2CompatibilitySupport : 1; |
cdalton | 0edea2c | 2015-05-21 08:27:44 -0700 | [diff] [blame] | 353 | bool fMultisampleDisableSupport : 1; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 354 | bool fUseNonVBOVertexAndIndexDynamicData : 1; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 355 | bool fIsCoreProfile : 1; |
robertphillips@google.com | 56ce48a | 2013-10-31 21:44:25 +0000 | [diff] [blame] | 356 | bool fFullClearIsFree : 1; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 357 | |
mtklein | 2aa1f7e | 2015-02-20 12:35:32 -0800 | [diff] [blame] | 358 | struct ReadPixelsSupportedFormat { |
| 359 | GrGLenum fFormat; |
| 360 | GrGLenum fType; |
| 361 | GrGLenum fFboFormat; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 362 | |
mtklein | 2aa1f7e | 2015-02-20 12:35:32 -0800 | [diff] [blame] | 363 | bool operator==(const ReadPixelsSupportedFormat& rhs) const { |
| 364 | return fFormat == rhs.fFormat |
| 365 | && fType == rhs.fType |
| 366 | && fFboFormat == rhs.fFboFormat; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 367 | } |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 368 | }; |
mtklein | 02f46cf | 2015-03-20 13:48:42 -0700 | [diff] [blame] | 369 | mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCache; |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 370 | |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 371 | typedef GrCaps INHERITED; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 372 | }; |
| 373 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 374 | class GrGLSLCaps : public GrShaderCaps { |
| 375 | public: |
| 376 | SK_DECLARE_INST_COUNT(GrGLSLCaps) |
| 377 | |
| 378 | /** |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 379 | * Indicates how GLSL must interact with advanced blend equations. The KHR extension requires |
| 380 | * special layout qualifiers in the fragment shader. |
| 381 | */ |
| 382 | enum AdvBlendEqInteraction { |
| 383 | kNotSupported_AdvBlendEqInteraction, //<! No _blend_equation_advanced extension |
| 384 | kAutomatic_AdvBlendEqInteraction, //<! No interaction required |
| 385 | kGeneralEnable_AdvBlendEqInteraction, //<! layout(blend_support_all_equations) out |
| 386 | kSpecificEnables_AdvBlendEqInteraction, //<! Specific layout qualifiers per equation |
| 387 | |
| 388 | kLast_AdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction |
| 389 | }; |
| 390 | |
| 391 | /** |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 392 | * Initializes the GrGLSLCaps to the set of features supported in the current |
| 393 | * OpenGL context accessible via ctxInfo. |
| 394 | */ |
bsalomon | 4ee6bd8 | 2015-05-27 13:23:23 -0700 | [diff] [blame] | 395 | GrGLSLCaps(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*, |
| 396 | const GrGLCaps&); |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 397 | |
| 398 | /** |
| 399 | * Some helper functions for encapsulating various extensions to read FB Buffer on openglES |
| 400 | * |
| 401 | * TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar to this effect |
| 402 | */ |
| 403 | bool fbFetchSupport() const { return fFBFetchSupport; } |
| 404 | |
| 405 | bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; } |
| 406 | |
| 407 | const char* fbFetchColorName() const { return fFBFetchColorName; } |
| 408 | |
| 409 | const char* fbFetchExtensionString() const { return fFBFetchExtensionString; } |
| 410 | |
| 411 | bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } |
| 412 | |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 413 | AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInteraction; } |
| 414 | |
| 415 | bool mustEnableAdvBlendEqs() const { |
| 416 | return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction; |
| 417 | } |
| 418 | |
| 419 | bool mustEnableSpecificAdvBlendEqs() const { |
| 420 | return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction; |
| 421 | } |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 422 | |
| 423 | bool mustDeclareFragmentShaderOutput() const { |
| 424 | return fGLSLGeneration > k110_GrGLSLGeneration; |
| 425 | } |
| 426 | |
| 427 | GrGLSLGeneration generation() const { return fGLSLGeneration; } |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 428 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 429 | /** |
| 430 | * Returns a string containing the caps info. |
| 431 | */ |
| 432 | SkString dump() const override; |
| 433 | |
| 434 | private: |
| 435 | // Must be called after fGeometryShaderSupport is initialized. |
| 436 | void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*); |
| 437 | |
bsalomon | 6df8640 | 2015-06-01 10:41:49 -0700 | [diff] [blame] | 438 | GrGLSLGeneration fGLSLGeneration; |
| 439 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 440 | bool fDropsTileOnZeroDivide : 1; |
| 441 | bool fFBFetchSupport : 1; |
| 442 | bool fFBFetchNeedsCustomOutput : 1; |
| 443 | |
| 444 | const char* fFBFetchColorName; |
| 445 | const char* fFBFetchExtensionString; |
| 446 | |
cdalton | 8917d62 | 2015-05-06 13:40:21 -0700 | [diff] [blame] | 447 | AdvBlendEqInteraction fAdvBlendEqInteraction; |
| 448 | |
cdalton | 4cd6713 | 2015-06-10 19:23:46 -0700 | [diff] [blame] | 449 | friend class GrGLCaps; // For initialization. |
| 450 | |
jvanverth | e9c0fc6 | 2015-04-29 11:18:05 -0700 | [diff] [blame] | 451 | typedef GrShaderCaps INHERITED; |
| 452 | }; |
| 453 | |
jvanverth | cfc1886 | 2015-04-28 08:48:20 -0700 | [diff] [blame] | 454 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 455 | #endif |