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

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

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