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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 workarounds->max_cube_map_texture_size = 4096; | 92 workarounds->max_cube_map_texture_size = 4096; |
93 if (workarounds->max_cube_map_texture_size_limit_1024) | 93 if (workarounds->max_cube_map_texture_size_limit_1024) |
94 workarounds->max_cube_map_texture_size = 1024; | 94 workarounds->max_cube_map_texture_size = 1024; |
95 if (workarounds->max_cube_map_texture_size_limit_512) | 95 if (workarounds->max_cube_map_texture_size_limit_512) |
96 workarounds->max_cube_map_texture_size = 512; | 96 workarounds->max_cube_map_texture_size = 512; |
97 } | 97 } |
98 | 98 |
99 } // anonymous namespace. | 99 } // anonymous namespace. |
100 | 100 |
101 FeatureInfo::FeatureFlags::FeatureFlags() | 101 FeatureInfo::FeatureFlags::FeatureFlags() |
102 : chromium_framebuffer_multisample(false), | 102 : chromium_color_buffer_float(false), |
103 chromium_framebuffer_multisample(false), | |
103 use_core_framebuffer_multisample(false), | 104 use_core_framebuffer_multisample(false), |
104 multisampled_render_to_texture(false), | 105 multisampled_render_to_texture(false), |
105 use_img_for_multisampled_render_to_texture(false), | 106 use_img_for_multisampled_render_to_texture(false), |
106 oes_standard_derivatives(false), | 107 oes_standard_derivatives(false), |
107 oes_egl_image_external(false), | 108 oes_egl_image_external(false), |
108 oes_depth24(false), | 109 oes_depth24(false), |
109 oes_compressed_etc1_rgb8_texture(false), | 110 oes_compressed_etc1_rgb8_texture(false), |
110 packed_depth24_stencil8(false), | 111 packed_depth24_stencil8(false), |
111 npot_ok(false), | 112 npot_ok(false), |
112 enable_texture_float_linear(false), | 113 enable_texture_float_linear(false), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
430 npot_ok = true; | 431 npot_ok = true; |
431 } | 432 } |
432 | 433 |
433 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, | 434 // 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 | 435 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear |
435 bool enable_texture_float = false; | 436 bool enable_texture_float = false; |
436 bool enable_texture_float_linear = false; | 437 bool enable_texture_float_linear = false; |
437 bool enable_texture_half_float = false; | 438 bool enable_texture_half_float = false; |
438 bool enable_texture_half_float_linear = false; | 439 bool enable_texture_half_float_linear = false; |
439 | 440 |
440 bool have_arb_texture_float = extensions.Contains("GL_ARB_texture_float"); | 441 bool may_enable_chromium_color_buffer_float = false; |
441 | 442 |
442 if (have_arb_texture_float) { | 443 if (extensions.Contains("GL_ARB_texture_float")) { |
443 enable_texture_float = true; | 444 enable_texture_float = true; |
444 enable_texture_float_linear = true; | 445 enable_texture_float_linear = true; |
445 enable_texture_half_float = true; | 446 enable_texture_half_float = true; |
446 enable_texture_half_float_linear = true; | 447 enable_texture_half_float_linear = true; |
448 may_enable_chromium_color_buffer_float = true; | |
447 } else { | 449 } else { |
448 if (extensions.Contains("GL_OES_texture_float") || have_arb_texture_float) { | 450 if (extensions.Contains("GL_OES_texture_float")) { |
449 enable_texture_float = true; | 451 enable_texture_float = true; |
450 if (extensions.Contains("GL_OES_texture_float_linear") || | 452 if (extensions.Contains("GL_OES_texture_float_linear")) { |
451 have_arb_texture_float) { | |
452 enable_texture_float_linear = true; | 453 enable_texture_float_linear = true; |
453 } | 454 } |
455 if (is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) { | |
456 may_enable_chromium_color_buffer_float = true; | |
457 } | |
454 } | 458 } |
455 if (extensions.Contains("GL_OES_texture_half_float") || | 459 if (extensions.Contains("GL_OES_texture_half_float")) { |
456 have_arb_texture_float) { | |
457 enable_texture_half_float = true; | 460 enable_texture_half_float = true; |
458 if (extensions.Contains("GL_OES_texture_half_float_linear") || | 461 if (extensions.Contains("GL_OES_texture_half_float_linear")) { |
459 have_arb_texture_float) { | |
460 enable_texture_half_float_linear = true; | 462 enable_texture_half_float_linear = true; |
461 } | 463 } |
462 } | 464 } |
463 } | 465 } |
464 | 466 |
465 if (enable_texture_float) { | 467 if (enable_texture_float) { |
466 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); | 468 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); |
467 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT); | 469 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT); |
468 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT); | 470 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT); |
469 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT); | 471 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); | 485 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES); |
484 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); | 486 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); |
485 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); | 487 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); |
486 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); | 488 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); |
487 AddExtensionString("GL_OES_texture_half_float"); | 489 AddExtensionString("GL_OES_texture_half_float"); |
488 if (enable_texture_half_float_linear) { | 490 if (enable_texture_half_float_linear) { |
489 AddExtensionString("GL_OES_texture_half_float_linear"); | 491 AddExtensionString("GL_OES_texture_half_float_linear"); |
490 } | 492 } |
491 } | 493 } |
492 | 494 |
495 if (may_enable_chromium_color_buffer_float) { | |
496 DCHECK(GL_RGBA32F_ARB == GL_RGBA32F && GL_RGBA32F_EXT == GL_RGBA32F && | |
497 GL_RGB32F_ARB == GL_RGB32F && GL_RGB32F_EXT == GL_RGB32F); | |
piman
2014/02/07 00:43:10
nit: you can use COMPILE_ASSERT
oetuaho-nv
2014/02/07 09:26:58
Done.
| |
498 // We don't check extension support beyond ARB_texture_float on desktop GL, | |
499 // and spec prior to OpenGL 3.0 mandates framebuffer support only for one | |
500 // implementation-chosen format. Check for framebuffer completeness with | |
501 // formats that the extension exposes, and only enable the extension when | |
502 // framebuffers created with both float texture formats result in a | |
503 // complete framebuffer. | |
504 GLint fb_binding = 0; | |
505 GLint tex_binding = 0; | |
506 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding); | |
507 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding); | |
508 | |
509 GLuint tex_id = 0; | |
510 GLuint fb_id = 0; | |
511 GLsizei width = 16; | |
512 GLfloat* data = new GLfloat[width * width * 4]; | |
piman
2014/02/07 00:43:10
Why not passing NULL to the glTexImage2D below?
oetuaho-nv
2014/02/07 09:26:58
True, NULL is fine.
| |
513 | |
514 glGenTextures(1, &tex_id); | |
515 glGenFramebuffersEXT(1, &fb_id); | |
516 glBindTexture(GL_TEXTURE_2D, tex_id); | |
517 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, GL_RGBA, | |
518 GL_FLOAT, static_cast<GLvoid*>(data)); | |
519 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id); | |
520 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | |
521 GL_TEXTURE_2D, tex_id, 0); | |
522 GLenum statusRGBA = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
523 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, | |
524 GL_FLOAT, static_cast<GLvoid*>(data)); | |
525 GLenum statusRGB = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | |
526 glDeleteFramebuffersEXT(1, &fb_id); | |
527 glDeleteTextures(1, &tex_id); | |
528 | |
529 delete[] data; | |
530 | |
531 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding)); | |
532 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding)); | |
533 | |
534 DCHECK(glGetError() == GL_NO_ERROR); | |
535 | |
536 if (statusRGBA == GL_FRAMEBUFFER_COMPLETE && | |
537 statusRGB == GL_FRAMEBUFFER_COMPLETE) { | |
538 validators_.texture_internal_format.AddValue(GL_RGBA32F); | |
539 validators_.texture_internal_format.AddValue(GL_RGB32F); | |
540 feature_flags_.chromium_color_buffer_float = true; | |
541 AddExtensionString("GL_CHROMIUM_color_buffer_float"); | |
542 } | |
543 } | |
544 | |
493 // Check for multisample support | 545 // Check for multisample support |
494 if (!disallowed_features_.multisampling && | 546 if (!disallowed_features_.multisampling && |
495 !workarounds_.disable_framebuffer_multisample) { | 547 !workarounds_.disable_framebuffer_multisample) { |
496 bool ext_has_multisample = | 548 bool ext_has_multisample = |
497 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3; | 549 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3; |
498 if (feature_flags_.is_angle) { | 550 if (feature_flags_.is_angle) { |
499 ext_has_multisample |= | 551 ext_has_multisample |= |
500 extensions.Contains("GL_ANGLE_framebuffer_multisample"); | 552 extensions.Contains("GL_ANGLE_framebuffer_multisample"); |
501 } | 553 } |
502 feature_flags_.use_core_framebuffer_multisample = is_es3; | 554 feature_flags_.use_core_framebuffer_multisample = is_es3; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 if (extensions_.find(str) == std::string::npos) { | 774 if (extensions_.find(str) == std::string::npos) { |
723 extensions_ += (extensions_.empty() ? "" : " ") + str; | 775 extensions_ += (extensions_.empty() ? "" : " ") + str; |
724 } | 776 } |
725 } | 777 } |
726 | 778 |
727 FeatureInfo::~FeatureInfo() { | 779 FeatureInfo::~FeatureInfo() { |
728 } | 780 } |
729 | 781 |
730 } // namespace gles2 | 782 } // namespace gles2 |
731 } // namespace gpu | 783 } // namespace gpu |
OLD | NEW |