| 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // glCompressedTexImage2D is available on all OpenGL ES devices... | 480 // glCompressedTexImage2D is available on all OpenGL ES devices... |
| 479 // however, it is only available on standard OpenGL after version 1.3 | 481 // however, it is only available on standard OpenGL after version 1.3 |
| 480 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); | 482 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); |
| 481 | 483 |
| 482 // Check for ETC1 | 484 // Check for ETC1 |
| 483 bool hasETC1 = false; | 485 bool hasETC1 = false; |
| 484 | 486 |
| 485 // First check version for support | 487 // First check version for support |
| 486 if (kGL_GrGLStandard == standard) { | 488 if (kGL_GrGLStandard == standard) { |
| 487 hasETC1 = hasCompressTex2D && | 489 hasETC1 = hasCompressTex2D && |
| 488 (version >= GR_GL_VER(4, 3) || | 490 (version >= GR_GL_VER(4, 3) || |
| 489 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); | 491 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); |
| 490 } else { | 492 } else { |
| 491 hasETC1 = hasCompressTex2D && | 493 hasETC1 = hasCompressTex2D && |
| 492 (version >= GR_GL_VER(3, 0) || | 494 (version >= GR_GL_VER(3, 0) || |
| 493 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || | 495 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 494 // ETC2 is a superset of ETC1, so we can just check for that, too. | 496 // ETC2 is a superset of ETC1, so we can just check for that, too. |
| 495 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && | 497 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
| 496 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); | 498 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); |
| 497 } | 499 } |
| 498 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; | 500 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 536 |
| 535 // Check for R11_EAC | 537 // Check for R11_EAC |
| 536 if (kGL_GrGLStandard == standard) { | 538 if (kGL_GrGLStandard == standard) { |
| 537 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = | 539 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = |
| 538 version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility"); | 540 version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility"); |
| 539 } else { | 541 } else { |
| 540 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); | 542 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); |
| 541 } | 543 } |
| 542 } | 544 } |
| 543 | 545 |
| 544 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, | 546 bool GrGLCaps::doReadPixelsSupported(const GrGLInterface* intf, |
| 545 GrGLenum format, | 547 GrGLenum format, |
| 546 GrGLenum type) const { | 548 GrGLenum type) const { |
| 547 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { | 549 if (GR_GL_RGBA == format && GR_GL_UNSIGNED_BYTE == type) { |
| 548 // ES 2 guarantees this format is supported | 550 // ES 2 guarantees this format is supported |
| 549 return true; | 551 return true; |
| 550 } | 552 } |
| 551 | 553 |
| 552 if (!fTwoFormatLimit) { | 554 if (!fTwoFormatLimit) { |
| 553 // not limited by ES 2's constraints | 555 // not limited by ES 2's constraints |
| 554 return true; | 556 return true; |
| 555 } | 557 } |
| 556 | 558 |
| 557 GrGLint otherFormat = GR_GL_RGBA; | 559 GrGLint otherFormat = GR_GL_RGBA; |
| 558 GrGLint otherType = GR_GL_UNSIGNED_BYTE; | 560 GrGLint otherType = GR_GL_UNSIGNED_BYTE; |
| 559 | 561 |
| 560 // The other supported format/type combo supported for ReadPixels | 562 // The other supported format/type combo supported for ReadPixels |
| 561 // can change based on which render target is bound | 563 // can change based on which render target is bound |
| 562 GR_GL_GetIntegerv(intf, | 564 GR_GL_GetIntegerv(intf, |
| 563 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, | 565 GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, |
| 564 &otherFormat); | 566 &otherFormat); |
| 565 | 567 |
| 566 GR_GL_GetIntegerv(intf, | 568 GR_GL_GetIntegerv(intf, |
| 567 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, | 569 GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, |
| 568 &otherType); | 570 &otherType); |
| 569 | 571 |
| 570 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; | 572 return (GrGLenum)otherFormat == format && (GrGLenum)otherType == type; |
| 571 } | 573 } |
| 572 | 574 |
| 575 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 576 GrGLenum format, |
| 577 GrGLenum type, |
| 578 GrGLenum currFboFormat) const { |
| 579 |
| 580 ReadPixelsSupportedFormatsKey key = {format, type, currFboFormat}; |
| 581 |
| 582 ReadPixelsSupportedFormats* cachedValue = fReadPixelsSupportedCache.find(key
); |
| 583 |
| 584 if (NULL == cachedValue) { |
| 585 bool value = doReadPixelsSupported(intf, format, type); |
| 586 cachedValue = new ReadPixelsSupportedFormats(key, value); |
| 587 fReadPixelsSupportedCache.put(cachedValue); |
| 588 } |
| 589 |
| 590 return cachedValue->value(); |
| 591 } |
| 592 |
| 573 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { | 593 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { |
| 574 | 594 |
| 575 fMSFBOType = kNone_MSFBOType; | 595 fMSFBOType = kNone_MSFBOType; |
| 576 if (kGL_GrGLStandard != ctxInfo.standard()) { | 596 if (kGL_GrGLStandard != ctxInfo.standard()) { |
| 577 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed | 597 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed |
| 578 // ES3 driver bugs on at least one device with a tiled GPU (N10). | 598 // ES3 driver bugs on at least one device with a tiled GPU (N10). |
| 579 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { | 599 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { |
| 580 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; | 600 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; |
| 581 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")
) { | 601 } else if (ctxInfo.hasExtension("GL_IMG_multisampled_render_to_texture")
) { |
| 582 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; | 602 fMSFBOType = kES_IMG_MsToTexture_MSFBOType; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 811 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
| 792 r.appendf("Fragment coord conventions support: %s\n", | 812 r.appendf("Fragment coord conventions support: %s\n", |
| 793 (fFragCoordsConventionSupport ? "YES": "NO")); | 813 (fFragCoordsConventionSupport ? "YES": "NO")); |
| 794 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 814 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
| 795 r.appendf("Use non-VBO for dynamic data: %s\n", | 815 r.appendf("Use non-VBO for dynamic data: %s\n", |
| 796 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 816 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 797 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 817 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
| 798 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 818 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
| 799 return r; | 819 return r; |
| 800 } | 820 } |
| 821 |
| 822 //Computes a hash based on the three values in the key struct |
| 823 // bits 31------------15---------7---------------0 |
| 824 // fFormat(15:0) fType(7:0) fFboFormat(7:0) |
| 825 uint32_t GrGLCaps::ReadPixelsSupportedFormats::Hash(const ReadPixelsSupportedFor
matsKey& key) { |
| 826 // fFormat has different values like 0x190X or 0x8XXX: 16 bits are required |
| 827 uint32_t hash = ((static_cast<uint32_t>(key.fFormat) & 0xFFFF) << 16); |
| 828 // fType is 0x14XX: 8 lower bits are enough |
| 829 hash |= ((static_cast<uint32_t>(key.fType) & 0xFF) << 8); |
| 830 // fFboFormat is enum GrPixelConfig which has less than 15 values: 8 bits OK |
| 831 hash |= (static_cast<uint32_t>(key.fFboFormat) & 0xFF); |
| 832 |
| 833 return hash; |
| 834 } |
| OLD | NEW |