0

Add AllowD3D11WarpFallback to support WebGL on WARP

Add an experiment which falls back to D3D11 WARP instead of SwiftShader
when there is no hardware GL available.

WARP fallback takes precedent over SwiftShader but is disabled by
default.

Bug: 402163834
Change-Id: I50fc1e46ae9ad299c1ac2711c02d50e2c22af438
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6293164
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Reviewed-by: Joe Mason <joenotcharles@google.com>
Cr-Commit-Position: refs/heads/main@{#1434802}
This commit is contained in:
Geoff Lang
2025-03-19 08:09:13 -07:00
committed by Chromium LUCI CQ
parent c90b3f9cac
commit dafa5e3a66
46 changed files with 377 additions and 75 deletions

@ -392,12 +392,12 @@ void RequestVideoMemoryUsageStats(
base::BindOnce(&OnVideoMemoryUsageStats, std::move(callback)));
}
// Determines if SwiftShader is available as a fallback for WebGL.
bool SwiftShaderAllowed() {
// Determines if software GL is available as a fallback for WebGL.
bool SoftwareGLAllowed() {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
return !command_line->HasSwitch(switches::kDisableSoftwareRasterizer) &&
features::IsSwiftShaderAllowed(command_line);
features::IsAnySoftwareGLAllowed(command_line);
}
// These values are logged to UMA. Entries should not be renumbered and numeric
@ -507,8 +507,9 @@ void GpuDataManagerImplPrivate::InitializeGpuModes() {
// browser process to reset everything.
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS)
fallback_modes_.push_back(gpu::GpuMode::DISPLAY_COMPOSITOR);
if (SwiftShaderAllowed())
fallback_modes_.push_back(gpu::GpuMode::SWIFTSHADER);
if (SoftwareGLAllowed()) {
fallback_modes_.push_back(gpu::GpuMode::SOFTWARE_GL);
}
#endif // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS)
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
@ -593,18 +594,18 @@ bool GpuDataManagerImplPrivate::GpuAccessAllowed(std::string* reason) const {
case gpu::GpuMode::HARDWARE_GRAPHITE:
case gpu::GpuMode::HARDWARE_VULKAN:
return true;
case gpu::GpuMode::SWIFTSHADER:
DCHECK(SwiftShaderAllowed());
case gpu::GpuMode::SOFTWARE_GL:
DCHECK(SoftwareGLAllowed());
return true;
default:
if (reason) {
// If SwiftShader is allowed, then we are here because it was blocked.
if (SwiftShaderAllowed()) {
*reason = "GPU process crashed too many times with SwiftShader.";
if (SoftwareGLAllowed()) {
*reason = "GPU process crashed too many times with software GL.";
} else {
*reason = "GPU access is disabled ";
// just running with --disable-gpu only will go to
// GpuMode::SWIFTSHADER instead. Adding --disable-gpu and
// GpuMode::SOFTWARE_GL instead. Adding --disable-gpu and
// --disable-software-rasterizer makes GpuAccessAllowed false and it
// comes here.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
@ -1313,7 +1314,7 @@ void GpuDataManagerImplPrivate::AppendGpuCommandLine(
case gpu::GpuMode::HARDWARE_VULKAN:
use_gl = browser_command_line->GetSwitchValueASCII(switches::kUseGL);
break;
case gpu::GpuMode::SWIFTSHADER:
case gpu::GpuMode::SOFTWARE_GL:
gl::SetSoftwareWebGLCommandLineSwitches(command_line);
break;
default:

@ -494,7 +494,12 @@ TEST_F(GpuDataManagerImplPrivateTest, NoDefaultFallbackToSwiftShaderForGanesh) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableSkiaGraphite);
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(features::kAllowSwiftShaderFallback);
feature_list.InitWithFeatures({}, {
features::kAllowSwiftShaderFallback,
#if BUILDFLAG(IS_WIN)
features::kAllowD3D11WarpFallback,
#endif // BUILDFLAG(IS_WIN)
});
ScopedGpuDataManagerImplPrivate manager;
EXPECT_EQ(gpu::GpuMode::HARDWARE_GL, manager->GetGpuMode());
@ -513,7 +518,7 @@ TEST_F(GpuDataManagerImplPrivateTest, ExplicitFallbackToSwiftShaderForGanesh) {
EXPECT_EQ(gpu::GpuMode::HARDWARE_GL, manager->GetGpuMode());
manager->FallBackToNextGpuMode();
EXPECT_EQ(gpu::GpuMode::SWIFTSHADER, manager->GetGpuMode());
EXPECT_EQ(gpu::GpuMode::SOFTWARE_GL, manager->GetGpuMode());
}
TEST_F(GpuDataManagerImplPrivateTest,
@ -587,7 +592,7 @@ TEST_F(GpuDataManagerImplPrivateTest,
manager->FallBackToNextGpuMode();
manager->FallBackToNextGpuMode();
EXPECT_EQ(gpu::GpuMode::SWIFTSHADER, manager->GetGpuMode());
EXPECT_EQ(gpu::GpuMode::SOFTWARE_GL, manager->GetGpuMode());
}
TEST_F(GpuDataManagerImplPrivateTest,
@ -637,7 +642,12 @@ TEST_F(GpuDataManagerImplPrivateTest,
#if !defined(CAST_AUDIO_ONLY)
TEST_F(GpuDataManagerImplPrivateTest, GpuStartsWithGpuDisabled) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(features::kAllowSwiftShaderFallback);
feature_list.InitWithFeatures({}, {
features::kAllowSwiftShaderFallback,
#if BUILDFLAG(IS_WIN)
features::kAllowD3D11WarpFallback,
#endif // BUILDFLAG(IS_WIN)
});
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kDisableGpu);
ScopedGpuDataManagerImplPrivate manager;
@ -680,11 +690,14 @@ TEST_F(GpuDataManagerImplPrivateTest, FallbackFromVulkanToGL) {
TEST_F(GpuDataManagerImplPrivateTest, VulkanInitializationFails) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({features::kVulkan},
{
#if BUILDFLAG(ENABLE_SWIFTSHADER)
{features::kAllowSwiftShaderFallback});
#else
{});
features::kAllowSwiftShaderFallback,
#endif // BUILDFLAG(ENABLE_SWIFTSHADER)
#if BUILDFLAG(IS_WIN)
features::kAllowD3D11WarpFallback,
#endif // BUILDFLAG(IS_WIN)
});
ScopedGpuDataManagerImplPrivate manager;
EXPECT_EQ(gpu::GpuMode::HARDWARE_VULKAN, manager->GetGpuMode());
@ -710,7 +723,12 @@ TEST_F(GpuDataManagerImplPrivateTest, VulkanInitializationFails) {
TEST_F(GpuDataManagerImplPrivateTest, FallbackFromVulkanWithGLDisabled) {
base::test::ScopedFeatureList feature_list;
feature_list.InitWithFeatures({features::kVulkan},
{features::kAllowSwiftShaderFallback});
{
features::kAllowSwiftShaderFallback,
#if BUILDFLAG(IS_WIN)
features::kAllowD3D11WarpFallback,
#endif // BUILDFLAG(IS_WIN)
});
ScopedGpuDataManagerImplPrivate manager;
EXPECT_EQ(gpu::GpuMode::HARDWARE_VULKAN, manager->GetGpuMode());

@ -157,7 +157,10 @@ const char* GetProcessLifetimeUmaName(gpu::GpuMode gpu_mode) {
case gpu::GpuMode::HARDWARE_GRAPHITE:
case gpu::GpuMode::HARDWARE_VULKAN:
return kProcessLifetimeEventsHardwareAccelerated;
case gpu::GpuMode::SWIFTSHADER:
case gpu::GpuMode::SOFTWARE_GL:
// All software modes currently share the SwiftShader metric because we
// cant differentiate different software backends at this level (and
// probably don't want to).
return kProcessLifetimeEventsSwiftShader;
case gpu::GpuMode::DISPLAY_COMPOSITOR:
return nullptr;

@ -313,8 +313,10 @@ class GpuProcessIntegrationTest(gpu_integration_test.GpuIntegrationTest):
def _GpuProcess_feature_status_under_swiftshader(self,
test_path: str) -> None:
# Hit test group 2 with entry 153 from kSoftwareRenderingListEntries.
self.RestartBrowserIfNecessaryWithArgs(
['--gpu-blocklist-test-group=2', '--enable-unsafe-swiftshader'])
self.RestartBrowserIfNecessaryWithArgs([
'--gpu-blocklist-test-group=2', '--enable-unsafe-swiftshader',
'--disable-features=AllowD3D11WarpFallback'
])
self._Navigate(test_path)
feature_status_list = _GetBrowserBridgeProperty(
self.tab, 'gpuInfo.featureStatus.featureStatus')
@ -338,6 +340,32 @@ class GpuProcessIntegrationTest(gpu_integration_test.GpuIntegrationTest):
elif name == '2d_canvas' and status != 'enabled':
self.fail('2D Canvas status for hardware GPU failed: %s' % status)
def _GpuProcess_feature_status_under_warp(self, test_path: str) -> None:
if not host_information.IsWindows():
return
# Hit test group 2 with entry 153 from kSoftwareRenderingListEntries.
self.RestartBrowserIfNecessaryWithArgs([
'--gpu-blocklist-test-group=2',
'--enable-features=AllowD3D11WarpFallback'
])
self._Navigate(test_path)
feature_status_list = _GetBrowserBridgeProperty(
self.tab, 'gpuInfo.featureStatus.featureStatus')
for name, status in feature_status_list.items():
if name == 'webgl' and status != 'unavailable_software':
self.fail('WebGL status for WARP failed: %s' % status)
elif name == '2d_canvas' and status != 'unavailable_software':
self.fail('2D Canvas status for WARP failed: %s' % status)
feature_status_for_hardware_gpu_list = _GetBrowserBridgeProperty(
self.tab, 'gpuInfo.featureStatusForHardwareGpu.featureStatus')
for name, status in feature_status_for_hardware_gpu_list.items():
if name == 'webgl' and status != 'unavailable_off':
self.fail('WebGL status for hardware GPU failed: %s' % status)
elif name == '2d_canvas' and status != 'enabled':
self.fail('2D Canvas status for hardware GPU failed: %s' % status)
def _GpuProcess_one_extra_workaround(self, test_path: str) -> None:
# Start this test by launching the browser with no command line
# arguments.
@ -475,9 +503,15 @@ class GpuProcessIntegrationTest(gpu_integration_test.GpuIntegrationTest):
# attempt to use an API which would start the GPU process.
args_list = (
# Triggering test_group 2 where WebGL is blocklisted.
['--gpu-blocklist-test-group=2', '--enable-unsafe-swiftshader'],
[
'--gpu-blocklist-test-group=2', '--enable-unsafe-swiftshader',
'--disable-features=AllowD3D11WarpFallback'
],
# Explicitly disable GPU access.
[cba.DISABLE_GPU, '--enable-unsafe-swiftshader'])
[
cba.DISABLE_GPU, '--enable-unsafe-swiftshader',
'--disable-features=AllowD3D11WarpFallback'
])
for args in args_list:
self.RestartBrowserIfNecessaryWithArgs(args)
self._NavigateAndWait(test_path)
@ -526,13 +560,78 @@ class GpuProcessIntegrationTest(gpu_integration_test.GpuIntegrationTest):
if tab.EvaluateJavaScript('!gl_context.getExtension("' + ext + '")'):
self.fail('Expected %s support' % ext)
def _GpuProcess_warp_for_webgl(self, test_path: str) -> None:
if not host_information.IsWindows():
return
# This test loads functional_webgl.html so that there is a deliberate
# attempt to use an API which would start the GPU process.
# WARP fallback is preferred over SwiftShader if both are enabled.
args_list = (
# Triggering test_group 2 where WebGL is blocklisted.
[
'--gpu-blocklist-test-group=2',
'--enable-features=AllowD3D11WarpFallback'
],
# Explicitly disable GPU access.
[cba.DISABLE_GPU, '--enable-features=AllowD3D11WarpFallback'])
for args in args_list:
self.RestartBrowserIfNecessaryWithArgs(args)
self._NavigateAndWait(test_path)
# Validate the WebGL unmasked renderer string.
renderer = self.tab.EvaluateJavaScript('gl_renderer')
if not renderer:
self.fail('getParameter(UNMASKED_RENDERER_WEBGL) was null')
if 'WARP' not in renderer:
self.fail('Expected WARP renderer; instead got ' + renderer)
# Validate GPU info.
system_info = self.browser.GetSystemInfo()
if not system_info:
self.fail("Browser doesn't support GetSystemInfo")
gpu = system_info.gpu
if not gpu:
self.fail('Target machine must have a GPU')
if not gpu.aux_attributes:
self.fail('Browser must support GPU aux attributes')
if 'WARP' not in gpu.aux_attributes['gl_renderer']:
self.fail('Expected "WARP" in GPU info GL renderer string')
if 'Google' not in gpu.aux_attributes['gl_vendor']:
self.fail('Expected "Google" in GPU info GL vendor string')
device = gpu.devices[0]
if not device:
self.fail("System Info doesn't have a device")
# Validate extensions.
ext_list = [
'ANGLE_instanced_arrays',
'EXT_blend_minmax',
'EXT_texture_filter_anisotropic',
'OES_element_index_uint',
'OES_standard_derivatives',
'OES_texture_float',
'OES_texture_float_linear',
'OES_texture_half_float',
'OES_texture_half_float_linear',
'OES_vertex_array_object',
'WEBGL_compressed_texture_etc1',
'WEBGL_debug_renderer_info',
'WEBGL_depth_texture',
'WEBGL_draw_buffers',
'WEBGL_lose_context',
]
tab = self.tab
for ext in ext_list:
if tab.EvaluateJavaScript('!gl_context.getExtension("' + ext + '")'):
self.fail('Expected %s support' % ext)
def _GpuProcess_no_swiftshader_for_webgl_without_flags(
self, test_path: str) -> None:
# This test loads functional_webgl.html with GPU disabled and verifies that
# SwiftShader is not available without the --enable-unsafe-swiftshader flag
# or AllowSwiftShaderFallback killswitch.
# Because AllowSwiftShaderFallback is currently enabled by default, disable
# it to test the upcoming default behavior
# it to test the upcoming default behavior.
# Make sure to force disable WARP fallback which takes precedence over
# SwiftShader fallback when both are enabled.
disable_hardware_webgl_args_list = [
# Triggering test_group 2 where WebGL is blocklisted.
['--gpu-blocklist-test-group=2'],
@ -540,12 +639,22 @@ class GpuProcessIntegrationTest(gpu_integration_test.GpuIntegrationTest):
[cba.DISABLE_GPU],
]
disable_swiftshader_fallback_feature = [
'--disable-features=AllowSwiftShaderFallback'
'--disable-features=AllowSwiftShaderFallback',
'--disable-features=AllowD3D11WarpFallback'
]
allow_swiftshader_args_list = [
['--enable-unsafe-swiftshader'],
['--use-gl=angle', '--use-angle=swiftshader'],
['--enable-features=AllowSwiftShaderFallback']
[
'--enable-unsafe-swiftshader',
'--disable-features=AllowD3D11WarpFallback'
],
[
'--use-gl=angle', '--use-angle=swiftshader',
'--disable-features=AllowD3D11WarpFallback'
],
[
'--enable-features=AllowSwiftShaderFallback',
'--disable-features=AllowD3D11WarpFallback'
]
]
for disable_hardware_webgl_args in disable_hardware_webgl_args_list:
self.RestartBrowserIfNecessaryWithArgs(

@ -113,6 +113,8 @@ class PixelIntegrationTest(sghitb.SkiaGoldHeartbeatIntegrationTestBase):
if host_information.IsLinux() or (host_information.IsWindows()
and not host_information.IsArmCpu()):
pages += namespace.SwiftShaderPages(cls.test_base_name)
if host_information.IsWindows():
pages += namespace.WARPPages(cls.test_base_name)
for p in pages:
yield (p.name, posixpath.join(gpu_path_util.GPU_DATA_RELATIVE_PATH,
p.url), [p])

@ -1004,7 +1004,10 @@ class PixelTestPages():
# Currently this is Windows and Linux.
@staticmethod
def SwiftShaderPages(base_name: str) -> List[PixelTestPage]:
browser_args = [cba.DISABLE_GPU]
browser_args = [
cba.DISABLE_GPU, '--enable-features=AllowSwiftShaderFallback',
'--disable-features=AllowD3D11WarpFallback'
]
suffix = '_SwiftShader'
standard_crop = ca.NonWhiteContentCropAction(
initial_crop=ca.FixedRectCropAction(0, 0, 350, 350))
@ -1027,6 +1030,36 @@ class PixelTestPages():
browser_args=browser_args),
]
# Only add these tests on platforms where D3D11 WARP is enabled.
# Currently this is Windows.
@staticmethod
def WARPPages(base_name: str) -> List[PixelTestPage]:
browser_args = [
cba.DISABLE_GPU, '--disable-features=AllowSwiftShaderFallback',
'--enable-features=AllowD3D11WarpFallback'
]
suffix = '_WARP'
standard_crop = ca.NonWhiteContentCropAction(
initial_crop=ca.FixedRectCropAction(0, 0, 350, 350))
return [
PixelTestPage('pixel_canvas2d.html',
base_name + '_Canvas2DRedBox' + suffix,
crop_action=standard_crop,
browser_args=browser_args),
PixelTestPage('pixel_css3d.html',
base_name + '_CSS3DBlueBox' + suffix,
crop_action=standard_crop,
browser_args=browser_args),
PixelTestPage('pixel_webgl_aa_alpha.html',
base_name + '_WebGLGreenTriangle_AA_Alpha' + suffix,
crop_action=standard_crop,
browser_args=browser_args),
PixelTestPage('pixel_repeated_webgl_to_2d.html',
base_name + '_RepeatedWebGLTo2D' + suffix,
crop_action=standard_crop,
browser_args=browser_args),
]
# Test rendering where GPU process is blocked.
@staticmethod
def NoGpuProcessPages(base_name: str) -> List[PixelTestPage]:

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -28,6 +28,7 @@
# cros-chrome ]
# GPU
# tags: [ amd amd-0x6613 amd-0x679e amd-0x67ef amd-0x6821 amd-0x7340 amd-0x7480
# amd64
# apple apple-apple-m1 apple-apple-m2
# apple-angle-metal-renderer:-apple-m1
# apple-angle-metal-renderer:-apple-m2
@ -36,6 +37,7 @@
# imagination
# intel intel-gen-9 intel-gen-12 intel-0xa2e intel-0xd26 intel-0xa011
# intel-0x3e92 intel-0x3e9b intel-0x4680 intel-0x5912 intel-0x9bc5
# microsoft microsoft-0xffff
# nvidia nvidia-0xfe9 nvidia-0x1cb3 nvidia-0x2184 nvidia-0x2783
# qualcomm qualcomm-0x41333430 qualcomm-0x36333630 qualcomm-0x36334330 ]
# Architecture

@ -79,6 +79,7 @@ TAG_SPECIALIZATIONS = {
'amd-0x7340',
'amd-0x7480',
],
'amd64': [],
'apple': [
'apple-apple-m1',
'apple-apple-m2',
@ -106,6 +107,9 @@ TAG_SPECIALIZATIONS = {
'intel-0x5912',
'intel-0x9bc5',
],
'microsoft': [
'microsoft-0xffff',
],
'nvidia': [
'nvidia-0xfe9',
'nvidia-0x1cb3',

@ -215,7 +215,9 @@ void WebTestBrowserMainRunner::Initialize() {
// only default to a software GL if the flag isn't already specified.
if (!command_line.HasSwitch(switches::kUseGpuInTests) &&
!command_line.HasSwitch(switches::kUseGL)) {
gl::SetSoftwareGLCommandLineSwitches(&command_line);
gl::SetGLImplementationCommandLineSwitches(
gl::GLImplementationParts(gl::ANGLEImplementation::kSwiftShader),
&command_line);
}
}
command_line.AppendSwitchASCII(switches::kTouchEventFeatureDetection,

@ -223,9 +223,10 @@ void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) {
const auto useGL = command_line->GetSwitchValueASCII(switches::kUseGL);
const auto useANGLE = command_line->GetSwitchValueASCII(switches::kUseANGLE);
feature_flags_.is_swiftshader_for_webgl =
feature_flags_.is_software_webgl =
(useGL == gl::kGLImplementationANGLEName) &&
(useANGLE == gl::kANGLEImplementationSwiftShaderForWebGLName);
(useANGLE == gl::kANGLEImplementationSwiftShaderForWebGLName ||
useANGLE == gl::kANGLEImplementationD3D11WarpForWebGLName);
// The shader translator is needed to translate from WebGL-conformant GLES SL
// to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to

@ -86,7 +86,7 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool map_buffer_range = false;
bool ext_discard_framebuffer = false;
bool angle_depth_texture = false;
bool is_swiftshader_for_webgl = false;
bool is_software_webgl = false;
bool angle_texture_usage = false;
bool ext_texture_storage = false;
bool blend_equation_advanced = false;

@ -2991,11 +2991,11 @@ gpu::ContextResult GLES2DecoderImpl::Initialize(
// If the failIfMajorPerformanceCaveat context creation attribute was true
// and we are using a software renderer, fail.
if (attrib_helper.fail_if_major_perf_caveat &&
feature_info_->feature_flags().is_swiftshader_for_webgl) {
feature_info_->feature_flags().is_software_webgl) {
// Must not destroy ContextGroup if it is not initialized.
group_ = nullptr;
LOG(ERROR) << "ContextResult::kFatalFailure: "
"fail_if_major_perf_caveat + swiftshader";
"fail_if_major_perf_caveat + software gl";
return gpu::ContextResult::kFatalFailure;
}

@ -952,8 +952,8 @@ gpu::ContextResult GLES2DecoderPassthroughImpl::Initialize(
FAIL_INIT_IF_NOT(feature_info_->feature_flags().khr_debug,
"missing GL_KHR_debug");
FAIL_INIT_IF_NOT(!attrib_helper.fail_if_major_perf_caveat ||
!feature_info_->feature_flags().is_swiftshader_for_webgl,
"fail_if_major_perf_caveat + swiftshader");
!feature_info_->feature_flags().is_software_webgl,
"fail_if_major_perf_caveat + software gl");
FAIL_INIT_IF_NOT(!attrib_helper.enable_gpu_rasterization,
"GPU rasterization not supported");
FAIL_INIT_IF_NOT(!IsES31ForTestingContextType(attrib_helper.context_type) ||

@ -198,6 +198,8 @@ std::string GetDisplayTypeString(gl::DisplayType type) {
return "ANGLE_METAL";
case gl::ANGLE_METAL_NULL:
return "ANGLE_METAL_NULL";
case gl::ANGLE_D3D11_WARP:
return "ANGLE_D3D11_WARP";
default:
NOTREACHED();
}

@ -16,8 +16,8 @@ enum class GpuMode {
HARDWARE_VULKAN,
// The GPU process is running with hardware acceleration, using Graphite-Dawn.
HARDWARE_GRAPHITE,
// The GPU process is running for SwiftShader WebGL.
SWIFTSHADER,
// The GPU process is running for software WebGL.
SOFTWARE_GL,
// The GPU process is running for the display compositor.
DISPLAY_COMPOSITOR,
};

@ -459,7 +459,7 @@ GpuFeatureInfo ComputeGpuFeatureInfoWithNoGpu() {
return gpu_feature_info;
}
GpuFeatureInfo ComputeGpuFeatureInfoForSwiftShader() {
GpuFeatureInfo ComputeGpuFeatureInfoForSoftwareGL() {
GpuFeatureInfo gpu_feature_info;
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS] =
kGpuFeatureStatusSoftware;
@ -498,7 +498,7 @@ GpuFeatureInfo ComputeGpuFeatureInfo(const GPUInfo& gpu_info,
base::CommandLine* command_line,
bool* needs_more_info) {
GPU_STARTUP_TRACE_EVENT("gpu_util::ComputeGpuFeatureInfo");
bool use_swift_shader = false;
bool use_software_gl = false;
bool blocklist_needs_more_info = false;
std::optional<gl::GLImplementationParts> requested_impl =
@ -507,20 +507,21 @@ GpuFeatureInfo ComputeGpuFeatureInfo(const GPUInfo& gpu_info,
if (*requested_impl == gl::kGLImplementationNone)
return ComputeGpuFeatureInfoWithNoGpu();
use_swift_shader = gl::IsSoftwareGLImplementation(*requested_impl);
if (use_swift_shader) {
use_software_gl = gl::IsSoftwareGLImplementation(*requested_impl);
if (use_software_gl) {
std::string use_gl = command_line->GetSwitchValueASCII(switches::kUseGL);
std::string use_angle =
command_line->GetSwitchValueASCII(switches::kUseANGLE);
if (use_angle == gl::kANGLEImplementationSwiftShaderForWebGLName) {
return ComputeGpuFeatureInfoForSwiftShader();
if (use_angle == gl::kANGLEImplementationSwiftShaderForWebGLName ||
use_angle == gl::kANGLEImplementationD3D11WarpName) {
return ComputeGpuFeatureInfoForSoftwareGL();
}
}
}
if (gpu_preferences.use_vulkan ==
gpu::VulkanImplementationName::kSwiftshader) {
use_swift_shader = true;
use_software_gl = true;
}
GpuFeatureInfo gpu_feature_info;
@ -553,33 +554,33 @@ GpuFeatureInfo ComputeGpuFeatureInfo(const GPUInfo& gpu_info,
#if !BUILDFLAG(IS_CHROMEOS)
gpu_feature_info.status_values[GPU_FEATURE_TYPE_GPU_TILE_RASTERIZATION] =
GetGpuRasterizationFeatureStatus(blocklisted_features, *command_line,
use_swift_shader);
use_software_gl);
#else
// TODO(penghuang): call GetGpuRasterizationFeatureStatus() with
// |use_swift_shader|.
// |use_software_gl|.
gpu_feature_info.status_values[GPU_FEATURE_TYPE_GPU_TILE_RASTERIZATION] =
GetGpuRasterizationFeatureStatus(blocklisted_features, *command_line,
/*use_swift_shader=*/false);
/*use_software_gl=*/false);
#endif
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL] =
GetWebGLFeatureStatus(blocklisted_features, use_swift_shader);
GetWebGLFeatureStatus(blocklisted_features, use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGL2] =
GetWebGL2FeatureStatus(blocklisted_features, use_swift_shader);
GetWebGL2FeatureStatus(blocklisted_features, use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_WEBGPU] =
GetWebGPUFeatureStatus(blocklisted_features, use_swift_shader);
GetWebGPUFeatureStatus(blocklisted_features, use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS] =
Get2DCanvasFeatureStatus(blocklisted_features, use_swift_shader);
Get2DCanvasFeatureStatus(blocklisted_features, use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_VIDEO_DECODE] =
GetAcceleratedVideoDecodeFeatureStatus(blocklisted_features,
use_swift_shader);
use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_VIDEO_ENCODE] =
GetAcceleratedVideoEncodeFeatureStatus(blocklisted_features,
use_swift_shader);
use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ANDROID_SURFACE_CONTROL] =
GetAndroidSurfaceControlFeatureStatus(blocklisted_features,
gpu_preferences);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_ACCELERATED_GL] =
GetGLFeatureStatus(blocklisted_features, use_swift_shader);
GetGLFeatureStatus(blocklisted_features, use_software_gl);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_VULKAN] =
GetVulkanFeatureStatus(blocklisted_features, gpu_preferences);
gpu_feature_info.status_values[GPU_FEATURE_TYPE_SKIA_GRAPHITE] =

@ -25,8 +25,8 @@ enum class IntelGpuGeneration;
// Set GPU feature status if GPU is blocked.
GPU_EXPORT GpuFeatureInfo ComputeGpuFeatureInfoWithNoGpu();
// Set GPU feature status for SwiftShader.
GPU_EXPORT GpuFeatureInfo ComputeGpuFeatureInfoForSwiftShader();
// Set GPU feature status for software GL implementations.
GPU_EXPORT GpuFeatureInfo ComputeGpuFeatureInfoForSoftwareGL();
// This function should only be called from the GPU process, or the Browser
// process while using in-process GPU. This function is safe to call at any

@ -1158,7 +1158,7 @@ void GpuInit::SaveHardwareGpuInfoAndGpuFeatureInfo() {
void GpuInit::AdjustInfoToSwiftShader() {
gpu_info_.passthrough_cmd_decoder = false;
gpu_feature_info_ = ComputeGpuFeatureInfoForSwiftShader();
gpu_feature_info_ = ComputeGpuFeatureInfoForSoftwareGL();
CollectContextGraphicsInfo(&gpu_info_);
DCHECK_EQ(gpu_info_.passthrough_cmd_decoder, false);

@ -204,6 +204,7 @@ enum class WebGLANGLEImplementation {
kWebGL1_SwiftShader = 7,
kWebGL1_Metal = 8,
kWebGL1_Default = 9,
kWebGL1_D3D11Warp = 10,
// Leave some space between WebGL1 and WebGL2 enums in case ANGLE has
// new implementations, say ANGLE/Dawn.
@ -218,8 +219,9 @@ enum class WebGLANGLEImplementation {
kWebGL2_SwiftShader = 27,
kWebGL2_Metal = 28,
kWebGL2_Default = 29,
kWebGL2_D3D11Warp = 30,
kMaxValue = kWebGL2_Default,
kMaxValue = kWebGL2_D3D11Warp,
};
constexpr base::TimeDelta kDurationBetweenRestoreAttempts = base::Seconds(1);

@ -7940,6 +7940,7 @@ Called by update_use_counter_feature_enum.py.-->
<int value="7" label="WebGL1, SwiftShader"/>
<int value="8" label="WebGL1, Metal"/>
<int value="9" label="WebGL1, Default"/>
<int value="10" label="WebGL1, D3D11Warp"/>
<int value="20" label="WebGL2, None"/>
<int value="21" label="WebGL2, D3D9 (should never happen)"/>
<int value="22" label="WebGL2, D3D11"/>
@ -7950,6 +7951,7 @@ Called by update_use_counter_feature_enum.py.-->
<int value="27" label="WebGL2, SwiftShader"/>
<int value="28" label="WebGL2, Metal"/>
<int value="29" label="WebGL2, Default"/>
<int value="30" label="WebGL2, D3D11Warp"/>
</enum>
<enum name="WebOTPBackendAvailability">

@ -414,6 +414,7 @@ chromium-metrics-reviews@google.com.
<int value="16" label="ANGLE OpenGL ES EGL"/>
<int value="17" label="ANGLE Metal"/>
<int value="18" label="ANGLE Metal NULL"/>
<int value="19" label="ANGLE D3D11 WARP"/>
</enum>
<enum name="FrameIntervalMatcherType">

@ -18,7 +18,8 @@ enum class ANGLEImplementation {
kSwiftShader = 7,
kMetal = 8,
kDefault = 9,
kMaxValue = kDefault,
kD3D11Warp = 10,
kMaxValue = kD3D11Warp,
};
} // namespace gl

@ -202,7 +202,7 @@ bool GLContextEGL::InitializeImpl(GLSurface* compatible_surface,
DCHECK(context_client_minor_version == 0);
}
bool is_swangle = IsSoftwareGLImplementation(GetGLImplementationParts());
bool is_swangle = IsSwiftShaderGLImplementation(GetGLImplementationParts());
if (attribs.webgl_compatibility_context && is_swangle &&
IsARMSwiftShaderPlatform() &&

@ -20,6 +20,8 @@
#include "base/synchronization/atomic_flag.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "gl_display.h"
#include "gl_switches.h"
#include "ui/base/ozone_buildflags.h"
#include "ui/gl/angle_platform_impl.h"
#include "ui/gl/egl_util.h"
@ -286,6 +288,13 @@ EGLDisplay GetDisplayFromType(
return GetPlatformANGLEDisplay(
display, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, enabled_angle_features,
disabled_angle_features, extra_display_attribs);
case ANGLE_D3D11_WARP:
extra_display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
extra_display_attribs.push_back(
EGL_PLATFORM_ANGLE_DEVICE_TYPE_D3D_WARP_ANGLE);
return GetPlatformANGLEDisplay(
display, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, enabled_angle_features,
disabled_angle_features, extra_display_attribs);
case ANGLE_D3D11_NULL:
extra_display_attribs.push_back(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE);
extra_display_attribs.push_back(
@ -389,6 +398,8 @@ ANGLEImplementation GetANGLEImplementationFromDisplayType(
case ANGLE_D3D11_NULL:
case ANGLE_D3D11on12:
return ANGLEImplementation::kD3D11;
case ANGLE_D3D11_WARP:
return ANGLEImplementation::kD3D11Warp;
case ANGLE_OPENGL:
case ANGLE_OPENGL_EGL:
case ANGLE_OPENGL_NULL:
@ -422,6 +433,8 @@ const char* DisplayTypeString(DisplayType display_type) {
return "D3D9";
case ANGLE_D3D11:
return "D3D11";
case ANGLE_D3D11_WARP:
return "D3D11Warp";
case ANGLE_D3D11_NULL:
return "D3D11Null";
case ANGLE_OPENGL:

@ -45,7 +45,8 @@ class EGLDisplayPlatform {
};
// If adding a new type, also add it to EGLDisplayType in
// tools/metrics/histograms/enums.xml. Don't remove or reorder entries.
// tools/metrics/histograms/metadata/gpu/enums.xml. Don't remove or reorder
// entries.
enum DisplayType {
DEFAULT = 0,
SWIFT_SHADER = 1,
@ -66,7 +67,8 @@ enum DisplayType {
ANGLE_OPENGLES_EGL = 16,
ANGLE_METAL = 17,
ANGLE_METAL_NULL = 18,
DISPLAY_TYPE_MAX = 19,
ANGLE_D3D11_WARP = 19,
DISPLAY_TYPE_MAX = 20,
};
enum DisplayPlatform {

@ -348,6 +348,22 @@ bool IsSwiftShaderAllowed(const base::CommandLine* command_line) {
IsSwiftShaderAllowedByFeature();
}
#if BUILDFLAG(IS_WIN)
BASE_FEATURE(kAllowD3D11WarpFallback,
"AllowD3D11WarpFallback",
base::FEATURE_DISABLED_BY_DEFAULT);
#endif
bool IsAnySoftwareGLAllowed(const base::CommandLine* command_line) {
#if BUILDFLAG(IS_WIN)
if (base::FeatureList::IsEnabled(kAllowD3D11WarpFallback)) {
return true;
}
#endif
return IsSwiftShaderAllowed(command_line);
}
base::TimeDelta GetGLCompileShaderDelay() {
#if BUILDFLAG(ENABLE_VALIDATING_COMMAND_DECODER)
if (UsePassthroughCommandDecoder()) {

@ -66,6 +66,13 @@ GL_EXPORT bool IsSwiftShaderAllowedByFeature();
// IsSwiftShaderAllowedByFeature.
GL_EXPORT bool IsSwiftShaderAllowed(const base::CommandLine* command_line);
#if BUILDFLAG(IS_WIN)
GL_EXPORT BASE_DECLARE_FEATURE(kAllowD3D11WarpFallback);
#endif
// Check if any form of software WebGL fallback is available
GL_EXPORT bool IsAnySoftwareGLAllowed(const base::CommandLine* command_line);
// Query the delay we add to glCompileShader.
// Default is 0 if kAddDelayToGLCompileShader is off.
GL_EXPORT base::TimeDelta GetGLCompileShaderDelay();

@ -20,6 +20,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "ui/gl/angle_implementation.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_features.h"
@ -109,6 +110,8 @@ std::string GLImplementationParts::ANGLEString() const {
return "swiftshader";
case ANGLEImplementation::kMetal:
return "metal";
case ANGLEImplementation::kD3D11Warp:
return "d3d11-warp";
case ANGLEImplementation::kDefault:
return "default";
}
@ -134,6 +137,10 @@ const struct {
GLImplementationParts(ANGLEImplementation::kD3D11)},
{kGLImplementationANGLEName, kANGLEImplementationD3D11on12Name,
GLImplementationParts(ANGLEImplementation::kD3D11)},
{kGLImplementationANGLEName, kANGLEImplementationD3D11WarpName,
GLImplementationParts(ANGLEImplementation::kD3D11Warp)},
{kGLImplementationANGLEName, kANGLEImplementationD3D11WarpForWebGLName,
GLImplementationParts(ANGLEImplementation::kD3D11Warp)},
{kGLImplementationANGLEName, kANGLEImplementationD3D11NULLName,
GLImplementationParts(ANGLEImplementation::kD3D11)},
{kGLImplementationANGLEName, kANGLEImplementationOpenGLName,
@ -226,22 +233,49 @@ GLImplementationParts GetNamedGLImplementation(const std::string& gl_name,
}
GLImplementationParts GetSoftwareGLImplementation() {
#if BUILDFLAG(IS_WIN)
if (base::FeatureList::IsEnabled(features::kAllowD3D11WarpFallback)) {
return GLImplementationParts(ANGLEImplementation::kD3D11Warp);
}
#endif
return GLImplementationParts(ANGLEImplementation::kSwiftShader);
}
bool IsSoftwareGLImplementation(GLImplementationParts implementation) {
return (implementation == GetSoftwareGLImplementation());
return implementation.angle == ANGLEImplementation::kSwiftShader ||
implementation.angle == ANGLEImplementation::kD3D11Warp;
}
void SetSoftwareGLCommandLineSwitches(base::CommandLine* command_line) {
GLImplementationParts implementation = GetSoftwareGLImplementation();
GL_EXPORT bool IsSwiftShaderGLImplementation(
GLImplementationParts implementation) {
return implementation.angle == ANGLEImplementation::kSwiftShader;
}
void SetGLImplementationCommandLineSwitches(
const GLImplementationParts& implementation,
base::CommandLine* command_line) {
command_line->AppendSwitchASCII(
switches::kUseGL, gl::GetGLImplementationGLName(implementation));
command_line->AppendSwitchASCII(
switches::kUseANGLE, gl::GetGLImplementationANGLEName(implementation));
}
void SetSoftwareGLCommandLineSwitches(base::CommandLine* command_line) {
GLImplementationParts implementation = GetSoftwareGLImplementation();
SetGLImplementationCommandLineSwitches(implementation, command_line);
}
void SetSoftwareWebGLCommandLineSwitches(base::CommandLine* command_line) {
#if BUILDFLAG(IS_WIN)
if (base::FeatureList::IsEnabled(features::kAllowD3D11WarpFallback)) {
command_line->AppendSwitchASCII(switches::kUseGL,
kGLImplementationANGLEName);
command_line->AppendSwitchASCII(switches::kUseANGLE,
kANGLEImplementationD3D11WarpForWebGLName);
return;
}
#endif
command_line->AppendSwitchASCII(switches::kUseGL, kGLImplementationANGLEName);
command_line->AppendSwitchASCII(switches::kUseANGLE,
kANGLEImplementationSwiftShaderForWebGLName);
@ -281,11 +315,6 @@ GetRequestedGLImplementationFromCommandLine(
gl_name = kGLImplementationANGLEName;
}
if ((gl_name == kGLImplementationANGLEName) &&
((angle_name == kANGLEImplementationSwiftShaderName) ||
(angle_name == kANGLEImplementationSwiftShaderForWebGLName))) {
return GLImplementationParts(ANGLEImplementation::kSwiftShader);
}
return GetNamedGLImplementation(gl_name, angle_name);
}

@ -167,6 +167,11 @@ GL_EXPORT ANGLEImplementation GetANGLEImplementation();
// Get the software GL implementation
GL_EXPORT GLImplementationParts GetSoftwareGLImplementation();
// Set the command line flags to request the provided GL implementation
GL_EXPORT void SetGLImplementationCommandLineSwitches(
const GLImplementationParts& implementation,
base::CommandLine* command_line);
// Set the software GL implementation on the provided command line
GL_EXPORT void SetSoftwareGLCommandLineSwitches(
base::CommandLine* command_line);
@ -184,6 +189,9 @@ GetRequestedGLImplementationFromCommandLine(
// Whether the implementation is one of the software GL implementations
GL_EXPORT bool IsSoftwareGLImplementation(GLImplementationParts implementation);
GL_EXPORT bool IsSwiftShaderGLImplementation(
GLImplementationParts implementation);
// Get the GL implementation with a given name.
GL_EXPORT GLImplementationParts
GetNamedGLImplementation(const std::string& gl_name,

@ -30,6 +30,8 @@ const char kANGLEImplementationDefaultName[] = "default";
const char kANGLEImplementationD3D9Name[] = "d3d9";
const char kANGLEImplementationD3D11Name[] = "d3d11";
const char kANGLEImplementationD3D11on12Name[] = "d3d11on12";
const char kANGLEImplementationD3D11WarpName[] = "d3d11-warp";
const char kANGLEImplementationD3D11WarpForWebGLName[] = "d3d11-warp-webgl";
const char kANGLEImplementationOpenGLName[] = "gl";
const char kANGLEImplementationOpenGLEGLName[] = "gl-egl";
const char kANGLEImplementationOpenGLESName[] = "gles";

@ -26,6 +26,8 @@ GL_EXPORT extern const char kANGLEImplementationDefaultName[];
GL_EXPORT extern const char kANGLEImplementationD3D9Name[];
GL_EXPORT extern const char kANGLEImplementationD3D11Name[];
GL_EXPORT extern const char kANGLEImplementationD3D11on12Name[];
GL_EXPORT extern const char kANGLEImplementationD3D11WarpName[];
GL_EXPORT extern const char kANGLEImplementationD3D11WarpForWebGLName[];
GL_EXPORT extern const char kANGLEImplementationOpenGLName[];
GL_EXPORT extern const char kANGLEImplementationOpenGLEGLName[];
GL_EXPORT extern const char kANGLEImplementationOpenGLESName[];

@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_features.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/init/gl_factory.h"
@ -44,6 +45,12 @@ void GetEGLInitDisplays(bool supports_angle_d3d,
bool default_angle_metal =
base::FeatureList::IsEnabled(features::kDefaultANGLEMetal);
bool default_angle_vulkan = features::IsDefaultANGLEVulkan();
const char* default_software_renderer = kANGLEImplementationSwiftShaderName;
#if BUILDFLAG(IS_WIN)
if (base::FeatureList::IsEnabled(features::kAllowD3D11WarpFallback)) {
default_software_renderer = kANGLEImplementationD3D11WarpName;
}
#endif
// If we're already requesting software GL, make sure we don't fallback to the
// GPU
@ -52,7 +59,7 @@ void GetEGLInitDisplays(bool supports_angle_d3d,
std::string requested_renderer =
force_software_gl
? kANGLEImplementationSwiftShaderName
? default_software_renderer
: command_line->GetSwitchValueASCII(switches::kUseANGLE);
bool use_angle_default =
@ -101,6 +108,8 @@ void GetEGLInitDisplays(bool supports_angle_d3d,
AddInitDisplay(init_displays, ANGLE_D3D11_NULL);
} else if (requested_renderer == kANGLEImplementationD3D11on12Name) {
AddInitDisplay(init_displays, ANGLE_D3D11on12);
} else if (requested_renderer == kANGLEImplementationD3D11WarpName) {
AddInitDisplay(init_displays, ANGLE_D3D11_WARP);
}
}
}

@ -25,6 +25,7 @@ enum ANGLEImplementation {
kVulkan,
kSwiftShader,
kMetal,
kD3D11Warp,
kDefault,
};
@ -34,4 +35,4 @@ struct GLImplementationParts {
GLImplementation gl;
// The ANGLE implementation currently in use.
ANGLEImplementation angle;
};
};

@ -78,6 +78,8 @@ EnumTraits<gl::mojom::ANGLEImplementation, gl::ANGLEImplementation>::ToMojom(
return gl::mojom::ANGLEImplementation::kSwiftShader;
case gl::ANGLEImplementation::kMetal:
return gl::mojom::ANGLEImplementation::kMetal;
case gl::ANGLEImplementation::kD3D11Warp:
return gl::mojom::ANGLEImplementation::kD3D11Warp;
case gl::ANGLEImplementation::kDefault:
return gl::mojom::ANGLEImplementation::kDefault;
}
@ -116,6 +118,9 @@ bool EnumTraits<gl::mojom::ANGLEImplementation, gl::ANGLEImplementation>::
case gl::mojom::ANGLEImplementation::kMetal:
*out = gl::ANGLEImplementation::kMetal;
return true;
case gl::mojom::ANGLEImplementation::kD3D11Warp:
*out = gl::ANGLEImplementation::kD3D11Warp;
return true;
case gl::mojom::ANGLEImplementation::kDefault:
*out = gl::ANGLEImplementation::kDefault;
return true;