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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
14 #include "gpu/command_buffer/service/gpu_switches.h" | 15 #include "gpu/command_buffer/service/gpu_switches.h" |
15 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
16 | 17 |
17 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
18 #include "ui/gl/io_surface_support_mac.h" | 19 #include "ui/gl/io_surface_support_mac.h" |
19 #endif | 20 #endif |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 workarounds->max_cube_map_texture_size = 4096; | 93 workarounds->max_cube_map_texture_size = 4096; |
93 if (workarounds->max_cube_map_texture_size_limit_1024) | 94 if (workarounds->max_cube_map_texture_size_limit_1024) |
94 workarounds->max_cube_map_texture_size = 1024; | 95 workarounds->max_cube_map_texture_size = 1024; |
95 if (workarounds->max_cube_map_texture_size_limit_512) | 96 if (workarounds->max_cube_map_texture_size_limit_512) |
96 workarounds->max_cube_map_texture_size = 512; | 97 workarounds->max_cube_map_texture_size = 512; |
97 } | 98 } |
98 | 99 |
99 } // anonymous namespace. | 100 } // anonymous namespace. |
100 | 101 |
101 FeatureInfo::FeatureFlags::FeatureFlags() | 102 FeatureInfo::FeatureFlags::FeatureFlags() |
102 : chromium_framebuffer_multisample(false), | 103 : chromium_color_buffer_float_rgba(false), |
104 chromium_color_buffer_float_rgb(false), | |
105 chromium_framebuffer_multisample(false), | |
103 use_core_framebuffer_multisample(false), | 106 use_core_framebuffer_multisample(false), |
104 multisampled_render_to_texture(false), | 107 multisampled_render_to_texture(false), |
105 use_img_for_multisampled_render_to_texture(false), | 108 use_img_for_multisampled_render_to_texture(false), |
106 oes_standard_derivatives(false), | 109 oes_standard_derivatives(false), |
107 oes_egl_image_external(false), | 110 oes_egl_image_external(false), |
108 oes_depth24(false), | 111 oes_depth24(false), |
109 oes_compressed_etc1_rgb8_texture(false), | 112 oes_compressed_etc1_rgb8_texture(false), |
110 packed_depth24_stencil8(false), | 113 packed_depth24_stencil8(false), |
111 npot_ok(false), | 114 npot_ok(false), |
112 enable_texture_float_linear(false), | 115 enable_texture_float_linear(false), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 npot_ok = true; | 433 npot_ok = true; |
431 } | 434 } |
432 | 435 |
433 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, | 436 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, |
434 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear | 437 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear |
435 bool enable_texture_float = false; | 438 bool enable_texture_float = false; |
436 bool enable_texture_float_linear = false; | 439 bool enable_texture_float_linear = false; |
437 bool enable_texture_half_float = false; | 440 bool enable_texture_half_float = false; |
438 bool enable_texture_half_float_linear = false; | 441 bool enable_texture_half_float_linear = false; |
439 | 442 |
440 bool have_arb_texture_float = extensions.Contains("GL_ARB_texture_float"); | 443 bool may_enable_chromium_color_buffer_float = false; |
441 | 444 |
442 if (have_arb_texture_float) { | 445 if (extensions.Contains("GL_ARB_texture_float")) { |
443 enable_texture_float = true; | 446 enable_texture_float = true; |
444 enable_texture_float_linear = true; | 447 enable_texture_float_linear = true; |
445 enable_texture_half_float = true; | 448 enable_texture_half_float = true; |
446 enable_texture_half_float_linear = true; | 449 enable_texture_half_float_linear = true; |
450 may_enable_chromium_color_buffer_float = true; | |
447 } else { | 451 } else { |
448 if (extensions.Contains("GL_OES_texture_float") || have_arb_texture_float) { | 452 if (extensions.Contains("GL_OES_texture_float")) { |
449 enable_texture_float = true; | 453 enable_texture_float = true; |
450 if (extensions.Contains("GL_OES_texture_float_linear") || | 454 if (extensions.Contains("GL_OES_texture_float_linear")) { |
451 have_arb_texture_float) { | |
452 enable_texture_float_linear = true; | 455 enable_texture_float_linear = true; |
453 } | 456 } |
457 if (is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) { | |
458 may_enable_chromium_color_buffer_float = true; | |
459 } | |
454 } | 460 } |
455 if (extensions.Contains("GL_OES_texture_half_float") || | 461 if (extensions.Contains("GL_OES_texture_half_float")) { |
456 have_arb_texture_float) { | |
457 enable_texture_half_float = true; | 462 enable_texture_half_float = true; |
458 if (extensions.Contains("GL_OES_texture_half_float_linear") || | 463 if (extensions.Contains("GL_OES_texture_half_float_linear")) { |
459 have_arb_texture_float) { | |
460 enable_texture_half_float_linear = true; | 464 enable_texture_half_float_linear = true; |
461 } | 465 } |
462 } | 466 } |
463 } | 467 } |
464 | 468 |
465 if (enable_texture_float) { | 469 if (enable_texture_float) { |
466 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); | 470 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); |
467 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT); | 471 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT); |
468 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT); | 472 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT); |
469 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT); | 473 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT); |
(...skipping 13 matching lines...) Expand all Loading... | |
483 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES); | 487 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES); |
484 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); | 488 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); |
485 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); | 489 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); |
486 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); | 490 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); |
487 AddExtensionString("GL_OES_texture_half_float"); | 491 AddExtensionString("GL_OES_texture_half_float"); |
488 if (enable_texture_half_float_linear) { | 492 if (enable_texture_half_float_linear) { |
489 AddExtensionString("GL_OES_texture_half_float_linear"); | 493 AddExtensionString("GL_OES_texture_half_float_linear"); |
490 } | 494 } |
491 } | 495 } |
492 | 496 |
497 if (may_enable_chromium_color_buffer_float) { | |
498 COMPILE_ASSERT(GL_RGBA32F_ARB == GL_RGBA32F && | |
499 GL_RGBA32F_EXT == GL_RGBA32F && | |
500 GL_RGB32F_ARB == GL_RGB32F && | |
501 GL_RGB32F_EXT == GL_RGB32F, | |
502 sized_float_internal_format_variations_must_match); | |
503 // We don't check extension support beyond ARB_texture_float on desktop GL, | |
504 // and format support varies between GL configurations. For example, spec | |
505 // prior to OpenGL 3.0 mandates framebuffer support only for one | |
506 // implementation-chosen format, and ES3.0 EXT_color_buffer_float does not | |
507 // support rendering to RGB32F. Check for framebuffer completeness with | |
508 // formats that the extensions expose, and only enable an extension when a | |
509 // framebuffer created with its texture format is reported as complete. | |
510 GLint fb_binding = 0; | |
511 GLint tex_binding = 0; | |
512 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding); | |
513 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding); | |
514 | |
515 GLuint tex_id = 0; | |
516 GLuint fb_id = 0; | |
517 GLsizei width = 16; | |
518 | |
519 glGenTextures(1, &tex_id); | |
520 glGenFramebuffersEXT(1, &fb_id); | |
521 glBindTexture(GL_TEXTURE_2D, tex_id); | |
522 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, GL_RGBA, | |
523 GL_FLOAT, NULL); | |
Ken Russell (switch to Gerrit)
2014/02/11 00:37:23
Do you need to also set the GL_TEXTURE_MIN_FILTER
oetuaho-nv
2014/02/11 12:42:16
Done.
| |
524 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id); | |
525 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
526 GL_TEXTURE_2D, tex_id, 0); | |
527 GLenum statusRGBA = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
528 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, | |
529 GL_FLOAT, NULL); | |
530 GLenum statusRGB = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
531 glDeleteFramebuffersEXT(1, &fb_id); | |
532 glDeleteTextures(1, &tex_id); | |
533 | |
534 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding)); | |
535 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding)); | |
536 | |
537 DCHECK(glGetError() == GL_NO_ERROR); | |
538 | |
539 if (statusRGBA == GL_FRAMEBUFFER_COMPLETE) { | |
540 validators_.texture_internal_format.AddValue(GL_RGBA32F); | |
541 feature_flags_.chromium_color_buffer_float_rgba = true; | |
542 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba"); | |
543 } | |
544 if (statusRGB == GL_FRAMEBUFFER_COMPLETE) { | |
545 validators_.texture_internal_format.AddValue(GL_RGB32F); | |
546 feature_flags_.chromium_color_buffer_float_rgb = true; | |
547 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb"); | |
548 } | |
549 } | |
550 | |
493 // Check for multisample support | 551 // Check for multisample support |
494 if (!disallowed_features_.multisampling && | 552 if (!disallowed_features_.multisampling && |
495 !workarounds_.disable_framebuffer_multisample) { | 553 !workarounds_.disable_framebuffer_multisample) { |
496 bool ext_has_multisample = | 554 bool ext_has_multisample = |
497 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3; | 555 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3; |
498 if (feature_flags_.is_angle) { | 556 if (feature_flags_.is_angle) { |
499 ext_has_multisample |= | 557 ext_has_multisample |= |
500 extensions.Contains("GL_ANGLE_framebuffer_multisample"); | 558 extensions.Contains("GL_ANGLE_framebuffer_multisample"); |
501 } | 559 } |
502 feature_flags_.use_core_framebuffer_multisample = is_es3; | 560 feature_flags_.use_core_framebuffer_multisample = is_es3; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 | 770 |
713 if ((is_es3 || extensions.Contains("GL_EXT_discard_framebuffer")) && | 771 if ((is_es3 || extensions.Contains("GL_EXT_discard_framebuffer")) && |
714 !workarounds_.disable_ext_discard_framebuffer) { | 772 !workarounds_.disable_ext_discard_framebuffer) { |
715 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer. | 773 // DiscardFramebufferEXT is automatically bound to InvalidateFramebuffer. |
716 AddExtensionString("GL_EXT_discard_framebuffer"); | 774 AddExtensionString("GL_EXT_discard_framebuffer"); |
717 feature_flags_.ext_discard_framebuffer = true; | 775 feature_flags_.ext_discard_framebuffer = true; |
718 } | 776 } |
719 } | 777 } |
720 | 778 |
721 void FeatureInfo::AddExtensionString(const std::string& str) { | 779 void FeatureInfo::AddExtensionString(const std::string& str) { |
722 if (extensions_.find(str) == std::string::npos) { | 780 size_t pos = extensions_.find(str); |
781 while (pos != std::string::npos && | |
782 pos + str.length() < extensions_.length() && | |
piman
2014/02/10 23:09:03
nit: indenting looks wrong, continuation should al
oetuaho-nv
2014/02/11 12:42:16
Done.
| |
783 extensions_.substr(pos + str.length(), 1) != " ") { | |
784 // This extension name is a substring of another. | |
785 pos = extensions_.find(str, pos + str.length()); | |
786 } | |
787 if (pos == std::string::npos) { | |
723 extensions_ += (extensions_.empty() ? "" : " ") + str; | 788 extensions_ += (extensions_.empty() ? "" : " ") + str; |
724 } | 789 } |
piman
2014/02/10 23:09:03
/me thinks we should make extension_ a list (or ha
Ken Russell (switch to Gerrit)
2014/02/11 00:37:23
Agreed on both points.
| |
725 } | 790 } |
726 | 791 |
727 FeatureInfo::~FeatureInfo() { | 792 FeatureInfo::~FeatureInfo() { |
728 } | 793 } |
729 | 794 |
730 } // namespace gles2 | 795 } // namespace gles2 |
731 } // namespace gpu | 796 } // namespace gpu |
OLD | NEW |