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 12 #include <functional> 13 14 #include "GrCaps.h" 15 #include "GrGLStencilAttachment.h" 16 #include "GrSwizzle.h" 17 #include "SkChecksum.h" 18 #include "SkTHash.h" 19 #include "SkTArray.h" 20 #include "../private/GrGLSL.h" 21 22 class GrGLContextInfo; 23 class GrGLRenderTarget; 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 */ 30 class GrGLCaps : public GrCaps { 31 public: 32 typedef GrGLStencilAttachment::Format StencilFormat; 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 */ 42 kNone_MSFBOType = 0, 43 /** 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 47 */ 48 kStandard_MSFBOType, 49 /** 50 * GL_APPLE_framebuffer_multisample ES extension 51 */ 52 kES_Apple_MSFBOType, 53 /** 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). 58 */ 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, 65 /** 66 * GL_NV_framebuffer_mixed_samples. 67 */ 68 kMixedSamples_MSFBOType, 69 70 kLast_MSFBOType = kMixedSamples_MSFBOType 71 }; 72 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, 81 }; 82 83 enum InvalidateFBType { 84 kNone_InvalidateFBType, 85 kDiscard_InvalidateFBType, //<! glDiscardFramebuffer() 86 kInvalidate_InvalidateFBType, //<! glInvalidateFramebuffer() 87 88 kLast_InvalidateFBType = kInvalidate_InvalidateFBType 89 }; 90 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 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 108 /** 109 * Initializes the GrGLCaps to the set of features supported in the current 110 * OpenGL context accessible via ctxInfo. 111 */ 112 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, 113 const GrGLInterface* glInterface); 114 115 int getSampleCount(int requestedCount, GrPixelConfig config) const override; 116 isConfigTexturable(GrPixelConfig config)117 bool isConfigTexturable(GrPixelConfig config) const override { 118 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag); 119 } 120 isConfigRenderable(GrPixelConfig config,bool withMSAA)121 bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { 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 } canConfigBeImageStorage(GrPixelConfig config)128 bool canConfigBeImageStorage(GrPixelConfig config) const override { 129 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseAsImageStorage_Flag); 130 } canConfigBeFBOColorAttachment(GrPixelConfig config)131 bool canConfigBeFBOColorAttachment(GrPixelConfig config) const { 132 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kFBOColorAttachment_Flag); 133 } 134 isConfigTexSupportEnabled(GrPixelConfig config)135 bool isConfigTexSupportEnabled(GrPixelConfig config) const { 136 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseTexStorage_Flag); 137 } 138 canUseConfigWithTexelBuffer(GrPixelConfig config)139 bool canUseConfigWithTexelBuffer(GrPixelConfig config) const { 140 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseWithTexelBuffer_Flag); 141 } 142 143 /** Returns the mapping between GrPixelConfig components and GL internal format components. */ configSwizzle(GrPixelConfig config)144 const GrSwizzle& configSwizzle(GrPixelConfig config) const { 145 return fConfigTable[config].fSwizzle; 146 } 147 configSizedInternalFormat(GrPixelConfig config)148 GrGLenum configSizedInternalFormat(GrPixelConfig config) const { 149 return fConfigTable[config].fFormats.fSizedInternalFormat; 150 } 151 152 bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, 153 GrGLenum* internalFormat, GrGLenum* externalFormat, 154 GrGLenum* externalType) const; 155 156 bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig, 157 GrGLenum* externalFormat, GrGLenum* externalType) const; 158 159 bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const; 160 161 /** The format to use read/write a texture as an image in a shader */ getImageFormat(GrPixelConfig config)162 GrGLenum getImageFormat(GrPixelConfig config) const { 163 return fConfigTable[config].fFormats.fSizedInternalFormat; 164 } 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 */ stencilFormats()171 const SkTArray<StencilFormat, true>& stencilFormats() const { 172 return fStencilFormats; 173 } 174 175 /** 176 * Has a stencil format index been found for the config (or we've found that no format works). 177 */ hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config)178 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const { 179 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_StencilIndex; 180 } 181 182 /** 183 * Gets the stencil format index for the config. This assumes 184 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns a value < 0 if 185 * no stencil format is supported with the config. Otherwise, returned index refers to the array 186 * returned by stencilFormats(). 187 */ getStencilFormatIndexForConfig(GrPixelConfig config)188 int getStencilFormatIndexForConfig(GrPixelConfig config) const { 189 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config)); 190 return fConfigTable[config].fStencilFormatIndex; 191 } 192 193 /** 194 * If index is >= 0 this records an index into stencilFormats() as the best stencil format for 195 * the config. If < 0 it records that the config has no supported stencil format index. 196 */ setStencilFormatIndexForConfig(GrPixelConfig config,int index)197 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) { 198 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config)); 199 if (index < 0) { 200 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_StencilFormatIndex; 201 } else { 202 fConfigTable[config].fStencilFormatIndex = index; 203 } 204 } 205 206 /** 207 * Call to note that a color config has been verified as a valid color 208 * attachment. This may save future calls to glCheckFramebufferStatus 209 * using isConfigVerifiedColorAttachment(). 210 */ markConfigAsValidColorAttachment(GrPixelConfig config)211 void markConfigAsValidColorAttachment(GrPixelConfig config) { 212 fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag; 213 } 214 215 /** 216 * Call to check whether a config has been verified as a valid color 217 * attachment. 218 */ isConfigVerifiedColorAttachment(GrPixelConfig config)219 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { 220 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColorAttachment_Flag); 221 } 222 223 /** 224 * Reports the type of MSAA FBO support. 225 */ msFBOType()226 MSFBOType msFBOType() const { return fMSFBOType; } 227 228 /** 229 * Does the preferred MSAA FBO extension have MSAA renderbuffers? 230 */ usesMSAARenderBuffers()231 bool usesMSAARenderBuffers() const { 232 return kNone_MSFBOType != fMSFBOType && 233 kES_IMG_MsToTexture_MSFBOType != fMSFBOType && 234 kES_EXT_MsToTexture_MSFBOType != fMSFBOType && 235 kMixedSamples_MSFBOType != fMSFBOType; 236 } 237 238 /** 239 * What functionality is supported by glBlitFramebuffer. 240 */ blitFramebufferSupportFlags()241 uint32_t blitFramebufferSupportFlags() const { return fBlitFramebufferFlags; } 242 243 /** 244 * Is the MSAA FBO extension one where the texture is multisampled when bound to an FBO and 245 * then implicitly resolved when read. 246 */ usesImplicitMSAAResolve()247 bool usesImplicitMSAAResolve() const { 248 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || 249 kES_EXT_MsToTexture_MSFBOType == fMSFBOType; 250 } 251 invalidateFBType()252 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } 253 254 /// What type of buffer mapping is supported? mapBufferType()255 MapBufferType mapBufferType() const { return fMapBufferType; } 256 257 /// What type of transfer buffer is supported? transferBufferType()258 TransferBufferType transferBufferType() const { return fTransferBufferType; } 259 260 /// The maximum number of fragment uniform vectors (GLES has min. 16). maxFragmentUniformVectors()261 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } 262 263 /** 264 * Depending on the ES extensions present the BGRA external format may 265 * correspond to either a BGRA or RGBA internalFormat. On desktop GL it is 266 * RGBA. 267 */ 268 bool bgraIsInternalFormat() const; 269 270 /// Is there support for GL_UNPACK_ROW_LENGTH unpackRowLengthSupport()271 bool unpackRowLengthSupport() const { return fUnpackRowLengthSupport; } 272 273 /// Is there support for GL_UNPACK_FLIP_Y unpackFlipYSupport()274 bool unpackFlipYSupport() const { return fUnpackFlipYSupport; } 275 276 /// Is there support for GL_PACK_ROW_LENGTH packRowLengthSupport()277 bool packRowLengthSupport() const { return fPackRowLengthSupport; } 278 279 /// Is there support for GL_PACK_REVERSE_ROW_ORDER packFlipYSupport()280 bool packFlipYSupport() const { return fPackFlipYSupport; } 281 282 /// Is there support for texture parameter GL_TEXTURE_USAGE textureUsageSupport()283 bool textureUsageSupport() const { return fTextureUsageSupport; } 284 285 /// Is there support for GL_RED and GL_R8 textureRedSupport()286 bool textureRedSupport() const { return fTextureRedSupport; } 287 288 /// Is GL_ALPHA8 renderable alpha8IsRenderable()289 bool alpha8IsRenderable() const { return fAlpha8IsRenderable; } 290 291 /// Is GL_ARB_IMAGING supported imagingSupport()292 bool imagingSupport() const { return fImagingSupport; } 293 294 /// Is there support for Vertex Array Objects? vertexArrayObjectSupport()295 bool vertexArrayObjectSupport() const { return fVertexArrayObjectSupport; } 296 297 /// Is there support for GL_EXT_direct_state_access? directStateAccessSupport()298 bool directStateAccessSupport() const { return fDirectStateAccessSupport; } 299 300 /// Is there support for GL_KHR_debug? debugSupport()301 bool debugSupport() const { return fDebugSupport; } 302 303 /// Is there support for ES2 compatability? ES2CompatibilitySupport()304 bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; } 305 306 /// Is there support for glDraw*Instanced? drawInstancedSupport()307 bool drawInstancedSupport() const { return fDrawInstancedSupport; } 308 309 /// Is there support for glDraw*Indirect? Note that the baseInstance fields of indirect draw 310 /// commands cannot be used unless we have base instance support. drawIndirectSupport()311 bool drawIndirectSupport() const { return fDrawIndirectSupport; } 312 313 /// Is there support for glMultiDraw*Indirect? Note that the baseInstance fields of indirect 314 /// draw commands cannot be used unless we have base instance support. multiDrawIndirectSupport()315 bool multiDrawIndirectSupport() const { return fMultiDrawIndirectSupport; } 316 317 /// Is there support for glDrawRangeElements? drawRangeElementsSupport()318 bool drawRangeElementsSupport() const { return fDrawRangeElementsSupport; } 319 320 /// Are the baseInstance fields supported in indirect draw commands? baseInstanceSupport()321 bool baseInstanceSupport() const { return fBaseInstanceSupport; } 322 323 /// Use indices or vertices in CPU arrays rather than VBOs for dynamic content. useNonVBOVertexAndIndexDynamicData()324 bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; } 325 326 /// Does ReadPixels support reading readConfig pixels from a FBO that is surfaceConfig? 327 bool readPixelsSupported(GrPixelConfig surfaceConfig, 328 GrPixelConfig readConfig, 329 std::function<void (GrGLenum, GrGLint*)> getIntegerv, 330 std::function<bool ()> bindRenderTarget, 331 std::function<void ()> unbindRenderTarget) const; 332 isCoreProfile()333 bool isCoreProfile() const { return fIsCoreProfile; } 334 bindFragDataLocationSupport()335 bool bindFragDataLocationSupport() const { return fBindFragDataLocationSupport; } 336 bindUniformLocationSupport()337 bool bindUniformLocationSupport() const { return fBindUniformLocationSupport; } 338 339 /// Are textures with GL_TEXTURE_RECTANGLE type supported. rectangleTextureSupport()340 bool rectangleTextureSupport() const { return fRectangleTextureSupport; } 341 342 /// GL_ARB_texture_swizzle textureSwizzleSupport()343 bool textureSwizzleSupport() const { return fTextureSwizzleSupport; } 344 mipMapLevelAndLodControlSupport()345 bool mipMapLevelAndLodControlSupport() const { return fMipMapLevelAndLodControlSupport; } 346 doManualMipmapping()347 bool doManualMipmapping() const { return fDoManualMipmapping; } 348 srgbDecodeDisableSupport()349 bool srgbDecodeDisableSupport() const { return fSRGBDecodeDisableSupport; } srgbDecodeDisableAffectsMipmaps()350 bool srgbDecodeDisableAffectsMipmaps() const { return fSRGBDecodeDisableAffectsMipmaps; } 351 352 /** 353 * Returns a string containing the caps info. 354 */ 355 SkString dump() const override; 356 rgba8888PixelsOpsAreSlow()357 bool rgba8888PixelsOpsAreSlow() const { return fRGBA8888PixelsOpsAreSlow; } partialFBOReadIsSlow()358 bool partialFBOReadIsSlow() const { return fPartialFBOReadIsSlow; } rgbaToBgraReadbackConversionsAreSlow()359 bool rgbaToBgraReadbackConversionsAreSlow() const { 360 return fRGBAToBGRAReadbackConversionsAreSlow; 361 } 362 363 // Certain Intel GPUs on Mac fail to clear if the glClearColor is made up of only 1s and 0s. clearToBoundaryValuesIsBroken()364 bool clearToBoundaryValuesIsBroken() const { return fClearToBoundaryValuesIsBroken; } 365 366 /// glClearTex(Sub)Image support clearTextureSupport()367 bool clearTextureSupport() const { return fClearTextureSupport; } 368 369 // Adreno/MSAA drops a draw on the imagefiltersbase GM if the base vertex param to 370 // glDrawArrays is nonzero. 371 // https://bugs.chromium.org/p/skia/issues/detail?id=6650 drawArraysBaseVertexIsBroken()372 bool drawArraysBaseVertexIsBroken() const { return fDrawArraysBaseVertexIsBroken; } 373 374 /// Adreno 4xx devices experience an issue when there are a large number of stencil clip bit 375 /// clears. The minimal repro steps are not precisely known but drawing a rect with a stencil 376 /// op instead of using glClear seems to resolve the issue. useDrawToClearStencilClip()377 bool useDrawToClearStencilClip() const { return fUseDrawToClearStencilClip; } 378 379 // If true then we must use an intermediate surface to perform partial updates to unorm textures 380 // that have ever been bound to a FBO. disallowTexSubImageForUnormConfigTexturesEverBoundToFBO()381 bool disallowTexSubImageForUnormConfigTexturesEverBoundToFBO() const { 382 return fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO; 383 } 384 385 // Use an intermediate surface to write pixels (full or partial overwrite) to into a texture 386 // that is bound to an FBO. useDrawInsteadOfAllRenderTargetWrites()387 bool useDrawInsteadOfAllRenderTargetWrites() const { 388 return fUseDrawInsteadOfAllRenderTargetWrites; 389 } 390 391 // At least some Adreno 3xx drivers draw lines incorrectly after drawing non-lines. Toggling 392 // face culling on and off seems to resolve this. requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines()393 bool requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() const { 394 return fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines; 395 } 396 397 bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, 398 bool* rectsMustMatch, bool* disallowSubrect) const override; 399 400 private: 401 enum ExternalFormatUsage { 402 kTexImage_ExternalFormatUsage, 403 kOther_ExternalFormatUsage, 404 405 kLast_ExternalFormatUsage = kOther_ExternalFormatUsage 406 }; 407 static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1; 408 bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig, 409 ExternalFormatUsage usage, GrGLenum* externalFormat, 410 GrGLenum* externalType) const; 411 412 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*); 413 void initGLSL(const GrGLContextInfo&); 414 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); 415 416 void onApplyOptionsOverrides(const GrContextOptions& options) override; 417 418 void initFSAASupport(const GrContextOptions& contextOptions, const GrGLContextInfo&, 419 const GrGLInterface*); 420 void initBlendEqationSupport(const GrGLContextInfo&); 421 void initStencilSupport(const GrGLContextInfo&); 422 // This must be called after initFSAASupport(). 423 void initConfigTable(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*, 424 GrShaderCaps*); 425 426 void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*, GrShaderCaps*); 427 428 GrGLStandard fStandard; 429 430 SkTArray<StencilFormat, true> fStencilFormats; 431 432 int fMaxFragmentUniformVectors; 433 434 MSFBOType fMSFBOType; 435 InvalidateFBType fInvalidateFBType; 436 MapBufferType fMapBufferType; 437 TransferBufferType fTransferBufferType; 438 439 bool fUnpackRowLengthSupport : 1; 440 bool fUnpackFlipYSupport : 1; 441 bool fPackRowLengthSupport : 1; 442 bool fPackFlipYSupport : 1; 443 bool fTextureUsageSupport : 1; 444 bool fTextureRedSupport : 1; 445 bool fAlpha8IsRenderable: 1; 446 bool fImagingSupport : 1; 447 bool fVertexArrayObjectSupport : 1; 448 bool fDirectStateAccessSupport : 1; 449 bool fDebugSupport : 1; 450 bool fES2CompatibilitySupport : 1; 451 bool fDrawInstancedSupport : 1; 452 bool fDrawIndirectSupport : 1; 453 bool fDrawRangeElementsSupport : 1; 454 bool fMultiDrawIndirectSupport : 1; 455 bool fBaseInstanceSupport : 1; 456 bool fUseNonVBOVertexAndIndexDynamicData : 1; 457 bool fIsCoreProfile : 1; 458 bool fBindFragDataLocationSupport : 1; 459 bool fRGBA8888PixelsOpsAreSlow : 1; 460 bool fPartialFBOReadIsSlow : 1; 461 bool fBindUniformLocationSupport : 1; 462 bool fRectangleTextureSupport : 1; 463 bool fTextureSwizzleSupport : 1; 464 bool fMipMapLevelAndLodControlSupport : 1; 465 bool fRGBAToBGRAReadbackConversionsAreSlow : 1; 466 bool fDoManualMipmapping : 1; 467 bool fSRGBDecodeDisableSupport : 1; 468 bool fSRGBDecodeDisableAffectsMipmaps : 1; 469 bool fClearToBoundaryValuesIsBroken : 1; 470 bool fClearTextureSupport : 1; 471 bool fDrawArraysBaseVertexIsBroken : 1; 472 bool fUseDrawToClearStencilClip : 1; 473 bool fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO : 1; 474 bool fUseDrawInsteadOfAllRenderTargetWrites : 1; 475 bool fRequiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines : 1; 476 477 uint32_t fBlitFramebufferFlags; 478 479 /** Number type of the components (with out considering number of bits.) */ 480 enum FormatType { 481 kNormalizedFixedPoint_FormatType, 482 kFloat_FormatType, 483 kInteger_FormatType, 484 }; 485 486 struct ReadPixelsFormat { ReadPixelsFormatReadPixelsFormat487 ReadPixelsFormat() : fFormat(0), fType(0) {} 488 GrGLenum fFormat; 489 GrGLenum fType; 490 }; 491 492 struct ConfigFormats { ConfigFormatsConfigFormats493 ConfigFormats() { 494 // Inits to known bad GL enum values. 495 memset(this, 0xAB, sizeof(ConfigFormats)); 496 } 497 GrGLenum fBaseInternalFormat; 498 GrGLenum fSizedInternalFormat; 499 500 /** The external format and type are to be used when uploading/downloading data using this 501 config where both the CPU data and GrSurface are the same config. To get the external 502 format and type when converting between configs while copying to/from memory use 503 getExternalFormat(). 504 The kTexImage external format is usually the same as kOther except for kSRGBA on some 505 GL contexts. */ 506 GrGLenum fExternalFormat[kExternalFormatUsageCnt]; 507 GrGLenum fExternalType; 508 509 // Either the base or sized internal format depending on the GL and config. 510 GrGLenum fInternalFormatTexImage; 511 GrGLenum fInternalFormatRenderbuffer; 512 }; 513 514 struct ConfigInfo { ConfigInfoConfigInfo515 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {} 516 517 ConfigFormats fFormats; 518 519 FormatType fFormatType; 520 521 // On ES contexts there are restrictions on type type/format that may be used for 522 // ReadPixels. One is implicitly specified by the current FBO's format. The other is 523 // queryable. This stores the queried option (lazily). 524 ReadPixelsFormat fSecondReadPixelsFormat; 525 526 enum { 527 // This indicates that a stencil format has not yet been determined for the config. 528 kUnknown_StencilIndex = -1, 529 // This indicates that there is no supported stencil format for the config. 530 kUnsupported_StencilFormatIndex = -2 531 }; 532 533 // Index fStencilFormats. 534 int fStencilFormatIndex; 535 536 SkTDArray<int> fColorSampleCounts; 537 538 enum { 539 kVerifiedColorAttachment_Flag = 0x1, 540 kTextureable_Flag = 0x2, 541 kRenderable_Flag = 0x4, 542 kRenderableWithMSAA_Flag = 0x8, 543 /** kFBOColorAttachment means that even if the config cannot be a GrRenderTarget, we can 544 still attach it to a FBO for blitting or reading pixels. */ 545 kFBOColorAttachment_Flag = 0x10, 546 kCanUseTexStorage_Flag = 0x20, 547 kCanUseWithTexelBuffer_Flag = 0x40, 548 kCanUseAsImageStorage_Flag = 0x80, 549 }; 550 uint32_t fFlags; 551 552 GrSwizzle fSwizzle; 553 }; 554 555 ConfigInfo fConfigTable[kGrPixelConfigCnt]; 556 557 typedef GrCaps INHERITED; 558 }; 559 560 #endif 561