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
, const CommandLine
& command_line
) {
60 for (int i
= 0; i
< NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES
; i
++) {
61 if (!command_line
.HasSwitch(kFeatureList
[i
].name
))
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
);
69 case FORCE_INTEGRATED_GPU
:
70 workarounds
->erase(FORCE_DISCRETE_GPU
);
71 workarounds
->insert(FORCE_INTEGRATED_GPU
);
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
);
82 workarounds
->insert(kFeatureList
[i
].type
);