ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 1 | // Copyright 2017 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 | #include "gpu/config/gpu_finch_features.h" |
| 5 | |
Khushal | b39ecde | 2019-03-06 00:28:56 | [diff] [blame] | 6 | #if defined(OS_ANDROID) |
Khushal | cc93a50 | 2019-04-04 22:12:57 | [diff] [blame] | 7 | #include "base/android/build_info.h" |
| 8 | #include "base/metrics/field_trial_params.h" |
| 9 | #include "base/strings/string_split.h" |
Khushal | b39ecde | 2019-03-06 00:28:56 | [diff] [blame] | 10 | #include "ui/gl/android/android_surface_control_compat.h" |
| 11 | #endif |
| 12 | |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 13 | namespace features { |
Khushal | cc93a50 | 2019-04-04 22:12:57 | [diff] [blame] | 14 | namespace { |
| 15 | |
| 16 | #if defined(OS_ANDROID) |
| 17 | bool FieldIsInBlacklist(const char* current_value, std::string blacklist_str) { |
| 18 | std::vector<std::string> blacklist = base::SplitString( |
| 19 | blacklist_str, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 20 | for (const std::string& value : blacklist) { |
| 21 | if (value == current_value) |
| 22 | return true; |
| 23 | } |
| 24 | |
| 25 | return false; |
| 26 | } |
| 27 | #endif |
| 28 | |
| 29 | } // namespace |
| 30 | |
Maggie Chen | 1ecb074 | 2018-11-28 07:27:37 | [diff] [blame] | 31 | #if defined(OS_ANDROID) |
| 32 | // Use android AImageReader when playing videos with MediaPlayer. |
| 33 | const base::Feature kAImageReaderMediaPlayer{"AImageReaderMediaPlayer", |
| 34 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 35 | |
| 36 | // Use android SurfaceControl API for managing display compositor's buffer queue |
| 37 | // and using overlays on Android. |
| 38 | // Note that the feature only works with VizDisplayCompositor enabled. |
| 39 | const base::Feature kAndroidSurfaceControl{"AndroidSurfaceControl", |
| 40 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 41 | #endif |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 42 | |
| 43 | // Enable GPU Rasterization by default. This can still be overridden by |
| 44 | // --force-gpu-rasterization or --disable-gpu-rasterization. |
Eric Karl | ba990bf | 2018-01-03 00:19:35 | [diff] [blame] | 45 | #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_CHROMEOS) || \ |
Sergey Ulanov | 54c27942 | 2019-05-14 01:08:04 | [diff] [blame] | 46 | defined(OS_ANDROID) || defined(OS_FUCHSIA) |
Eric Karl | ba990bf | 2018-01-03 00:19:35 | [diff] [blame] | 47 | // DefaultEnableGpuRasterization has launched on Mac, Windows, ChromeOS, and |
| 48 | // Android. |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 49 | const base::Feature kDefaultEnableGpuRasterization{ |
| 50 | "DefaultEnableGpuRasterization", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 51 | #else |
| 52 | const base::Feature kDefaultEnableGpuRasterization{ |
| 53 | "DefaultEnableGpuRasterization", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 54 | #endif |
| 55 | |
Adrienne Walker | c87477e | 2018-06-06 22:28:21 | [diff] [blame] | 56 | // Enable out of process rasterization by default. This can still be overridden |
| 57 | // by --enable-oop-rasterization or --disable-oop-rasterization. |
Khushal Sagar | 4ea64440 | 2019-06-13 17:27:38 | [diff] [blame] | 58 | #if defined(OS_ANDROID) |
| 59 | const base::Feature kDefaultEnableOopRasterization{ |
| 60 | "DefaultEnableOopRasterization", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 61 | #else |
Adrienne Walker | c87477e | 2018-06-06 22:28:21 | [diff] [blame] | 62 | const base::Feature kDefaultEnableOopRasterization{ |
| 63 | "DefaultEnableOopRasterization", base::FEATURE_DISABLED_BY_DEFAULT}; |
Khushal Sagar | 4ea64440 | 2019-06-13 17:27:38 | [diff] [blame] | 64 | #endif |
Adrienne Walker | c87477e | 2018-06-06 22:28:21 | [diff] [blame] | 65 | |
Maggie Chen | 132c38e5 | 2019-02-04 22:18:47 | [diff] [blame] | 66 | // Allow putting a video swapchain underneath the main swapchain, so overlays |
| 67 | // can be used even if there are controls on top of the video. It can be |
| 68 | // enabled only when overlay is supported. |
| 69 | const base::Feature kDirectCompositionUnderlays{ |
Maggie Chen | 78bcd491 | 2019-04-02 00:59:08 | [diff] [blame] | 70 | "DirectCompositionUnderlays", base::FEATURE_ENABLED_BY_DEFAULT}; |
Maggie Chen | 132c38e5 | 2019-02-04 22:18:47 | [diff] [blame] | 71 | |
Sunny Sachanandani | 35c727c | 2019-07-09 13:12:52 | [diff] [blame^] | 72 | #if defined(OS_WIN) |
| 73 | // Use a high priority for GPU process on Windows. |
| 74 | const base::Feature kGpuProcessHighPriorityWin{ |
| 75 | "GpuProcessHighPriorityWin", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 76 | #endif |
| 77 | |
Sunny Sachanandani | 5cd10e96 | 2019-06-13 22:55:32 | [diff] [blame] | 78 | // Use ThreadPriority::DISPLAY for GPU main, viz compositor and IO threads. |
Michael Spang | 6f14d005 | 2019-07-02 21:03:49 | [diff] [blame] | 79 | #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
Sunny Sachanandani | 5cd10e96 | 2019-06-13 22:55:32 | [diff] [blame] | 80 | const base::Feature kGpuUseDisplayThreadPriority{ |
| 81 | "GpuUseDisplayThreadPriority", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 82 | #else |
| 83 | const base::Feature kGpuUseDisplayThreadPriority{ |
| 84 | "GpuUseDisplayThreadPriority", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 85 | #endif |
| 86 | |
Zhenyao Mo | cc6ea77 | 2019-04-25 22:33:51 | [diff] [blame] | 87 | // Allow GPU watchdog to keep waiting for ackowledgement if one is already |
| 88 | // issued from the monitored thread. |
| 89 | const base::Feature kGpuWatchdogNoTerminationAwaitingAcknowledge{ |
| 90 | "GpuWatchdogNoTerminationAwaitingAcknowledge", |
| 91 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 92 | |
Maggie Chen | 3590ec2 | 2019-06-14 00:28:09 | [diff] [blame] | 93 | // Gpu watchdog V2 to simplify the logic and reduce GPU hangs |
| 94 | const base::Feature kGpuWatchdogV2{"GpuWatchdogV2", |
| 95 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 96 | |
Christopher Cameron | 4f7ce36 | 2019-04-26 02:21:37 | [diff] [blame] | 97 | #if defined(OS_MACOSX) |
| 98 | // Enable use of Metal for OOP rasterization. |
| 99 | const base::Feature kMetal{"Metal", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 100 | #endif |
| 101 | |
Maggie Chen | 1ecb074 | 2018-11-28 07:27:37 | [diff] [blame] | 102 | // Causes us to use the SharedImageManager, removing support for the old |
| 103 | // mailbox system. Any consumers of the GPU process using the old mailbox |
| 104 | // system will experience undefined results. |
| 105 | const base::Feature kSharedImageManager{"SharedImageManager", |
| 106 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 107 | |
| 108 | // For Windows only. Use overlay swapchain to present software protected videos |
| 109 | // for all GPUs |
| 110 | const base::Feature kUseDCOverlaysForSoftwareProtectedVideo{ |
| 111 | "UseDCOverlaysForSoftwareProtectedVideo", |
| 112 | base::FEATURE_DISABLED_BY_DEFAULT}; |
| 113 | |
Andres Calderon Jaramillo | 605253d | 2018-09-05 15:46:35 | [diff] [blame] | 114 | // Controls the decode acceleration of JPEG images (as opposed to camera |
| 115 | // captures) in Chrome OS using the VA-API. |
| 116 | // TODO(andrescj): remove or enable by default in Chrome OS once |
| 117 | // https://crbug.com/868400 is resolved. |
| 118 | const base::Feature kVaapiJpegImageDecodeAcceleration{ |
| 119 | "VaapiJpegImageDecodeAcceleration", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 120 | |
Khushal | b39ecde | 2019-03-06 00:28:56 | [diff] [blame] | 121 | #if defined(OS_ANDROID) |
| 122 | bool IsAndroidSurfaceControlEnabled() { |
Khushal | cc93a50 | 2019-04-04 22:12:57 | [diff] [blame] | 123 | if (!gl::SurfaceControl::IsSupported()) |
| 124 | return false; |
| 125 | |
| 126 | if (!base::FeatureList::IsEnabled(kAndroidSurfaceControl)) |
| 127 | return false; |
| 128 | |
| 129 | if (FieldIsInBlacklist(base::android::BuildInfo::GetInstance()->model(), |
| 130 | base::GetFieldTrialParamValueByFeature( |
| 131 | kAndroidSurfaceControl, "blacklisted_models"))) { |
| 132 | return false; |
| 133 | } |
| 134 | |
| 135 | if (FieldIsInBlacklist( |
| 136 | base::android::BuildInfo::GetInstance()->android_build_id(), |
| 137 | base::GetFieldTrialParamValueByFeature(kAndroidSurfaceControl, |
| 138 | "blacklisted_build_ids"))) { |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | return true; |
Khushal | b39ecde | 2019-03-06 00:28:56 | [diff] [blame] | 143 | } |
| 144 | #endif |
| 145 | |
ericrk | 41a1579e | 2017-02-10 20:56:28 | [diff] [blame] | 146 | } // namespace features |