| 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 "GrCaps.h" | 12 #include "GrCaps.h" |
| 13 #include "GrGLSL.h" | 13 #include "glsl/GrGLSL.h" |
| 14 #include "GrGLStencilAttachment.h" | 14 #include "GrGLStencilAttachment.h" |
| 15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
| 16 #include "SkTHash.h" | 16 #include "SkTHash.h" |
| 17 #include "SkTArray.h" | 17 #include "SkTArray.h" |
| 18 | 18 |
| 19 class GrGLContextInfo; | 19 class GrGLContextInfo; |
| 20 class GrGLSLCaps; | 20 class GrGLSLCaps; |
| 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 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 | 321 |
| 322 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); | 322 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); |
| 323 void initBlendEqationSupport(const GrGLContextInfo&); | 323 void initBlendEqationSupport(const GrGLContextInfo&); |
| 324 void initStencilFormats(const GrGLContextInfo&); | 324 void initStencilFormats(const GrGLContextInfo&); |
| 325 // This must be called after initFSAASupport(). | 325 // This must be called after initFSAASupport(). |
| 326 void initConfigRenderableTable(const GrGLContextInfo&); | 326 void initConfigRenderableTable(const GrGLContextInfo&); |
| 327 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*)
; | 327 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*)
; |
| 328 | 328 |
| 329 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; | 329 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; |
| 330 | 330 |
| 331 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, |
| 332 const GrGLInterface* intf, |
| 333 GrGLSLCaps* glslCaps); |
| 334 |
| 331 // tracks configs that have been verified to pass the FBO completeness when | 335 // tracks configs that have been verified to pass the FBO completeness when |
| 332 // used as a color attachment | 336 // used as a color attachment |
| 333 VerifiedColorConfigs fVerifiedColorConfigs; | 337 VerifiedColorConfigs fVerifiedColorConfigs; |
| 334 | 338 |
| 335 SkTArray<StencilFormat, true> fStencilFormats; | 339 SkTArray<StencilFormat, true> fStencilFormats; |
| 336 // tracks configs that have been verified to pass the FBO completeness when | 340 // tracks configs that have been verified to pass the FBO completeness when |
| 337 // used as a color attachment when a particular stencil format is used | 341 // used as a color attachment when a particular stencil format is used |
| 338 // as a stencil attachment. | 342 // as a stencil attachment. |
| 339 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs; | 343 SkTArray<VerifiedColorConfigs, true> fStencilVerifiedColorConfigs; |
| 340 | 344 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return fFormat == rhs.fFormat | 384 return fFormat == rhs.fFormat |
| 381 && fType == rhs.fType | 385 && fType == rhs.fType |
| 382 && fFboFormat == rhs.fFboFormat; | 386 && fFboFormat == rhs.fFboFormat; |
| 383 } | 387 } |
| 384 }; | 388 }; |
| 385 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; | 389 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; |
| 386 | 390 |
| 387 typedef GrCaps INHERITED; | 391 typedef GrCaps INHERITED; |
| 388 }; | 392 }; |
| 389 | 393 |
| 390 class GrGLSLCaps : public GrShaderCaps { | |
| 391 public: | |
| 392 SK_DECLARE_INST_COUNT(GrGLSLCaps) | |
| 393 | |
| 394 /** | |
| 395 * Indicates how GLSL must interact with advanced blend equations. The KHR ex
tension requires | |
| 396 * special layout qualifiers in the fragment shader. | |
| 397 */ | |
| 398 enum AdvBlendEqInteraction { | |
| 399 kNotSupported_AdvBlendEqInteraction, //<! No _blend_equation_advance
d extension | |
| 400 kAutomatic_AdvBlendEqInteraction, //<! No interaction required | |
| 401 kGeneralEnable_AdvBlendEqInteraction, //<! layout(blend_support_all_e
quations) out | |
| 402 kSpecificEnables_AdvBlendEqInteraction, //<! Specific layout qualifiers
per equation | |
| 403 | |
| 404 kLast_AdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction | |
| 405 }; | |
| 406 | |
| 407 /** | |
| 408 * Initializes the GrGLSLCaps to the set of features supported in the curren
t | |
| 409 * OpenGL context accessible via ctxInfo. | |
| 410 */ | |
| 411 GrGLSLCaps(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterf
ace*, | |
| 412 const GrGLCaps&); | |
| 413 | |
| 414 /** | |
| 415 * Some helper functions for encapsulating various extensions to read FB Buf
fer on openglES | |
| 416 * | |
| 417 * TODO(joshualitt) On desktop opengl 4.2+ we can achieve something similar
to this effect | |
| 418 */ | |
| 419 bool fbFetchSupport() const { return fFBFetchSupport; } | |
| 420 | |
| 421 bool fbFetchNeedsCustomOutput() const { return fFBFetchNeedsCustomOutput; } | |
| 422 | |
| 423 bool bindlessTextureSupport() const { return fBindlessTextureSupport; } | |
| 424 | |
| 425 const char* fbFetchColorName() const { return fFBFetchColorName; } | |
| 426 | |
| 427 const char* fbFetchExtensionString() const { return fFBFetchExtensionString;
} | |
| 428 | |
| 429 bool dropsTileOnZeroDivide() const { return fDropsTileOnZeroDivide; } | |
| 430 | |
| 431 AdvBlendEqInteraction advBlendEqInteraction() const { return fAdvBlendEqInte
raction; } | |
| 432 | |
| 433 bool mustEnableAdvBlendEqs() const { | |
| 434 return fAdvBlendEqInteraction >= kGeneralEnable_AdvBlendEqInteraction; | |
| 435 } | |
| 436 | |
| 437 bool mustEnableSpecificAdvBlendEqs() const { | |
| 438 return fAdvBlendEqInteraction == kSpecificEnables_AdvBlendEqInteraction; | |
| 439 } | |
| 440 | |
| 441 bool mustDeclareFragmentShaderOutput() const { | |
| 442 return fGLSLGeneration > k110_GrGLSLGeneration; | |
| 443 } | |
| 444 | |
| 445 GrGLSLGeneration generation() const { return fGLSLGeneration; } | |
| 446 | |
| 447 /** | |
| 448 * Returns a string containing the caps info. | |
| 449 */ | |
| 450 SkString dump() const override; | |
| 451 | |
| 452 private: | |
| 453 // Must be called after fGeometryShaderSupport is initialized. | |
| 454 void initShaderPrecisionTable(const GrGLContextInfo&, const GrGLInterface*); | |
| 455 | |
| 456 GrGLSLGeneration fGLSLGeneration; | |
| 457 | |
| 458 bool fDropsTileOnZeroDivide : 1; | |
| 459 bool fFBFetchSupport : 1; | |
| 460 bool fFBFetchNeedsCustomOutput : 1; | |
| 461 bool fBindlessTextureSupport : 1; | |
| 462 | |
| 463 const char* fFBFetchColorName; | |
| 464 const char* fFBFetchExtensionString; | |
| 465 | |
| 466 AdvBlendEqInteraction fAdvBlendEqInteraction; | |
| 467 | |
| 468 friend class GrGLCaps; // For initialization. | |
| 469 | |
| 470 typedef GrShaderCaps INHERITED; | |
| 471 }; | |
| 472 | |
| 473 | |
| 474 #endif | 394 #endif |
| OLD | NEW |