| 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 "ui/gl/gl_context_glx.h" | 5 #include "ui/gl/gl_context_glx.h" |
| 6 | 6 |
| 7 extern "C" { | 7 extern "C" { |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 } | 9 } |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "gpu/config/gpu_info_collector.h" |
| 15 #include "ui/gl/GL/glextchromium.h" | 16 #include "ui/gl/GL/glextchromium.h" |
| 16 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
| 17 #include "ui/gl/gl_implementation.h" | 18 #include "ui/gl/gl_implementation.h" |
| 18 #include "ui/gl/gl_surface_glx.h" | 19 #include "ui/gl/gl_surface_glx.h" |
| 19 | 20 |
| 20 namespace gl { | 21 namespace gl { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 static int IgnoreX11Errors(Display*, XErrorEvent*) { | 25 static int IgnoreX11Errors(Display*, XErrorEvent*) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 { 0, { GLVersion(1, 0) } }, | 118 { 0, { GLVersion(1, 0) } }, |
| 118 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(3, 2) } }, | 119 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(3, 2) } }, |
| 119 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(3, 1) } }, | 120 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(3, 1) } }, |
| 120 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(3, 0) } }, | 121 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(3, 0) } }, |
| 121 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(2, 0) } }, | 122 { GLX_CONTEXT_ES2_PROFILE_BIT_EXT, { GLVersion(2, 0) } }, |
| 122 }; | 123 }; |
| 123 // clang-format on | 124 // clang-format on |
| 124 | 125 |
| 125 std::string client_vendor = glXGetClientString(display, GLX_VENDOR); | 126 std::string client_vendor = glXGetClientString(display, GLX_VENDOR); |
| 126 bool is_mesa = client_vendor.find("Mesa") != std::string::npos; | 127 bool is_mesa = client_vendor.find("Mesa") != std::string::npos; |
| 128 bool is_mesa_optimus = false; |
| 127 | 129 |
| 128 const ContextCreationInfo* to_try = contexts_to_try; | 130 const ContextCreationInfo* to_try = contexts_to_try; |
| 129 size_t to_try_length = arraysize(contexts_to_try); | 131 size_t to_try_length = arraysize(contexts_to_try); |
| 130 if (is_mesa) { | 132 if (is_mesa) { |
| 131 to_try = mesa_contexts_to_try; | 133 to_try = mesa_contexts_to_try; |
| 132 to_try_length = arraysize(mesa_contexts_to_try); | 134 to_try_length = arraysize(mesa_contexts_to_try); |
| 135 |
| 136 gpu::GPUInfo gpu_info; |
| 137 gpu::CollectInfoResult result = gpu::CollectBasicGraphicsInfo(&gpu_info); |
| 138 |
| 139 is_mesa_optimus = result == gpu::kCollectInfoSucess && gpu_info.optimus; |
| 133 } | 140 } |
| 134 | 141 |
| 135 for (size_t i = 0; i < to_try_length; ++i) { | 142 for (size_t i = 0; i < to_try_length; ++i) { |
| 136 const ContextCreationInfo& info = to_try[i]; | 143 const ContextCreationInfo& info = to_try[i]; |
| 144 |
| 137 if (!GLSurfaceGLX::IsCreateContextES2ProfileSupported() && | 145 if (!GLSurfaceGLX::IsCreateContextES2ProfileSupported() && |
| 138 info.profileFlag == GLX_CONTEXT_ES2_PROFILE_BIT_EXT) { | 146 info.profileFlag == GLX_CONTEXT_ES2_PROFILE_BIT_EXT) { |
| 139 continue; | 147 continue; |
| 140 } | 148 } |
| 149 |
| 150 // Core profile on Mesa Optimus causes rendering problems |
| 151 // See https://crbug.com/659030 |
| 152 if (is_mesa_optimus && |
| 153 info.profileFlag == GLX_CONTEXT_CORE_PROFILE_BIT_ARB) { |
| 154 continue; |
| 155 } |
| 156 |
| 141 GLXContext context = CreateContextAttribs(display, config, share, | 157 GLXContext context = CreateContextAttribs(display, config, share, |
| 142 info.version, info.profileFlag); | 158 info.version, info.profileFlag); |
| 143 if (context != nullptr) { | 159 if (context != nullptr) { |
| 144 return context; | 160 return context; |
| 145 } | 161 } |
| 146 } | 162 } |
| 147 | 163 |
| 148 return nullptr; | 164 return nullptr; |
| 149 } | 165 } |
| 150 } | 166 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 328 |
| 313 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { | 329 bool GLContextGLX::WasAllocatedUsingRobustnessExtension() { |
| 314 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); | 330 return GLSurfaceGLX::IsCreateContextRobustnessSupported(); |
| 315 } | 331 } |
| 316 | 332 |
| 317 GLContextGLX::~GLContextGLX() { | 333 GLContextGLX::~GLContextGLX() { |
| 318 Destroy(); | 334 Destroy(); |
| 319 } | 335 } |
| 320 | 336 |
| 321 } // namespace gl | 337 } // namespace gl |
| OLD | NEW |