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 |
11 | 11 |
12 #include "GrDrawTargetCaps.h" | 12 #include "GrDrawTargetCaps.h" |
13 #include "GrGLStencilAttachment.h" | 13 #include "GrGLStencilAttachment.h" |
14 #include "SkChecksum.h" | 14 #include "SkChecksum.h" |
15 #include "SkTHash.h" | 15 #include "SkTHash.h" |
16 #include "SkTArray.h" | 16 #include "SkTArray.h" |
17 | 17 |
18 class GrGLContextInfo; | 18 class GrGLContextInfo; |
| 19 class GrGLSLCaps; |
19 | 20 |
20 /** | 21 /** |
21 * Stores some capabilities of a GL context. Most are determined by the GL | 22 * Stores some capabilities of a GL context. Most are determined by the GL |
22 * version and the extensions string. It also tracks formats that have passed | 23 * version and the extensions string. It also tracks formats that have passed |
23 * the FBO completeness test. | 24 * the FBO completeness test. |
24 */ | 25 */ |
25 class GrGLCaps : public GrDrawTargetCaps { | 26 class GrGLCaps : public GrDrawTargetCaps { |
26 public: | 27 public: |
27 SK_DECLARE_INST_COUNT(GrGLCaps) | 28 SK_DECLARE_INST_COUNT(GrGLCaps) |
28 | 29 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 159 |
159 /** | 160 /** |
160 * Is the MSAA FBO extension one where the texture is multisampled when boun
d to an FBO and | 161 * Is the MSAA FBO extension one where the texture is multisampled when boun
d to an FBO and |
161 * then implicitly resolved when read. | 162 * then implicitly resolved when read. |
162 */ | 163 */ |
163 bool usesImplicitMSAAResolve() const { | 164 bool usesImplicitMSAAResolve() const { |
164 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || | 165 return kES_IMG_MsToTexture_MSFBOType == fMSFBOType || |
165 kES_EXT_MsToTexture_MSFBOType == fMSFBOType; | 166 kES_EXT_MsToTexture_MSFBOType == fMSFBOType; |
166 } | 167 } |
167 | 168 |
168 /** | |
169 * Some helper functions for encapsulating various extensions to read FB Buf
fer on openglES | |
170 * | |
171 * TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar
to this effect | |
172 */ | |
173 bool fbFetchSupport() const { return fFBFetchSupport; } | |
174 | |
175 bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; } | |
176 | |
177 const char* fbFetchColorName() const { return fFBFetchColorName; } | |
178 | |
179 const char* fbFetchExtensionString() const { return fFBFetchExtensionString;
} | |
180 | |
181 bool fbMixedSamplesSupport() const { return fFBMixedSamplesSupport; } | 169 bool fbMixedSamplesSupport() const { return fFBMixedSamplesSupport; } |
182 | 170 |
183 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } | 171 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } |
184 | 172 |
185 /// What type of buffer mapping is supported? | 173 /// What type of buffer mapping is supported? |
186 MapBufferType mapBufferType() const { return fMapBufferType; } | 174 MapBufferType mapBufferType() const { return fMapBufferType; } |
187 | 175 |
188 /** | 176 /** |
189 * Gets an array of legal stencil formats. These formats are not guaranteed | 177 * Gets an array of legal stencil formats. These formats are not guaranteed |
190 * to be supported by the driver but are legal GLenum names given the GL | 178 * to be supported by the driver but are legal GLenum names given the GL |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 bool readPixelsSupported(const GrGLInterface* intf, | 246 bool readPixelsSupported(const GrGLInterface* intf, |
259 GrGLenum format, | 247 GrGLenum format, |
260 GrGLenum type, | 248 GrGLenum type, |
261 GrGLenum currFboFormat) const; | 249 GrGLenum currFboFormat) const; |
262 | 250 |
263 bool isCoreProfile() const { return fIsCoreProfile; } | 251 bool isCoreProfile() const { return fIsCoreProfile; } |
264 | 252 |
265 | 253 |
266 bool fullClearIsFree() const { return fFullClearIsFree; } | 254 bool fullClearIsFree() const { return fFullClearIsFree; } |
267 | 255 |
268 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } | |
269 | |
270 /** | 256 /** |
271 * Returns a string containing the caps info. | 257 * Returns a string containing the caps info. |
272 */ | 258 */ |
273 SkString dump() const override; | 259 SkString dump() const override; |
274 | 260 |
275 /** | 261 /** |
276 * LATC can appear under one of three possible names. In order to know | 262 * LATC can appear under one of three possible names. In order to know |
277 * which GL internal format to use, we need to keep track of which name | 263 * which GL internal format to use, we need to keep track of which name |
278 * we found LATC under. The default is LATC. | 264 * we found LATC under. The default is LATC. |
279 */ | 265 */ |
280 enum LATCAlias { | 266 enum LATCAlias { |
281 kLATC_LATCAlias, | 267 kLATC_LATCAlias, |
282 kRGTC_LATCAlias, | 268 kRGTC_LATCAlias, |
283 k3DC_LATCAlias | 269 k3DC_LATCAlias |
284 }; | 270 }; |
285 | 271 |
286 LATCAlias latcAlias() const { return fLATCAlias; } | 272 LATCAlias latcAlias() const { return fLATCAlias; } |
287 | 273 |
| 274 GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderC
aps.get()); } |
| 275 |
288 private: | 276 private: |
289 /** | 277 /** |
290 * Maintains a bit per GrPixelConfig. It is used to avoid redundantly | 278 * Maintains a bit per GrPixelConfig. It is used to avoid redundantly |
291 * performing glCheckFrameBufferStatus for the same config. | 279 * performing glCheckFrameBufferStatus for the same config. |
292 */ | 280 */ |
293 struct VerifiedColorConfigs { | 281 struct VerifiedColorConfigs { |
294 VerifiedColorConfigs() { | 282 VerifiedColorConfigs() { |
295 this->reset(); | 283 this->reset(); |
296 } | 284 } |
297 | 285 |
(...skipping 24 matching lines...) Expand all Loading... |
322 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); | 310 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); |
323 } | 311 } |
324 }; | 312 }; |
325 | 313 |
326 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); | 314 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); |
327 void initStencilFormats(const GrGLContextInfo&); | 315 void initStencilFormats(const GrGLContextInfo&); |
328 // This must be called after initFSAASupport(). | 316 // This must be called after initFSAASupport(). |
329 void initConfigRenderableTable(const GrGLContextInfo&); | 317 void initConfigRenderableTable(const GrGLContextInfo&); |
330 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*)
; | 318 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*)
; |
331 | 319 |
332 // Must be called after fGeometryShaderSupport is initialized. | |
333 void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*); | |
334 | |
335 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; | 320 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; |
336 | 321 |
337 // tracks configs that have been verified to pass the FBO completeness when | 322 // tracks configs that have been verified to pass the FBO completeness when |
338 // used as a color attachment | 323 // used as a color attachment |
339 VerifiedColorConfigs fVerifiedColorConfigs; | 324 VerifiedColorConfigs fVerifiedColorConfigs; |
340 | 325 |
341 SkTArray<StencilFormat, true> fStencilFormats; | 326 SkTArray<StencilFormat, true> fStencilFormats; |
342 // tracks configs that have been verified to pass the FBO completeness when | 327 // tracks configs that have been verified to pass the FBO completeness when |
343 // used as a color attachment when a particular stencil format is used | 328 // used as a color attachment when a particular stencil format is used |
344 // as a stencil attachment. | 329 // as a stencil attachment. |
(...skipping 19 matching lines...) Expand all Loading... |
364 bool fTexStorageSupport : 1; | 349 bool fTexStorageSupport : 1; |
365 bool fTextureRedSupport : 1; | 350 bool fTextureRedSupport : 1; |
366 bool fImagingSupport : 1; | 351 bool fImagingSupport : 1; |
367 bool fTwoFormatLimit : 1; | 352 bool fTwoFormatLimit : 1; |
368 bool fFragCoordsConventionSupport : 1; | 353 bool fFragCoordsConventionSupport : 1; |
369 bool fVertexArrayObjectSupport : 1; | 354 bool fVertexArrayObjectSupport : 1; |
370 bool fES2CompatibilitySupport : 1; | 355 bool fES2CompatibilitySupport : 1; |
371 bool fUseNonVBOVertexAndIndexDynamicData : 1; | 356 bool fUseNonVBOVertexAndIndexDynamicData : 1; |
372 bool fIsCoreProfile : 1; | 357 bool fIsCoreProfile : 1; |
373 bool fFullClearIsFree : 1; | 358 bool fFullClearIsFree : 1; |
374 bool fDropsTileOnZeroDivide : 1; | |
375 bool fFBFetchSupport : 1; | |
376 bool fFBFetchNeedsCustomOutput : 1; | |
377 bool fFBMixedSamplesSupport : 1; | 359 bool fFBMixedSamplesSupport : 1; |
378 | 360 |
379 const char* fFBFetchColorName; | |
380 const char* fFBFetchExtensionString; | |
381 | |
382 struct ReadPixelsSupportedFormat { | 361 struct ReadPixelsSupportedFormat { |
383 GrGLenum fFormat; | 362 GrGLenum fFormat; |
384 GrGLenum fType; | 363 GrGLenum fType; |
385 GrGLenum fFboFormat; | 364 GrGLenum fFboFormat; |
386 | 365 |
387 bool operator==(const ReadPixelsSupportedFormat& rhs) const { | 366 bool operator==(const ReadPixelsSupportedFormat& rhs) const { |
388 return fFormat == rhs.fFormat | 367 return fFormat == rhs.fFormat |
389 && fType == rhs.fType | 368 && fType == rhs.fType |
390 && fFboFormat == rhs.fFboFormat; | 369 && fFboFormat == rhs.fFboFormat; |
391 } | 370 } |
392 }; | 371 }; |
393 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; | 372 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; |
394 | 373 |
395 typedef GrDrawTargetCaps INHERITED; | 374 typedef GrDrawTargetCaps INHERITED; |
396 }; | 375 }; |
397 | 376 |
398 typedef GrGLCaps GrGLSLCaps; | 377 |
| 378 class GrGLSLCaps : public GrShaderCaps { |
| 379 public: |
| 380 SK_DECLARE_INST_COUNT(GrGLSLCaps) |
| 381 |
| 382 /** |
| 383 * Creates a GrGLSLCaps that advertises no support for any extensions, |
| 384 * formats, etc. Call init to initialize from a GrGLContextInfo. |
| 385 */ |
| 386 GrGLSLCaps(); |
| 387 ~GrGLSLCaps() override {} |
| 388 |
| 389 GrGLSLCaps(const GrGLSLCaps& caps); |
| 390 |
| 391 GrGLSLCaps& operator = (const GrGLSLCaps& caps); |
| 392 |
| 393 /** |
| 394 * Resets the caps such that nothing is supported. |
| 395 */ |
| 396 void reset() override; |
| 397 |
| 398 /** |
| 399 * Initializes the GrGLSLCaps to the set of features supported in the curren
t |
| 400 * OpenGL context accessible via ctxInfo. |
| 401 */ |
| 402 bool init(const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterface); |
| 403 |
| 404 /** |
| 405 * Some helper functions for encapsulating various extensions to read FB Buf
fer on openglES |
| 406 * |
| 407 * TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar
to this effect |
| 408 */ |
| 409 bool fbFetchSupport() const { return fFBFetchSupport; } |
| 410 |
| 411 bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; } |
| 412 |
| 413 const char* fbFetchColorName() const { return fFBFetchColorName; } |
| 414 |
| 415 const char* fbFetchExtensionString() const { return fFBFetchExtensionString;
} |
| 416 |
| 417 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } |
| 418 |
| 419 /** |
| 420 * Returns a string containing the caps info. |
| 421 */ |
| 422 SkString dump() const override; |
| 423 |
| 424 private: |
| 425 // Must be called after fGeometryShaderSupport is initialized. |
| 426 void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*); |
| 427 |
| 428 bool fDropsTileOnZeroDivide : 1; |
| 429 bool fFBFetchSupport : 1; |
| 430 bool fFBFetchNeedsCustomOutput : 1; |
| 431 |
| 432 const char* fFBFetchColorName; |
| 433 const char* fFBFetchExtensionString; |
| 434 |
| 435 typedef GrShaderCaps INHERITED; |
| 436 }; |
| 437 |
399 | 438 |
400 #endif | 439 #endif |
OLD | NEW |