Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: gpu/command_buffer/service/feature_info.cc

Issue 2117183006: gpu: Clarify sized texture format is available only if ES3 context or immutable texture is supported (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to ToT Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // GL_APPLE_texture_format_BGRA8888 explicitly declare GL_BGRA8_EXT is
690 // added to internal format on ES3 context, but
691 // GL_EXT_texture_format_BGRA8888 doesn't.
692 if (gl_version_info_->is_es3 && has_apple_bgra) {
693 validators_.texture_internal_format.AddValue(GL_BGRA8_EXT);
694 validators_.texture_sized_color_renderable_internal_format.AddValue(
695 GL_BGRA8_EXT);
696 validators_.texture_sized_texture_filterable_internal_format.AddValue(
697 GL_BGRA8_EXT);
698 }
688 } 699 }
689 700
690 // On desktop, all devices support BGRA render buffers (note that on desktop 701 // On desktop, all devices support BGRA render buffers (note that on desktop
691 // BGRA internal formats are converted to RGBA in the API implementation). 702 // BGRA internal formats are converted to RGBA in the API implementation).
692 // For ES, there is no extension that exposes BGRA renderbuffers, however 703 // For ES, there is no extension that exposes BGRA renderbuffers, however
693 // Angle does support these. 704 // Angle does support these.
694 bool enable_render_buffer_bgra = 705 bool enable_render_buffer_bgra =
695 gl_version_info_->is_angle || !gl_version_info_->is_es; 706 gl_version_info_->is_angle || !gl_version_info_->is_es;
696 707
697 if (enable_render_buffer_bgra) { 708 if (enable_render_buffer_bgra) {
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (extensions.Contains("GL_ANGLE_texture_usage")) { 1108 if (extensions.Contains("GL_ANGLE_texture_usage")) {
1098 feature_flags_.angle_texture_usage = true; 1109 feature_flags_.angle_texture_usage = true;
1099 AddExtensionString("GL_ANGLE_texture_usage"); 1110 AddExtensionString("GL_ANGLE_texture_usage");
1100 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE); 1111 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE);
1101 } 1112 }
1102 1113
1103 if (enable_texture_storage) { 1114 if (enable_texture_storage) {
1104 feature_flags_.ext_texture_storage = true; 1115 feature_flags_.ext_texture_storage = true;
1105 AddExtensionString("GL_EXT_texture_storage"); 1116 AddExtensionString("GL_EXT_texture_storage");
1106 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT); 1117 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT);
1107 if (enable_texture_format_bgra8888) 1118 if (enable_texture_format_bgra8888) {
1108 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT); 1119 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT);
1120 // GL_APPLE_texture_format_BGRA8888 can add it above.
1121 if (!validators_.texture_sized_color_renderable_internal_format.IsValid(
Zhenyao Mo 2016/10/10 20:30:29 I am not sure I follow the logic of this block. t
dshwang 2016/10/10 20:57:10 Sorry for insufficient explanation. |texture_sized
Zhenyao Mo 2016/10/10 21:00:27 But this also enables TexImage calls to use these
dshwang 2016/10/10 21:18:29 Oh, I didn't know. Even if EXT_texture_format_BGR
1122 GL_BGRA8_EXT)) {
1123 validators_.texture_sized_color_renderable_internal_format.AddValue(
1124 GL_BGRA8_EXT);
1125 }
1126 if (!validators_.texture_sized_texture_filterable_internal_format.IsValid(
1127 GL_BGRA8_EXT)) {
1128 validators_.texture_sized_texture_filterable_internal_format.AddValue(
1129 GL_BGRA8_EXT);
1130 }
1131 }
1109 if (enable_texture_float) { 1132 if (enable_texture_float) {
1110 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT); 1133 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT);
1111 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT); 1134 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT);
1112 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT); 1135 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT);
1113 validators_.texture_internal_format_storage.AddValue( 1136 validators_.texture_internal_format_storage.AddValue(
1114 GL_LUMINANCE32F_EXT); 1137 GL_LUMINANCE32F_EXT);
1115 validators_.texture_internal_format_storage.AddValue( 1138 validators_.texture_internal_format_storage.AddValue(
1116 GL_LUMINANCE_ALPHA32F_EXT); 1139 GL_LUMINANCE_ALPHA32F_EXT);
1117 } 1140 }
1118 if (enable_texture_half_float) { 1141 if (enable_texture_half_float) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 if (pos == std::string::npos) { 1560 if (pos == std::string::npos) {
1538 extensions_ += (extensions_.empty() ? "" : " ") + str; 1561 extensions_ += (extensions_.empty() ? "" : " ") + str;
1539 } 1562 }
1540 } 1563 }
1541 1564
1542 FeatureInfo::~FeatureInfo() { 1565 FeatureInfo::~FeatureInfo() {
1543 } 1566 }
1544 1567
1545 } // namespace gles2 1568 } // namespace gles2
1546 } // namespace gpu 1569 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698