Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: gpu/config/gpu_driver_bug_workarounds.cc

Issue 1871613002: Compute GpuDriverBugWorkarounds only one time in the GPU process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_workarounds.h"
6
7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h"
10 #include "gpu/config/gpu_switches.h"
11
12 namespace gpu {
13
14 // static
15 void GpuDriverBugWorkarounds::Initialize(GpuDriverBugWorkarounds& workarounds) {
16 Initialize(nullptr, workarounds);
17 }
18
19 // static
20 void GpuDriverBugWorkarounds::Initialize(const base::CommandLine* command_line,
21 GpuDriverBugWorkarounds& workarounds) {
22 if (!command_line) {
23 command_line = base::CommandLine::InitializedForCurrentProcess()
24 ? base::CommandLine::ForCurrentProcess()
25 : nullptr;
piman 2016/04/12 04:38:44 If we get nullptr, we'll crash below, won't we?
Julien Isorce Samsung 2016/04/12 16:11:33 yes it will crash. I spotted that as well but I le
26 }
27
28 std::string types =
29 command_line->GetSwitchValueASCII(switches::kGpuDriverBugWorkarounds);
30 StringToWorkarounds(types, &workarounds);
31 }
32
33 GpuDriverBugWorkarounds::GpuDriverBugWorkarounds()
34 :
35 #define GPU_OP(type, name) name(false),
36 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
37 #undef GPU_OP
38 max_texture_size(0),
39 max_cube_map_texture_size(0),
40 max_fragment_uniform_vectors(0),
41 max_varying_vectors(0),
42 max_vertex_uniform_vectors(0),
43 max_copy_texture_chromium_size(0) {
44 }
45
46 GpuDriverBugWorkarounds::GpuDriverBugWorkarounds(
47 const GpuDriverBugWorkarounds& other) = default;
48
49 GpuDriverBugWorkarounds::~GpuDriverBugWorkarounds() {}
50
51 // Process a string of wordaround type IDs (seperated by ',') and set up
52 // the corresponding Workaround flags.
53 void StringToWorkarounds(const std::string& types,
54 GpuDriverBugWorkarounds* workarounds) {
55 DCHECK(workarounds);
56 for (const base::StringPiece& piece : base::SplitStringPiece(
57 types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
58 int number = 0;
59 bool succeed = base::StringToInt(piece, &number);
60 DCHECK(succeed);
61 switch (number) {
62 #define GPU_OP(type, name) \
63 case gpu::type: \
64 workarounds->name = true; \
65 break;
66 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
67 #undef GPU_OP
68 default:
69 NOTIMPLEMENTED();
70 }
71 }
72 if (workarounds->max_texture_size_limit_4096)
73 workarounds->max_texture_size = 4096;
74 if (workarounds->max_cube_map_texture_size_limit_4096)
75 workarounds->max_cube_map_texture_size = 4096;
76 if (workarounds->max_cube_map_texture_size_limit_1024)
77 workarounds->max_cube_map_texture_size = 1024;
78 if (workarounds->max_cube_map_texture_size_limit_512)
79 workarounds->max_cube_map_texture_size = 512;
80
81 if (workarounds->max_fragment_uniform_vectors_32)
82 workarounds->max_fragment_uniform_vectors = 32;
83 if (workarounds->max_varying_vectors_16)
84 workarounds->max_varying_vectors = 16;
85 if (workarounds->max_vertex_uniform_vectors_256)
86 workarounds->max_vertex_uniform_vectors = 256;
87
88 if (workarounds->max_copy_texture_chromium_size_1048576)
89 workarounds->max_copy_texture_chromium_size = 1048576;
90 if (workarounds->max_copy_texture_chromium_size_262144)
91 workarounds->max_copy_texture_chromium_size = 262144;
92 }
93
94 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698