| 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 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
| 10 #include "GrGLContext.h" | 10 #include "GrGLContext.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 fTexStorageSupport = false; | 41 fTexStorageSupport = false; |
| 42 fTextureRedSupport = false; | 42 fTextureRedSupport = false; |
| 43 fImagingSupport = false; | 43 fImagingSupport = false; |
| 44 fTwoFormatLimit = false; | 44 fTwoFormatLimit = false; |
| 45 fFragCoordsConventionSupport = false; | 45 fFragCoordsConventionSupport = false; |
| 46 fVertexArrayObjectSupport = false; | 46 fVertexArrayObjectSupport = false; |
| 47 fUseNonVBOVertexAndIndexDynamicData = false; | 47 fUseNonVBOVertexAndIndexDynamicData = false; |
| 48 fIsCoreProfile = false; | 48 fIsCoreProfile = false; |
| 49 fFullClearIsFree = false; | 49 fFullClearIsFree = false; |
| 50 fDropsTileOnZeroDivide = false; | 50 fDropsTileOnZeroDivide = false; |
| 51 |
| 52 fReadPixelsSupportedCache.clear(); |
| 51 } | 53 } |
| 52 | 54 |
| 53 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { | 55 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { |
| 54 *this = caps; | 56 *this = caps; |
| 55 } | 57 } |
| 56 | 58 |
| 57 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { | 59 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { |
| 58 INHERITED::operator=(caps); | 60 INHERITED::operator=(caps); |
| 59 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; | 61 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; |
| 60 fStencilFormats = caps.fStencilFormats; | 62 fStencilFormats = caps.fStencilFormats; |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 // glCompressedTexImage2D is available on all OpenGL ES devices... | 499 // glCompressedTexImage2D is available on all OpenGL ES devices... |
| 498 // however, it is only available on standard OpenGL after version 1.3 | 500 // however, it is only available on standard OpenGL after version 1.3 |
| 499 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); | 501 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); |
| 500 | 502 |
| 501 // Check for ETC1 | 503 // Check for ETC1 |
| 502 bool hasETC1 = false; | 504 bool hasETC1 = false; |
| 503 | 505 |
| 504 // First check version for support | 506 // First check version for support |
| 505 if (kGL_GrGLStandard == standard) { | 507 if (kGL_GrGLStandard == standard) { |
| 506 hasETC1 = hasCompressTex2D && | 508 hasETC1 = hasCompressTex2D && |
| 507 (version >= GR_GL_VER(4, 3) || | 509 (version >= GR_GL_VER(4, 3) || |
| 508 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); | 510 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); |
| 509 } else { | 511 } else { |
| 510 hasETC1 = hasCompressTex2D && | 512 hasETC1 = hasCompressTex2D && |
| 511 (version >= GR_GL_VER(3, 0) || | 513 (version >= GR_GL_VER(3, 0) || |
| 512 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || | 514 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 513 // ETC2 is a superset of ETC1, so we can just check for that, too. | 515 // ETC2 is a superset of ETC1, so we can just check for that, too. |
| 514 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && | 516 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
| 515 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); | 517 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); |
| 516 } | 518 } |
| 517 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; | 519 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 555 |
| 554 // Check for R11_EAC | 556 // Check for R11_EAC |
| 555 if (kGL_GrGLStandard == standard) { | 557 if (kGL_GrGLStandard == standard) { |
| 556 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = | 558 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = |
| 557 version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility"); | 559 version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility"); |
| 558 } else { | 560 } else { |
| 559 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); | 561 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); |
| 560 } | 562 } |
| 561 } | 563 } |
| 562 | 564 |
| 563 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, | 565 bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, |
| 564 GrGLenum format, | 566 GrGLenum format, |
| 565 GrGLenum type) const { | 567 GrGLenum type) const { |
| 566 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { | 568 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
| 567 // ES 2 guarantees this format is supported | 569 // ES 2 guarantees this format is supported |
| 568 return true; | 570 return true; |
| 569 } | 571 } |
| 570 | 572 |
| 571 if (!fTwoFormatLimit) { | 573 if (!fTwoFormatLimit) { |
| 572 // not limited by ES 2's constraints | 574 // not limited by ES 2's constraints |
| 573 return true; | 575 return true; |
| 574 } | 576 } |
| 575 | 577 |
| 576 GrGLint otherFormat = GR_GL_RGBA; | 578 GrGLint otherFormat = GR_GL_RGBA; |
| 577 GrGLint otherType = GR_GL_UNSIGNED_BYTE; | 579 GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
| 578 | 580 |
| 579 // The other supported format/type combo supported for ReadPixels | 581 // The other supported format/type combo supported for ReadPixels |
| 580 // can change based on which render target is bound | 582 // can change based on which render target is bound |
| 581 GR_GL_GetIntegerv(intf, | 583 GR_GL_GetIntegerv(intf, |
| 582 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, | 584 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
| 583 &otherFormat); | 585 &otherFormat); |
| 584 | 586 |
| 585 GR_GL_GetIntegerv(intf, | 587 GR_GL_GetIntegerv(intf, |
| 586 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, | 588 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 587 &otherType); | 589 &otherType); |
| 588 | 590 |
| 589 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; | 591 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
| 590 } | 592 } |
| 591 | 593 |
| 594 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 595 GrGLenum format, |
| 596 GrGLenum type, |
| 597 GrGLenum currFboFormat) const { |
| 598 |
| 599 ReadPixelsSupportedFormats::Key key = {format, type, currFboFormat}; |
| 600 |
| 601 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key
); |
| 602 |
| 603 if (NULL == cachedValue) { |
| 604 bool value = doReadPixelsSupported(intf, format, type); |
| 605 ReadPixelsSupportedFormats newValue(key, value); |
| 606 fReadPixelsSupportedCache.add(newValue); |
| 607 |
| 608 return newValue.value(); |
| 609 } |
| 610 |
| 611 return cachedValue->value(); |
| 612 } |
| 613 |
| 592 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { | 614 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { |
| 593 | 615 |
| 594 fMSFBOType = kNone_MSFBOType; | 616 fMSFBOType = kNone_MSFBOType; |
| 595 if (kGL_GrGLStandard != ctxInfo.standard()) { | 617 if (kGL_GrGLStandard != ctxInfo.standard()) { |
| 596 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed | 618 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
| 597 // ES3 driver bugs on at least one device with a tiled GPU (N10). | 619 // ES3 driver bugs on at least one device with a tiled GPU (N10). |
| 598 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { | 620 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 599 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; | 621 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
| 600 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")
) { | 622 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")
) { |
| 601 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; | 623 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 832 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
| 811 r.appendf("Fragment coord conventions support: %s\n", | 833 r.appendf("Fragment coord conventions support: %s\n", |
| 812 (fFragCoordsConventionSupport ? "YES": "NO")); | 834 (fFragCoordsConventionSupport ? "YES": "NO")); |
| 813 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 835 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
| 814 r.appendf("Use non-VBO for dynamic data: %s\n", | 836 r.appendf("Use non-VBO for dynamic data: %s\n", |
| 815 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 837 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 816 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 838 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
| 817 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 839 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
| 818 return r; | 840 return r; |
| 819 } | 841 } |
| OLD | NEW |