Rationalize and fix chromium android linker histogram recording.
[chromium-blink-merge.git] / gpu / config / gpu_driver_bug_list.cc
bloba091c4218f711be9dd6eb1568fe685033763f697
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
3 // found in the LICENSE file.
5 #include "gpu/config/gpu_driver_bug_list.h"
7 #include "base/basictypes.h"
8 #include "base/logging.h"
9 #include "gpu/config/gpu_driver_bug_workaround_type.h"
11 namespace gpu {
13 namespace {
15 struct GpuDriverBugWorkaroundInfo {
16 GpuDriverBugWorkaroundType type;
17 const char* name;
20 const GpuDriverBugWorkaroundInfo kFeatureList[] = {
21 #define GPU_OP(type, name) { type, #name },
22 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
23 #undef GPU_OP
26 } // namespace anonymous
28 GpuDriverBugList::GpuDriverBugList()
29 : GpuControlList() {
32 GpuDriverBugList::~GpuDriverBugList() {
35 // static
36 GpuDriverBugList* GpuDriverBugList::Create() {
37 GpuDriverBugList* list = new GpuDriverBugList();
39 DCHECK_EQ(static_cast<int>(arraysize(kFeatureList)),
40 NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES);
41 for (int i = 0; i < NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES; ++i) {
42 list->AddSupportedFeature(kFeatureList[i].name,
43 kFeatureList[i].type);
45 return list;
48 std::string GpuDriverBugWorkaroundTypeToString(
49 GpuDriverBugWorkaroundType type) {
50 if (type < NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES)
51 return kFeatureList[type].name;
52 else
53 return "unknown";
56 // static
57 void GpuDriverBugList::AppendWorkaroundsFromCommandLine(
58 std::set<int>* workarounds, const CommandLine& command_line) {
59 DCHECK(workarounds);
60 for (int i = 0; i < NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES; i++) {
61 if (!command_line.HasSwitch(kFeatureList[i].name))
62 continue;
63 // Removing conflicting workarounds.
64 switch (kFeatureList[i].type) {
65 case FORCE_DISCRETE_GPU:
66 workarounds->erase(FORCE_INTEGRATED_GPU);
67 workarounds->insert(FORCE_DISCRETE_GPU);
68 break;
69 case FORCE_INTEGRATED_GPU:
70 workarounds->erase(FORCE_DISCRETE_GPU);
71 workarounds->insert(FORCE_INTEGRATED_GPU);
72 break;
73 case MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512:
74 case MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024:
75 case MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096:
76 workarounds->erase(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512);
77 workarounds->erase(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024);
78 workarounds->erase(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096);
79 workarounds->insert(kFeatureList[i].type);
80 break;
81 default:
82 workarounds->insert(kFeatureList[i].type);
83 break;
88 } // namespace gpu