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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: gpu/config/gpu_driver_bug_workarounds.cc
diff --git a/gpu/config/gpu_driver_bug_workarounds.cc b/gpu/config/gpu_driver_bug_workarounds.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9d5b9d3abdba5eb9120d18a6e6a9b62c83e6bb18
--- /dev/null
+++ b/gpu/config/gpu_driver_bug_workarounds.cc
@@ -0,0 +1,94 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/config/gpu_driver_bug_workarounds.h"
+
+#include "base/command_line.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
+#include "gpu/config/gpu_switches.h"
+
+namespace gpu {
+
+// static
+void GpuDriverBugWorkarounds::Initialize(GpuDriverBugWorkarounds& workarounds) {
+ Initialize(nullptr, workarounds);
+}
+
+// static
+void GpuDriverBugWorkarounds::Initialize(const base::CommandLine* command_line,
+ GpuDriverBugWorkarounds& workarounds) {
+ if (!command_line) {
+ command_line = base::CommandLine::InitializedForCurrentProcess()
+ ? base::CommandLine::ForCurrentProcess()
+ : 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
+ }
+
+ std::string types =
+ command_line->GetSwitchValueASCII(switches::kGpuDriverBugWorkarounds);
+ StringToWorkarounds(types, &workarounds);
+}
+
+GpuDriverBugWorkarounds::GpuDriverBugWorkarounds()
+ :
+#define GPU_OP(type, name) name(false),
+ GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
+#undef GPU_OP
+ max_texture_size(0),
+ max_cube_map_texture_size(0),
+ max_fragment_uniform_vectors(0),
+ max_varying_vectors(0),
+ max_vertex_uniform_vectors(0),
+ max_copy_texture_chromium_size(0) {
+}
+
+GpuDriverBugWorkarounds::GpuDriverBugWorkarounds(
+ const GpuDriverBugWorkarounds& other) = default;
+
+GpuDriverBugWorkarounds::~GpuDriverBugWorkarounds() {}
+
+// Process a string of wordaround type IDs (seperated by ',') and set up
+// the corresponding Workaround flags.
+void StringToWorkarounds(const std::string& types,
+ GpuDriverBugWorkarounds* workarounds) {
+ DCHECK(workarounds);
+ for (const base::StringPiece& piece : base::SplitStringPiece(
+ types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ int number = 0;
+ bool succeed = base::StringToInt(piece, &number);
+ DCHECK(succeed);
+ switch (number) {
+#define GPU_OP(type, name) \
+ case gpu::type: \
+ workarounds->name = true; \
+ break;
+ GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
+#undef GPU_OP
+ default:
+ NOTIMPLEMENTED();
+ }
+ }
+ if (workarounds->max_texture_size_limit_4096)
+ workarounds->max_texture_size = 4096;
+ if (workarounds->max_cube_map_texture_size_limit_4096)
+ workarounds->max_cube_map_texture_size = 4096;
+ if (workarounds->max_cube_map_texture_size_limit_1024)
+ workarounds->max_cube_map_texture_size = 1024;
+ if (workarounds->max_cube_map_texture_size_limit_512)
+ workarounds->max_cube_map_texture_size = 512;
+
+ if (workarounds->max_fragment_uniform_vectors_32)
+ workarounds->max_fragment_uniform_vectors = 32;
+ if (workarounds->max_varying_vectors_16)
+ workarounds->max_varying_vectors = 16;
+ if (workarounds->max_vertex_uniform_vectors_256)
+ workarounds->max_vertex_uniform_vectors = 256;
+
+ if (workarounds->max_copy_texture_chromium_size_1048576)
+ workarounds->max_copy_texture_chromium_size = 1048576;
+ if (workarounds->max_copy_texture_chromium_size_262144)
+ workarounds->max_copy_texture_chromium_size = 262144;
+}
+
+} // namespace gpu

Powered by Google App Engine
This is Rietveld 408576698