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 | 1aa2029 | 2016-01-22 08:16:09 -0800 | [diff] [blame] | 12 | #include <functional> |
| 13 | |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 14 | #include "GrCaps.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 15 | #include "GrGLStencilAttachment.h" |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 16 | #include "GrSwizzle.h" |
piotaixr | e4b2314 | 2014-10-02 10:57:53 -0700 | [diff] [blame] | 17 | #include "SkChecksum.h" |
mtklein | 2aa1f7e | 2015-02-20 12:35:32 -0800 | [diff] [blame] | 18 | #include "SkTHash.h" |
robertphillips@google.com | a2d7148 | 2012-08-01 20:08:47 +0000 | [diff] [blame] | 19 | #include "SkTArray.h" |
Brian Salomon | 94efbf5 | 2016-11-29 13:43:05 -0500 | [diff] [blame] | 20 | #include "../private/GrGLSL.h" |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 21 | |
| 22 | class GrGLContextInfo; |
bsalomon | 1aa2029 | 2016-01-22 08:16:09 -0800 | [diff] [blame] | 23 | class GrGLRenderTarget; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * Stores some capabilities of a GL context. Most are determined by the GL |
| 27 | * version and the extensions string. It also tracks formats that have passed |
| 28 | * the FBO completeness test. |
| 29 | */ |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 30 | class GrGLCaps : public GrCaps { |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 31 | public: |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 32 | typedef GrGLStencilAttachment::Format StencilFormat; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * The type of MSAA for FBOs supported. Different extensions have different |
| 36 | * semantics of how / when a resolve is performed. |
| 37 | */ |
| 38 | enum MSFBOType { |
| 39 | /** |
| 40 | * no support for MSAA FBOs |
| 41 | */ |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 42 | kNone_MSFBOType = 0, |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 43 | /** |
Robert Phillips | 5ab7276 | 2017-06-07 12:04:18 -0400 | [diff] [blame] | 44 | * OpenGL 3.0+, OpenGL ES 3.0+, GL_ARB_framebuffer_object, |
| 45 | * GL_CHROMIUM_framebuffer_multisample, GL_ANGLE_framebuffer_multisample, |
| 46 | * or GL_EXT_framebuffer_multisample |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 47 | */ |
Brian Salomon | 00731b4 | 2016-10-14 11:30:51 -0400 | [diff] [blame] | 48 | kStandard_MSFBOType, |
commit-bot@chromium.org | a8e5a06 | 2013-09-05 23:44:09 +0000 | [diff] [blame] | 49 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 50 | * GL_APPLE_framebuffer_multisample ES extension |
| 51 | */ |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 52 | kES_Apple_MSFBOType, |
bsalomon@google.com | f3a60c0 | 2013-03-19 19:06:09 +0000 | [diff] [blame] | 53 | /** |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 54 | * GL_IMG_multisampled_render_to_texture. This variation does not have MSAA renderbuffers. |
| 55 | * Instead the texture is multisampled when bound to the FBO and then resolved automatically |
| 56 | * when read. It also defines an alternate value for GL_MAX_SAMPLES (which we call |
| 57 | * GR_GL_MAX_SAMPLES_IMG). |
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 | kES_IMG_MsToTexture_MSFBOType, |
| 60 | /** |
| 61 | * GL_EXT_multisampled_render_to_texture. Same as the IMG one above but uses the standard |
| 62 | * GL_MAX_SAMPLES value. |
| 63 | */ |
| 64 | kES_EXT_MsToTexture_MSFBOType, |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame] | 65 | /** |
| 66 | * GL_NV_framebuffer_mixed_samples. |
| 67 | */ |
| 68 | kMixedSamples_MSFBOType, |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 69 | |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame] | 70 | kLast_MSFBOType = kMixedSamples_MSFBOType |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
Brian Salomon | e5e7eb1 | 2016-10-14 16:18:33 -0400 | [diff] [blame] | 73 | enum BlitFramebufferFlags { |
| 74 | kNoSupport_BlitFramebufferFlag = 1 << 0, |
| 75 | kNoScalingOrMirroring_BlitFramebufferFlag = 1 << 1, |
| 76 | kResolveMustBeFull_BlitFrambufferFlag = 1 << 2, |
| 77 | kNoMSAADst_BlitFramebufferFlag = 1 << 3, |
| 78 | kNoFormatConversion_BlitFramebufferFlag = 1 << 4, |
| 79 | kNoFormatConversionForMSAASrc_BlitFramebufferFlag = 1 << 5, |
| 80 | kRectsMustMatchForMSAASrc_BlitFramebufferFlag = 1 << 6, |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 81 | }; |
| 82 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 83 | enum InvalidateFBType { |
| 84 | kNone_InvalidateFBType, |
| 85 | kDiscard_InvalidateFBType, //<! glDiscardFramebuffer() |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 86 | kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer() |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 87 | |
| 88 | kLast_InvalidateFBType = kInvalidate_InvalidateFBType |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 89 | }; |
| 90 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 91 | enum MapBufferType { |
| 92 | kNone_MapBufferType, |
| 93 | kMapBuffer_MapBufferType, // glMapBuffer() |
| 94 | kMapBufferRange_MapBufferType, // glMapBufferRange() |
| 95 | kChromium_MapBufferType, // GL_CHROMIUM_map_sub |
| 96 | |
| 97 | kLast_MapBufferType = kChromium_MapBufferType, |
| 98 | }; |
| 99 | |
jvanverth | d7a2c1f | 2015-12-07 07:36:44 -0800 | [diff] [blame] | 100 | enum TransferBufferType { |
| 101 | kNone_TransferBufferType, |
| 102 | kPBO_TransferBufferType, // ARB_pixel_buffer_object |
| 103 | kChromium_TransferBufferType, // CHROMIUM_pixel_transfer_buffer_object |
| 104 | |
| 105 | kLast_TransferBufferType = kChromium_TransferBufferType, |
| 106 | }; |
| 107 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 108 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 109 | * Initializes the GrGLCaps to the set of features supported in the current |
| 110 | * OpenGL context accessible via ctxInfo. |
| 111 | */ |
bsalomon | 682c269 | 2015-05-22 14:01:46 -0700 | [diff] [blame] | 112 | GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, |
| 113 | const GrGLInterface* glInterface); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 114 | |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 115 | int getSampleCount(int requestedCount, GrPixelConfig config) const override; |
| 116 | |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 117 | bool isConfigTexturable(GrPixelConfig config) const override { |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 118 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag); |
| 119 | } |
| 120 | |
| 121 | bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 122 | if (withMSAA) { |
| 123 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderableWithMSAA_Flag); |
| 124 | } else { |
| 125 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag); |
| 126 | } |
| 127 | } |
Greg Daniel | bb76ace | 2017-09-29 15:58:22 -0400 | [diff] [blame] | 128 | |
| 129 | bool isConfigCopyable(GrPixelConfig config) const override { |
| 130 | // In GL we have three ways to be able to copy. CopyTexImage, blit, and draw. CopyTexImage |
| 131 | // requires the src to be an FBO attachment, blit requires both src and dst to be FBO |
| 132 | // attachments, and draw requires the dst to be an FBO attachment. Thus to copy from and to |
| 133 | // the same config, we need that config to be renderable so we can attach it to an FBO. |
| 134 | return this->isConfigRenderable(config, false); |
| 135 | } |
| 136 | |
Brian Salomon | 71d9d84 | 2016-11-03 13:42:00 -0400 | [diff] [blame] | 137 | bool canConfigBeFBOColorAttachment(GrPixelConfig config) const { |
| 138 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kFBOColorAttachment_Flag); |
| 139 | } |
| 140 | |
cblume | 790d513 | 2016-02-29 11:13:29 -0800 | [diff] [blame] | 141 | bool isConfigTexSupportEnabled(GrPixelConfig config) const { |
cblume | 790d513 | 2016-02-29 11:13:29 -0800 | [diff] [blame] | 142 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseTexStorage_Flag); |
| 143 | } |
| 144 | |
cdalton | 74b8d32 | 2016-04-11 14:47:28 -0700 | [diff] [blame] | 145 | bool canUseConfigWithTexelBuffer(GrPixelConfig config) const { |
| 146 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseWithTexelBuffer_Flag); |
| 147 | } |
| 148 | |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 149 | /** Returns the mapping between GrPixelConfig components and GL internal format components. */ |
| 150 | const GrSwizzle& configSwizzle(GrPixelConfig config) const { |
| 151 | return fConfigTable[config].fSwizzle; |
| 152 | } |
| 153 | |
cdalton | 74b8d32 | 2016-04-11 14:47:28 -0700 | [diff] [blame] | 154 | GrGLenum configSizedInternalFormat(GrPixelConfig config) const { |
| 155 | return fConfigTable[config].fFormats.fSizedInternalFormat; |
| 156 | } |
| 157 | |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 158 | bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, |
| 159 | GrGLenum* internalFormat, GrGLenum* externalFormat, |
| 160 | GrGLenum* externalType) const; |
| 161 | |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 162 | bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, |
| 163 | GrGLenum* externalFormat, GrGLenum* externalType) const; |
| 164 | |
| 165 | bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const; |
| 166 | |
Brian Salomon | f9f4512 | 2016-11-29 11:59:17 -0500 | [diff] [blame] | 167 | /** The format to use read/write a texture as an image in a shader */ |
| 168 | GrGLenum getImageFormat(GrPixelConfig config) const { |
| 169 | return fConfigTable[config].fFormats.fSizedInternalFormat; |
| 170 | } |
| 171 | |
bsalomon | 3044737 | 2015-12-21 09:03:05 -0800 | [diff] [blame] | 172 | /** |
| 173 | * Gets an array of legal stencil formats. These formats are not guaranteed |
| 174 | * to be supported by the driver but are legal GLenum names given the GL |
| 175 | * version and extensions supported. |
| 176 | */ |
| 177 | const SkTArray<StencilFormat, true>& stencilFormats() const { |
| 178 | return fStencilFormats; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Has a stencil format index been found for the config (or we've found that no format works). |
| 183 | */ |
| 184 | bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const { |
| 185 | return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Gets the stencil format index for the config. This assumes |
| 190 | * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if |
| 191 | * no stencil format is supported with the config. Otherwise, returned index refers to the array |
| 192 | * returned by stencilFormats(). |
| 193 | */ |
| 194 | int getStencilFormatIndexForConfig(GrPixelConfig config) const { |
| 195 | SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config)); |
| 196 | return fConfigTable[config].fStencilFormatIndex; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * If index is >= 0 this records an index into stencilFormats() as the best stencil format for |
| 201 | * the config. If < 0 it records that the config has no supported stencil format index. |
| 202 | */ |
| 203 | void setStencilFormatIndexForConfig(GrPixelConfig config, int index) { |
| 204 | SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config)); |
| 205 | if (index < 0) { |
| 206 | fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex; |
| 207 | } else { |
| 208 | fConfigTable[config].fStencilFormatIndex = index; |
| 209 | } |
| 210 | } |
| 211 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 212 | /** |
| 213 | * Call to note that a color config has been verified as a valid color |
| 214 | * attachment. This may save future calls to glCheckFramebufferStatus |
| 215 | * using isConfigVerifiedColorAttachment(). |
| 216 | */ |
| 217 | void markConfigAsValidColorAttachment(GrPixelConfig config) { |
bsalomon | 480e8c0 | 2015-12-21 13:44:18 -0800 | [diff] [blame] | 218 | fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Call to check whether a config has been verified as a valid color |
| 223 | * attachment. |
| 224 | */ |
| 225 | bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { |
bsalomon | 480e8c0 | 2015-12-21 13:44:18 -0800 | [diff] [blame] | 226 | return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag); |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | /** |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 230 | * Reports the type of MSAA FBO support. |
| 231 | */ |
| 232 | MSFBOType msFBOType() const { return fMSFBOType; } |
| 233 | |
| 234 | /** |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 235 | * Does the preferred MSAA FBO extension have MSAA renderbuffers? |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 236 | */ |
| 237 | bool usesMSAARenderBuffers() const { |
| 238 | return kNone_MSFBOType != fMSFBOType && |
| 239 | kES_IMG_MsToTexture_MSFBOType != fMSFBOType && |
vbuzinov | dded696 | 2015-06-12 08:59:45 -0700 | [diff] [blame] | 240 | kES_EXT_MsToTexture_MSFBOType != fMSFBOType && |
| 241 | kMixedSamples_MSFBOType != fMSFBOType; |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | /** |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 245 | * What functionality is supported by glBlitFramebuffer. |
| 246 | */ |
Brian Salomon | e5e7eb1 | 2016-10-14 16:18:33 -0400 | [diff] [blame] | 247 | uint32_t blitFramebufferSupportFlags() const { return fBlitFramebufferFlags; } |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 248 | |
| 249 | /** |
bsalomon@google.com | 347c382 | 2013-05-01 20:10:01 +0000 | [diff] [blame] | 250 | * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and |
| 251 | * then implicitly resolved when read. |
| 252 | */ |
| 253 | bool usesImplicitMSAAResolve() const { |
| 254 | return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || |
| 255 | kES_EXT_MsToTexture_MSFBOType == fMSFBOType; |
| 256 | } |
| 257 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 258 | InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } |
| 259 | |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 260 | /// What type of buffer mapping is supported? |
| 261 | MapBufferType mapBufferType() const { return fMapBufferType; } |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 262 | |
jvanverth | d7a2c1f | 2015-12-07 07:36:44 -0800 | [diff] [blame] | 263 | /// What type of transfer buffer is supported? |
| 264 | TransferBufferType transferBufferType() const { return fTransferBufferType; } |
| 265 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 266 | /// The maximum number of fragment uniform vectors (GLES has min. 16). |
| 267 | int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } |
| 268 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 269 | /** |
| 270 | * Depending on the ES extensions present the BGRA external format may |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 271 | * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 272 | * RGBA. |
| 273 | */ |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 274 | bool bgraIsInternalFormat() const; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 275 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 276 | /// Is there support for GL_UNPACK_ROW_LENGTH |
| 277 | bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; } |
| 278 | |
| 279 | /// Is there support for GL_UNPACK_FLIP_Y |
| 280 | bool unpackFlipYSupport() const { return fUnpackFlipYSupport; } |
| 281 | |
| 282 | /// Is there support for GL_PACK_ROW_LENGTH |
| 283 | bool packRowLengthSupport() const { return fPackRowLengthSupport; } |
| 284 | |
| 285 | /// Is there support for GL_PACK_REVERSE_ROW_ORDER |
| 286 | bool packFlipYSupport() const { return fPackFlipYSupport; } |
| 287 | |
| 288 | /// Is there support for texture parameter GL_TEXTURE_USAGE |
| 289 | bool textureUsageSupport() const { return fTextureUsageSupport; } |
| 290 | |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 291 | /// Is there support for GL_RED and GL_R8 |
| 292 | bool textureRedSupport() const { return fTextureRedSupport; } |
| 293 | |
Robert Phillips | 5ab7276 | 2017-06-07 12:04:18 -0400 | [diff] [blame] | 294 | /// Is GL_ALPHA8 renderable |
| 295 | bool alpha8IsRenderable() const { return fAlpha8IsRenderable; } |
| 296 | |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 297 | /// Is GL_ARB_IMAGING supported |
| 298 | bool imagingSupport() const { return fImagingSupport; } |
| 299 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 300 | /// Is there support for Vertex Array Objects? |
| 301 | bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } |
| 302 | |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 303 | /// Is there support for GL_EXT_direct_state_access? |
| 304 | bool directStateAccessSupport() const { return fDirectStateAccessSupport; } |
| 305 | |
| 306 | /// Is there support for GL_KHR_debug? |
| 307 | bool debugSupport() const { return fDebugSupport; } |
| 308 | |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 309 | /// Is there support for ES2 compatability? |
| 310 | bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } |
| 311 | |
csmartdalton | 4c18b62 | 2016-07-29 12:19:28 -0700 | [diff] [blame] | 312 | /// Is there support for glDraw*Instanced? |
| 313 | bool drawInstancedSupport() const { return fDrawInstancedSupport; } |
| 314 | |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 315 | /// Is there support for glDraw*Indirect? Note that the baseInstance fields of indirect draw |
| 316 | /// commands cannot be used unless we have base instance support. |
| 317 | bool drawIndirectSupport() const { return fDrawIndirectSupport; } |
| 318 | |
| 319 | /// Is there support for glMultiDraw*Indirect? Note that the baseInstance fields of indirect |
| 320 | /// draw commands cannot be used unless we have base instance support. |
| 321 | bool multiDrawIndirectSupport() const { return fMultiDrawIndirectSupport; } |
| 322 | |
bsalomon | fc9527a | 2016-08-29 09:18:39 -0700 | [diff] [blame] | 323 | /// Is there support for glDrawRangeElements? |
| 324 | bool drawRangeElementsSupport() const { return fDrawRangeElementsSupport; } |
| 325 | |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 326 | /// Are the baseInstance fields supported in indirect draw commands? |
| 327 | bool baseInstanceSupport() const { return fBaseInstanceSupport; } |
| 328 | |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 329 | /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 330 | bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; } |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 331 | |
Brian Salomon | 71d9d84 | 2016-11-03 13:42:00 -0400 | [diff] [blame] | 332 | /// Does ReadPixels support reading readConfig pixels from a FBO that is surfaceConfig? |
| 333 | bool readPixelsSupported(GrPixelConfig surfaceConfig, |
bsalomon | 7928ef6 | 2016-01-05 10:26:39 -0800 | [diff] [blame] | 334 | GrPixelConfig readConfig, |
bsalomon | 1aa2029 | 2016-01-22 08:16:09 -0800 | [diff] [blame] | 335 | std::function<void (GrGLenum, GrGLint*)> getIntegerv, |
bsalomon | 2c3db32 | 2016-11-08 13:26:24 -0800 | [diff] [blame] | 336 | std::function<bool ()> bindRenderTarget, |
| 337 | std::function<void ()> unbindRenderTarget) const; |
skia.committer@gmail.com | 631cdcb | 2013-03-01 12:12:55 +0000 | [diff] [blame] | 338 | |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 339 | bool isCoreProfile() const { return fIsCoreProfile; } |
robertphillips@google.com | 1d89c93 | 2012-06-27 19:31:41 +0000 | [diff] [blame] | 340 | |
joshualitt | c1f56b5 | 2015-06-22 12:31:31 -0700 | [diff] [blame] | 341 | bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; } |
| 342 | |
joshualitt | 7bdd70a | 2015-10-01 06:28:11 -0700 | [diff] [blame] | 343 | bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; } |
| 344 | |
bsalomon | e5286e0 | 2016-01-14 09:24:09 -0800 | [diff] [blame] | 345 | /// Are textures with GL_TEXTURE_RECTANGLE type supported. |
| 346 | bool rectangleTextureSupport() const { return fRectangleTextureSupport; } |
| 347 | |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 348 | /// GL_ARB_texture_swizzle |
| 349 | bool textureSwizzleSupport() const { return fTextureSwizzleSupport; } |
| 350 | |
cblume | 09bd2c0 | 2016-03-01 14:08:28 -0800 | [diff] [blame] | 351 | bool mipMapLevelAndLodControlSupport() const { return fMipMapLevelAndLodControlSupport; } |
| 352 | |
brianosman | 09563ce | 2016-06-02 08:59:34 -0700 | [diff] [blame] | 353 | bool doManualMipmapping() const { return fDoManualMipmapping; } |
| 354 | |
brianosman | 851c238 | 2016-12-07 10:03:25 -0800 | [diff] [blame] | 355 | bool srgbDecodeDisableAffectsMipmaps() const { return fSRGBDecodeDisableAffectsMipmaps; } |
brianosman | 2047189 | 2016-12-02 06:43:32 -0800 | [diff] [blame] | 356 | |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 357 | void onDumpJSON(SkJSONWriter*) const override; |
commit-bot@chromium.org | beb8b3a | 2014-04-15 15:37:51 +0000 | [diff] [blame] | 358 | |
bsalomon | 88c7b98 | 2015-07-31 11:20:16 -0700 | [diff] [blame] | 359 | bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } |
| 360 | bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; } |
ericrk | b4ecabd | 2016-03-11 15:18:20 -0800 | [diff] [blame] | 361 | bool rgbaToBgraReadbackConversionsAreSlow() const { |
| 362 | return fRGBAToBGRAReadbackConversionsAreSlow; |
| 363 | } |
bsalomon | 88c7b98 | 2015-07-31 11:20:16 -0700 | [diff] [blame] | 364 | |
Eric Karl | aeaf22b | 2017-05-18 15:08:09 -0700 | [diff] [blame] | 365 | // Certain Intel GPUs on Mac fail to clear if the glClearColor is made up of only 1s and 0s. |
| 366 | bool clearToBoundaryValuesIsBroken() const { return fClearToBoundaryValuesIsBroken; } |
Chris Dalton | 9926f4b | 2017-05-17 15:15:50 -0600 | [diff] [blame] | 367 | |
Brian Salomon | d17b4a6 | 2017-05-23 16:53:47 -0400 | [diff] [blame] | 368 | /// glClearTex(Sub)Image support |
| 369 | bool clearTextureSupport() const { return fClearTextureSupport; } |
| 370 | |
Chris Dalton | 9926f4b | 2017-05-17 15:15:50 -0600 | [diff] [blame] | 371 | // Adreno/MSAA drops a draw on the imagefiltersbase GM if the base vertex param to |
| 372 | // glDrawArrays is nonzero. |
| 373 | // https://bugs.chromium.org/p/skia/issues/detail?id=6650 |
| 374 | bool drawArraysBaseVertexIsBroken() const { return fDrawArraysBaseVertexIsBroken; } |
| 375 | |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 376 | // Many drivers have issues with color clears. |
| 377 | bool useDrawToClearColor() const { return fUseDrawToClearColor; } |
| 378 | |
Mike Klein | 31550db | 2017-06-06 23:29:53 +0000 | [diff] [blame] | 379 | /// Adreno 4xx devices experience an issue when there are a large number of stencil clip bit |
| 380 | /// clears. The minimal repro steps are not precisely known but drawing a rect with a stencil |
| 381 | /// op instead of using glClear seems to resolve the issue. |
| 382 | bool useDrawToClearStencilClip() const { return fUseDrawToClearStencilClip; } |
| 383 | |
Brian Salomon | 9bada54 | 2017-06-12 12:09:30 -0400 | [diff] [blame] | 384 | // If true then we must use an intermediate surface to perform partial updates to unorm textures |
| 385 | // that have ever been bound to a FBO. |
| 386 | bool disallowTexSubImageForUnormConfigTexturesEverBoundToFBO() const { |
| 387 | return fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO; |
| 388 | } |
| 389 | |
| 390 | // Use an intermediate surface to write pixels (full or partial overwrite) to into a texture |
| 391 | // that is bound to an FBO. |
| 392 | bool useDrawInsteadOfAllRenderTargetWrites() const { |
| 393 | return fUseDrawInsteadOfAllRenderTargetWrites; |
| 394 | } |
| 395 | |
Brian Salomon | 6d9c88b | 2017-06-12 10:24:42 -0400 | [diff] [blame] | 396 | // At least some Adreno 3xx drivers draw lines incorrectly after drawing non-lines. Toggling |
| 397 | // face culling on and off seems to resolve this. |
| 398 | bool requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() const { |
| 399 | return fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines; |
Brian Salomon | af971de | 2017-06-08 16:11:33 -0400 | [diff] [blame] | 400 | } |
| 401 | |
Chris Dalton | cc604e5 | 2017-10-06 16:27:32 -0600 | [diff] [blame] | 402 | // Returns the observed maximum number of instances the driver can handle in a single call to |
| 403 | // glDrawArraysInstanced without crashing, or 'pendingInstanceCount' if this |
| 404 | // workaround is not necessary. |
| 405 | // NOTE: the return value may be larger than pendingInstanceCount. |
| 406 | int maxInstancesPerDrawArraysWithoutCrashing(int pendingInstanceCount) const { |
| 407 | return fMaxInstancesPerDrawArraysWithoutCrashing ? fMaxInstancesPerDrawArraysWithoutCrashing |
| 408 | : pendingInstanceCount; |
| 409 | } |
| 410 | |
Robert Phillips | bf25d43 | 2017-04-07 10:08:53 -0400 | [diff] [blame] | 411 | bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, |
| 412 | bool* rectsMustMatch, bool* disallowSubrect) const override; |
Brian Salomon | 467921e | 2017-03-06 16:17:12 -0500 | [diff] [blame] | 413 | |
Ethan Nicholas | d1b2eec | 2017-11-01 15:45:43 -0400 | [diff] [blame] | 414 | bool programBinarySupport() const { |
| 415 | return fProgramBinarySupport; |
| 416 | } |
| 417 | |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame^] | 418 | bool validateBackendTexture(const GrBackendTexture&, SkColorType, |
| 419 | GrPixelConfig*) const override; |
| 420 | bool validateBackendRenderTarget(const GrBackendRenderTarget&, SkColorType, |
| 421 | GrPixelConfig*) const override; |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 422 | |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame^] | 423 | private: |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 424 | enum ExternalFormatUsage { |
| 425 | kTexImage_ExternalFormatUsage, |
| 426 | kOther_ExternalFormatUsage, |
| 427 | |
| 428 | kLast_ExternalFormatUsage = kOther_ExternalFormatUsage |
| 429 | }; |
| 430 | static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1; |
| 431 | bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig, |
| 432 | ExternalFormatUsage usage, GrGLenum* externalFormat, |
| 433 | GrGLenum* externalType) const; |
| 434 | |
cdalton | 4cd6713 | 2015-06-10 19:23:46 -0700 | [diff] [blame] | 435 | void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*); |
Chris Dalton | 47c8ed3 | 2017-11-15 18:27:09 -0700 | [diff] [blame] | 436 | void initGLSL(const GrGLContextInfo&, const GrGLInterface*); |
kkinnunen | cfe62e3 | 2015-07-01 02:58:50 -0700 | [diff] [blame] | 437 | bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); |
bsalomon | 424cc26 | 2015-05-22 10:37:30 -0700 | [diff] [blame] | 438 | |
egdaniel | b7e7d57 | 2015-11-04 04:23:53 -0800 | [diff] [blame] | 439 | void onApplyOptionsOverrides(const GrContextOptions& options) override; |
| 440 | |
Eric Karl | 5c77975 | 2017-05-08 12:02:07 -0700 | [diff] [blame] | 441 | void initFSAASupport(const GrContextOptions& contextOptions, const GrGLContextInfo&, |
| 442 | const GrGLInterface*); |
cdalton | 1dd0542 | 2015-06-12 09:01:18 -0700 | [diff] [blame] | 443 | void initBlendEqationSupport(const GrGLContextInfo&); |
Eric Karl | 5c77975 | 2017-05-08 12:02:07 -0700 | [diff] [blame] | 444 | void initStencilSupport(const GrGLContextInfo&); |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 445 | // This must be called after initFSAASupport(). |
brianosman | 2047189 | 2016-12-02 06:43:32 -0800 | [diff] [blame] | 446 | void initConfigTable(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*, |
| 447 | GrShaderCaps*); |
commit-bot@chromium.org | 42dc813 | 2014-05-27 19:26:59 +0000 | [diff] [blame] | 448 | |
bsalomon | 1aa2029 | 2016-01-22 08:16:09 -0800 | [diff] [blame] | 449 | GrGLStandard fStandard; |
| 450 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 451 | SkTArray<StencilFormat, true> fStencilFormats; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 452 | |
| 453 | int fMaxFragmentUniformVectors; |
bsalomon@google.com | 60da417 | 2012-06-01 19:25:00 +0000 | [diff] [blame] | 454 | |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 455 | MSFBOType fMSFBOType; |
commit-bot@chromium.org | 52ffbf6 | 2014-04-02 16:19:33 +0000 | [diff] [blame] | 456 | InvalidateFBType fInvalidateFBType; |
commit-bot@chromium.org | 160b478 | 2014-05-05 12:32:37 +0000 | [diff] [blame] | 457 | MapBufferType fMapBufferType; |
jvanverth | d7a2c1f | 2015-12-07 07:36:44 -0800 | [diff] [blame] | 458 | TransferBufferType fTransferBufferType; |
bsalomon@google.com | 6b0cf02 | 2013-05-03 13:35:14 +0000 | [diff] [blame] | 459 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 460 | bool fUnpackRowLengthSupport : 1; |
| 461 | bool fUnpackFlipYSupport : 1; |
| 462 | bool fPackRowLengthSupport : 1; |
| 463 | bool fPackFlipYSupport : 1; |
| 464 | bool fTextureUsageSupport : 1; |
robertphillips@google.com | 443e5a5 | 2012-04-30 20:01:21 +0000 | [diff] [blame] | 465 | bool fTextureRedSupport : 1; |
Robert Phillips | 5ab7276 | 2017-06-07 12:04:18 -0400 | [diff] [blame] | 466 | bool fAlpha8IsRenderable: 1; |
bsalomon@google.com | e76b7cc | 2012-06-18 12:47:06 +0000 | [diff] [blame] | 467 | bool fImagingSupport : 1; |
bsalomon@google.com | 07631cf | 2013-03-05 14:14:58 +0000 | [diff] [blame] | 468 | bool fVertexArrayObjectSupport : 1; |
cdalton | 626e1ff | 2015-06-12 13:56:46 -0700 | [diff] [blame] | 469 | bool fDirectStateAccessSupport : 1; |
| 470 | bool fDebugSupport : 1; |
jvanverth | 3f801cb | 2014-12-16 09:49:38 -0800 | [diff] [blame] | 471 | bool fES2CompatibilitySupport : 1; |
csmartdalton | 4c18b62 | 2016-07-29 12:19:28 -0700 | [diff] [blame] | 472 | bool fDrawInstancedSupport : 1; |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 473 | bool fDrawIndirectSupport : 1; |
bsalomon | fc9527a | 2016-08-29 09:18:39 -0700 | [diff] [blame] | 474 | bool fDrawRangeElementsSupport : 1; |
cdalton | 06604b9 | 2016-02-05 10:09:51 -0800 | [diff] [blame] | 475 | bool fMultiDrawIndirectSupport : 1; |
| 476 | bool fBaseInstanceSupport : 1; |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 477 | bool fUseNonVBOVertexAndIndexDynamicData : 1; |
bsalomon@google.com | 2b1b8c0 | 2013-02-28 22:06:02 +0000 | [diff] [blame] | 478 | bool fIsCoreProfile : 1; |
joshualitt | c1f56b5 | 2015-06-22 12:31:31 -0700 | [diff] [blame] | 479 | bool fBindFragDataLocationSupport : 1; |
bsalomon | 88c7b98 | 2015-07-31 11:20:16 -0700 | [diff] [blame] | 480 | bool fRGBA8888PixelsOpsAreSlow : 1; |
| 481 | bool fPartialFBOReadIsSlow : 1; |
joshualitt | 7bdd70a | 2015-10-01 06:28:11 -0700 | [diff] [blame] | 482 | bool fBindUniformLocationSupport : 1; |
bsalomon | e5286e0 | 2016-01-14 09:24:09 -0800 | [diff] [blame] | 483 | bool fRectangleTextureSupport : 1; |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 484 | bool fTextureSwizzleSupport : 1; |
cblume | 09bd2c0 | 2016-03-01 14:08:28 -0800 | [diff] [blame] | 485 | bool fMipMapLevelAndLodControlSupport : 1; |
ericrk | b4ecabd | 2016-03-11 15:18:20 -0800 | [diff] [blame] | 486 | bool fRGBAToBGRAReadbackConversionsAreSlow : 1; |
brianosman | 09563ce | 2016-06-02 08:59:34 -0700 | [diff] [blame] | 487 | bool fDoManualMipmapping : 1; |
brianosman | 851c238 | 2016-12-07 10:03:25 -0800 | [diff] [blame] | 488 | bool fSRGBDecodeDisableAffectsMipmaps : 1; |
Eric Karl | aeaf22b | 2017-05-18 15:08:09 -0700 | [diff] [blame] | 489 | bool fClearToBoundaryValuesIsBroken : 1; |
Brian Salomon | d17b4a6 | 2017-05-23 16:53:47 -0400 | [diff] [blame] | 490 | bool fClearTextureSupport : 1; |
Chris Dalton | 9926f4b | 2017-05-17 15:15:50 -0600 | [diff] [blame] | 491 | bool fDrawArraysBaseVertexIsBroken : 1; |
Brian Salomon | 43f8bf0 | 2017-10-18 08:33:29 -0400 | [diff] [blame] | 492 | bool fUseDrawToClearColor : 1; |
Mike Klein | 31550db | 2017-06-06 23:29:53 +0000 | [diff] [blame] | 493 | bool fUseDrawToClearStencilClip : 1; |
Brian Salomon | 9bada54 | 2017-06-12 12:09:30 -0400 | [diff] [blame] | 494 | bool fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO : 1; |
| 495 | bool fUseDrawInsteadOfAllRenderTargetWrites : 1; |
Brian Salomon | 6d9c88b | 2017-06-12 10:24:42 -0400 | [diff] [blame] | 496 | bool fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines : 1; |
Ethan Nicholas | d1b2eec | 2017-11-01 15:45:43 -0400 | [diff] [blame] | 497 | bool fProgramBinarySupport : 1; |
joshualitt | 5816233 | 2014-08-01 06:44:53 -0700 | [diff] [blame] | 498 | |
Brian Salomon | e5e7eb1 | 2016-10-14 16:18:33 -0400 | [diff] [blame] | 499 | uint32_t fBlitFramebufferFlags; |
Chris Dalton | cc604e5 | 2017-10-06 16:27:32 -0600 | [diff] [blame] | 500 | int fMaxInstancesPerDrawArraysWithoutCrashing; |
bsalomon | 083617b | 2016-02-12 12:10:14 -0800 | [diff] [blame] | 501 | |
bsalomon | 7928ef6 | 2016-01-05 10:26:39 -0800 | [diff] [blame] | 502 | /** Number type of the components (with out considering number of bits.) */ |
| 503 | enum FormatType { |
| 504 | kNormalizedFixedPoint_FormatType, |
| 505 | kFloat_FormatType, |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 506 | kInteger_FormatType, |
bsalomon | 7928ef6 | 2016-01-05 10:26:39 -0800 | [diff] [blame] | 507 | }; |
| 508 | |
| 509 | struct ReadPixelsFormat { |
| 510 | ReadPixelsFormat() : fFormat(0), fType(0) {} |
| 511 | GrGLenum fFormat; |
| 512 | GrGLenum fType; |
| 513 | }; |
| 514 | |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 515 | struct ConfigFormats { |
| 516 | ConfigFormats() { |
| 517 | // Inits to known bad GL enum values. |
| 518 | memset(this, 0xAB, sizeof(ConfigFormats)); |
| 519 | } |
| 520 | GrGLenum fBaseInternalFormat; |
| 521 | GrGLenum fSizedInternalFormat; |
| 522 | |
| 523 | /** The external format and type are to be used when uploading/downloading data using this |
| 524 | config where both the CPU data and GrSurface are the same config. To get the external |
| 525 | format and type when converting between configs while copying to/from memory use |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 526 | getExternalFormat(). |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 527 | The kTexImage external format is usually the same as kOther except for kSRGBA on some |
| 528 | GL contexts. */ |
| 529 | GrGLenum fExternalFormat[kExternalFormatUsageCnt]; |
| 530 | GrGLenum fExternalType; |
| 531 | |
bsalomon | 76148af | 2016-01-12 11:13:47 -0800 | [diff] [blame] | 532 | // Either the base or sized internal format depending on the GL and config. |
| 533 | GrGLenum fInternalFormatTexImage; |
| 534 | GrGLenum fInternalFormatRenderbuffer; |
| 535 | }; |
| 536 | |
bsalomon | 3044737 | 2015-12-21 09:03:05 -0800 | [diff] [blame] | 537 | struct ConfigInfo { |
bsalomon | 7928ef6 | 2016-01-05 10:26:39 -0800 | [diff] [blame] | 538 | ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {} |
bsalomon | 3044737 | 2015-12-21 09:03:05 -0800 | [diff] [blame] | 539 | |
| 540 | ConfigFormats fFormats; |
| 541 | |
bsalomon | 7928ef6 | 2016-01-05 10:26:39 -0800 | [diff] [blame] | 542 | FormatType fFormatType; |
| 543 | |
| 544 | // On ES contexts there are restrictions on type type/format that may be used for |
| 545 | // ReadPixels. One is implicitly specified by the current FBO's format. The other is |
| 546 | // queryable. This stores the queried option (lazily). |
| 547 | ReadPixelsFormat fSecondReadPixelsFormat; |
| 548 | |
bsalomon | 3044737 | 2015-12-21 09:03:05 -0800 | [diff] [blame] | 549 | enum { |
| 550 | // This indicates that a stencil format has not yet been determined for the config. |
| 551 | kUnknown_StencilIndex = -1, |
| 552 | // This indicates that there is no supported stencil format for the config. |
| 553 | kUnsupported_StencilFormatIndex = -2 |
| 554 | }; |
bsalomon | 480e8c0 | 2015-12-21 13:44:18 -0800 | [diff] [blame] | 555 | |
| 556 | // Index fStencilFormats. |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 557 | int fStencilFormatIndex; |
| 558 | |
| 559 | SkTDArray<int> fColorSampleCounts; |
bsalomon | 480e8c0 | 2015-12-21 13:44:18 -0800 | [diff] [blame] | 560 | |
| 561 | enum { |
bsalomon | 41e4384e | 2016-01-08 09:12:44 -0800 | [diff] [blame] | 562 | kVerifiedColorAttachment_Flag = 0x1, |
| 563 | kTextureable_Flag = 0x2, |
| 564 | kRenderable_Flag = 0x4, |
| 565 | kRenderableWithMSAA_Flag = 0x8, |
Brian Salomon | 71d9d84 | 2016-11-03 13:42:00 -0400 | [diff] [blame] | 566 | /** kFBOColorAttachment means that even if the config cannot be a GrRenderTarget, we can |
| 567 | still attach it to a FBO for blitting or reading pixels. */ |
| 568 | kFBOColorAttachment_Flag = 0x10, |
| 569 | kCanUseTexStorage_Flag = 0x20, |
| 570 | kCanUseWithTexelBuffer_Flag = 0x40, |
bsalomon | 480e8c0 | 2015-12-21 13:44:18 -0800 | [diff] [blame] | 571 | }; |
| 572 | uint32_t fFlags; |
bsalomon | cdee009 | 2016-01-08 13:20:12 -0800 | [diff] [blame] | 573 | |
| 574 | GrSwizzle fSwizzle; |
bsalomon | 3044737 | 2015-12-21 09:03:05 -0800 | [diff] [blame] | 575 | }; |
| 576 | |
| 577 | ConfigInfo fConfigTable[kGrPixelConfigCnt]; |
| 578 | |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 579 | typedef GrCaps INHERITED; |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 580 | }; |
| 581 | |
bsalomon@google.com | f7fa806 | 2012-02-14 14:09:57 +0000 | [diff] [blame] | 582 | #endif |