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

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: fix unittest failure; exclude EXT_draw_buffers 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 397
400 // Check if we should allow GL_EXT_texture_format_BGRA8888 398 // Check if we should allow GL_EXT_texture_format_BGRA8888
(...skipping 30 matching lines...) Expand all
431 validators_.render_buffer_format.AddValue(GL_BGRA8_EXT); 429 validators_.render_buffer_format.AddValue(GL_BGRA8_EXT);
432 } 430 }
433 431
434 if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) { 432 if (extensions.Contains("GL_OES_rgb8_rgba8") || gfx::HasDesktopGLFeatures()) {
435 AddExtensionString("GL_OES_rgb8_rgba8"); 433 AddExtensionString("GL_OES_rgb8_rgba8");
436 validators_.render_buffer_format.AddValue(GL_RGB8_OES); 434 validators_.render_buffer_format.AddValue(GL_RGB8_OES);
437 validators_.render_buffer_format.AddValue(GL_RGBA8_OES); 435 validators_.render_buffer_format.AddValue(GL_RGBA8_OES);
438 } 436 }
439 437
440 // Check if we should allow GL_OES_texture_npot 438 // Check if we should allow GL_OES_texture_npot
441 if (extensions.Contains("GL_ARB_texture_non_power_of_two") || 439 if (is_es3 || extensions.Contains("GL_ARB_texture_non_power_of_two") ||
442 extensions.Contains("GL_OES_texture_npot")) { 440 extensions.Contains("GL_OES_texture_npot")) {
443 AddExtensionString("GL_OES_texture_npot"); 441 AddExtensionString("GL_OES_texture_npot");
444 npot_ok = true; 442 feature_flags_.npot_ok |= true;
piman 2014/08/28 18:17:39 nit: feature_flags_.npot_ok = true
dshwang 2014/08/29 07:49:09 Done.
445 } 443 }
446 444
447 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, 445 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float,
448 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear 446 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear
449 bool enable_texture_float = false; 447 bool enable_texture_float = false;
450 bool enable_texture_float_linear = false; 448 bool enable_texture_float_linear = false;
451 bool enable_texture_half_float = false; 449 bool enable_texture_half_float = false;
452 bool enable_texture_half_float_linear = false; 450 bool enable_texture_half_float_linear = false;
453 451
454 bool may_enable_chromium_color_buffer_float = false; 452 bool may_enable_chromium_color_buffer_float = false;
455 453
456 if (extensions.Contains("GL_ARB_texture_float")) { 454 if (extensions.Contains("GL_ARB_texture_float")) {
457 enable_texture_float = true; 455 enable_texture_float = true;
458 enable_texture_float_linear = true; 456 enable_texture_float_linear = true;
459 enable_texture_half_float = true; 457 enable_texture_half_float = true;
460 enable_texture_half_float_linear = true; 458 enable_texture_half_float_linear = true;
461 may_enable_chromium_color_buffer_float = true; 459 may_enable_chromium_color_buffer_float = true;
462 } else { 460 } else {
463 if (extensions.Contains("GL_OES_texture_float")) { 461 if (is_es3 || extensions.Contains("GL_OES_texture_float")) {
464 enable_texture_float = true; 462 enable_texture_float = true;
465 if (extensions.Contains("GL_OES_texture_float_linear")) { 463 if (extensions.Contains("GL_OES_texture_float_linear")) {
466 enable_texture_float_linear = true; 464 enable_texture_float_linear = true;
467 } 465 }
468 if ((is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) || 466 if ((is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) ||
469 feature_flags_.is_angle) { 467 feature_flags_.is_angle) {
470 may_enable_chromium_color_buffer_float = true; 468 may_enable_chromium_color_buffer_float = true;
471 } 469 }
472 } 470 }
473 if (extensions.Contains("GL_OES_texture_half_float")) { 471 if (is_es3 || extensions.Contains("GL_OES_texture_half_float")) {
474 enable_texture_half_float = true; 472 enable_texture_half_float = true;
475 if (extensions.Contains("GL_OES_texture_half_float_linear")) { 473 if (is_es3 || extensions.Contains("GL_OES_texture_half_float_linear")) {
476 enable_texture_half_float_linear = true; 474 enable_texture_half_float_linear = true;
477 } 475 }
478 } 476 }
479 } 477 }
480 478
481 if (enable_texture_float) { 479 if (enable_texture_float) {
482 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT); 480 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT);
483 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT); 481 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT);
484 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT); 482 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT);
485 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT); 483 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT);
486 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_FLOAT); 484 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_FLOAT);
487 validators_.pixel_type.AddValue(GL_FLOAT); 485 validators_.pixel_type.AddValue(GL_FLOAT);
488 validators_.read_pixel_type.AddValue(GL_FLOAT); 486 validators_.read_pixel_type.AddValue(GL_FLOAT);
489 AddExtensionString("GL_OES_texture_float"); 487 AddExtensionString("GL_OES_texture_float");
490 if (enable_texture_float_linear) { 488 if (enable_texture_float_linear) {
491 AddExtensionString("GL_OES_texture_float_linear"); 489 AddExtensionString("GL_OES_texture_float_linear");
492 } 490 }
493 } 491 }
494 492
495 if (enable_texture_half_float) { 493 if (enable_texture_half_float) {
496 texture_format_validators_[GL_ALPHA].AddValue(GL_HALF_FLOAT_OES); 494 texture_format_validators_[GL_ALPHA].AddValue(GL_HALF_FLOAT_OES);
dshwang 2014/08/29 07:49:09 I exclude half_float support because GL_HALF_FLOAT
497 texture_format_validators_[GL_RGB].AddValue(GL_HALF_FLOAT_OES); 495 texture_format_validators_[GL_RGB].AddValue(GL_HALF_FLOAT_OES);
498 texture_format_validators_[GL_RGBA].AddValue(GL_HALF_FLOAT_OES); 496 texture_format_validators_[GL_RGBA].AddValue(GL_HALF_FLOAT_OES);
499 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES); 497 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES);
500 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); 498 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES);
501 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); 499 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
502 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); 500 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
503 AddExtensionString("GL_OES_texture_half_float"); 501 AddExtensionString("GL_OES_texture_half_float");
504 if (enable_texture_half_float_linear) { 502 if (enable_texture_half_float_linear) {
505 AddExtensionString("GL_OES_texture_half_float_linear"); 503 AddExtensionString("GL_OES_texture_half_float_linear");
506 } 504 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 } 595 }
598 596
599 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() || 597 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
600 is_es3) { 598 is_es3) {
601 AddExtensionString("GL_OES_depth24"); 599 AddExtensionString("GL_OES_depth24");
602 feature_flags_.oes_depth24 = true; 600 feature_flags_.oes_depth24 = true;
603 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24); 601 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
604 } 602 }
605 603
606 if (!workarounds_.disable_oes_standard_derivatives && 604 if (!workarounds_.disable_oes_standard_derivatives &&
607 (extensions.Contains("GL_OES_standard_derivatives") || 605 (is_es3 || extensions.Contains("GL_OES_standard_derivatives") ||
608 gfx::HasDesktopGLFeatures())) { 606 gfx::HasDesktopGLFeatures())) {
609 AddExtensionString("GL_OES_standard_derivatives"); 607 AddExtensionString("GL_OES_standard_derivatives");
610 feature_flags_.oes_standard_derivatives = true; 608 feature_flags_.oes_standard_derivatives = true;
611 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 609 validators_.hint_target.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
612 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES); 610 validators_.g_l_state.AddValue(GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES);
613 } 611 }
614 612
615 if (extensions.Contains("GL_OES_EGL_image_external")) { 613 if (extensions.Contains("GL_OES_EGL_image_external")) {
616 AddExtensionString("GL_OES_EGL_image_external"); 614 AddExtensionString("GL_OES_EGL_image_external");
617 feature_flags_.oes_egl_image_external = true; 615 feature_flags_.oes_egl_image_external = true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 #if defined(OS_MACOSX) 668 #if defined(OS_MACOSX)
671 AddExtensionString("GL_CHROMIUM_iosurface"); 669 AddExtensionString("GL_CHROMIUM_iosurface");
672 #endif 670 #endif
673 671
674 // TODO(gman): Add support for these extensions. 672 // TODO(gman): Add support for these extensions.
675 // GL_OES_depth32 673 // GL_OES_depth32
676 674
677 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear; 675 feature_flags_.enable_texture_float_linear |= enable_texture_float_linear;
678 feature_flags_.enable_texture_half_float_linear |= 676 feature_flags_.enable_texture_half_float_linear |=
679 enable_texture_half_float_linear; 677 enable_texture_half_float_linear;
680 feature_flags_.npot_ok |= npot_ok;
681 678
682 if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) { 679 if (extensions.Contains("GL_ANGLE_pack_reverse_row_order")) {
683 AddExtensionString("GL_ANGLE_pack_reverse_row_order"); 680 AddExtensionString("GL_ANGLE_pack_reverse_row_order");
684 feature_flags_.angle_pack_reverse_row_order = true; 681 feature_flags_.angle_pack_reverse_row_order = true;
685 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE); 682 validators_.pixel_store.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
686 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE); 683 validators_.g_l_state.AddValue(GL_PACK_REVERSE_ROW_ORDER_ANGLE);
687 } 684 }
688 685
689 if (extensions.Contains("GL_ANGLE_texture_usage")) { 686 if (extensions.Contains("GL_ANGLE_texture_usage")) {
690 feature_flags_.angle_texture_usage = true; 687 feature_flags_.angle_texture_usage = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 746 }
750 747
751 if (!workarounds_.disable_ext_draw_buffers && 748 if (!workarounds_.disable_ext_draw_buffers &&
752 (extensions.Contains("GL_ARB_draw_buffers") || 749 (extensions.Contains("GL_ARB_draw_buffers") ||
753 extensions.Contains("GL_EXT_draw_buffers"))) { 750 extensions.Contains("GL_EXT_draw_buffers"))) {
754 AddExtensionString("GL_EXT_draw_buffers"); 751 AddExtensionString("GL_EXT_draw_buffers");
755 feature_flags_.ext_draw_buffers = true; 752 feature_flags_.ext_draw_buffers = true;
756 753
757 GLint max_color_attachments = 0; 754 GLint max_color_attachments = 0;
758 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments); 755 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments);
759 for (GLenum i = GL_COLOR_ATTACHMENT1_EXT; 756 for (GLenum i = GL_COLOR_ATTACHMENT0_EXT;
piman 2014/08/28 18:17:39 nit: GL_COLOR_ATTACHMENT0_EXT is already in valida
760 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + max_color_attachments); 757 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0_EXT +
758 max_color_attachments);
761 ++i) { 759 ++i) {
762 validators_.attachment.AddValue(i); 760 validators_.attachment.AddValue(i);
763 } 761 }
764 762
765 validators_.g_l_state.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT); 763 validators_.g_l_state.AddValue(GL_MAX_COLOR_ATTACHMENTS_EXT);
766 validators_.g_l_state.AddValue(GL_MAX_DRAW_BUFFERS_ARB); 764 validators_.g_l_state.AddValue(GL_MAX_DRAW_BUFFERS_ARB);
767 GLint max_draw_buffers = 0; 765 GLint max_draw_buffers = 0;
768 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_buffers); 766 glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &max_draw_buffers);
769 for (GLenum i = GL_DRAW_BUFFER0_ARB; 767 for (GLenum i = GL_DRAW_BUFFER0_ARB;
770 i < static_cast<GLenum>(GL_DRAW_BUFFER0_ARB + max_draw_buffers); 768 i < static_cast<GLenum>(GL_DRAW_BUFFER0_ARB + max_draw_buffers);
771 ++i) { 769 ++i) {
772 validators_.g_l_state.AddValue(i); 770 validators_.g_l_state.AddValue(i);
773 } 771 }
774 } 772 }
775 773
776 if (extensions.Contains("GL_EXT_blend_minmax") || 774 if (is_es3 || extensions.Contains("GL_EXT_blend_minmax") ||
777 gfx::HasDesktopGLFeatures()) { 775 gfx::HasDesktopGLFeatures()) {
778 AddExtensionString("GL_EXT_blend_minmax"); 776 AddExtensionString("GL_EXT_blend_minmax");
779 validators_.equation.AddValue(GL_MIN_EXT); 777 validators_.equation.AddValue(GL_MIN_EXT);
780 validators_.equation.AddValue(GL_MAX_EXT); 778 validators_.equation.AddValue(GL_MAX_EXT);
781 } 779 }
782 780
781 // TODO(dshwang): GLES3 supports gl_FragDepth, not gl_FragDepthEXT.
783 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) { 782 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
784 AddExtensionString("GL_EXT_frag_depth"); 783 AddExtensionString("GL_EXT_frag_depth");
785 feature_flags_.ext_frag_depth = true; 784 feature_flags_.ext_frag_depth = true;
786 } 785 }
787 786
788 if (extensions.Contains("GL_EXT_shader_texture_lod") || 787 if (extensions.Contains("GL_EXT_shader_texture_lod") ||
789 gfx::HasDesktopGLFeatures()) { 788 gfx::HasDesktopGLFeatures()) {
790 AddExtensionString("GL_EXT_shader_texture_lod"); 789 AddExtensionString("GL_EXT_shader_texture_lod");
791 feature_flags_.ext_shader_texture_lod = true; 790 feature_flags_.ext_shader_texture_lod = true;
792 } 791 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 if (pos == std::string::npos) { 853 if (pos == std::string::npos) {
855 extensions_ += (extensions_.empty() ? "" : " ") + str; 854 extensions_ += (extensions_.empty() ? "" : " ") + str;
856 } 855 }
857 } 856 }
858 857
859 FeatureInfo::~FeatureInfo() { 858 FeatureInfo::~FeatureInfo() {
860 } 859 }
861 860
862 } // namespace gles2 861 } // namespace gles2
863 } // namespace gpu 862 } // 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