Commit 4a6ed968 authored by zmo@chromium.org's avatar zmo@chromium.org

Add semantics to apply gpu blakclist to AMD swichable when a discrete/integrated GPU is in use

BUG=376562
TEST=gpu_unittests
R=kbr@chromium.org

Review URL: https://codereview.chromium.org/338183005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278703 0039d316-1c4b-4281-b951-d872f2087c98
parent 1020fead
......@@ -87,6 +87,10 @@ int CompareLexicalNumberStrings(
}
const char kMultiGpuStyleStringAMDSwitchable[] = "amd_switchable";
const char kMultiGpuStyleStringAMDSwitchableDiscrete[] =
"amd_switchable_discrete";
const char kMultiGpuStyleStringAMDSwitchableIntegrated[] =
"amd_switchable_integrated";
const char kMultiGpuStyleStringOptimus[] = "optimus";
const char kMultiGpuCategoryStringPrimary[] = "primary";
......@@ -1078,6 +1082,10 @@ GpuControlList::GpuControlListEntry::StringToMultiGpuStyle(
return kMultiGpuStyleOptimus;
if (style == kMultiGpuStyleStringAMDSwitchable)
return kMultiGpuStyleAMDSwitchable;
if (style == kMultiGpuStyleStringAMDSwitchableIntegrated)
return kMultiGpuStyleAMDSwitchableIntegrated;
if (style == kMultiGpuStyleStringAMDSwitchableDiscrete)
return kMultiGpuStyleAMDSwitchableDiscrete;
return kMultiGpuStyleNone;
}
......@@ -1199,6 +1207,22 @@ bool GpuControlList::GpuControlListEntry::Contains(
if (!gpu_info.amd_switchable)
return false;
break;
case kMultiGpuStyleAMDSwitchableDiscrete:
if (!gpu_info.amd_switchable)
return false;
// The discrete GPU is always the primary GPU.
// This is guaranteed by GpuInfoCollector.
if (!gpu_info.gpu.active)
return false;
break;
case kMultiGpuStyleAMDSwitchableIntegrated:
if (!gpu_info.amd_switchable)
return false;
// Assume the integrated GPU is the first in the secondary GPU list.
if (gpu_info.secondary_gpus.size() == 0 ||
!gpu_info.secondary_gpus[0].active)
return false;
break;
case kMultiGpuStyleNone:
break;
}
......
......@@ -324,6 +324,8 @@ class GPU_EXPORT GpuControlList {
enum MultiGpuStyle {
kMultiGpuStyleOptimus,
kMultiGpuStyleAMDSwitchable,
kMultiGpuStyleAMDSwitchableIntegrated,
kMultiGpuStyleAMDSwitchableDiscrete,
kMultiGpuStyleNone
};
......
......@@ -23,8 +23,12 @@
// "version" is a VERSION structure (defined below).
// 3. "vendor_id" is a string. 0 is reserved.
// 4. "device_id" is an array of strings. 0 is reserved.
// 5. "multi_gpu_style" is a string, valid values include "optimus", and
// "amd_switchable".
// 5. "multi_gpu_style" is a string, valid values include:
// a) "optimus": NVIDIA dual GPU
// b) "amd_switchable": AMD dual GPU
// c) "amd_switchable_integrated": AMD dual GPU, integrated GPU is active
// d) "amd_switchable_discrete": AMD dual GPU, discrete GPU is active
// c) and d) are only valid on Win, as on Mac we can switch GPU on the fly.
// 6. "multi_gpu_category" is a string, valid values include "any", "primary",
// "secondary", and "active". If unspecified, the default value is "primary".
// See gpu_control_list.h for more details on the meanings of the strings.
......
......@@ -12,6 +12,7 @@
const char kOsVersion[] = "10.6.4";
const uint32 kIntelVendorId = 0x8086;
const uint32 kNvidiaVendorId = 0x10de;
const uint32 kAmdVendorId = 0x10de;
#define LONG_STRING_CONST(...) #__VA_ARGS__
......@@ -448,5 +449,98 @@ TEST_F(GpuControlListTest, ExceptionWithoutVendorId) {
EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0);
}
TEST_F(GpuControlListTest, AMDSwitchable) {
GPUInfo gpu_info;
gpu_info.amd_switchable = true;
gpu_info.gpu.vendor_id = kAmdVendorId;
gpu_info.gpu.device_id = 0x6760;
GPUInfo::GPUDevice integrated_gpu;
integrated_gpu.vendor_id = kIntelVendorId;
integrated_gpu.device_id = 0x0116;
gpu_info.secondary_gpus.push_back(integrated_gpu);
{ // amd_switchable_discrete entry
const std::string json= LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"multi_gpu_style": "amd_switchable_discrete",
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
// Integrated GPU is active
gpu_info.gpu.active = false;
gpu_info.secondary_gpus[0].active = true;
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
// Discrete GPU is active
gpu_info.gpu.active = true;
gpu_info.secondary_gpus[0].active = false;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0);
}
{ // amd_switchable_integrated entry
const std::string json= LONG_STRING_CONST(
{
"name": "gpu control list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"multi_gpu_style": "amd_switchable_integrated",
"features": [
"test_feature_0"
]
}
]
}
);
scoped_ptr<GpuControlList> control_list(Create());
EXPECT_TRUE(control_list->LoadList(json, GpuControlList::kAllOs));
// Discrete GPU is active
gpu_info.gpu.active = true;
gpu_info.secondary_gpus[0].active = false;
std::set<int> features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
// Integrated GPU is active
gpu_info.gpu.active = false;
gpu_info.secondary_gpus[0].active = true;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_SINGLE_FEATURE(features, TEST_FEATURE_0);
// For non AMD switchable
gpu_info.amd_switchable = false;
features = control_list->MakeDecision(
GpuControlList::kOsWin, kOsVersion, gpu_info);
EXPECT_EMPTY_SET(features);
}
}
} // namespace gpu
......@@ -18,7 +18,7 @@ const char kSoftwareRenderingListJson[] = LONG_STRING_CONST(
{
"name": "software rendering list",
// Please update the version number whenever you change this file.
"version": "8.5",
"version": "8.6",
"entries": [
{
"id": 1,
......@@ -1092,7 +1092,7 @@ LONG_STRING_CONST(
"os": {
"type": "win"
},
"multi_gpu_style": "amd_switchable",
"multi_gpu_style": "amd_switchable_discrete",
"features": [
"accelerated_video_decode"
]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment