OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef GrGLCaps_DEFINED | 9 #ifndef GrGLCaps_DEFINED |
10 #define GrGLCaps_DEFINED | 10 #define GrGLCaps_DEFINED |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 /** | 22 /** |
23 * Stores some capabilities of a GL context. Most are determined by the GL | 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 | 24 * version and the extensions string. It also tracks formats that have passed |
25 * the FBO completeness test. | 25 * the FBO completeness test. |
26 */ | 26 */ |
27 class GrGLCaps : public GrCaps { | 27 class GrGLCaps : public GrCaps { |
28 public: | 28 public: |
29 typedef GrGLStencilAttachment::Format StencilFormat; | 29 typedef GrGLStencilAttachment::Format StencilFormat; |
30 | 30 |
| 31 /** Provides information about the mappiing from GrPixelConfig to GL formats
. */ |
| 32 struct ConfigFormats { |
| 33 ConfigFormats() { |
| 34 // Inits to known bad GL enum values. |
| 35 memset(this, 0xAB, sizeof(ConfigFormats)); |
| 36 } |
| 37 GrGLenum fBaseInternalFormat; |
| 38 GrGLenum fSizedInternalFormat; |
| 39 GrGLenum fExternalFormat; |
| 40 GrGLenum fExternalType; |
| 41 |
| 42 // The <format> parameter to use for glTexImage and glTexSubImage. |
| 43 // This is usually the same as fExternalFormat except for kSRGBA on some
GL contexts. |
| 44 GrGLenum fExternalFormatForTexImage; |
| 45 // Either the base or sized internal format depending on the GL and conf
ig. |
| 46 GrGLenum fInternalFormatTexImage; |
| 47 }; |
| 48 |
31 /** | 49 /** |
32 * The type of MSAA for FBOs supported. Different extensions have different | 50 * The type of MSAA for FBOs supported. Different extensions have different |
33 * semantics of how / when a resolve is performed. | 51 * semantics of how / when a resolve is performed. |
34 */ | 52 */ |
35 enum MSFBOType { | 53 enum MSFBOType { |
36 /** | 54 /** |
37 * no support for MSAA FBOs | 55 * no support for MSAA FBOs |
38 */ | 56 */ |
39 kNone_MSFBOType = 0, | 57 kNone_MSFBOType = 0, |
40 /** | 58 /** |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 kLast_TransferBufferType = kChromium_TransferBufferType, | 116 kLast_TransferBufferType = kChromium_TransferBufferType, |
99 }; | 117 }; |
100 | 118 |
101 /** | 119 /** |
102 * Initializes the GrGLCaps to the set of features supported in the current | 120 * Initializes the GrGLCaps to the set of features supported in the current |
103 * OpenGL context accessible via ctxInfo. | 121 * OpenGL context accessible via ctxInfo. |
104 */ | 122 */ |
105 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxI
nfo, | 123 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxI
nfo, |
106 const GrGLInterface* glInterface); | 124 const GrGLInterface* glInterface); |
107 | 125 |
| 126 /** Returns conversions to various GL format parameters for a GrPixelCfonig.
*/ |
| 127 const ConfigFormats& configGLFormats(GrPixelConfig config) const { |
| 128 return fConfigTable[config].fFormats; |
| 129 } |
| 130 |
| 131 |
| 132 /** |
| 133 * Gets an array of legal stencil formats. These formats are not guaranteed |
| 134 * to be supported by the driver but are legal GLenum names given the GL |
| 135 * version and extensions supported. |
| 136 */ |
| 137 const SkTArray<StencilFormat, true>& stencilFormats() const { |
| 138 return fStencilFormats; |
| 139 } |
| 140 |
| 141 /** |
| 142 * Has a stencil format index been found for the config (or we've found that
no format works). |
| 143 */ |
| 144 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const { |
| 145 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_
StencilIndex; |
| 146 } |
| 147 |
| 148 /** |
| 149 * Gets the stencil format index for the config. This assumes |
| 150 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns
a value < 0 if |
| 151 * no stencil format is supported with the config. Otherwise, returned index
refers to the array |
| 152 * returned by stencilFormats(). |
| 153 */ |
| 154 int getStencilFormatIndexForConfig(GrPixelConfig config) const { |
| 155 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config)); |
| 156 return fConfigTable[config].fStencilFormatIndex; |
| 157 } |
| 158 |
| 159 /** |
| 160 * If index is >= 0 this records an index into stencilFormats() as the best
stencil format for |
| 161 * the config. If < 0 it records that the config has no supported stencil fo
rmat index. |
| 162 */ |
| 163 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) { |
| 164 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config)); |
| 165 if (index < 0) { |
| 166 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_
StencilFormatIndex; |
| 167 } else { |
| 168 fConfigTable[config].fStencilFormatIndex = index; |
| 169 } |
| 170 } |
| 171 |
108 /** | 172 /** |
109 * Call to note that a color config has been verified as a valid color | 173 * Call to note that a color config has been verified as a valid color |
110 * attachment. This may save future calls to glCheckFramebufferStatus | 174 * attachment. This may save future calls to glCheckFramebufferStatus |
111 * using isConfigVerifiedColorAttachment(). | 175 * using isConfigVerifiedColorAttachment(). |
112 */ | 176 */ |
113 void markConfigAsValidColorAttachment(GrPixelConfig config) { | 177 void markConfigAsValidColorAttachment(GrPixelConfig config) { |
114 fVerifiedColorConfigs.markVerified(config); | 178 fVerifiedColorConfigs.markVerified(config); |
115 } | 179 } |
116 | 180 |
117 /** | 181 /** |
(...skipping 29 matching lines...) Expand all Loading... |
147 } | 211 } |
148 | 212 |
149 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } | 213 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } |
150 | 214 |
151 /// What type of buffer mapping is supported? | 215 /// What type of buffer mapping is supported? |
152 MapBufferType mapBufferType() const { return fMapBufferType; } | 216 MapBufferType mapBufferType() const { return fMapBufferType; } |
153 | 217 |
154 /// What type of transfer buffer is supported? | 218 /// What type of transfer buffer is supported? |
155 TransferBufferType transferBufferType() const { return fTransferBufferType;
} | 219 TransferBufferType transferBufferType() const { return fTransferBufferType;
} |
156 | 220 |
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). | 221 /// The maximum number of fragment uniform vectors (GLES has min. 16). |
167 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } | 222 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } |
168 | 223 |
169 /// maximum number of attribute values per vertex | 224 /// maximum number of attribute values per vertex |
170 int maxVertexAttributes() const { return fMaxVertexAttributes; } | 225 int maxVertexAttributes() const { return fMaxVertexAttributes; } |
171 | 226 |
172 /// maximum number of texture units accessible in the fragment shader. | 227 /// maximum number of texture units accessible in the fragment shader. |
173 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } | 228 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } |
174 | 229 |
175 /// ES requires an extension to support RGBA8 in RenderBufferStorage | 230 /// ES requires an extension to support RGBA8 in RenderBufferStorage |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*,
bool srgbSupport); | 380 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*,
bool srgbSupport); |
326 | 381 |
327 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; | 382 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; |
328 | 383 |
329 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, | 384 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, |
330 const GrGLInterface* intf, | 385 const GrGLInterface* intf, |
331 GrGLSLCaps* glslCaps); | 386 GrGLSLCaps* glslCaps); |
332 | 387 |
333 void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glsl
Caps); | 388 void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glsl
Caps); |
334 | 389 |
| 390 void initConfigTable(const GrGLContextInfo&); |
| 391 |
335 // tracks configs that have been verified to pass the FBO completeness when | 392 // tracks configs that have been verified to pass the FBO completeness when |
336 // used as a color attachment | 393 // used as a color attachment |
337 VerifiedColorConfigs fVerifiedColorConfigs; | 394 VerifiedColorConfigs fVerifiedColorConfigs; |
338 | 395 |
339 SkTArray<StencilFormat, true> fStencilFormats; | 396 SkTArray<StencilFormat, true> fStencilFormats; |
340 | 397 |
341 int fMaxFragmentUniformVectors; | 398 int fMaxFragmentUniformVectors; |
342 int fMaxVertexAttributes; | 399 int fMaxVertexAttributes; |
343 int fMaxFragmentTextureUnits; | 400 int fMaxFragmentTextureUnits; |
344 | 401 |
(...skipping 21 matching lines...) Expand all Loading... |
366 bool fMultisampleDisableSupport : 1; | 423 bool fMultisampleDisableSupport : 1; |
367 bool fUseNonVBOVertexAndIndexDynamicData : 1; | 424 bool fUseNonVBOVertexAndIndexDynamicData : 1; |
368 bool fIsCoreProfile : 1; | 425 bool fIsCoreProfile : 1; |
369 bool fBindFragDataLocationSupport : 1; | 426 bool fBindFragDataLocationSupport : 1; |
370 bool fSRGBWriteControl : 1; | 427 bool fSRGBWriteControl : 1; |
371 bool fRGBA8888PixelsOpsAreSlow : 1; | 428 bool fRGBA8888PixelsOpsAreSlow : 1; |
372 bool fPartialFBOReadIsSlow : 1; | 429 bool fPartialFBOReadIsSlow : 1; |
373 bool fBindUniformLocationSupport : 1; | 430 bool fBindUniformLocationSupport : 1; |
374 bool fExternalTextureSupport : 1; | 431 bool fExternalTextureSupport : 1; |
375 | 432 |
| 433 struct ConfigInfo { |
| 434 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex) {}; |
| 435 |
| 436 ConfigFormats fFormats; |
| 437 |
| 438 // Index into GrGLCaps's list of stencil formats. Support is determined
experimentally and |
| 439 // lazily. |
| 440 int fStencilFormatIndex; |
| 441 |
| 442 enum { |
| 443 // This indicates that a stencil format has not yet been determined
for the config. |
| 444 kUnknown_StencilIndex = -1, |
| 445 // This indicates that there is no supported stencil format for the
config. |
| 446 kUnsupported_StencilFormatIndex = -2 |
| 447 }; |
| 448 }; |
| 449 |
| 450 ConfigInfo fConfigTable[kGrPixelConfigCnt]; |
| 451 |
376 struct ReadPixelsSupportedFormat { | 452 struct ReadPixelsSupportedFormat { |
377 GrGLenum fFormat; | 453 GrGLenum fFormat; |
378 GrGLenum fType; | 454 GrGLenum fType; |
379 GrGLenum fFboFormat; | 455 GrGLenum fFboFormat; |
380 | 456 |
381 bool operator==(const ReadPixelsSupportedFormat& rhs) const { | 457 bool operator==(const ReadPixelsSupportedFormat& rhs) const { |
382 return fFormat == rhs.fFormat | 458 return fFormat == rhs.fFormat |
383 && fType == rhs.fType | 459 && fType == rhs.fType |
384 && fFboFormat == rhs.fFboFormat; | 460 && fFboFormat == rhs.fFboFormat; |
385 } | 461 } |
386 }; | 462 }; |
387 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; | 463 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; |
388 | 464 |
389 typedef GrCaps INHERITED; | 465 typedef GrCaps INHERITED; |
390 }; | 466 }; |
391 | 467 |
392 #endif | 468 #endif |
OLD | NEW |