chromium/ui/gl/gl_switches.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/gl/gl_switches.h"

#include "build/build_config.h"
#include "ui/gl/gl_display_manager.h"

#if BUILDFLAG(IS_ANDROID)
#include "base/android/build_info.h"
#endif

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#include <vulkan/vulkan_core.h>
#include "third_party/angle/src/gpu_info_util/SystemInfo.h"  // nogncheck
#endif

namespace gl {

const char kGLImplementationEGLName[] =;
const char kGLImplementationANGLEName[] =;
const char kGLImplementationMockName[] =;
const char kGLImplementationStubName[] =;
const char kGLImplementationDisabledName[] =;

const char kANGLEImplementationDefaultName[]  =;
const char kANGLEImplementationD3D9Name[]     =;
const char kANGLEImplementationD3D11Name[]    =;
const char kANGLEImplementationD3D11on12Name[] =;
const char kANGLEImplementationOpenGLName[]   =;
const char kANGLEImplementationOpenGLEGLName[] =;
const char kANGLEImplementationOpenGLESName[] =;
const char kANGLEImplementationOpenGLESEGLName[] =;
const char kANGLEImplementationNullName[] =;
const char kANGLEImplementationVulkanName[] =;
const char kANGLEImplementationSwiftShaderName[] =;
const char kANGLEImplementationSwiftShaderForWebGLName[] =;
const char kANGLEImplementationMetalName[] =;
const char kANGLEImplementationNoneName[] =;

// Special switches for "NULL"/stub driver implementations.
const char kANGLEImplementationD3D11NULLName[] =;
const char kANGLEImplementationOpenGLNULLName[] =;
const char kANGLEImplementationOpenGLESNULLName[] =;
const char kANGLEImplementationVulkanNULLName[] =;
const char kANGLEImplementationMetalNULLName[] =;

// The command decoder names that can be passed to --use-cmd-decoder.
const char kCmdDecoderValidatingName[] =;
const char kCmdDecoderPassthroughName[] =;

// Swap chain formats for direct composition SDR video overlays.
const char kSwapChainFormatNV12[] =;
const char kSwapChainFormatYUY2[] =;
const char kSwapChainFormatBGRA[] =;

}  // namespace gl

namespace switches {

// Disable workarounds for various GPU driver bugs.
const char kDisableGpuDriverBugWorkarounds[] =;

// Stop the GPU from synchronizing presentation with vblank.
const char kDisableGpuVsync[]               =;

// Turns on GPU logging (debug build only).
const char kEnableGPUServiceLogging[]       =;

// Turns on calling TRACE for every GL call.
const char kEnableGPUServiceTracing[]       =;

// Select which ANGLE backend to use. Options are:
//  default: Attempts several ANGLE renderers until one successfully
//           initializes, varying ES support by platform.
//  d3d9: Legacy D3D9 renderer, ES2 only.
//  d3d11: D3D11 renderer, ES2 and ES3.
//  warp: D3D11 renderer using software rasterization, ES2 and ES3.
//  gl: Desktop GL renderer, ES2 and ES3.
//  gles: GLES renderer, ES2 and ES3.
const char kUseANGLE[]                      =;

// Use the Pass-through command decoder, skipping all validation and state
// tracking. Switch lives in ui/gl because it affects the GL binding
// initialization on platforms that would otherwise not default to using
// EGL bindings.
const char kUseCmdDecoder[] =;

// ANGLE features are defined per-backend in third_party/angle/include/platform
// Enables specified comma separated ANGLE features if found.
const char kEnableANGLEFeatures[] =;
// Disables specified comma separated ANGLE features if found.
const char kDisableANGLEFeatures[] =;

// Select which implementation of GL the GPU process should use. Options are:
//  desktop: whatever desktop OpenGL the user has installed (Linux and Mac
//           default).
//  egl: whatever EGL / GLES2 the user has installed (Windows default - actually
//       ANGLE).
//  swiftshader: The SwiftShader software renderer.
const char kUseGL[]                         =;

// Inform Chrome that a GPU context will not be lost in power saving mode,
// screen saving mode, etc.  Note that this flag does not ensure that a GPU
// context will never be lost in any situations, say, a GPU reset.
const char kGpuNoContextLost[]              =;

// Flag used for Linux tests: for desktop GL bindings, try to load this GL
// library first, but fall back to regular library if loading fails.
const char kTestGLLib[]                     =;

// Use hardware gpu, if available, for tests.
const char kUseGpuInTests[] =;

// Enable use of the SGI_video_sync extension, which can have
// driver/sandbox/window manager compatibility issues.
const char kEnableSgiVideoSync[] =;

// Disables GL drawing operations which produce pixel output. With this
// the GL output will not be correct but tests will run faster.
const char kDisableGLDrawingForTests[] =;

// Forces the use of software GL instead of hardware gpu for tests.
const char kOverrideUseSoftwareGLForTests[] =;

// Disables specified comma separated GL Extensions if found.
const char kDisableGLExtensions[] =;

// Enables SwapBuffersWithBounds if it is supported.
const char kEnableSwapBuffersWithBounds[] =;

// Enables using DirectComposition video overlays, even if hardware overlays
// aren't supported.
const char kEnableDirectCompositionVideoOverlays[] =;

// Initialize the GPU process using the adapter with the specified LUID. This is
// only used on Windows, as LUID is a Windows specific structure.
const char kUseAdapterLuid[] =;

// Used for overriding the swap chain format for direct composition SDR video
// overlays.
const char kDirectCompositionVideoSwapChainFormat[] =;

// This is the list of switches passed from this file that are passed from the
// GpuProcessHost to the GPU Process. Add your switch to this list if you need
// to read it in the GPU process, else don't add it.
const char* const kGLSwitchesCopiedFromGpuProcessHost[] =;
const size_t kGLSwitchesCopiedFromGpuProcessHostNumSwitches =;

#if BUILDFLAG(IS_ANDROID)
// On some Android emulators with software GL, ANGLE
// is exposing the native fence sync extension but it doesn't
// actually work. This switch is used to disable the Android native fence sync
// during test to avoid crashes.
//
// TODO(https://crbug.com/337886037): Remove this flag once the upstream ANGLE
// is fixed.
const char kDisableAndroidNativeFenceSyncForTesting[] =
    "disable-android-native-fence-sync-for-testing";
#endif
}  // namespace switches

namespace features {

// Enable DComp debug visualizations. This can be useful to determine how much
// work DWM is doing when we update our tree.
//
// Please be aware that some of these visualizations result in quickly flashing
// colors.
BASE_FEATURE();

// Use BufferCount of 3 for the direct composition root swap chain.
BASE_FEATURE();

// Use BufferCount of 3 for direct composition video swap chains.
BASE_FEATURE();

// Allow overlay swapchain to present on all GPUs even if they only support
// software overlays. GPU deny lists limit it to NVIDIA only at the moment.
BASE_FEATURE();

// Adjust the letterbox video size and position to the center of the screen so
// that DWM power optimization can be turned on.
BASE_FEATURE();

// Do not consider hardware YUV overlay count when promoting quads to DComp
// visuals. If there are more videos than hardware overlay planes, there may be
// a performance hit compared to drawing all the videos into a single swap
// chain. This feature is intended for testing and debugging.
BASE_FEATURE();

// Allow dual GPU rendering through EGL where supported, i.e., allow a WebGL
// or WebGPU context to be on the high performance GPU if preferred and Chrome
// internal rendering to be on the low power GPU.
BASE_FEATURE();
#endif

// Allow overlay swapchain to use Intel video processor for super resolution.
BASE_FEATURE();

// Allow overlay swapchain to use NVIDIA video processor for super resolution.
BASE_FEATURE();

// Allow overlay swapchain to use NVIDIA video processor for trueHDR.
BASE_FEATURE();

// Default to using ANGLE's OpenGL backend
BASE_FEATURE();

// Default to using ANGLE's Metal backend.
BASE_FEATURE();

// Default to using ANGLE's Vulkan backend.
BASE_FEATURE();

// Track current program's shaders at glUseProgram() call for crash report
// purpose. Only effective on Windows because the attached shaders may only
// be reliably retrieved with ANGLE backend.
BASE_FEATURE();

// Enable sharing Vulkan device queue with ANGLE's Vulkan backend.
BASE_FEATURE();

bool IsDefaultANGLEVulkan() {}

// Use waitable swap chain on Windows to reduce display latency.
BASE_FEATURE();

// If using waitable swap chain, specify the maximum number of queued frames.
const base::FeatureParam<int> kDXGIWaitableSwapChainMaxQueuedFrames{};

// Force a present interval of 0. This asks Windows to cancel the remaining time
// on the previously presented frame instead of synchronizing with vblank(s).
// Frames may be discarded if they are presented more frequently than one per
// vblank.
BASE_FEATURE();

bool SupportsEGLDualGPURendering() {}

}  // namespace features