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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // that compatibility. So if EXT_texture_format_BGRA8888 (but not | 644 // that compatibility. So if EXT_texture_format_BGRA8888 (but not |
645 // APPLE_texture_format_BGRA8888) is present on an underlying ES3 context, we | 645 // APPLE_texture_format_BGRA8888) is present on an underlying ES3 context, we |
646 // have to choose which one of BGRA vs texture storage we expose. | 646 // have to choose which one of BGRA vs texture storage we expose. |
647 // When creating ES2 contexts, we prefer support BGRA to texture storage, so | 647 // When creating ES2 contexts, we prefer support BGRA to texture storage, so |
648 // we disable texture storage if only EXT_texture_format_BGRA8888 is present. | 648 // we disable texture storage if only EXT_texture_format_BGRA8888 is present. |
649 // If neither is present, we expose texture storage. | 649 // If neither is present, we expose texture storage. |
650 // When creating ES3 contexts, we do need to expose texture storage, so we | 650 // When creating ES3 contexts, we do need to expose texture storage, so we |
651 // disable BGRA if we have to. | 651 // disable BGRA if we have to. |
652 bool has_apple_bgra = extensions.Contains("GL_APPLE_texture_format_BGRA8888"); | 652 bool has_apple_bgra = extensions.Contains("GL_APPLE_texture_format_BGRA8888"); |
653 bool has_ext_bgra = extensions.Contains("GL_EXT_texture_format_BGRA8888"); | 653 bool has_ext_bgra = extensions.Contains("GL_EXT_texture_format_BGRA8888"); |
654 bool has_bgra = has_ext_bgra || has_apple_bgra || !gl_version_info_->is_es; | 654 bool enable_texture_format_bgra8888 = |
| 655 has_ext_bgra || has_apple_bgra || !gl_version_info_->is_es; |
655 | 656 |
656 bool has_ext_texture_storage = extensions.Contains("GL_EXT_texture_storage"); | 657 bool has_ext_texture_storage = extensions.Contains("GL_EXT_texture_storage"); |
657 bool has_arb_texture_storage = extensions.Contains("GL_ARB_texture_storage"); | 658 bool has_arb_texture_storage = extensions.Contains("GL_ARB_texture_storage"); |
658 bool has_texture_storage = | 659 bool has_texture_storage = |
659 !workarounds_.disable_texture_storage && | 660 !workarounds_.disable_texture_storage && |
660 (has_ext_texture_storage || has_arb_texture_storage || | 661 (has_ext_texture_storage || has_arb_texture_storage || |
661 gl_version_info_->is_es3 || gl_version_info_->IsAtLeastGL(4, 2)); | 662 gl_version_info_->is_es3 || gl_version_info_->IsAtLeastGL(4, 2)); |
662 | 663 |
663 bool enable_texture_format_bgra8888 = has_bgra; | |
664 bool enable_texture_storage = has_texture_storage; | 664 bool enable_texture_storage = has_texture_storage; |
665 | 665 |
666 bool texture_storage_incompatible_with_bgra = | 666 bool texture_storage_incompatible_with_bgra = |
667 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; |
668 if (texture_storage_incompatible_with_bgra && | 668 if (texture_storage_incompatible_with_bgra && |
669 enable_texture_format_bgra8888 && enable_texture_storage) { | 669 enable_texture_format_bgra8888 && enable_texture_storage) { |
670 switch (context_type_) { | 670 switch (context_type_) { |
671 case CONTEXT_TYPE_OPENGLES2: | 671 case CONTEXT_TYPE_OPENGLES2: |
672 case CONTEXT_TYPE_WEBGL1: | 672 case CONTEXT_TYPE_WEBGL1: |
673 enable_texture_storage = false; | 673 enable_texture_storage = false; |
674 break; | 674 break; |
675 case CONTEXT_TYPE_OPENGLES3: | 675 case CONTEXT_TYPE_OPENGLES3: |
676 case CONTEXT_TYPE_WEBGL2: | 676 case CONTEXT_TYPE_WEBGL2: |
677 enable_texture_format_bgra8888 = false; | 677 enable_texture_format_bgra8888 = false; |
678 break; | 678 break; |
679 } | 679 } |
680 } | 680 } |
681 | 681 |
682 if (enable_texture_format_bgra8888) { | 682 if (enable_texture_format_bgra8888) { |
683 feature_flags_.ext_texture_format_bgra8888 = true; | 683 feature_flags_.ext_texture_format_bgra8888 = true; |
684 AddExtensionString("GL_EXT_texture_format_BGRA8888"); | 684 AddExtensionString("GL_EXT_texture_format_BGRA8888"); |
685 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); | 685 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); |
686 validators_.texture_format.AddValue(GL_BGRA_EXT); | 686 validators_.texture_format.AddValue(GL_BGRA_EXT); |
687 validators_.texture_unsized_internal_format.AddValue(GL_BGRA_EXT); | 687 validators_.texture_unsized_internal_format.AddValue(GL_BGRA_EXT); |
| 688 |
| 689 if (IsES3Capable()) { |
| 690 validators_.texture_internal_format.AddValue(GL_BGRA8_EXT); |
| 691 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 692 GL_BGRA8_EXT); |
| 693 validators_.texture_sized_texture_filterable_internal_format.AddValue( |
| 694 GL_BGRA8_EXT); |
| 695 } |
688 } | 696 } |
689 | 697 |
690 // On desktop, all devices support BGRA render buffers (note that on desktop | 698 // On desktop, all devices support BGRA render buffers (note that on desktop |
691 // BGRA internal formats are converted to RGBA in the API implementation). | 699 // BGRA internal formats are converted to RGBA in the API implementation). |
692 // For ES, there is no extension that exposes BGRA renderbuffers, however | 700 // For ES, there is no extension that exposes BGRA renderbuffers, however |
693 // Angle does support these. | 701 // Angle does support these. |
694 bool enable_render_buffer_bgra = | 702 bool enable_render_buffer_bgra = |
695 gl_version_info_->is_angle || !gl_version_info_->is_es; | 703 gl_version_info_->is_angle || !gl_version_info_->is_es; |
696 | 704 |
697 if (enable_render_buffer_bgra) { | 705 if (enable_render_buffer_bgra) { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 if (extensions.Contains("GL_ANGLE_texture_usage")) { | 1105 if (extensions.Contains("GL_ANGLE_texture_usage")) { |
1098 feature_flags_.angle_texture_usage = true; | 1106 feature_flags_.angle_texture_usage = true; |
1099 AddExtensionString("GL_ANGLE_texture_usage"); | 1107 AddExtensionString("GL_ANGLE_texture_usage"); |
1100 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE); | 1108 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE); |
1101 } | 1109 } |
1102 | 1110 |
1103 if (enable_texture_storage) { | 1111 if (enable_texture_storage) { |
1104 feature_flags_.ext_texture_storage = true; | 1112 feature_flags_.ext_texture_storage = true; |
1105 AddExtensionString("GL_EXT_texture_storage"); | 1113 AddExtensionString("GL_EXT_texture_storage"); |
1106 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT); | 1114 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT); |
1107 if (enable_texture_format_bgra8888) | 1115 if (enable_texture_format_bgra8888) { |
1108 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT); | 1116 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT); |
| 1117 // It can be added above if the context is ES3 capable. |
| 1118 if (!validators_.texture_sized_color_renderable_internal_format.IsValid( |
| 1119 GL_BGRA8_EXT)) { |
| 1120 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 1121 GL_BGRA8_EXT); |
| 1122 } |
| 1123 if (!validators_.texture_sized_texture_filterable_internal_format.IsValid( |
| 1124 GL_BGRA8_EXT)) { |
| 1125 validators_.texture_sized_texture_filterable_internal_format.AddValue( |
| 1126 GL_BGRA8_EXT); |
| 1127 } |
| 1128 } |
1109 if (enable_texture_float) { | 1129 if (enable_texture_float) { |
1110 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT); | 1130 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT); |
1111 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT); | 1131 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT); |
1112 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT); | 1132 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT); |
1113 validators_.texture_internal_format_storage.AddValue( | 1133 validators_.texture_internal_format_storage.AddValue( |
1114 GL_LUMINANCE32F_EXT); | 1134 GL_LUMINANCE32F_EXT); |
1115 validators_.texture_internal_format_storage.AddValue( | 1135 validators_.texture_internal_format_storage.AddValue( |
1116 GL_LUMINANCE_ALPHA32F_EXT); | 1136 GL_LUMINANCE_ALPHA32F_EXT); |
1117 } | 1137 } |
1118 if (enable_texture_half_float) { | 1138 if (enable_texture_half_float) { |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 if (pos == std::string::npos) { | 1557 if (pos == std::string::npos) { |
1538 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1558 extensions_ += (extensions_.empty() ? "" : " ") + str; |
1539 } | 1559 } |
1540 } | 1560 } |
1541 | 1561 |
1542 FeatureInfo::~FeatureInfo() { | 1562 FeatureInfo::~FeatureInfo() { |
1543 } | 1563 } |
1544 | 1564 |
1545 } // namespace gles2 | 1565 } // namespace gles2 |
1546 } // namespace gpu | 1566 } // namespace gpu |
OLD | NEW |