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

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

Issue 2443123004: Revert of gpu: Clarify sized texture format is available only if ES3 context or immutable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 1 month 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // etc. 208 // etc.
209 // The flag here is for testing only. 209 // The flag here is for testing only.
210 disable_shader_translator_ = 210 disable_shader_translator_ =
211 command_line->HasSwitch(switches::kDisableGLSLTranslator); 211 command_line->HasSwitch(switches::kDisableGLSLTranslator);
212 212
213 unsafe_es3_apis_enabled_ = false; 213 unsafe_es3_apis_enabled_ = false;
214 214
215 // Default context_type_ to a GLES2 Context. 215 // Default context_type_ to a GLES2 Context.
216 context_type_ = CONTEXT_TYPE_OPENGLES2; 216 context_type_ = CONTEXT_TYPE_OPENGLES2;
217 217
218 chromium_color_buffer_float_rgba_available_ = false;
219 chromium_color_buffer_float_rgb_available_ = false;
218 ext_color_buffer_float_available_ = false; 220 ext_color_buffer_float_available_ = false;
219 oes_texture_float_linear_available_ = false; 221 oes_texture_float_linear_available_ = false;
220 oes_texture_half_float_linear_available_ = false; 222 oes_texture_half_float_linear_available_ = false;
221 } 223 }
222 224
223 bool FeatureInfo::Initialize(ContextType context_type, 225 bool FeatureInfo::Initialize(ContextType context_type,
224 const DisallowedFeatures& disallowed_features) { 226 const DisallowedFeatures& disallowed_features) {
225 disallowed_features_ = disallowed_features; 227 disallowed_features_ = disallowed_features;
226 context_type_ = context_type; 228 context_type_ = context_type;
227 InitializeFeatures(); 229 InitializeFeatures();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 GL_RGBA16F); 293 GL_RGBA16F);
292 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R32F); 294 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R32F);
293 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG32F); 295 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG32F);
294 validators_.texture_sized_color_renderable_internal_format.AddValue( 296 validators_.texture_sized_color_renderable_internal_format.AddValue(
295 GL_RGBA32F); 297 GL_RGBA32F);
296 validators_.texture_sized_color_renderable_internal_format.AddValue( 298 validators_.texture_sized_color_renderable_internal_format.AddValue(
297 GL_R11F_G11F_B10F); 299 GL_R11F_G11F_B10F);
298 } 300 }
299 301
300 void FeatureInfo::EnableCHROMIUMColorBufferFloatRGBA() { 302 void FeatureInfo::EnableCHROMIUMColorBufferFloatRGBA() {
301 if (!feature_flags_.chromium_color_buffer_float_rgba) 303 if (!chromium_color_buffer_float_rgba_available_)
302 return; 304 return;
303 validators_.texture_internal_format.AddValue(GL_RGBA32F); 305 validators_.texture_internal_format.AddValue(GL_RGBA32F);
304 validators_.texture_sized_color_renderable_internal_format.AddValue( 306 validators_.texture_sized_color_renderable_internal_format.AddValue(
305 GL_RGBA32F); 307 GL_RGBA32F);
306 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba"); 308 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
307 } 309 }
308 310
309 void FeatureInfo::EnableCHROMIUMColorBufferFloatRGB() { 311 void FeatureInfo::EnableCHROMIUMColorBufferFloatRGB() {
310 if (!feature_flags_.chromium_color_buffer_float_rgb) 312 if (!chromium_color_buffer_float_rgb_available_)
311 return; 313 return;
312 validators_.texture_internal_format.AddValue(GL_RGB32F); 314 validators_.texture_internal_format.AddValue(GL_RGB32F);
313 validators_.texture_sized_color_renderable_internal_format.AddValue( 315 validators_.texture_sized_color_renderable_internal_format.AddValue(
314 GL_RGB32F); 316 GL_RGB32F);
315 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb"); 317 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
316 } 318 }
317 319
318 void FeatureInfo::EnableOESTextureFloatLinear() { 320 void FeatureInfo::EnableOESTextureFloatLinear() {
319 if (!oes_texture_float_linear_available_) 321 if (!oes_texture_float_linear_available_)
320 return; 322 return;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 // that compatibility. So if EXT_texture_format_BGRA8888 (but not 644 // that compatibility. So if EXT_texture_format_BGRA8888 (but not
643 // 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
644 // 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.
645 // 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
646 // 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.
647 // If neither is present, we expose texture storage. 649 // If neither is present, we expose texture storage.
648 // 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
649 // disable BGRA if we have to. 651 // disable BGRA if we have to.
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 has_bgra = has_ext_bgra || has_apple_bgra || !gl_version_info_->is_es;
653 has_ext_bgra || has_apple_bgra || !gl_version_info_->is_es;
654 655
655 bool has_ext_texture_storage = extensions.Contains("GL_EXT_texture_storage"); 656 bool has_ext_texture_storage = extensions.Contains("GL_EXT_texture_storage");
656 bool has_arb_texture_storage = extensions.Contains("GL_ARB_texture_storage"); 657 bool has_arb_texture_storage = extensions.Contains("GL_ARB_texture_storage");
657 bool has_texture_storage = 658 bool has_texture_storage =
658 !workarounds_.disable_texture_storage && 659 !workarounds_.disable_texture_storage &&
659 (has_ext_texture_storage || has_arb_texture_storage || 660 (has_ext_texture_storage || has_arb_texture_storage ||
660 gl_version_info_->is_es3 || gl_version_info_->IsAtLeastGL(4, 2)); 661 gl_version_info_->is_es3 || gl_version_info_->IsAtLeastGL(4, 2));
661 662
663 bool enable_texture_format_bgra8888 = has_bgra;
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: 672 case CONTEXT_TYPE_WEBGL1:
671 enable_texture_storage = false; 673 enable_texture_storage = false;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 888
887 glDeleteFramebuffersEXT(1, &fb_id); 889 glDeleteFramebuffersEXT(1, &fb_id);
888 glDeleteTextures(1, &tex_id); 890 glDeleteTextures(1, &tex_id);
889 891
890 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding)); 892 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding));
891 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding)); 893 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding));
892 894
893 DCHECK(glGetError() == GL_NO_ERROR); 895 DCHECK(glGetError() == GL_NO_ERROR);
894 896
895 if (status_rgba == GL_FRAMEBUFFER_COMPLETE) { 897 if (status_rgba == GL_FRAMEBUFFER_COMPLETE) {
896 feature_flags_.chromium_color_buffer_float_rgba = true; 898 chromium_color_buffer_float_rgba_available_ = true;
897 if (!disallowed_features_.chromium_color_buffer_float_rgba) 899 if (!disallowed_features_.chromium_color_buffer_float_rgba)
898 EnableCHROMIUMColorBufferFloatRGBA(); 900 EnableCHROMIUMColorBufferFloatRGBA();
899 } 901 }
900 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) { 902 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) {
901 feature_flags_.chromium_color_buffer_float_rgb = true; 903 chromium_color_buffer_float_rgb_available_ = true;
902 if (!disallowed_features_.chromium_color_buffer_float_rgb) 904 if (!disallowed_features_.chromium_color_buffer_float_rgb)
903 EnableCHROMIUMColorBufferFloatRGB(); 905 EnableCHROMIUMColorBufferFloatRGB();
904 } 906 }
905 } 907 }
906 908
907 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0 909 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0
908 if (enable_ext_color_buffer_float && IsES3Capable()) { 910 if (enable_ext_color_buffer_float && IsES3Capable()) {
909 ext_color_buffer_float_available_ = true; 911 ext_color_buffer_float_available_ = true;
910 if (!disallowed_features_.ext_color_buffer_float) 912 if (!disallowed_features_.ext_color_buffer_float)
911 EnableEXTColorBufferFloat(); 913 EnableEXTColorBufferFloat();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 if (extensions.Contains("GL_ANGLE_texture_usage")) { 1097 if (extensions.Contains("GL_ANGLE_texture_usage")) {
1096 feature_flags_.angle_texture_usage = true; 1098 feature_flags_.angle_texture_usage = true;
1097 AddExtensionString("GL_ANGLE_texture_usage"); 1099 AddExtensionString("GL_ANGLE_texture_usage");
1098 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE); 1100 validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE);
1099 } 1101 }
1100 1102
1101 if (enable_texture_storage) { 1103 if (enable_texture_storage) {
1102 feature_flags_.ext_texture_storage = true; 1104 feature_flags_.ext_texture_storage = true;
1103 AddExtensionString("GL_EXT_texture_storage"); 1105 AddExtensionString("GL_EXT_texture_storage");
1104 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT); 1106 validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT);
1105 if (enable_texture_format_bgra8888) { 1107 if (enable_texture_format_bgra8888)
1106 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT); 1108 validators_.texture_internal_format_storage.AddValue(GL_BGRA8_EXT);
1107 validators_.texture_sized_color_renderable_internal_format.AddValue(
1108 GL_BGRA8_EXT);
1109 validators_.texture_sized_texture_filterable_internal_format.AddValue(
1110 GL_BGRA8_EXT);
1111 }
1112 if (enable_texture_float) { 1109 if (enable_texture_float) {
1113 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT); 1110 validators_.texture_internal_format_storage.AddValue(GL_RGBA32F_EXT);
1114 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT); 1111 validators_.texture_internal_format_storage.AddValue(GL_RGB32F_EXT);
1115 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT); 1112 validators_.texture_internal_format_storage.AddValue(GL_ALPHA32F_EXT);
1116 validators_.texture_internal_format_storage.AddValue( 1113 validators_.texture_internal_format_storage.AddValue(
1117 GL_LUMINANCE32F_EXT); 1114 GL_LUMINANCE32F_EXT);
1118 validators_.texture_internal_format_storage.AddValue( 1115 validators_.texture_internal_format_storage.AddValue(
1119 GL_LUMINANCE_ALPHA32F_EXT); 1116 GL_LUMINANCE_ALPHA32F_EXT);
1120 } 1117 }
1121 if (enable_texture_half_float) { 1118 if (enable_texture_half_float) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 GL_DRAW_BUFFER13, 1470 GL_DRAW_BUFFER13,
1474 GL_DRAW_BUFFER14, 1471 GL_DRAW_BUFFER14,
1475 GL_DRAW_BUFFER15, 1472 GL_DRAW_BUFFER15,
1476 }; 1473 };
1477 if (max_draw_buffers < kTotalDrawBufferEnums) { 1474 if (max_draw_buffers < kTotalDrawBufferEnums) {
1478 validators_.g_l_state.RemoveValues( 1475 validators_.g_l_state.RemoveValues(
1479 kDrawBuffers + max_draw_buffers, 1476 kDrawBuffers + max_draw_buffers,
1480 kTotalDrawBufferEnums - max_draw_buffers); 1477 kTotalDrawBufferEnums - max_draw_buffers);
1481 } 1478 }
1482 1479
1483 if (feature_flags_.ext_texture_format_bgra8888) {
1484 validators_.texture_internal_format.AddValue(GL_BGRA8_EXT);
1485 validators_.texture_sized_color_renderable_internal_format.AddValue(
1486 GL_BGRA8_EXT);
1487 validators_.texture_sized_texture_filterable_internal_format.AddValue(
1488 GL_BGRA8_EXT);
1489 }
1490
1491 unsafe_es3_apis_enabled_ = true; 1480 unsafe_es3_apis_enabled_ = true;
1492 } 1481 }
1493 1482
1494 bool FeatureInfo::IsWebGLContext() const { 1483 bool FeatureInfo::IsWebGLContext() const {
1495 // Switch statement to cause a compile-time error if we miss a case. 1484 // Switch statement to cause a compile-time error if we miss a case.
1496 switch (context_type_) { 1485 switch (context_type_) {
1497 case CONTEXT_TYPE_WEBGL1: 1486 case CONTEXT_TYPE_WEBGL1:
1498 case CONTEXT_TYPE_WEBGL2: 1487 case CONTEXT_TYPE_WEBGL2:
1499 return true; 1488 return true;
1500 case CONTEXT_TYPE_OPENGLES2: 1489 case CONTEXT_TYPE_OPENGLES2:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 if (pos == std::string::npos) { 1537 if (pos == std::string::npos) {
1549 extensions_ += (extensions_.empty() ? "" : " ") + str; 1538 extensions_ += (extensions_.empty() ? "" : " ") + str;
1550 } 1539 }
1551 } 1540 }
1552 1541
1553 FeatureInfo::~FeatureInfo() { 1542 FeatureInfo::~FeatureInfo() {
1554 } 1543 }
1555 1544
1556 } // namespace gles2 1545 } // namespace gles2
1557 } // namespace gpu 1546 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.h ('k') | gpu/command_buffer/service/framebuffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698