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