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"
15 struct GpuDriverBugWorkaroundInfo
{
16 GpuDriverBugWorkaroundType type
;
20 const GpuDriverBugWorkaroundInfo kFeatureList
[] = {
21 #define GPU_OP(type, name) { type, #name },
22 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP
)
26 } // namespace anonymous
28 GpuDriverBugList::GpuDriverBugList()
32 GpuDriverBugList::~GpuDriverBugList() {
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
);
48 std::string
GpuDriverBugWorkaroundTypeToString(
49 GpuDriverBugWorkaroundType type
) {
50 if (type
< NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES
)
51 return kFeatureList
[type
].name
;
57 void GpuDriverBugList::AppendWorkaroundsFromCommandLine(
58 std::set
<int>* workarounds
,
59 const base::CommandLine
& command_line
) {
61 for (int i
= 0; i
< NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES
; i
++) {
62 if (!command_line
.HasSwitch(kFeatureList
[i
].name
))
64 // Removing conflicting workarounds.
65 switch (kFeatureList
[i
].type
) {
66 case FORCE_DISCRETE_GPU
:
67 workarounds
->erase(FORCE_INTEGRATED_GPU
);
68 workarounds
->insert(FORCE_DISCRETE_GPU
);
70 case FORCE_INTEGRATED_GPU
:
71 workarounds
->erase(FORCE_DISCRETE_GPU
);
72 workarounds
->insert(FORCE_INTEGRATED_GPU
);
74 case MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512
:
75 case MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024
:
76 case MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096
:
77 workarounds
->erase(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512
);
78 workarounds
->erase(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024
);
79 workarounds
->erase(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096
);
80 workarounds
->insert(kFeatureList
[i
].type
);
83 workarounds
->insert(kFeatureList
[i
].type
);