OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT); | 635 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT); |
636 validators_.texture_internal_format_storage.AddValue( | 636 validators_.texture_internal_format_storage.AddValue( |
637 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT); | 637 GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT); |
638 } | 638 } |
639 | 639 |
640 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in | 640 // Note: Only APPLE_texture_format_BGRA8888 extension allows BGRA8_EXT in |
641 // ES3's glTexStorage2D, whereas EXT_texture_format_BGRA8888 doesn't provide | 641 // ES3's glTexStorage2D, whereas EXT_texture_format_BGRA8888 doesn't provide |
642 // that compatibility. So if EXT_texture_format_BGRA8888 (but not | 642 // that compatibility. So if EXT_texture_format_BGRA8888 (but not |
643 // APPLE_texture_format_BGRA8888) is present on an underlying ES3 context, we | 643 // APPLE_texture_format_BGRA8888) is present on an underlying ES3 context, we |
644 // have to choose which one of BGRA vs texture storage we expose. | 644 // have to choose which one of BGRA vs texture storage we expose. |
645 // When creating ES2 contexts, we prefer support BGRA to texture storage, so | 645 // When creating ES2 contexts, we prefer support BGRA to texture storage, in |
646 // we disable texture storage if only EXT_texture_format_BGRA8888 is present. | 646 // order to use BGRA as platform color in the compositor, so we disable |
| 647 // texture storage if only EXT_texture_format_BGRA8888 is present. |
647 // If neither is present, we expose texture storage. | 648 // If neither is present, we expose texture storage. |
648 // When creating ES3 contexts, we do need to expose texture storage, so we | 649 // When creating ES3 contexts, we do need to expose texture storage, so we |
649 // disable BGRA if we have to. | 650 // disable BGRA if we have to. |
| 651 // When WebGL contexts, BRGA is not needed, because WebGL doesn't expose it. |
650 bool has_apple_bgra = extensions.Contains("GL_APPLE_texture_format_BGRA8888"); | 652 bool has_apple_bgra = extensions.Contains("GL_APPLE_texture_format_BGRA8888"); |
651 bool has_ext_bgra = extensions.Contains("GL_EXT_texture_format_BGRA8888"); | 653 bool has_ext_bgra = extensions.Contains("GL_EXT_texture_format_BGRA8888"); |
652 bool enable_texture_format_bgra8888 = | 654 bool enable_texture_format_bgra8888 = |
653 has_ext_bgra || has_apple_bgra || !gl_version_info_->is_es; | 655 has_ext_bgra || has_apple_bgra || !gl_version_info_->is_es; |
654 | 656 |
655 bool has_ext_texture_storage = extensions.Contains("GL_EXT_texture_storage"); | 657 bool has_ext_texture_storage = extensions.Contains("GL_EXT_texture_storage"); |
656 bool has_arb_texture_storage = extensions.Contains("GL_ARB_texture_storage"); | 658 bool has_arb_texture_storage = extensions.Contains("GL_ARB_texture_storage"); |
657 bool has_texture_storage = | 659 bool has_texture_storage = |
658 !workarounds_.disable_texture_storage && | 660 !workarounds_.disable_texture_storage && |
659 (has_ext_texture_storage || has_arb_texture_storage || | 661 (has_ext_texture_storage || has_arb_texture_storage || |
660 gl_version_info_->is_es3 || gl_version_info_->IsAtLeastGL(4, 2)); | 662 gl_version_info_->is_es3 || gl_version_info_->IsAtLeastGL(4, 2)); |
661 | 663 |
662 bool enable_texture_storage = has_texture_storage; | 664 bool enable_texture_storage = has_texture_storage; |
663 | 665 |
664 bool texture_storage_incompatible_with_bgra = | 666 bool texture_storage_incompatible_with_bgra = |
665 gl_version_info_->is_es3 && !has_ext_texture_storage && !has_apple_bgra; | 667 gl_version_info_->is_es3 && !has_ext_texture_storage && !has_apple_bgra; |
666 if (texture_storage_incompatible_with_bgra && | 668 if (texture_storage_incompatible_with_bgra && |
667 enable_texture_format_bgra8888 && enable_texture_storage) { | 669 enable_texture_format_bgra8888 && enable_texture_storage) { |
668 switch (context_type_) { | 670 switch (context_type_) { |
669 case CONTEXT_TYPE_OPENGLES2: | 671 case CONTEXT_TYPE_OPENGLES2: |
670 case CONTEXT_TYPE_WEBGL1: | |
671 enable_texture_storage = false; | 672 enable_texture_storage = false; |
672 break; | 673 break; |
673 case CONTEXT_TYPE_OPENGLES3: | 674 case CONTEXT_TYPE_OPENGLES3: |
| 675 case CONTEXT_TYPE_WEBGL1: |
674 case CONTEXT_TYPE_WEBGL2: | 676 case CONTEXT_TYPE_WEBGL2: |
675 enable_texture_format_bgra8888 = false; | 677 enable_texture_format_bgra8888 = false; |
676 break; | 678 break; |
677 } | 679 } |
678 } | 680 } |
679 | 681 |
680 if (enable_texture_format_bgra8888) { | 682 if (enable_texture_format_bgra8888) { |
681 feature_flags_.ext_texture_format_bgra8888 = true; | 683 feature_flags_.ext_texture_format_bgra8888 = true; |
682 AddExtensionString("GL_EXT_texture_format_BGRA8888"); | 684 AddExtensionString("GL_EXT_texture_format_BGRA8888"); |
683 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); | 685 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 if (pos == std::string::npos) { | 1550 if (pos == std::string::npos) { |
1549 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1551 extensions_ += (extensions_.empty() ? "" : " ") + str; |
1550 } | 1552 } |
1551 } | 1553 } |
1552 | 1554 |
1553 FeatureInfo::~FeatureInfo() { | 1555 FeatureInfo::~FeatureInfo() { |
1554 } | 1556 } |
1555 | 1557 |
1556 } // namespace gles2 | 1558 } // namespace gles2 |
1557 } // namespace gpu | 1559 } // namespace gpu |
OLD | NEW |