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

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

Issue 489023002: gpu: Enable relevant extentions on GLES3. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits, add COMPILE_ASSERT and exclude half_float Created 6 years, 3 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/feature_info_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/macros.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 disallowed_features_ = disallowed_features; 221 disallowed_features_ = disallowed_features;
222 InitializeFeatures(); 222 InitializeFeatures();
223 return true; 223 return true;
224 } 224 }
225 225
226 void FeatureInfo::InitializeFeatures() { 226 void FeatureInfo::InitializeFeatures() {
227 // Figure out what extensions to turn on. 227 // Figure out what extensions to turn on.
228 StringSet extensions( 228 StringSet extensions(
229 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); 229 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
230 230
231 bool npot_ok = false;
232
233 const char* renderer_str = 231 const char* renderer_str =
234 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); 232 reinterpret_cast<const char*>(glGetString(GL_RENDERER));
235 if (renderer_str) { 233 if (renderer_str) {
236 feature_flags_.is_angle = StartsWithASCII(renderer_str, "ANGLE", true); 234 feature_flags_.is_angle = StartsWithASCII(renderer_str, "ANGLE", true);
237 } 235 }
238 236
239 bool is_es3 = false; 237 bool is_es3 = false;
240 const char* version_str = 238 const char* version_str =
241 reinterpret_cast<const char*>(glGetString(GL_VERSION)); 239 reinterpret_cast<const char*>(glGetString(GL_VERSION));
242 if (version_str) { 240 if (version_str) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 if (enable_depth_texture) { 365 if (enable_depth_texture) {
368 texture_format_validators_[GL_DEPTH_STENCIL] 366 texture_format_validators_[GL_DEPTH_STENCIL]
369 .AddValue(GL_UNSIGNED_INT_24_8); 367 .AddValue(GL_UNSIGNED_INT_24_8);
370 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL); 368 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
371 validators_.texture_format.AddValue(GL_DEPTH_STENCIL); 369 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
372 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8); 370 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
373 } 371 }
374 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8); 372 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
375 } 373 }
376 374
377 if (extensions.Contains("GL_OES_vertex_array_object") || 375 if (is_es3 || extensions.Contains("GL_OES_vertex_array_object") ||
378 extensions.Contains("GL_ARB_vertex_array_object") || 376 extensions.Contains("GL_ARB_vertex_array_object") ||
379 extensions.Contains("GL_APPLE_vertex_array_object")) { 377 extensions.Contains("GL_APPLE_vertex_array_object")) {
380 feature_flags_.native_vertex_array_object = true; 378 feature_flags_.native_vertex_array_object = true;
381 } 379 }
382 380
383 // If we're using client_side_arrays we have to emulate 381 // If we're using client_side_arrays we have to emulate
384 // vertex array objects since vertex array objects do not work 382 // vertex array objects since vertex array objects do not work
385 // with client side arrays. 383 // with client side arrays.
386 if (workarounds_.use_client_side_arrays_for_stream_buffers) { 384 if (workarounds_.use_client_side_arrays_for_stream_buffers) {
387 feature_flags_.native_vertex_array_object = false; 385 feature_flags_.native_vertex_array_object = false;
388 } 386 }
389 387
390 if (extensions.Contains("GL_OES_element_index_uint") || 388 if (is_es3 || extensions.Contains("GL_OES_element_index_uint") ||
391 gfx::HasDesktopGLFeatures()) { 389 gfx::HasDesktopGLFeatures()) {
392 AddExtensionString("GL_OES_element_index_uint"); 390 AddExtensionString("GL_OES_element_index_uint");
393 validators_.index_type.AddValue(GL_UNSIGNED_INT); 391 validators_.index_type.AddValue(GL_UNSIGNED_INT);
394 } 392 }
395 393
396 bool enable_texture_format_bgra8888 = false; 394 bool enable_texture_format_bgra8888 = false;
397 bool enable_read_format_bgra = false; 395 bool enable_read_format_bgra = false;
398 bool enable_render_buffer_bgra = false; 396 bool enable_render_buffer_bgra = false;
399 bool enable_immutable_texture_format_bgra_on_es3 = 397 bool enable_immutable_texture_format_bgra_on_es3 =
400 extensions.Contains("GL_APPLE_texture_format_BGRA8888"); 398 extensions.Contains("GL_APPLE_texture_format_BGRA8888");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 validators_.render_buffer_format.AddValue(GL_BGRA8_EXT); 431 validators_.render_buffer_format.AddValue(GL_BGRA8_EXT);
434 } 432 }
435 433
436 if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) { 434 if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
437 AddExtensionString("GL_OES_rgb8_rgba8"); 435 AddExtensionString("GL_OES_rgb8_rgba8");
438 validators_.render_buffer_format.AddValue(GL_RGB8_OES); 436 validators_.render_buffer_format.AddValue(GL_RGB8_OES);
439 validators_.render_buffer_format.AddValue(GL_RGBA8_OES); 437 validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
440 } 438 }
441 439
442 // Check if we should allow GL_OES_texture_npot 440 // Check if we should allow GL_OES_texture_npot
443 if (extensions.Contains("GL_ARB_texture_non_power_of_two") || 441 if (is_es3 || extensions.Contains("GL_ARB_texture_non_power_of_two") ||
444 extensions.Contains("GL_OES_texture_npot")) { 442 extensions.Contains("GL_OES_texture_npot")) {
445 AddExtensionString("GL_OES_texture_npot"); 443 AddExtensionString("GL_OES_texture_npot");
446 npot_ok = true; 444 feature_flags_.npot_ok = true;
447 } 445 }
448 446
449 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, 447 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
450 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear 448 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
451 bool enable_texture_float = false; 449 bool enable_texture_float = false;
452 bool enable_texture_float_linear = false; 450 bool enable_texture_float_linear = false;
453 bool enable_texture_half_float = false; 451 bool enable_texture_half_float = false;
454 bool enable_texture_half_float_linear = false; 452 bool enable_texture_half_float_linear = false;
455 453
456 bool may_enable_chromium_color_buffer_float = false; 454 bool may_enable_chromium_color_buffer_float = false;
457 455
458 if (extensions.Contains("GL_ARB_texture_float")) { 456 if (extensions.Contains("GL_ARB_texture_float")) {
459 enable_texture_float = true; 457 enable_texture_float = true;
460 enable_texture_float_linear = true; 458 enable_texture_float_linear = true;
461 enable_texture_half_float = true; 459 enable_texture_half_float = true;
462 enable_texture_half_float_linear = true; 460 enable_texture_half_float_linear = true;
463 may_enable_chromium_color_buffer_float = true; 461 may_enable_chromium_color_buffer_float = true;
464 } else { 462 } else {
465 if (extensions.Contains("GL_OES_texture_float")) { 463 if (is_es3 || extensions.Contains("GL_OES_texture_float")) {
466 enable_texture_float = true; 464 enable_texture_float = true;
467 if (extensions.Contains("GL_OES_texture_float_linear")) { 465 if (extensions.Contains("GL_OES_texture_float_linear")) {
468 enable_texture_float_linear = true; 466 enable_texture_float_linear = true;
469 } 467 }
470 if ((is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) || 468 if ((is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) ||
471 feature_flags_.is_angle) { 469 feature_flags_.is_angle) {
472 may_enable_chromium_color_buffer_float = true; 470 may_enable_chromium_color_buffer_float = true;
473 } 471 }
474 } 472 }
473 // TODO(dshwang): GLES3 supports half float by default but GL_HALF_FLOAT_OES
474 // isn't equal to GL_HALF_FLOAT.
475 if (extensions.Contains("GL_OES_texture_half_float")) { 475 if (extensions.Contains("GL_OES_texture_half_float")) {
476 enable_texture_half_float = true; 476 enable_texture_half_float = true;
477 if (extensions.Contains("GL_OES_texture_half_float_linear")) { 477 if (extensions.Contains("GL_OES_texture_half_float_linear")) {
478 enable_texture_half_float_linear = true; 478 enable_texture_half_float_linear = true;
479 } 479 }
480 } 480 }
481 } 481 }
482 482
483 if (enable_texture_float) { 483 if (enable_texture_float) {
484 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); 484 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 599 }
600 600
601 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() || 601 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
602 is_es3) { 602 is_es3) {
603 AddExtensionString("GL_OES_depth24"); 603 AddExtensionString("GL_OES_depth24");
604 feature_flags_.oes_depth24 = true; 604 feature_flags_.oes_depth24 = true;
605 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24); 605 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
606 } 606 }
607 607
608 if (!workarounds_.disable_oes_standard_derivatives && 608 if (!workarounds_.disable_oes_standard_derivatives &&
609 (extensions.Contains("GL_OES_standard_derivatives") || 609 (is_es3 || extensions.Contains("GL_OES_standard_derivatives") ||
610 gfx::HasDesktopGLFeatures())) { 610 gfx::HasDesktopGLFeatures())) {
611 AddExtensionString("GL_OES_standard_derivatives"); 611 AddExtensionString("GL_OES_standard_derivatives");
612 feature_flags_.oes_standard_derivatives = true; 612 feature_flags_.oes_standard_derivatives = true;
613 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 613 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
614 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 614 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
615 } 615 }
616 616
617 if (extensions.Contains("GL_OES_EGL_image_external")) { 617 if (extensions.Contains("GL_OES_EGL_image_external")) {
618 AddExtensionString("GL_OES_EGL_image_external"); 618 AddExtensionString("GL_OES_EGL_image_external");
619 feature_flags_.oes_egl_image_external = true; 619 feature_flags_.oes_egl_image_external = true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 #if defined(OS_MACOSX) 672 #if defined(OS_MACOSX)
673 AddExtensionString("GL_CHROMIUM_iosurface"); 673 AddExtensionString("GL_CHROMIUM_iosurface");
674 #endif 674 #endif
675 675
676 // TODO(gman): Add support for these extensions. 676 // TODO(gman): Add support for these extensions.
677 // GL_OES_depth32 677 // GL_OES_depth32
678 678
679 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear; 679 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear;
680 feature_flags_.enable_texture_half_float_linear |= 680 feature_flags_.enable_texture_half_float_linear |=
681 enable_texture_half_float_linear; 681 enable_texture_half_float_linear;
682 feature_flags_.npot_ok |= npot_ok;
683 682
684 if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) { 683 if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) {
685 AddExtensionString("GL_ANGLE_pack_reverse_row_order"); 684 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
686 feature_flags_.angle_pack_reverse_row_order = true; 685 feature_flags_.angle_pack_reverse_row_order = true;
687 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE); 686 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
688 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE); 687 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
689 } 688 }
690 689
691 if (extensions.Contains("GL_ANGLE_texture_usage")) { 690 if (extensions.Contains("GL_ANGLE_texture_usage")) {
692 feature_flags_.angle_texture_usage = true; 691 feature_flags_.angle_texture_usage = true;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 AddExtensionString("GL_EXT_draw_buffers"); 766 AddExtensionString("GL_EXT_draw_buffers");
768 feature_flags_.ext_draw_buffers = true; 767 feature_flags_.ext_draw_buffers = true;
769 768
770 GLint max_color_attachments = 0; 769 GLint max_color_attachments = 0;
771 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments); 770 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments);
772 for (GLenum i = GL_COLOR_ATTACHMENT1_EXT; 771 for (GLenum i = GL_COLOR_ATTACHMENT1_EXT;
773 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + max_color_attachments); 772 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + max_color_attachments);
774 ++i) { 773 ++i) {
775 validators_.attachment.AddValue(i); 774 validators_.attachment.AddValue(i);
776 } 775 }
776 COMPILE_ASSERT(GL_COLOR_ATTACHMENT0_EXT == GL_COLOR_ATTACHMENT0,
777 color_attachment0_variation_must_match);
777 778
778 validators_.g_l_state.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT); 779 validators_.g_l_state.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT);
779 validators_.g_l_state.AddValue(GL_MAX_DRAW_BUFFERS_ARB); 780 validators_.g_l_state.AddValue(GL_MAX_DRAW_BUFFERS_ARB);
780 GLint max_draw_buffers = 0; 781 GLint max_draw_buffers = 0;
781 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_buffers); 782 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_buffers);
782 for (GLenum i = GL_DRAW_BUFFER0_ARB; 783 for (GLenum i = GL_DRAW_BUFFER0_ARB;
783 i < static_cast<GLenum>(GL_DRAW_BUFFER0_ARB + max_draw_buffers); 784 i < static_cast<GLenum>(GL_DRAW_BUFFER0_ARB + max_draw_buffers);
784 ++i) { 785 ++i) {
785 validators_.g_l_state.AddValue(i); 786 validators_.g_l_state.AddValue(i);
786 } 787 }
787 } 788 }
788 789
789 if (extensions.Contains("GL_EXT_blend_minmax") || 790 if (is_es3 || extensions.Contains("GL_EXT_blend_minmax") ||
790 gfx::HasDesktopGLFeatures()) { 791 gfx::HasDesktopGLFeatures()) {
791 AddExtensionString("GL_EXT_blend_minmax"); 792 AddExtensionString("GL_EXT_blend_minmax");
792 validators_.equation.AddValue(GL_MIN_EXT); 793 validators_.equation.AddValue(GL_MIN_EXT);
793 validators_.equation.AddValue(GL_MAX_EXT); 794 validators_.equation.AddValue(GL_MAX_EXT);
795 COMPILE_ASSERT(GL_MIN_EXT == GL_MIN && GL_MAX_EXT == GL_MAX,
796 min_max_variations_must_match);
794 } 797 }
795 798
799 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
796 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) { 800 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
797 AddExtensionString("GL_EXT_frag_depth"); 801 AddExtensionString("GL_EXT_frag_depth");
798 feature_flags_.ext_frag_depth = true; 802 feature_flags_.ext_frag_depth = true;
799 } 803 }
800 804
801 if (extensions.Contains("GL_EXT_shader_texture_lod") || 805 if (extensions.Contains("GL_EXT_shader_texture_lod") ||
802 gfx::HasDesktopGLFeatures()) { 806 gfx::HasDesktopGLFeatures()) {
803 AddExtensionString("GL_EXT_shader_texture_lod"); 807 AddExtensionString("GL_EXT_shader_texture_lod");
804 feature_flags_.ext_shader_texture_lod = true; 808 feature_flags_.ext_shader_texture_lod = true;
805 } 809 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 if (pos == std::string::npos) { 871 if (pos == std::string::npos) {
868 extensions_ += (extensions_.empty() ? "" : " ") + str; 872 extensions_ += (extensions_.empty() ? "" : " ") + str;
869 } 873 }
870 } 874 }
871 875
872 FeatureInfo::~FeatureInfo() { 876 FeatureInfo::~FeatureInfo() {
873 } 877 }
874 878
875 } // namespace gles2 879 } // namespace gles2
876 } // namespace gpu 880 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/feature_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698