1 // Copyright (c) 2012 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 "ui/gl/gl_switches.h"
6 
7 #include "base/stl_util.h"
8 
9 namespace gl {
10 
11 const char kGLImplementationDesktopName[] = "desktop";
12 const char kGLImplementationCoreProfileName[] = "core_profile";
13 const char kGLImplementationAppleName[] = "apple";
14 const char kGLImplementationEGLName[] = "egl";
15 const char kGLImplementationANGLEName[] = "angle";
16 const char kGLImplementationSwiftShaderName[] = "swiftshader";
17 const char kGLImplementationSwiftShaderForWebGLName[] = "swiftshader-webgl";
18 const char kGLImplementationMockName[] = "mock";
19 const char kGLImplementationStubName[] = "stub";
20 const char kGLImplementationDisabledName[] = "disabled";
21 
22 const char kANGLEImplementationDefaultName[]  = "default";
23 const char kANGLEImplementationD3D9Name[]     = "d3d9";
24 const char kANGLEImplementationD3D11Name[]    = "d3d11";
25 const char kANGLEImplementationD3D11on12Name[] = "d3d11on12";
26 const char kANGLEImplementationOpenGLName[]   = "gl";
27 const char kANGLEImplementationOpenGLEGLName[] = "gl-egl";
28 const char kANGLEImplementationOpenGLESName[] = "gles";
29 const char kANGLEImplementationOpenGLESEGLName[] = "gles-egl";
30 const char kANGLEImplementationNullName[] = "null";
31 const char kANGLEImplementationVulkanName[] = "vulkan";
32 const char kANGLEImplementationSwiftShaderName[] = "swiftshader";
33 
34 // Special switches for "NULL"/stub driver implementations.
35 const char kANGLEImplementationD3D11NULLName[] = "d3d11-null";
36 const char kANGLEImplementationOpenGLNULLName[] = "gl-null";
37 const char kANGLEImplementationOpenGLESNULLName[] = "gles-null";
38 const char kANGLEImplementationVulkanNULLName[] = "vulkan-null";
39 
40 // The command decoder names that can be passed to --use-cmd-decoder.
41 const char kCmdDecoderValidatingName[] = "validating";
42 const char kCmdDecoderPassthroughName[] = "passthrough";
43 
44 }  // namespace gl
45 
46 namespace switches {
47 
48 // Disables use of D3D11.
49 const char kDisableD3D11[]                  = "disable-d3d11";
50 
51 // Disables use of ES3 backend (use ES2 backend instead).
52 const char kDisableES3GLContext[]           = "disable-es3-gl-context";
53 
54 // Disables use of ES3 backend at a lower level, for testing purposes.
55 // This isn't guaranteed to work everywhere, so it's test-only.
56 const char kDisableES3GLContextForTesting[] =
57     "disable-es3-gl-context-for-testing";
58 
59 // Disable workarounds for various GPU driver bugs.
60 const char kDisableGpuDriverBugWorkarounds[] =
61     "disable-gpu-driver-bug-workarounds";
62 
63 // Stop the GPU from synchronizing presentation with vblank.
64 const char kDisableGpuVsync[]               = "disable-gpu-vsync";
65 
66 // Turns on GPU logging (debug build only).
67 const char kEnableGPUServiceLogging[]       = "enable-gpu-service-logging";
68 
69 // Turns on calling TRACE for every GL call.
70 const char kEnableGPUServiceTracing[]       = "enable-gpu-service-tracing";
71 
72 // Select which ANGLE backend to use. Options are:
73 //  default: Attempts several ANGLE renderers until one successfully
74 //           initializes, varying ES support by platform.
75 //  d3d9: Legacy D3D9 renderer, ES2 only.
76 //  d3d11: D3D11 renderer, ES2 and ES3.
77 //  warp: D3D11 renderer using software rasterization, ES2 and ES3.
78 //  gl: Desktop GL renderer, ES2 and ES3.
79 //  gles: GLES renderer, ES2 and ES3.
80 const char kUseANGLE[]                      = "use-angle";
81 
82 // Use the Pass-through command decoder, skipping all validation and state
83 // tracking. Switch lives in ui/gl because it affects the GL binding
84 // initialization on platforms that would otherwise not default to using
85 // EGL bindings.
86 const char kUseCmdDecoder[] = "use-cmd-decoder";
87 
88 // ANGLE features are defined per-backend in third_party/angle/include/platform
89 // Enables specified comma separated ANGLE features if found.
90 const char kEnableANGLEFeatures[] = "enable-angle-features";
91 // Disables specified comma separated ANGLE features if found.
92 const char kDisableANGLEFeatures[] = "disable-angle-features";
93 
94 // Select which implementation of GL the GPU process should use. Options are:
95 //  desktop: whatever desktop OpenGL the user has installed (Linux and Mac
96 //           default).
97 //  egl: whatever EGL / GLES2 the user has installed (Windows default - actually
98 //       ANGLE).
99 //  swiftshader: The SwiftShader software renderer.
100 const char kUseGL[]                         = "use-gl";
101 
102 // Inform Chrome that a GPU context will not be lost in power saving mode,
103 // screen saving mode, etc.  Note that this flag does not ensure that a GPU
104 // context will never be lost in any situations, say, a GPU reset.
105 const char kGpuNoContextLost[]              = "gpu-no-context-lost";
106 
107 // Flag used for Linux tests: for desktop GL bindings, try to load this GL
108 // library first, but fall back to regular library if loading fails.
109 const char kTestGLLib[]                     = "test-gl-lib";
110 
111 // Use hardware gpu, if available, for tests.
112 const char kUseGpuInTests[] = "use-gpu-in-tests";
113 
114 // Enable use of the SGI_video_sync extension, which can have
115 // driver/sandbox/window manager compatibility issues.
116 const char kEnableSgiVideoSync[] = "enable-sgi-video-sync";
117 
118 // Disables GL drawing operations which produce pixel output. With this
119 // the GL output will not be correct but tests will run faster.
120 const char kDisableGLDrawingForTests[] = "disable-gl-drawing-for-tests";
121 
122 // Forces the use of software GL instead of hardware gpu.
123 const char kOverrideUseSoftwareGLForTests[] =
124     "override-use-software-gl-for-tests";
125 
126 // Disables specified comma separated GL Extensions if found.
127 const char kDisableGLExtensions[] = "disable-gl-extensions";
128 
129 // Enables SwapBuffersWithBounds if it is supported.
130 const char kEnableSwapBuffersWithBounds[] = "enable-swap-buffers-with-bounds";
131 
132 // Disables DirectComposition surface.
133 const char kDisableDirectComposition[] = "disable-direct-composition";
134 
135 // Enables using DirectComposition video overlays, even if hardware overlays
136 // aren't supported.
137 const char kEnableDirectCompositionVideoOverlays[] =
138     "enable-direct-composition-video-overlays";
139 
140 // Disables using DirectComposition video overlays, even if hardware overlays
141 // are supported.
142 const char kDisableDirectCompositionVideoOverlays[] =
143     "disable-direct-composition-video-overlays";
144 
145 // This is the list of switches passed from this file that are passed from the
146 // GpuProcessHost to the GPU Process. Add your switch to this list if you need
147 // to read it in the GPU process, else don't add it.
148 const char* const kGLSwitchesCopiedFromGpuProcessHost[] = {
149     kDisableGpuDriverBugWorkarounds,
150     kDisableGpuVsync,
151     kDisableD3D11,
152     kDisableES3GLContext,
153     kDisableES3GLContextForTesting,
154     kEnableGPUServiceLogging,
155     kEnableGPUServiceTracing,
156     kEnableSgiVideoSync,
157     kGpuNoContextLost,
158     kDisableGLDrawingForTests,
159     kOverrideUseSoftwareGLForTests,
160     kUseANGLE,
161     kEnableSwapBuffersWithBounds,
162     kDisableDirectComposition,
163     kEnableDirectCompositionVideoOverlays,
164     kDisableDirectCompositionVideoOverlays,
165 };
166 const int kGLSwitchesCopiedFromGpuProcessHostNumSwitches =
167     base::size(kGLSwitchesCopiedFromGpuProcessHost);
168 
169 const char kCreateDefaultGLContext[] = "create-default-gl-context";
170 
171 }  // namespace switches
172 
173 namespace features {
174 
175 // Allow putting content with complex transforms (e.g. rotations) into an
176 // overlay.
177 const base::Feature kDirectCompositionComplexOverlays{
178     "DirectCompositionComplexOverlays", base::FEATURE_DISABLED_BY_DEFAULT};
179 
180 // Use IDXGIOutput::WaitForVBlank() to drive begin frames.
181 const base::Feature kDirectCompositionGpuVSync{
182     "DirectCompositionGpuVSync", base::FEATURE_ENABLED_BY_DEFAULT};
183 
184 // Use presentation feedback event queries (must be enabled) to limit latency.
185 const base::Feature kDirectCompositionLowLatencyPresentation{
186     "DirectCompositionLowLatencyPresentation",
187     base::FEATURE_DISABLED_BY_DEFAULT};
188 
189 // Allow using overlays for non-root render passes.
190 const base::Feature kDirectCompositionNonrootOverlays{
191     "DirectCompositionNonrootOverlays", base::FEATURE_DISABLED_BY_DEFAULT};
192 
193 // Overrides preferred overlay format to NV12 instead of YUY2.
194 const base::Feature kDirectCompositionPreferNV12Overlays{
195     "DirectCompositionPreferNV12Overlays", base::FEATURE_ENABLED_BY_DEFAULT};
196 
197 // Use per-present event queries to issue presentation feedback to clients.
198 // Also needs DirectCompositionGpuVSync.
199 const base::Feature kDirectCompositionPresentationFeedback{
200     "DirectCompositionPresentationFeedback", base::FEATURE_ENABLED_BY_DEFAULT};
201 
202 // Use decode swap chain created from compatible video decoder buffers.
203 const base::Feature kDirectCompositionUseNV12DecodeSwapChain{
204     "DirectCompositionUseNV12DecodeSwapChain",
205     base::FEATURE_ENABLED_BY_DEFAULT};
206 
207 // Default to using ANGLE's OpenGL backend
208 const base::Feature kDefaultANGLEOpenGL{"DefaultANGLEOpenGL",
209                                         base::FEATURE_DISABLED_BY_DEFAULT};
210 
211 // Track current program's shaders at glUseProgram() call for crash report
212 // purpose. Only effective on Windows because the attached shaders may only
213 // be reliably retrieved with ANGLE backend.
214 const base::Feature kTrackCurrentShaders{"TrackCurrentShaders",
215                                          base::FEATURE_DISABLED_BY_DEFAULT};
216 
217 }  // namespace features
218