forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpu_driver_bug_list_unittest.cc
211 lines (182 loc) · 6.54 KB
/
gpu_driver_bug_list_unittest.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
// 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 <stdint.h>
#include <memory>
#include "base/command_line.h"
#include "base/logging.h"
#include "gpu/config/gpu_control_list_jsons.h"
#include "gpu/config/gpu_driver_bug_list.h"
#include "gpu/config/gpu_driver_bug_workaround_type.h"
#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 {
public:
GpuDriverBugListTest() { }
~GpuDriverBugListTest() override {}
const GPUInfo& gpu_info() const {
return gpu_info_;
}
protected:
void SetUp() override {
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_name = "MacBookPro";
gpu_info_.machine_model_version = "7.1";
gpu_info_.gl_vendor = "NVIDIA Corporation";
gpu_info_.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
}
void TearDown() override {}
private:
GPUInfo gpu_info_;
};
TEST_F(GpuDriverBugListTest, CurrentDriverBugListValidation) {
std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
std::string json;
EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
}
TEST_F(GpuDriverBugListTest, CurrentListForARM) {
std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
GPUInfo gpu_info;
gpu_info.gl_vendor = "ARM";
gpu_info.gl_renderer = "MALi_T604";
std::set<int> bugs = list->MakeDecision(
GpuControlList::kOsAndroid, "4.1", gpu_info);
EXPECT_EQ(1u, bugs.count(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS));
}
TEST_F(GpuDriverBugListTest, CurrentListForImagination) {
std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
EXPECT_TRUE(list->LoadList(kGpuDriverBugListJson, GpuControlList::kAllOs));
GPUInfo gpu_info;
gpu_info.gl_vendor = "Imagination Technologies";
gpu_info.gl_renderer = "PowerVR SGX 540";
std::set<int> bugs = list->MakeDecision(
GpuControlList::kOsAndroid, "4.1", gpu_info);
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"
]
}
]
}
);
std::unique_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_t> 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]);
}
TEST_F(GpuDriverBugListTest, AppendSingleWorkaround) {
base::CommandLine command_line(0, NULL);
command_line.AppendSwitch(GpuDriverBugWorkaroundTypeToString(
DISABLE_CHROMIUM_FRAMEBUFFER_MULTISAMPLE));
std::set<int> workarounds;
workarounds.insert(EXIT_ON_CONTEXT_LOST);
workarounds.insert(INIT_VERTEX_ATTRIBUTES);
EXPECT_EQ(2u, workarounds.size());
GpuDriverBugList::AppendWorkaroundsFromCommandLine(
&workarounds, command_line);
EXPECT_EQ(3u, workarounds.size());
EXPECT_EQ(1u, workarounds.count(DISABLE_CHROMIUM_FRAMEBUFFER_MULTISAMPLE));
}
TEST_F(GpuDriverBugListTest, AppendForceGPUWorkaround) {
base::CommandLine command_line(0, NULL);
command_line.AppendSwitch(
GpuDriverBugWorkaroundTypeToString(FORCE_DISCRETE_GPU));
std::set<int> workarounds;
workarounds.insert(EXIT_ON_CONTEXT_LOST);
workarounds.insert(FORCE_INTEGRATED_GPU);
EXPECT_EQ(2u, workarounds.size());
EXPECT_EQ(1u, workarounds.count(FORCE_INTEGRATED_GPU));
GpuDriverBugList::AppendWorkaroundsFromCommandLine(
&workarounds, command_line);
EXPECT_EQ(2u, workarounds.size());
EXPECT_EQ(0u, workarounds.count(FORCE_INTEGRATED_GPU));
EXPECT_EQ(1u, workarounds.count(FORCE_DISCRETE_GPU));
}
TEST_F(GpuDriverBugListTest, NVIDIANumberingScheme) {
const std::string json = LONG_STRING_CONST(
{
"name": "gpu driver bug list",
"version": "0.1",
"entries": [
{
"id": 1,
"os": {
"type": "win"
},
"vendor_id": "0x10de",
"driver_version": {
"op": "<=",
"value": "8.17.12.6973"
},
"features": [
"disable_d3d11"
]
}
]
}
);
std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
EXPECT_TRUE(list->LoadList(json, GpuControlList::kAllOs));
GPUInfo gpu_info;
gpu_info.gl_vendor = "NVIDIA";
gpu_info.gl_renderer = "NVIDIA GeForce GT 120 OpenGL Engine";
gpu_info.gpu.vendor_id = 0x10de;
gpu_info.gpu.device_id = 0x0640;
// test the same driver version number
gpu_info.driver_version = "8.17.12.6973";
std::set<int> bugs = list->MakeDecision(
GpuControlList::kOsWin, "7.0", gpu_info);
EXPECT_EQ(1u, bugs.count(DISABLE_D3D11));
// test a lower driver version number
gpu_info.driver_version = "8.15.11.8647";
bugs = list->MakeDecision(GpuControlList::kOsWin, "7.0", gpu_info);
EXPECT_EQ(1u, bugs.count(DISABLE_D3D11));
// test a higher driver version number
gpu_info.driver_version = "9.18.13.2723";
bugs = list->MakeDecision(GpuControlList::kOsWin, "7.0", gpu_info);
EXPECT_EQ(0u, bugs.count(DISABLE_D3D11));
}
} // namespace gpu