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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" |
10 #include "gpu/command_buffer/service/gl_utils.h" | 11 #include "gpu/command_buffer/service/gl_utils.h" |
11 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
12 #include "ui/gl/gl_implementation.h" | 13 #include "ui/gl/gl_implementation.h" |
13 #if defined(OS_MACOSX) | 14 #if defined(OS_MACOSX) |
14 #include "ui/surface/io_surface_support_mac.h" | 15 #include "ui/surface/io_surface_support_mac.h" |
15 #endif | 16 #endif |
16 | 17 |
17 namespace gpu { | 18 namespace gpu { |
18 namespace gles2 { | 19 namespace gles2 { |
19 | 20 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 102 |
102 void FeatureInfo::AddFeatures(const char* desired_features) { | 103 void FeatureInfo::AddFeatures(const char* desired_features) { |
103 // Figure out what extensions to turn on. | 104 // Figure out what extensions to turn on. |
104 ExtensionHelper ext( | 105 ExtensionHelper ext( |
105 // Some unittests execute without a context made current | 106 // Some unittests execute without a context made current |
106 // so fall back to glGetString | 107 // so fall back to glGetString |
107 gfx::GLContext::GetCurrent() ? | 108 gfx::GLContext::GetCurrent() ? |
108 gfx::GLContext::GetCurrent()->GetExtensions().c_str() : | 109 gfx::GLContext::GetCurrent()->GetExtensions().c_str() : |
109 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), | 110 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)), |
110 desired_features); | 111 desired_features); |
| 112 const char* vendor_str = reinterpret_cast<const char*>( |
| 113 glGetString(GL_VENDOR)); |
| 114 if (vendor_str) { |
| 115 std::string str(StringToLowerASCII(std::string(vendor_str))); |
| 116 feature_flags_.is_intel = str.find("intel") != std::string::npos; |
| 117 feature_flags_.is_nvidia = str.find("nvidia") != std::string::npos; |
| 118 feature_flags_.is_amd = |
| 119 str.find("amd") != std::string::npos || |
| 120 str.find("ati") != std::string::npos; |
| 121 } |
111 | 122 |
112 bool npot_ok = false; | 123 bool npot_ok = false; |
113 | 124 |
114 AddExtensionString("GL_CHROMIUM_resource_safe"); | 125 AddExtensionString("GL_CHROMIUM_resource_safe"); |
115 AddExtensionString("GL_CHROMIUM_resize"); | 126 AddExtensionString("GL_CHROMIUM_resize"); |
116 AddExtensionString("GL_CHROMIUM_strict_attribs"); | 127 AddExtensionString("GL_CHROMIUM_strict_attribs"); |
117 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); | 128 AddExtensionString("GL_CHROMIUM_rate_limit_offscreen_context"); |
118 AddExtensionString("GL_CHROMIUM_set_visibility"); | 129 AddExtensionString("GL_CHROMIUM_set_visibility"); |
119 AddExtensionString("GL_CHROMIUM_gpu_memory_manager"); | 130 AddExtensionString("GL_CHROMIUM_gpu_memory_manager"); |
120 AddExtensionString("GL_CHROMIUM_discard_framebuffer"); | 131 AddExtensionString("GL_CHROMIUM_discard_framebuffer"); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 GL_LUMINANCE16F_EXT); | 450 GL_LUMINANCE16F_EXT); |
440 validators_.texture_internal_format_storage.AddValue( | 451 validators_.texture_internal_format_storage.AddValue( |
441 GL_LUMINANCE_ALPHA16F_EXT); | 452 GL_LUMINANCE_ALPHA16F_EXT); |
442 } | 453 } |
443 } | 454 } |
444 | 455 |
445 bool have_ext_occlusion_query_boolean = | 456 bool have_ext_occlusion_query_boolean = |
446 ext.Have("GL_EXT_occlusion_query_boolean"); | 457 ext.Have("GL_EXT_occlusion_query_boolean"); |
447 bool have_arb_occlusion_query2 = ext.Have("GL_ARB_occlusion_query2"); | 458 bool have_arb_occlusion_query2 = ext.Have("GL_ARB_occlusion_query2"); |
448 bool have_arb_occlusion_query = ext.Have("GL_ARB_occlusion_query"); | 459 bool have_arb_occlusion_query = ext.Have("GL_ARB_occlusion_query"); |
449 if (ext.Desire("GL_EXT_occlusion_query_boolean") && | 460 bool ext_occlusion_query_disallowed = false; |
| 461 |
| 462 #if defined(OS_LINUX) |
| 463 // Intel drivers on Linux appear to be buggy. |
| 464 ext_occlusion_query_disallowed = feature_flags_.is_intel; |
| 465 #endif |
| 466 |
| 467 if (!ext_occlusion_query_disallowed && |
| 468 ext.Desire("GL_EXT_occlusion_query_boolean") && |
450 (have_ext_occlusion_query_boolean || | 469 (have_ext_occlusion_query_boolean || |
451 have_arb_occlusion_query2 || | 470 have_arb_occlusion_query2 || |
452 have_arb_occlusion_query)) { | 471 have_arb_occlusion_query)) { |
453 AddExtensionString("GL_EXT_occlusion_query_boolean"); | 472 AddExtensionString("GL_EXT_occlusion_query_boolean"); |
454 feature_flags_.occlusion_query_boolean = true; | 473 feature_flags_.occlusion_query_boolean = true; |
455 feature_flags_.use_arb_occlusion_query2_for_occlusion_query_boolean = | 474 feature_flags_.use_arb_occlusion_query2_for_occlusion_query_boolean = |
456 !have_ext_occlusion_query_boolean && have_arb_occlusion_query2; | 475 !have_ext_occlusion_query_boolean && have_arb_occlusion_query2; |
457 feature_flags_.use_arb_occlusion_query_for_occlusion_query_boolean = | 476 feature_flags_.use_arb_occlusion_query_for_occlusion_query_boolean = |
458 !have_ext_occlusion_query_boolean && have_arb_occlusion_query && | 477 !have_ext_occlusion_query_boolean && have_arb_occlusion_query && |
459 !have_arb_occlusion_query2; | 478 !have_arb_occlusion_query2; |
(...skipping 13 matching lines...) Expand all Loading... |
473 } | 492 } |
474 | 493 |
475 void FeatureInfo::AddExtensionString(const std::string& str) { | 494 void FeatureInfo::AddExtensionString(const std::string& str) { |
476 if (extensions_.find(str) == std::string::npos) { | 495 if (extensions_.find(str) == std::string::npos) { |
477 extensions_ += (extensions_.empty() ? "" : " ") + str; | 496 extensions_ += (extensions_.empty() ? "" : " ") + str; |
478 } | 497 } |
479 } | 498 } |
480 | 499 |
481 } // namespace gles2 | 500 } // namespace gles2 |
482 } // namespace gpu | 501 } // namespace gpu |
OLD | NEW |