diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-05 23:51:24 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-05 23:51:24 +0000 |
commit | 40c19e72cdfe22f7be1ec9b6c8fd9951330a6893 (patch) | |
tree | 2efcf6ee9cdb9caecd4dca0ce0ad1dfea74ced0d /gpu | |
parent | 0cd768ecf392756b92869d4c54a0b280677f0265 (diff) | |
download | chromium_src-40c19e72cdfe22f7be1ec9b6c8fd9951330a6893.zip chromium_src-40c19e72cdfe22f7be1ec9b6c8fd9951330a6893.tar.gz chromium_src-40c19e72cdfe22f7be1ec9b6c8fd9951330a6893.tar.bz2 |
Merge gpu_switching_list into gpu_driver_bug_list.
BUG=314901
TEST=gpu_unittests
R=bajones@chromium.org, kbr@chromium.org, piman@chromium.org, sievers@chromium.org
Review URL: https://codereview.chromium.org/57633007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/config/gpu_driver_bug_list_json.cc | 31 | ||||
-rw-r--r-- | gpu/config/gpu_driver_bug_list_unittest.cc | 51 | ||||
-rw-r--r-- | gpu/config/gpu_driver_bug_workaround_type.h | 4 | ||||
-rw-r--r-- | gpu/config/gpu_switching_list.cc | 29 | ||||
-rw-r--r-- | gpu/config/gpu_switching_list.h | 29 | ||||
-rw-r--r-- | gpu/config/gpu_switching_list_json.cc | 58 | ||||
-rw-r--r-- | gpu/config/gpu_switching_list_unittest.cc | 108 | ||||
-rw-r--r-- | gpu/config/gpu_switching_option.h | 22 | ||||
-rw-r--r-- | gpu/config/gpu_util.cc | 40 | ||||
-rw-r--r-- | gpu/config/gpu_util.h | 13 | ||||
-rw-r--r-- | gpu/config/gpu_util_unittest.cc | 49 | ||||
-rw-r--r-- | gpu/gpu.gyp | 1 | ||||
-rw-r--r-- | gpu/gpu_config.gypi | 4 |
13 files changed, 127 insertions, 312 deletions
diff --git a/gpu/config/gpu_driver_bug_list_json.cc b/gpu/config/gpu_driver_bug_list_json.cc index 49d34f1..44d482a 100644 --- a/gpu/config/gpu_driver_bug_list_json.cc +++ b/gpu/config/gpu_driver_bug_list_json.cc @@ -19,7 +19,7 @@ const char kGpuDriverBugListJson[] = LONG_STRING_CONST( { "name": "gpu driver bug list", // Please update the version number whenever you change this file. - "version": "2.26", + "version": "3.0", "entries": [ { "id": 1, @@ -634,6 +634,35 @@ const char kGpuDriverBugListJson[] = LONG_STRING_CONST( "features": [ "use_virtualized_gl_contexts" ] + }, + { + "id": 48, + "description": "Force to use discrete GPU on older MacBookPro models.", + "cr_bugs": [113703], + "os": { + "type": "macosx", + "version": { + "op": ">=", + "value": "10.7" + } + }, + "machine_model": { + "name": { + "op": "=", + "value": "MacBookPro" + }, + "version": { + "op": "<", + "value": "8" + } + }, + "gpu_count": { + "op": "=", + "value": "2" + }, + "features": [ + "force_discrete_gpu" + ] } ] } diff --git a/gpu/config/gpu_driver_bug_list_unittest.cc b/gpu/config/gpu_driver_bug_list_unittest.cc index 597e730..1a5590c 100644 --- a/gpu/config/gpu_driver_bug_list_unittest.cc +++ b/gpu/config/gpu_driver_bug_list_unittest.cc @@ -10,6 +10,8 @@ #include "gpu/config/gpu_info.h" #include "testing/gtest/include/gtest/gtest.h" +#define LONG_STRING_CONST(...) #__VA_ARGS__ + namespace gpu { class GpuDriverBugListTest : public testing::Test { @@ -74,5 +76,54 @@ TEST_F(GpuDriverBugListTest, CurrentListForImagination) { EXPECT_EQ(1u, bugs.count(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS)); } +TEST_F(GpuDriverBugListTest, GpuSwitching) { + const std::string json = LONG_STRING_CONST( + { + "name": "gpu driver bug list", + "version": "0.1", + "entries": [ + { + "id": 1, + "os": { + "type": "macosx" + }, + "features": [ + "force_discrete_gpu" + ] + }, + { + "id": 2, + "os": { + "type": "win" + }, + "features": [ + "force_integrated_gpu" + ] + } + ] + } + ); + scoped_ptr<GpuDriverBugList> driver_bug_list(GpuDriverBugList::Create()); + EXPECT_TRUE(driver_bug_list->LoadList(json, GpuControlList::kAllOs)); + std::set<int> switching = driver_bug_list->MakeDecision( + GpuControlList::kOsMacosx, "10.8", gpu_info()); + EXPECT_EQ(1u, switching.size()); + EXPECT_EQ(1u, switching.count(FORCE_DISCRETE_GPU)); + std::vector<uint32> entries; + driver_bug_list->GetDecisionEntries(&entries, false); + ASSERT_EQ(1u, entries.size()); + EXPECT_EQ(1u, entries[0]); + + driver_bug_list.reset(GpuDriverBugList::Create()); + EXPECT_TRUE(driver_bug_list->LoadList(json, GpuControlList::kAllOs)); + switching = driver_bug_list->MakeDecision( + GpuControlList::kOsWin, "6.1", gpu_info()); + EXPECT_EQ(1u, switching.size()); + EXPECT_EQ(1u, switching.count(FORCE_INTEGRATED_GPU)); + driver_bug_list->GetDecisionEntries(&entries, false); + ASSERT_EQ(1u, entries.size()); + EXPECT_EQ(2u, entries[0]); +} + } // namespace gpu diff --git a/gpu/config/gpu_driver_bug_workaround_type.h b/gpu/config/gpu_driver_bug_workaround_type.h index 66db5ff..98031ae 100644 --- a/gpu/config/gpu_driver_bug_workaround_type.h +++ b/gpu/config/gpu_driver_bug_workaround_type.h @@ -38,6 +38,10 @@ enable_chromium_fast_npot_mo8_textures) \ GPU_OP(EXIT_ON_CONTEXT_LOST, \ exit_on_context_lost) \ + GPU_OP(FORCE_DISCRETE_GPU, \ + force_discrete_gpu) \ + GPU_OP(FORCE_INTEGRATED_GPU, \ + force_integrated_gpu) \ GPU_OP(INIT_GL_POSITION_IN_VERTEX_SHADER, \ init_gl_position_in_vertex_shader) \ GPU_OP(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024, \ diff --git a/gpu/config/gpu_switching_list.cc b/gpu/config/gpu_switching_list.cc deleted file mode 100644 index b87dfb2..0000000 --- a/gpu/config/gpu_switching_list.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "gpu/config/gpu_switching_list.h" - -#include "gpu/config/gpu_switching_option.h" - -namespace gpu { - -GpuSwitchingList::GpuSwitchingList() - : GpuControlList() { -} - -GpuSwitchingList::~GpuSwitchingList() { -} - -// static -GpuSwitchingList* GpuSwitchingList::Create() { - GpuSwitchingList* list = new GpuSwitchingList(); - list->AddSupportedFeature("force_integrated", - GPU_SWITCHING_OPTION_FORCE_INTEGRATED); - list->AddSupportedFeature("force_discrete", - GPU_SWITCHING_OPTION_FORCE_DISCRETE); - return list; -} - -} // namespace gpu - diff --git a/gpu/config/gpu_switching_list.h b/gpu/config/gpu_switching_list.h deleted file mode 100644 index 095597a..0000000 --- a/gpu/config/gpu_switching_list.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef GPU_CONFIG_GPU_SWITCHING_LIST_H_ -#define GPU_CONFIG_GPU_SWITCHING_LIST_H_ - -#include <string> - -#include "gpu/config/gpu_control_list.h" - -namespace gpu { - -class GPU_EXPORT GpuSwitchingList : public GpuControlList { - public: - virtual ~GpuSwitchingList(); - - static GpuSwitchingList* Create(); - - private: - GpuSwitchingList(); - - DISALLOW_COPY_AND_ASSIGN(GpuSwitchingList); -}; - -} // namespace gpu - -#endif // GPU_CONFIG_GPU_SWITCHING_LIST_H_ - diff --git a/gpu/config/gpu_switching_list_json.cc b/gpu/config/gpu_switching_list_json.cc deleted file mode 100644 index 81a8d22..0000000 --- a/gpu/config/gpu_switching_list_json.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Determines whether a certain gpu is prefered in a dual-gpu situation. -// The format of a valid gpu_switching_list.json file is defined in -// <gpu/config/gpu_control_list_format.txt>. -// The supported "features" can be found in <gpu/config/gpu_switching_list.cc>. - -#include "gpu/config/gpu_control_list_jsons.h" - -#define LONG_STRING_CONST(...) #__VA_ARGS__ - -namespace gpu { - -const char kGpuSwitchingListJson[] = LONG_STRING_CONST( - -{ - "name": "gpu switching list", - // Please update the version number whenever you change this file. - "version": "2.0", - "entries": [ - { - "id": 1, - "description": "Force to use discrete GPU on older MacBookPro models.", - "cr_bugs": [113703], - "os": { - "type": "macosx", - "version": { - "op": ">=", - "value": "10.7" - } - }, - "machine_model": { - "name": { - "op": "=", - "value": "MacBookPro" - }, - "version": { - "op": "<", - "value": "8" - } - }, - "gpu_count": { - "op": "=", - "value": "2" - }, - "features": [ - "force_discrete" - ] - } - ] -} - -); // LONG_STRING_CONST macro - -} // namespace gpu - diff --git a/gpu/config/gpu_switching_list_unittest.cc b/gpu/config/gpu_switching_list_unittest.cc deleted file mode 100644 index 56d0f8f..0000000 --- a/gpu/config/gpu_switching_list_unittest.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <vector> - -#include "base/memory/scoped_ptr.h" -#include "gpu/config/gpu_control_list_jsons.h" -#include "gpu/config/gpu_info.h" -#include "gpu/config/gpu_switching_list.h" -#include "gpu/config/gpu_switching_option.h" -#include "testing/gtest/include/gtest/gtest.h" - -#define LONG_STRING_CONST(...) #__VA_ARGS__ - -const char kOsVersion[] = "10.6.4"; - -namespace gpu { - -class GpuSwitchingListTest : public testing::Test { - public: - GpuSwitchingListTest() { } - - virtual ~GpuSwitchingListTest() { } - - const GPUInfo& gpu_info() const { - return gpu_info_; - } - - protected: - virtual void SetUp() { - gpu_info_.gpu.vendor_id = 0x10de; - gpu_info_.gpu.device_id = 0x0640; - gpu_info_.driver_vendor = "NVIDIA"; - gpu_info_.driver_version = "1.6.18"; - gpu_info_.driver_date = "7-14-2009"; - gpu_info_.machine_model = "MacBookPro 7.1"; - gpu_info_.gl_vendor = "NVIDIA Corporation"; - gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine"; - gpu_info_.performance_stats.graphics = 5.0; - gpu_info_.performance_stats.gaming = 5.0; - gpu_info_.performance_stats.overall = 5.0; - } - - virtual void TearDown() { - } - - private: - GPUInfo gpu_info_; -}; - -TEST_F(GpuSwitchingListTest, CurrentSwitchingListValidation) { - scoped_ptr<GpuSwitchingList> switching_list(GpuSwitchingList::Create()); - EXPECT_TRUE(switching_list->LoadList( - kGpuSwitchingListJson, GpuControlList::kAllOs)); -} - -TEST_F(GpuSwitchingListTest, GpuSwitching) { - const std::string json = LONG_STRING_CONST( - { - "name": "gpu switching list", - "version": "0.1", - "entries": [ - { - "id": 1, - "os": { - "type": "macosx" - }, - "features": [ - "force_discrete" - ] - }, - { - "id": 2, - "os": { - "type": "win" - }, - "features": [ - "force_integrated" - ] - } - ] - } - ); - scoped_ptr<GpuSwitchingList> switching_list(GpuSwitchingList::Create()); - EXPECT_TRUE(switching_list->LoadList(json, GpuControlList::kAllOs)); - std::set<int> switching = switching_list->MakeDecision( - GpuControlList::kOsMacosx, kOsVersion, gpu_info()); - EXPECT_EQ(1u, switching.size()); - EXPECT_EQ(1u, switching.count(GPU_SWITCHING_OPTION_FORCE_DISCRETE)); - std::vector<uint32> entries; - switching_list->GetDecisionEntries(&entries, false); - ASSERT_EQ(1u, entries.size()); - EXPECT_EQ(1u, entries[0]); - - switching_list.reset(GpuSwitchingList::Create()); - EXPECT_TRUE(switching_list->LoadList(json, GpuControlList::kAllOs)); - switching = switching_list->MakeDecision( - GpuControlList::kOsWin, kOsVersion, gpu_info()); - EXPECT_EQ(1u, switching.size()); - EXPECT_EQ(1u, switching.count(GPU_SWITCHING_OPTION_FORCE_INTEGRATED)); - switching_list->GetDecisionEntries(&entries, false); - ASSERT_EQ(1u, entries.size()); - EXPECT_EQ(2u, entries[0]); -} - -} // namespace gpu - diff --git a/gpu/config/gpu_switching_option.h b/gpu/config/gpu_switching_option.h deleted file mode 100644 index 036c15f..0000000 --- a/gpu/config/gpu_switching_option.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef GPU_CONFIG_GPU_SWITCHING_OPTION_H_ -#define GPU_CONFIG_GPU_SWITCHING_OPTION_H_ - -//#include "build/build_config.h" - -namespace gpu { - -enum GpuSwitchingOption { - GPU_SWITCHING_OPTION_AUTOMATIC, - GPU_SWITCHING_OPTION_FORCE_INTEGRATED, - GPU_SWITCHING_OPTION_FORCE_DISCRETE, - GPU_SWITCHING_OPTION_UNKNOWN -}; - -} // namespace gpu - -#endif // GPU_CONFIG_GPU_SWITCHING_OPTION_H_ - diff --git a/gpu/config/gpu_util.cc b/gpu/config/gpu_util.cc index 7fae88a..728546c 100644 --- a/gpu/config/gpu_util.cc +++ b/gpu/config/gpu_util.cc @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/strings/string_number_conversions.h" +#include "base/strings/string_split.h" #include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/config/gpu_control_list_jsons.h" #include "gpu/config/gpu_driver_bug_list.h" @@ -31,32 +32,20 @@ std::string IntSetToString(const std::set<int>& list) { return rt; } -} // namespace anonymous - -GpuSwitchingOption StringToGpuSwitchingOption( - const std::string& switching_string) { - if (switching_string == switches::kGpuSwitchingOptionNameAutomatic) - return GPU_SWITCHING_OPTION_AUTOMATIC; - if (switching_string == switches::kGpuSwitchingOptionNameForceIntegrated) - return GPU_SWITCHING_OPTION_FORCE_INTEGRATED; - if (switching_string == switches::kGpuSwitchingOptionNameForceDiscrete) - return GPU_SWITCHING_OPTION_FORCE_DISCRETE; - return GPU_SWITCHING_OPTION_UNKNOWN; -} - -std::string GpuSwitchingOptionToString(GpuSwitchingOption option) { - switch (option) { - case GPU_SWITCHING_OPTION_AUTOMATIC: - return switches::kGpuSwitchingOptionNameAutomatic; - case GPU_SWITCHING_OPTION_FORCE_INTEGRATED: - return switches::kGpuSwitchingOptionNameForceIntegrated; - case GPU_SWITCHING_OPTION_FORCE_DISCRETE: - return switches::kGpuSwitchingOptionNameForceDiscrete; - default: - return "unknown"; +void StringToIntSet(const std::string& str, std::set<int>* list) { + DCHECK(list); + std::vector<std::string> pieces; + base::SplitString(str, ',', &pieces); + for (size_t i = 0; i < pieces.size(); ++i) { + int number = 0; + bool succeed = base::StringToInt(pieces[i], &number); + DCHECK(succeed); + list->insert(number); } } +} // namespace anonymous + void MergeFeatureSets(std::set<int>* dst, const std::set<int>& src) { DCHECK(dst); if (src.empty()) @@ -79,4 +68,9 @@ void ApplyGpuDriverBugWorkarounds(CommandLine* command_line) { } } +void StringToFeatureSet( + const std::string& str, std::set<int>* feature_set) { + StringToIntSet(str, feature_set); +} + } // namespace gpu diff --git a/gpu/config/gpu_util.h b/gpu/config/gpu_util.h index 6d6800e..58e2db0 100644 --- a/gpu/config/gpu_util.h +++ b/gpu/config/gpu_util.h @@ -9,21 +9,12 @@ #include <string> #include "build/build_config.h" -#include "gpu/config/gpu_switching_option.h" #include "gpu/gpu_export.h" class CommandLine; namespace gpu { -// Maps string to GpuSwitchingOption; returns GPU_SWITCHING_UNKNOWN if an -// unknown name is input (case-sensitive). -GPU_EXPORT GpuSwitchingOption StringToGpuSwitchingOption( - const std::string& switching_string); - -// Gets a string version of a GpuSwitchingOption. -GPU_EXPORT std::string GpuSwitchingOptionToString(GpuSwitchingOption option); - // Merge features in src into dst. GPU_EXPORT void MergeFeatureSets( std::set<int>* dst, const std::set<int>& src); @@ -32,6 +23,10 @@ GPU_EXPORT void MergeFeatureSets( // system, and append the |command_line|. GPU_EXPORT void ApplyGpuDriverBugWorkarounds(CommandLine* command_line); +// |str| is in the format of "feature1,feature2,...,featureN". +GPU_EXPORT void StringToFeatureSet( + const std::string& str, std::set<int>* feature_set); + } // namespace gpu #endif // GPU_CONFIG_GPU_UTIL_H_ diff --git a/gpu/config/gpu_util_unittest.cc b/gpu/config/gpu_util_unittest.cc index f3e3f8f..e1264db 100644 --- a/gpu/config/gpu_util_unittest.cc +++ b/gpu/config/gpu_util_unittest.cc @@ -4,37 +4,9 @@ #include "gpu/config/gpu_util.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/gl/gl_switches.h" namespace gpu { -TEST(GpuUtilTest, GpuSwitchingOptionFromString) { - // Test StringToGpuSwitchingOption. - EXPECT_EQ(StringToGpuSwitchingOption( - switches::kGpuSwitchingOptionNameAutomatic), - GPU_SWITCHING_OPTION_AUTOMATIC); - EXPECT_EQ(StringToGpuSwitchingOption( - switches::kGpuSwitchingOptionNameForceDiscrete), - GPU_SWITCHING_OPTION_FORCE_DISCRETE); - EXPECT_EQ(StringToGpuSwitchingOption( - switches::kGpuSwitchingOptionNameForceIntegrated), - GPU_SWITCHING_OPTION_FORCE_INTEGRATED); - EXPECT_EQ(StringToGpuSwitchingOption("xxx"), GPU_SWITCHING_OPTION_UNKNOWN); -} - -TEST(GpuUtilTest, GpuSwitchingOptionToString) { - // Test GpuSwitchingOptionToString. - EXPECT_STREQ( - GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_AUTOMATIC).c_str(), - switches::kGpuSwitchingOptionNameAutomatic); - EXPECT_STREQ( - GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_FORCE_DISCRETE).c_str(), - switches::kGpuSwitchingOptionNameForceDiscrete); - EXPECT_STREQ( - GpuSwitchingOptionToString(GPU_SWITCHING_OPTION_FORCE_INTEGRATED).c_str(), - switches::kGpuSwitchingOptionNameForceIntegrated); -} - TEST(GpuUtilTest, MergeFeatureSets) { { // Merge two empty sets. @@ -75,4 +47,25 @@ TEST(GpuUtilTest, MergeFeatureSets) { } } +TEST(GpuUtilTest, StringToFeatureSet) { + { + // zero feature. + std::set<int> features; + StringToFeatureSet("", &features); + EXPECT_EQ(0u, features.size()); + } + { + // One features. + std::set<int> features; + StringToFeatureSet("4", &features); + EXPECT_EQ(1u, features.size()); + } + { + // Multiple features. + std::set<int> features; + StringToFeatureSet("1,9", &features); + EXPECT_EQ(2u, features.size()); + } +} + } // namespace gpu diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index fd7cac8..334c0b3 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -224,7 +224,6 @@ 'config/gpu_driver_bug_list_unittest.cc', 'config/gpu_info_collector_unittest.cc', 'config/gpu_info_unittest.cc', - 'config/gpu_switching_list_unittest.cc', 'config/gpu_test_config_unittest.cc', 'config/gpu_test_expectations_parser_unittest.cc', 'config/gpu_util_unittest.cc', diff --git a/gpu/gpu_config.gypi b/gpu/gpu_config.gypi index c95605b..9c1d581 100644 --- a/gpu/gpu_config.gypi +++ b/gpu/gpu_config.gypi @@ -35,10 +35,6 @@ 'config/gpu_info_collector.cc', 'config/gpu_info_collector.h', 'config/gpu_performance_stats.h', - 'config/gpu_switching_list_json.cc', - 'config/gpu_switching_list.cc', - 'config/gpu_switching_list.h', - 'config/gpu_switching_option.h', 'config/gpu_test_config.cc', 'config/gpu_test_config.h', 'config/gpu_test_expectations_parser.cc', |