Home | History | Annotate | Download | only in config
      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.
      4 
      5 #include "gpu/config/gpu_driver_bug_list.h"
      6 
      7 #include "base/basictypes.h"
      8 #include "base/logging.h"
      9 #include "gpu/config/gpu_driver_bug_workaround_type.h"
     10 
     11 namespace gpu {
     12 
     13 namespace {
     14 
     15 struct GpuDriverBugWorkaroundInfo {
     16   GpuDriverBugWorkaroundType type;
     17   const char* name;
     18 };
     19 
     20 const GpuDriverBugWorkaroundInfo kFeatureList[] = {
     21 #define GPU_OP(type, name) { type, #name },
     22   GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
     23 #undef GPU_OP
     24 };
     25 
     26 }  // namespace anonymous
     27 
     28 GpuDriverBugList::GpuDriverBugList()
     29     : GpuControlList() {
     30 }
     31 
     32 GpuDriverBugList::~GpuDriverBugList() {
     33 }
     34 
     35 // static
     36 GpuDriverBugList* GpuDriverBugList::Create() {
     37   GpuDriverBugList* list = new GpuDriverBugList();
     38 
     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);
     44   }
     45   return list;
     46 }
     47 
     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";
     54 }
     55 
     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;
     84     }
     85   }
     86 }
     87 
     88 }  // namespace gpu
     89 
     90