| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/browser/gpu/gpu_data_manager_impl_private.h" | 13 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
| 14 #include "content/browser/gpu/gpu_data_manager_testing_autogen.h" |
| 15 #include "content/browser/gpu/gpu_data_manager_testing_entry_enums_autogen.h" |
| 14 #include "content/public/browser/gpu_data_manager_observer.h" | 16 #include "content/public/browser/gpu_data_manager_observer.h" |
| 15 #include "gpu/config/gpu_feature_type.h" | 17 #include "gpu/config/gpu_feature_type.h" |
| 16 #include "gpu/config/gpu_info.h" | 18 #include "gpu/config/gpu_info.h" |
| 17 #include "gpu/config/gpu_switches.h" | 19 #include "gpu/config/gpu_switches.h" |
| 18 #include "gpu/ipc/common/memory_stats.h" | 20 #include "gpu/ipc/common/memory_stats.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 21 | 23 |
| 22 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 23 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // If a feature is allowed in preliminary step (browser side), but | 145 // If a feature is allowed in preliminary step (browser side), but |
| 144 // disabled when GPU process launches and collects full GPU info, | 146 // disabled when GPU process launches and collects full GPU info, |
| 145 // it's too late to let renderer know, so we basically block all GPU | 147 // it's too late to let renderer know, so we basically block all GPU |
| 146 // access, to be on the safe side. | 148 // access, to be on the safe side. |
| 147 ScopedGpuDataManagerImplPrivate manager; | 149 ScopedGpuDataManagerImplPrivate manager; |
| 148 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 150 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 149 std::string reason; | 151 std::string reason; |
| 150 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 152 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 151 EXPECT_TRUE(reason.empty()); | 153 EXPECT_TRUE(reason.empty()); |
| 152 | 154 |
| 153 const std::string blacklist_json = LONG_STRING_CONST( | 155 const gpu::GpuControlList::Entry kEntries[] = { |
| 154 { | 156 gpu::kGpuDataManagerTestingEntries[ |
| 155 "name": "gpu blacklist", | 157 gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklisting_0], |
| 156 "version": "0.1", | 158 gpu::kGpuDataManagerTestingEntries[ |
| 157 "entries": [ | 159 gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklisting_1], |
| 158 { | 160 }; |
| 159 "id": 1, | 161 const gpu::GpuControlListData kData("1.0", 2, kEntries); |
| 160 "features": [ | |
| 161 "accelerated_webgl" | |
| 162 ] | |
| 163 }, | |
| 164 { | |
| 165 "id": 2, | |
| 166 "gl_renderer": ".*GeForce.*", | |
| 167 "features": [ | |
| 168 "accelerated_2d_canvas" | |
| 169 ] | |
| 170 } | |
| 171 ] | |
| 172 } | |
| 173 ); | |
| 174 | 162 |
| 175 gpu::GPUInfo gpu_info; | 163 gpu::GPUInfo gpu_info; |
| 176 gpu_info.gpu.vendor_id = 0x10de; | 164 gpu_info.gpu.vendor_id = 0x10de; |
| 177 gpu_info.gpu.device_id = 0x0640; | 165 gpu_info.gpu.device_id = 0x0640; |
| 178 manager->InitializeForTesting(blacklist_json, gpu_info); | 166 manager->InitializeForTesting(kData, gpu_info); |
| 179 | 167 |
| 180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 168 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 181 EXPECT_TRUE(reason.empty()); | 169 EXPECT_TRUE(reason.empty()); |
| 182 if (manager->ShouldUseSwiftShader()) { | 170 if (manager->ShouldUseSwiftShader()) { |
| 183 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 171 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 184 manager->GetBlacklistedFeatureCount()); | 172 manager->GetBlacklistedFeatureCount()); |
| 185 } else { | 173 } else { |
| 186 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 174 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 187 } | 175 } |
| 188 EXPECT_TRUE( | 176 EXPECT_TRUE( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 213 // If a feature is allowed in preliminary step (browser side), but | 201 // If a feature is allowed in preliminary step (browser side), but |
| 214 // disabled when GPU process launches and collects full GPU info, | 202 // disabled when GPU process launches and collects full GPU info, |
| 215 // it's too late to let renderer know, so we basically block all GPU | 203 // it's too late to let renderer know, so we basically block all GPU |
| 216 // access, to be on the safe side. | 204 // access, to be on the safe side. |
| 217 ScopedGpuDataManagerImplPrivate manager; | 205 ScopedGpuDataManagerImplPrivate manager; |
| 218 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 206 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 219 std::string reason; | 207 std::string reason; |
| 220 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 208 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 221 EXPECT_TRUE(reason.empty()); | 209 EXPECT_TRUE(reason.empty()); |
| 222 | 210 |
| 223 const std::string blacklist_json = LONG_STRING_CONST( | 211 const gpu::GpuControlList::Entry kEntries[] = { |
| 224 { | 212 gpu::kGpuDataManagerTestingEntries[ |
| 225 "name": "gpu blacklist", | 213 gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklistingWebGL_0], |
| 226 "version": "0.1", | 214 gpu::kGpuDataManagerTestingEntries[ |
| 227 "entries": [ | 215 gpu::kGpuDataManagerImplPrivateTest_GpuSideBlacklistingWebGL_1], |
| 228 { | 216 }; |
| 229 "id": 1, | 217 const gpu::GpuControlListData kData("1.0", 2, kEntries); |
| 230 "features": [ | |
| 231 "accelerated_2d_canvas" | |
| 232 ] | |
| 233 }, | |
| 234 { | |
| 235 "id": 2, | |
| 236 "gl_renderer": ".*GeForce.*", | |
| 237 "features": [ | |
| 238 "accelerated_webgl", | |
| 239 "webgl2" | |
| 240 ] | |
| 241 } | |
| 242 ] | |
| 243 } | |
| 244 ); | |
| 245 | 218 |
| 246 gpu::GPUInfo gpu_info; | 219 gpu::GPUInfo gpu_info; |
| 247 gpu_info.gpu.vendor_id = 0x10de; | 220 gpu_info.gpu.vendor_id = 0x10de; |
| 248 gpu_info.gpu.device_id = 0x0640; | 221 gpu_info.gpu.device_id = 0x0640; |
| 249 manager->InitializeForTesting(blacklist_json, gpu_info); | 222 manager->InitializeForTesting(kData, gpu_info); |
| 250 | 223 |
| 251 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 224 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 252 EXPECT_TRUE(reason.empty()); | 225 EXPECT_TRUE(reason.empty()); |
| 253 if (manager->ShouldUseSwiftShader()) { | 226 if (manager->ShouldUseSwiftShader()) { |
| 254 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 227 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 255 manager->GetBlacklistedFeatureCount()); | 228 manager->GetBlacklistedFeatureCount()); |
| 256 } else { | 229 } else { |
| 257 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 230 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 258 } | 231 } |
| 259 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 232 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 275 EXPECT_TRUE( | 248 EXPECT_TRUE( |
| 276 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 249 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 277 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); | 250 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
| 278 } | 251 } |
| 279 | 252 |
| 280 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { | 253 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { |
| 281 ScopedGpuDataManagerImplPrivate manager; | 254 ScopedGpuDataManagerImplPrivate manager; |
| 282 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 255 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 283 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 256 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 284 | 257 |
| 285 const std::string blacklist_json = LONG_STRING_CONST( | 258 const gpu::GpuControlList::Entry kEntries[] = { |
| 286 { | 259 gpu::kGpuDataManagerTestingEntries[ |
| 287 "name": "gpu blacklist", | 260 gpu::kGpuDataManagerImplPrivateTest_GpuSideException], |
| 288 "version": "0.1", | 261 }; |
| 289 "entries": [ | 262 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
| 290 { | 263 |
| 291 "id": 1, | |
| 292 "exceptions": [ | |
| 293 { | |
| 294 "gl_renderer": ".*GeForce.*" | |
| 295 } | |
| 296 ], | |
| 297 "features": [ | |
| 298 "accelerated_webgl" | |
| 299 ] | |
| 300 } | |
| 301 ] | |
| 302 } | |
| 303 ); | |
| 304 gpu::GPUInfo gpu_info; | 264 gpu::GPUInfo gpu_info; |
| 305 gpu_info.gpu.vendor_id = 0x10de; | 265 gpu_info.gpu.vendor_id = 0x10de; |
| 306 gpu_info.gpu.device_id = 0x0640; | 266 gpu_info.gpu.device_id = 0x0640; |
| 307 manager->InitializeForTesting(blacklist_json, gpu_info); | 267 manager->InitializeForTesting(kData, gpu_info); |
| 308 | 268 |
| 309 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 269 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 310 EXPECT_EQ(manager->ShouldUseSwiftShader() | 270 EXPECT_EQ(manager->ShouldUseSwiftShader() |
| 311 ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES) | 271 ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES) |
| 312 : 1u, | 272 : 1u, |
| 313 manager->GetBlacklistedFeatureCount()); | 273 manager->GetBlacklistedFeatureCount()); |
| 314 | 274 |
| 315 // Now assume gpu process launches and full GPU info is collected. | 275 // Now assume gpu process launches and full GPU info is collected. |
| 316 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 276 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
| 317 manager->UpdateGpuInfo(gpu_info); | 277 manager->UpdateGpuInfo(gpu_info); |
| 318 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 278 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 319 // Since SwiftShader was enabled by first gpu_info, UpdateGpuInfo | 279 // Since SwiftShader was enabled by first gpu_info, UpdateGpuInfo |
| 320 // should have failed and SwiftShader should still be active | 280 // should have failed and SwiftShader should still be active |
| 321 EXPECT_EQ(manager->ShouldUseSwiftShader() | 281 EXPECT_EQ(manager->ShouldUseSwiftShader() |
| 322 ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES) | 282 ? static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES) |
| 323 : 0u, | 283 : 0u, |
| 324 manager->GetBlacklistedFeatureCount()); | 284 manager->GetBlacklistedFeatureCount()); |
| 325 } | 285 } |
| 326 | 286 |
| 327 TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { | 287 TEST_F(GpuDataManagerImplPrivateTest, DisableHardwareAcceleration) { |
| 328 ScopedGpuDataManagerImplPrivate manager; | 288 ScopedGpuDataManagerImplPrivate manager; |
| 329 manager->InitializeForTesting("", gpu::GPUInfo()); | 289 const gpu::GpuControlListData kData; |
| 290 manager->InitializeForTesting(kData, gpu::GPUInfo()); |
| 330 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 291 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 331 std::string reason; | 292 std::string reason; |
| 332 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 293 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 333 EXPECT_TRUE(reason.empty()); | 294 EXPECT_TRUE(reason.empty()); |
| 334 | 295 |
| 335 manager->DisableHardwareAcceleration(); | 296 manager->DisableHardwareAcceleration(); |
| 336 if (manager->ShouldUseSwiftShader()) { | 297 if (manager->ShouldUseSwiftShader()) { |
| 337 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 298 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 338 EXPECT_TRUE(reason.empty()); | 299 EXPECT_TRUE(reason.empty()); |
| 339 } else { | 300 } else { |
| 340 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); | 301 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
| 341 EXPECT_FALSE(reason.empty()); | 302 EXPECT_FALSE(reason.empty()); |
| 342 } | 303 } |
| 343 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 304 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 344 manager->GetBlacklistedFeatureCount()); | 305 manager->GetBlacklistedFeatureCount()); |
| 345 } | 306 } |
| 346 | 307 |
| 347 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) { | 308 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering) { |
| 348 // Blacklist, then register SwiftShader. | 309 // Blacklist, then register SwiftShader. |
| 349 ScopedGpuDataManagerImplPrivate manager; | 310 ScopedGpuDataManagerImplPrivate manager; |
| 350 manager->InitializeForTesting("", gpu::GPUInfo()); | 311 const gpu::GpuControlListData kData; |
| 312 manager->InitializeForTesting(kData, gpu::GPUInfo()); |
| 351 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 313 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 352 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 314 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 353 EXPECT_FALSE(manager->ShouldUseSwiftShader()); | 315 EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
| 354 | 316 |
| 355 manager->DisableHardwareAcceleration(); | 317 manager->DisableHardwareAcceleration(); |
| 356 EXPECT_EQ(manager->ShouldUseSwiftShader(), manager->GpuAccessAllowed(NULL)); | 318 EXPECT_EQ(manager->ShouldUseSwiftShader(), manager->GpuAccessAllowed(NULL)); |
| 357 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 319 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 358 manager->GetBlacklistedFeatureCount()); | 320 manager->GetBlacklistedFeatureCount()); |
| 359 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 321 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 360 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 322 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 361 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); | 323 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
| 362 } | 324 } |
| 363 | 325 |
| 364 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { | 326 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { |
| 365 // Register SwiftShader, then blacklist. | 327 // Register SwiftShader, then blacklist. |
| 366 ScopedGpuDataManagerImplPrivate manager; | 328 ScopedGpuDataManagerImplPrivate manager; |
| 367 manager->InitializeForTesting("", gpu::GPUInfo()); | 329 const gpu::GpuControlListData kData; |
| 330 manager->InitializeForTesting(kData, gpu::GPUInfo()); |
| 368 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 331 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 369 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 332 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 370 EXPECT_FALSE(manager->ShouldUseSwiftShader()); | 333 EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
| 371 | 334 |
| 372 manager->DisableHardwareAcceleration(); | 335 manager->DisableHardwareAcceleration(); |
| 373 if (manager->ShouldUseSwiftShader()) { | 336 if (manager->ShouldUseSwiftShader()) { |
| 374 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 337 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 375 } else { | 338 } else { |
| 376 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); | 339 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
| 377 } | 340 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 398 manager->UpdateGpuInfo(gpu_info); | 361 manager->UpdateGpuInfo(gpu_info); |
| 399 { | 362 { |
| 400 base::RunLoop run_loop; | 363 base::RunLoop run_loop; |
| 401 run_loop.RunUntilIdle(); | 364 run_loop.RunUntilIdle(); |
| 402 } | 365 } |
| 403 EXPECT_TRUE(observer.gpu_info_updated()); | 366 EXPECT_TRUE(observer.gpu_info_updated()); |
| 404 } | 367 } |
| 405 | 368 |
| 406 TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) { | 369 TEST_F(GpuDataManagerImplPrivateTest, NoGpuInfoUpdateWithSwiftShader) { |
| 407 ScopedGpuDataManagerImpl manager; | 370 ScopedGpuDataManagerImpl manager; |
| 408 manager->InitializeForTesting("", gpu::GPUInfo()); | 371 const gpu::GpuControlListData kData; |
| 372 manager->InitializeForTesting(kData, gpu::GPUInfo()); |
| 409 | 373 |
| 410 manager->DisableHardwareAcceleration(); | 374 manager->DisableHardwareAcceleration(); |
| 411 if (manager->ShouldUseSwiftShader()) { | 375 if (manager->ShouldUseSwiftShader()) { |
| 412 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 376 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 413 } else { | 377 } else { |
| 414 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); | 378 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
| 415 } | 379 } |
| 416 | 380 |
| 417 { | 381 { |
| 418 base::RunLoop run_loop; | 382 base::RunLoop run_loop; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 #if defined(OS_LINUX) | 551 #if defined(OS_LINUX) |
| 588 TEST_F(GpuDataManagerImplPrivateTest, SetGLStrings) { | 552 TEST_F(GpuDataManagerImplPrivateTest, SetGLStrings) { |
| 589 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 553 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
| 590 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 554 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
| 591 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 555 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
| 592 | 556 |
| 593 ScopedGpuDataManagerImplPrivate manager; | 557 ScopedGpuDataManagerImplPrivate manager; |
| 594 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 558 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 595 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 559 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 596 | 560 |
| 597 const std::string blacklist_json = LONG_STRING_CONST( | 561 const gpu::GpuControlList::Entry kEntries[] = { |
| 598 { | 562 gpu::kGpuDataManagerTestingEntries[ |
| 599 "name": "gpu blacklist", | 563 gpu::kGpuDataManagerImplPrivateTest_SetGLStrings], |
| 600 "version": "0.1", | 564 }; |
| 601 "entries": [ | 565 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
| 602 { | 566 |
| 603 "id": 1, | |
| 604 "vendor_id": "0x8086", | |
| 605 "exceptions": [ | |
| 606 { | |
| 607 "device_id": ["0x0042"], | |
| 608 "driver_version": { | |
| 609 "op": ">=", | |
| 610 "value": "8.0.2" | |
| 611 } | |
| 612 } | |
| 613 ], | |
| 614 "features": [ | |
| 615 "accelerated_webgl" | |
| 616 ] | |
| 617 } | |
| 618 ] | |
| 619 } | |
| 620 ); | |
| 621 gpu::GPUInfo gpu_info; | 567 gpu::GPUInfo gpu_info; |
| 622 gpu_info.gpu.vendor_id = 0x8086; | 568 gpu_info.gpu.vendor_id = 0x8086; |
| 623 gpu_info.gpu.device_id = 0x0042; | 569 gpu_info.gpu.device_id = 0x0042; |
| 624 manager->InitializeForTesting(blacklist_json, gpu_info); | 570 manager->InitializeForTesting(kData, gpu_info); |
| 625 | 571 |
| 626 // Not enough GPUInfo. | 572 // Not enough GPUInfo. |
| 627 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 573 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 628 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 574 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 629 | 575 |
| 630 // Now assume browser gets GL strings from local state. | 576 // Now assume browser gets GL strings from local state. |
| 631 // The entry applies, blacklist more features than from the preliminary step. | 577 // The entry applies, blacklist more features than from the preliminary step. |
| 632 // However, GPU process is not blocked because this is all browser side and | 578 // However, GPU process is not blocked because this is all browser side and |
| 633 // happens before renderer launching. | 579 // happens before renderer launching. |
| 634 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 580 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
| 635 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 581 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 636 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 582 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 637 EXPECT_TRUE( | 583 EXPECT_TRUE( |
| 638 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 584 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 639 } | 585 } |
| 640 | 586 |
| 641 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { | 587 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { |
| 642 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 588 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
| 643 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 589 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
| 644 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 590 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
| 645 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; | 591 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; |
| 646 | 592 |
| 647 ScopedGpuDataManagerImplPrivate manager; | 593 ScopedGpuDataManagerImplPrivate manager; |
| 648 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 594 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 649 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 595 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 650 | 596 |
| 651 const std::string blacklist_json = LONG_STRING_CONST( | 597 const gpu::GpuControlList::Entry kEntries[] = { |
| 652 { | 598 gpu::kGpuDataManagerTestingEntries[ |
| 653 "name": "gpu blacklist", | 599 gpu::kGpuDataManagerImplPrivateTest_SetGLStringsNoEffects], |
| 654 "version": "0.1", | 600 }; |
| 655 "entries": [ | 601 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
| 656 { | 602 |
| 657 "id": 1, | |
| 658 "vendor_id": "0x8086", | |
| 659 "exceptions": [ | |
| 660 { | |
| 661 "device_id": ["0x0042"], | |
| 662 "driver_version": { | |
| 663 "op": ">=", | |
| 664 "value": "8.0.2" | |
| 665 } | |
| 666 } | |
| 667 ], | |
| 668 "features": [ | |
| 669 "accelerated_webgl" | |
| 670 ] | |
| 671 } | |
| 672 ] | |
| 673 } | |
| 674 ); | |
| 675 gpu::GPUInfo gpu_info; | 603 gpu::GPUInfo gpu_info; |
| 676 gpu_info.gpu.vendor_id = 0x8086; | 604 gpu_info.gpu.vendor_id = 0x8086; |
| 677 gpu_info.gpu.device_id = 0x0042; | 605 gpu_info.gpu.device_id = 0x0042; |
| 678 gpu_info.gl_vendor = kGLVendorMesa; | 606 gpu_info.gl_vendor = kGLVendorMesa; |
| 679 gpu_info.gl_renderer = kGLRendererMesa; | 607 gpu_info.gl_renderer = kGLRendererMesa; |
| 680 gpu_info.gl_version = kGLVersionMesa801; | 608 gpu_info.gl_version = kGLVersionMesa801; |
| 681 gpu_info.driver_vendor = "Mesa"; | 609 gpu_info.driver_vendor = "Mesa"; |
| 682 gpu_info.driver_version = "8.0.1"; | 610 gpu_info.driver_version = "8.0.1"; |
| 683 manager->InitializeForTesting(blacklist_json, gpu_info); | 611 manager->InitializeForTesting(kData, gpu_info); |
| 684 | 612 |
| 685 // Full GPUInfo, the entry applies. | 613 // Full GPUInfo, the entry applies. |
| 686 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 614 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 687 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 615 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 688 EXPECT_TRUE( | 616 EXPECT_TRUE( |
| 689 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 617 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 690 | 618 |
| 691 // Now assume browser gets GL strings from local state. | 619 // Now assume browser gets GL strings from local state. |
| 692 // SetGLStrings() has no effects because GPUInfo already got these strings. | 620 // SetGLStrings() has no effects because GPUInfo already got these strings. |
| 693 // (Otherwise the entry should not apply.) | 621 // (Otherwise the entry should not apply.) |
| 694 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); | 622 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); |
| 695 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 623 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 696 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 624 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 697 EXPECT_TRUE( | 625 EXPECT_TRUE( |
| 698 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 626 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 699 } | 627 } |
| 700 | 628 |
| 701 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { | 629 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { |
| 702 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 630 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
| 703 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 631 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
| 704 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 632 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
| 705 | 633 |
| 706 ScopedGpuDataManagerImplPrivate manager; | 634 ScopedGpuDataManagerImplPrivate manager; |
| 707 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 635 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 708 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 636 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 709 | 637 |
| 710 const std::string blacklist_json = LONG_STRING_CONST({ | 638 const gpu::GpuControlList::Entry kEntries[] = { |
| 711 "name" : "gpu blacklist", | 639 gpu::kGpuDataManagerTestingEntries[ |
| 712 "version" : "0.1", | 640 gpu::kGpuDataManagerImplPrivateTest_SetGLStringsDefered], |
| 713 "entries" : [ { | 641 }; |
| 714 "id" : 1, | 642 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
| 715 "vendor_id" : "0x8086", | |
| 716 "device_id" : ["0x0042"], | |
| 717 "driver_vendor" : "Mesa", | |
| 718 "driver_version" : {"op" : ">=", "value" : "8.0.0"}, | |
| 719 "features" : ["accelerated_webgl"] | |
| 720 } ] | |
| 721 }); | |
| 722 | 643 |
| 723 // Check that it is allowed to call SetGLStrings before Initialize. | 644 // Check that it is allowed to call SetGLStrings before Initialize. |
| 724 | 645 |
| 725 // Assume browser gets GL strings from local state. | 646 // Assume browser gets GL strings from local state. |
| 726 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 647 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
| 727 | 648 |
| 728 gpu::GPUInfo gpu_info; | 649 gpu::GPUInfo gpu_info; |
| 729 gpu_info.gpu.vendor_id = 0x8086; | 650 gpu_info.gpu.vendor_id = 0x8086; |
| 730 gpu_info.gpu.device_id = 0x0042; | 651 gpu_info.gpu.device_id = 0x0042; |
| 731 manager->InitializeForTesting(blacklist_json, gpu_info); | 652 manager->InitializeForTesting(kData, gpu_info); |
| 732 | 653 |
| 733 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 654 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 734 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 655 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 735 EXPECT_TRUE( | 656 EXPECT_TRUE( |
| 736 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); | 657 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 737 } | 658 } |
| 738 #endif // OS_LINUX | 659 #endif // OS_LINUX |
| 739 | 660 |
| 740 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { | 661 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { |
| 741 ScopedGpuDataManagerImplPrivate manager; | 662 ScopedGpuDataManagerImplPrivate manager; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 764 EXPECT_STREQ("5,7", args.c_str()); | 685 EXPECT_STREQ("5,7", args.c_str()); |
| 765 } | 686 } |
| 766 | 687 |
| 767 TEST_F(GpuDataManagerImplPrivateTest, BlacklistAllFeatures) { | 688 TEST_F(GpuDataManagerImplPrivateTest, BlacklistAllFeatures) { |
| 768 ScopedGpuDataManagerImplPrivate manager; | 689 ScopedGpuDataManagerImplPrivate manager; |
| 769 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 690 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 770 std::string reason; | 691 std::string reason; |
| 771 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 692 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 772 EXPECT_TRUE(reason.empty()); | 693 EXPECT_TRUE(reason.empty()); |
| 773 | 694 |
| 774 const std::string blacklist_json = LONG_STRING_CONST( | 695 const gpu::GpuControlList::Entry kEntries[] = { |
| 775 { | 696 gpu::kGpuDataManagerTestingEntries[ |
| 776 "name": "gpu blacklist", | 697 gpu::kGpuDataManagerImplPrivateTest_BlacklistAllFeatures], |
| 777 "version": "0.1", | 698 }; |
| 778 "entries": [ | 699 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
| 779 { | |
| 780 "id": 1, | |
| 781 "features": [ | |
| 782 "all" | |
| 783 ] | |
| 784 } | |
| 785 ] | |
| 786 } | |
| 787 ); | |
| 788 | 700 |
| 789 gpu::GPUInfo gpu_info; | 701 gpu::GPUInfo gpu_info; |
| 790 gpu_info.gpu.vendor_id = 0x10de; | 702 gpu_info.gpu.vendor_id = 0x10de; |
| 791 gpu_info.gpu.device_id = 0x0640; | 703 gpu_info.gpu.device_id = 0x0640; |
| 792 manager->InitializeForTesting(blacklist_json, gpu_info); | 704 manager->InitializeForTesting(kData, gpu_info); |
| 793 | 705 |
| 794 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 706 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 795 manager->GetBlacklistedFeatureCount()); | 707 manager->GetBlacklistedFeatureCount()); |
| 796 if (manager->ShouldUseSwiftShader()) { | 708 if (manager->ShouldUseSwiftShader()) { |
| 797 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 709 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 798 EXPECT_TRUE(reason.empty()); | 710 EXPECT_TRUE(reason.empty()); |
| 799 } | 711 } |
| 800 } | 712 } |
| 801 | 713 |
| 802 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { | 714 TEST_F(GpuDataManagerImplPrivateTest, UpdateActiveGpu) { |
| 803 ScopedGpuDataManagerImpl manager; | 715 ScopedGpuDataManagerImpl manager; |
| 804 | 716 |
| 805 const std::string blacklist_json = LONG_STRING_CONST( | 717 const gpu::GpuControlList::Entry kEntries[] = { |
| 806 { | 718 gpu::kGpuDataManagerTestingEntries[ |
| 807 "name": "gpu blacklist", | 719 gpu::kGpuDataManagerImplPrivateTest_UpdateActiveGpu], |
| 808 "version": "0.1", | 720 }; |
| 809 "entries": [ | 721 const gpu::GpuControlListData kData("1.0", 1, kEntries); |
| 810 { | |
| 811 "id": 1, | |
| 812 "vendor_id": "0x8086", | |
| 813 "multi_gpu_category": "active", | |
| 814 "features": [ | |
| 815 "accelerated_webgl" | |
| 816 ] | |
| 817 } | |
| 818 ] | |
| 819 } | |
| 820 ); | |
| 821 | 722 |
| 822 // Two GPUs, the secondary Intel GPU is active. | 723 // Two GPUs, the secondary Intel GPU is active. |
| 823 gpu::GPUInfo gpu_info; | 724 gpu::GPUInfo gpu_info; |
| 824 gpu_info.gpu.vendor_id = 0x10de; | 725 gpu_info.gpu.vendor_id = 0x10de; |
| 825 gpu_info.gpu.device_id = 0x0640; | 726 gpu_info.gpu.device_id = 0x0640; |
| 826 gpu_info.gpu.active = false; | 727 gpu_info.gpu.active = false; |
| 827 gpu::GPUInfo::GPUDevice intel_gpu; | 728 gpu::GPUInfo::GPUDevice intel_gpu; |
| 828 intel_gpu.vendor_id = 0x8086; | 729 intel_gpu.vendor_id = 0x8086; |
| 829 intel_gpu.device_id = 0x04a1; | 730 intel_gpu.device_id = 0x04a1; |
| 830 intel_gpu.active = true; | 731 intel_gpu.active = true; |
| 831 gpu_info.secondary_gpus.push_back(intel_gpu); | 732 gpu_info.secondary_gpus.push_back(intel_gpu); |
| 832 | 733 |
| 833 manager->InitializeForTesting(blacklist_json, gpu_info); | 734 manager->InitializeForTesting(kData, gpu_info); |
| 834 TestObserver observer; | 735 TestObserver observer; |
| 835 manager->AddObserver(&observer); | 736 manager->AddObserver(&observer); |
| 836 | 737 |
| 837 if (manager->ShouldUseSwiftShader()) { | 738 if (manager->ShouldUseSwiftShader()) { |
| 838 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 739 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 839 manager->GetBlacklistedFeatureCount()); | 740 manager->GetBlacklistedFeatureCount()); |
| 840 } else { | 741 } else { |
| 841 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 742 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 842 } | 743 } |
| 843 | 744 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 EXPECT_TRUE(observer.gpu_info_updated()); | 796 EXPECT_TRUE(observer.gpu_info_updated()); |
| 896 if (manager->ShouldUseSwiftShader()) { | 797 if (manager->ShouldUseSwiftShader()) { |
| 897 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), | 798 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 898 manager->GetBlacklistedFeatureCount()); | 799 manager->GetBlacklistedFeatureCount()); |
| 899 } else { | 800 } else { |
| 900 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 801 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 901 } | 802 } |
| 902 } | 803 } |
| 903 | 804 |
| 904 } // namespace content | 805 } // namespace content |
| OLD | NEW |