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

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

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address review feedback, split extension and add tests Created 6 years, 10 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 <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
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
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
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 spec prior to OpenGL 3.0 mandates framebuffer support only for one
505 // implementation-chosen format. Check for framebuffer completeness with
506 // formats that the extension exposes, and only enable the extension when
507 // framebuffers created with both float texture formats result in a
508 // complete framebuffer.
509 GLint fb_binding = 0;
510 GLint tex_binding = 0;
511 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding);
512 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding);
513
514 GLuint tex_id = 0;
515 GLuint fb_id = 0;
516 GLsizei width = 16;
517
518 glGenTextures(1, &tex_id);
519 glGenFramebuffersEXT(1, &fb_id);
520 glBindTexture(GL_TEXTURE_2D, tex_id);
521 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, GL_RGBA,
522 GL_FLOAT, NULL);
523 glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id);
524 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
525 GL_TEXTURE_2D, tex_id, 0);
526 GLenum statusRGBA = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
527 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB,
528 GL_FLOAT, NULL);
529 GLenum statusRGB = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
530 glDeleteFramebuffersEXT(1, &fb_id);
531 glDeleteTextures(1, &tex_id);
532
533 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding));
534 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding));
535
536 DCHECK(glGetError() == GL_NO_ERROR);
537
538 // ES3.0 EXT_color_buffer_float doesn't support rendering to RGB32F, so
539 // split into two extensions.
540 if (statusRGBA == GL_FRAMEBUFFER_COMPLETE) {
541 validators_.texture_internal_format.AddValue(GL_RGBA32F);
542 feature_flags_.chromium_color_buffer_float_rgba = true;
543 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba");
544 }
545 if (statusRGB == GL_FRAMEBUFFER_COMPLETE) {
546 validators_.texture_internal_format.AddValue(GL_RGB32F);
547 feature_flags_.chromium_color_buffer_float_rgb = true;
548 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgb");
549 }
550 }
551
493 // Check for multisample support 552 // Check for multisample support
494 if (!disallowed_features_.multisampling && 553 if (!disallowed_features_.multisampling &&
495 !workarounds_.disable_framebuffer_multisample) { 554 !workarounds_.disable_framebuffer_multisample) {
496 bool ext_has_multisample = 555 bool ext_has_multisample =
497 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3; 556 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3;
498 if (feature_flags_.is_angle) { 557 if (feature_flags_.is_angle) {
499 ext_has_multisample |= 558 ext_has_multisample |=
500 extensions.Contains("GL_ANGLE_framebuffer_multisample"); 559 extensions.Contains("GL_ANGLE_framebuffer_multisample");
501 } 560 }
502 feature_flags_.use_core_framebuffer_multisample = is_es3; 561 feature_flags_.use_core_framebuffer_multisample = is_es3;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 if (extensions_.find(str) == std::string::npos) { 781 if (extensions_.find(str) == std::string::npos) {
723 extensions_ += (extensions_.empty() ? "" : " ") + str; 782 extensions_ += (extensions_.empty() ? "" : " ") + str;
724 } 783 }
725 } 784 }
726 785
727 FeatureInfo::~FeatureInfo() { 786 FeatureInfo::~FeatureInfo() {
728 } 787 }
729 788
730 } // namespace gles2 789 } // namespace gles2
731 } // namespace gpu 790 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698