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

Side by Side Diff: content/browser/gpu/gpu_data_manager_impl_private.cc

Issue 1743543004: Enable Accelerated Video Decode in Linux Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use std::tie Created 4 years, 9 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
« no previous file with comments | « no previous file | content/common/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/cpu.h"
10 #include "base/metrics/field_trial.h" 11 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
12 #include "base/metrics/sparse_histogram.h" 13 #include "base/metrics/sparse_histogram.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "base/sys_info.h" 17 #include "base/sys_info.h"
17 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
18 #include "base/version.h" 19 #include "base/version.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) { 241 if (gpu::CollectGpuID(&vendor_id, &device_id) == gpu::kCollectInfoSuccess) {
241 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id); 242 gpu_changed = manager->UpdateActiveGpu(vendor_id, device_id);
242 } 243 }
243 } 244 }
244 245
245 if (display_changed || gpu_changed) 246 if (display_changed || gpu_changed)
246 manager->HandleGpuSwitch(); 247 manager->HandleGpuSwitch();
247 } 248 }
248 #endif // OS_MACOSX 249 #endif // OS_MACOSX
249 250
251 #if defined(OS_LINUX)
252 bool ShouldEnableAcceleratedVideoDecodeInLinux() {
253 #if defined(OS_CHROMEOS)
254 return true;
255 #endif // defined(OS_CHROMEOS)
256
257 // Allow only latest Intel architecture. +IvyBridge
258 #if defined(ARCH_CPU_X86_FAMILY)
259 struct CPU {
260 int family; // family of the processor
261 int model; // model of processor
262 };
263 const CPU kIntelWhitelistTable[] = {
264 // http://instlatx64.atw.hu/ for CPUID
265 {0x06, 0x3A}, // IvyBridge
266 {0x06, 0x3C}, // Haswell
267 {0x06, 0x3D}, // Broadwell
268 {0x06, 0x3E}, // IvyBridge
269 {0x06, 0x3F}, // Haswell
270 {0x06, 0x45}, // Haswell
271 {0x06, 0x46}, // Haswell
272 {0x06, 0x47}, // Broadwell-H
273 {0x06, 0x4C}, // Braswell
274 {0x06, 0x4E}, // Skylake
275 {0x06, 0x56}, // Broadwell-DE
276 };
277
278 base::CPU cpuid;
279 const CPU search_elem = {cpuid.family(), cpuid.model()};
allan.jensen 2016/04/15 09:16:20 This seems completely wrong. VAAPI is usually co
280 bool allowed = std::binary_search(
281 kIntelWhitelistTable,
282 kIntelWhitelistTable + arraysize(kIntelWhitelistTable), search_elem,
283 [](const CPU& a, const CPU& b) {
284 return std::tie(a.family, a.model) < std::tie(b.family, b.model);
285 });
286 return allowed;
287 #endif // defined(ARCH_CPU_X86_FAMILY)
288
289 return false;
290 }
291 #endif
292
250 // Block all domains' use of 3D APIs for this many milliseconds if 293 // Block all domains' use of 3D APIs for this many milliseconds if
251 // approaching a threshold where system stability might be compromised. 294 // approaching a threshold where system stability might be compromised.
252 const int64_t kBlockAllDomainsMs = 10000; 295 const int64_t kBlockAllDomainsMs = 10000;
253 const int kNumResetsWithinDuration = 1; 296 const int kNumResetsWithinDuration = 1;
254 297
255 // Enums for UMA histograms. 298 // Enums for UMA histograms.
256 enum BlockStatusHistogram { 299 enum BlockStatusHistogram {
257 BLOCK_STATUS_NOT_BLOCKED, 300 BLOCK_STATUS_NOT_BLOCKED,
258 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED, 301 BLOCK_STATUS_SPECIFIC_DOMAIN_BLOCKED,
259 BLOCK_STATUS_ALL_DOMAINS_BLOCKED, 302 BLOCK_STATUS_ALL_DOMAINS_BLOCKED,
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 "DisableAcceleratedVideoDecode"); 990 "DisableAcceleratedVideoDecode");
948 if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) { 991 if (command_line->HasSwitch(switches::kDisableAcceleratedVideoDecode)) {
949 // It was already disabled on the command line. 992 // It was already disabled on the command line.
950 return false; 993 return false;
951 } 994 }
952 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE)) 995 if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE))
953 return true; 996 return true;
954 if (group_name == "Disabled") 997 if (group_name == "Disabled")
955 return true; 998 return true;
956 999
1000 #if defined(OS_LINUX)
1001 if (!ShouldEnableAcceleratedVideoDecodeInLinux())
1002 return true;
1003 #endif
1004
957 // Accelerated decode is never available with --disable-gpu. 1005 // Accelerated decode is never available with --disable-gpu.
958 return command_line->HasSwitch(switches::kDisableGpu); 1006 return command_line->HasSwitch(switches::kDisableGpu);
959 } 1007 }
960 1008
961 void GpuDataManagerImplPrivate::GetDisabledExtensions( 1009 void GpuDataManagerImplPrivate::GetDisabledExtensions(
962 std::string* disabled_extensions) const { 1010 std::string* disabled_extensions) const {
963 DCHECK(disabled_extensions); 1011 DCHECK(disabled_extensions);
964 *disabled_extensions = disabled_extensions_; 1012 *disabled_extensions = disabled_extensions_;
965 } 1013 }
966 1014
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; 1285 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure;
1238 #if defined(OS_WIN) 1286 #if defined(OS_WIN)
1239 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; 1287 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure;
1240 #endif 1288 #endif
1241 complete_gpu_info_already_requested_ = true; 1289 complete_gpu_info_already_requested_ = true;
1242 // Some observers might be waiting. 1290 // Some observers might be waiting.
1243 NotifyGpuInfoUpdate(); 1291 NotifyGpuInfoUpdate();
1244 } 1292 }
1245 1293
1246 } // namespace content 1294 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698