Commit 04b8bcdc authored by Jiawei Shao's avatar Jiawei Shao Committed by Commit Bot

WebGPU: Support command line parameters to enable/disable Dawn Toggles

This patch adds the support of forcing enabling and disabling Dawn
Toggles through command line parameters "--enable-dawn-features"
and "--disable-dawn-features". Each toggles are separated by ",".

e.g.
--enable-dawn-features=use_d3d12_render_pass,disable_robustness
--disable-dawn-features=lazy_clear_resource_on_first_use

This patch also removes the support of the command line parameter
"--disable-dawn-robustness" as now its functionality can be replaced by
"--enable-dawn-features=disable_robustness".

BUG=dawn:480

Change-Id: If8c4fcc7d29f83c5c583b285439e4df73e714764
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2529009Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAustin Eng <enga@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Cr-Commit-Position: refs/heads/master@{#827520}
parent a053ee49
......@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/context_group.h"
......@@ -163,8 +164,16 @@ GpuPreferences ParseGpuPreferences(const base::CommandLine* command_line) {
command_line->HasSwitch(switches::kEnableUnsafeWebGPU);
gpu_preferences.enable_dawn_backend_validation =
command_line->HasSwitch(switches::kEnableDawnBackendValidation);
gpu_preferences.disable_dawn_robustness =
command_line->HasSwitch(switches::kDisableDawnRobustness);
if (command_line->HasSwitch(switches::kEnableDawnFeatures)) {
gpu_preferences.enabled_dawn_features_list = base::SplitString(
command_line->GetSwitchValueASCII(switches::kEnableDawnFeatures), ",",
base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
}
if (command_line->HasSwitch(switches::kDisableDawnFeatures)) {
gpu_preferences.disabled_dawn_features_list = base::SplitString(
command_line->GetSwitchValueASCII(switches::kDisableDawnFeatures), ",",
base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
}
gpu_preferences.gr_context_type = ParseGrContextType();
gpu_preferences.use_vulkan = ParseVulkanImplementationName(command_line);
gpu_preferences.disable_vulkan_surface =
......
......@@ -583,7 +583,8 @@ class WebGPUDecoderImpl final : public WebGPUDecoder {
std::unique_ptr<dawn_native::Instance> dawn_instance_;
std::vector<dawn_native::Adapter> dawn_adapters_;
bool disable_dawn_robustness_;
std::vector<std::string> force_enabled_toggles_;
std::vector<std::string> force_disabled_toggles_;
DISALLOW_COPY_AND_ASSIGN(WebGPUDecoderImpl);
};
......@@ -627,11 +628,13 @@ WebGPUDecoderImpl::WebGPUDecoderImpl(
memory_tracker)),
dawn_platform_(new DawnPlatform()),
memory_transfer_service_(new DawnServiceMemoryTransferService(this)),
dawn_instance_(new dawn_native::Instance()),
disable_dawn_robustness_(gpu_preferences.disable_dawn_robustness) {
dawn_instance_(new dawn_native::Instance()) {
dawn_instance_->SetPlatform(dawn_platform_.get());
dawn_instance_->EnableBackendValidation(
gpu_preferences.enable_dawn_backend_validation);
force_enabled_toggles_ = gpu_preferences.enabled_dawn_features_list;
force_disabled_toggles_ = gpu_preferences.disabled_dawn_features_list;
}
WebGPUDecoderImpl::~WebGPUDecoderImpl() {
......@@ -673,8 +676,11 @@ error::Error WebGPUDecoderImpl::InitDawnDeviceAndSetWireServer(
device_descriptor.requiredExtensions.push_back("timestamp_query");
}
if (disable_dawn_robustness_) {
device_descriptor.forceEnabledToggles.push_back("disable_robustness");
for (const std::string& toggles : force_enabled_toggles_) {
device_descriptor.forceEnabledToggles.push_back(toggles.c_str());
}
for (const std::string& toggles : force_disabled_toggles_) {
device_descriptor.forceDisabledToggles.push_back(toggles.c_str());
}
WGPUDevice wgpu_device =
......
......@@ -243,10 +243,11 @@ struct GPU_EXPORT GpuPreferences {
// Enable validation layers in Dawn backends.
bool enable_dawn_backend_validation = false;
// Enable the toggle Toggle::DisableRobustness when creating Dawn device for
// the investigation of the performance issues related to the implementation
// of robustness in Dawn.
bool disable_dawn_robustness = false;
// The Dawn features(toggles) enabled on the creation of Dawn devices.
std::vector<std::string> enabled_dawn_features_list;
// The Dawn features(toggles) disabled on the creation of Dawn devices.
std::vector<std::string> disabled_dawn_features_list;
// Enable measuring blocked time on GPU Main thread
bool enable_gpu_blocked_time_metric = false;
......
......@@ -82,7 +82,9 @@ void CheckGpuPreferencesEqual(GpuPreferences left, GpuPreferences right) {
EXPECT_EQ(left.enable_webgpu, right.enable_webgpu);
EXPECT_EQ(left.enable_dawn_backend_validation,
right.enable_dawn_backend_validation);
EXPECT_EQ(left.disable_dawn_robustness, right.disable_dawn_robustness);
EXPECT_EQ(left.enabled_dawn_features_list, right.enabled_dawn_features_list);
EXPECT_EQ(left.disabled_dawn_features_list,
right.disabled_dawn_features_list);
EXPECT_EQ(left.enable_gpu_blocked_time_metric,
right.enable_gpu_blocked_time_metric);
EXPECT_EQ(left.enable_perf_data_collection,
......
......@@ -50,8 +50,11 @@ const char kEnableUnsafeWebGPU[] = "enable-unsafe-webgpu";
// Enable validation layers in Dawn backends.
const char kEnableDawnBackendValidation[] = "enable-dawn-backend-validation";
// Enable the toggle Toggle::DisableRobustness when creating Dawn device.
const char kDisableDawnRobustness[] = "disable-dawn-robustness";
// Set the Dawn features(toggles) enabled on the creation of Dawn devices.
const char kEnableDawnFeatures[] = "enable-dawn-features";
// Set the Dawn features(toggles) disabled on the creation of Dawn devices.
const char kDisableDawnFeatures[] = "disable-dawn-features";
// Increases the priority (to REALTIME_AUDIO) of gpu process and compositor
// thread.
......
......@@ -21,7 +21,8 @@ GPU_EXPORT extern const char kShaderDiskCacheSizeKB[];
GPU_EXPORT extern const char kDisableGpuProcessForDX12InfoCollection[];
GPU_EXPORT extern const char kEnableUnsafeWebGPU[];
GPU_EXPORT extern const char kEnableDawnBackendValidation[];
GPU_EXPORT extern const char kDisableDawnRobustness[];
GPU_EXPORT extern const char kEnableDawnFeatures[];
GPU_EXPORT extern const char kDisableDawnFeatures[];
GPU_EXPORT extern const char kUseHighGPUThreadPriorityForPerfTests[];
GPU_EXPORT extern const char kNoDelayForDX12VulkanInfoCollection[];
GPU_EXPORT extern const char kEnableGpuBlockedTime[];
......
......@@ -85,7 +85,8 @@ struct GpuPreferences {
bool enable_gpu_benchmarking_extension;
bool enable_webgpu;
bool enable_dawn_backend_validation;
bool disable_dawn_robustness;
array<string> enabled_dawn_features_list;
array<string> disabled_dawn_features_list;
bool enable_gpu_blocked_time_metric;
bool enable_perf_data_collection;
......
......@@ -176,7 +176,11 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
out->enable_webgpu = prefs.enable_webgpu();
out->enable_dawn_backend_validation =
prefs.enable_dawn_backend_validation();
out->disable_dawn_robustness = prefs.disable_dawn_robustness();
if (!prefs.ReadEnabledDawnFeaturesList(&out->enabled_dawn_features_list))
return false;
if (!prefs.ReadDisabledDawnFeaturesList(&out->disabled_dawn_features_list))
return false;
out->enable_gpu_blocked_time_metric =
prefs.enable_gpu_blocked_time_metric();
out->enable_perf_data_collection = prefs.enable_perf_data_collection();
......@@ -360,8 +364,13 @@ struct StructTraits<gpu::mojom::GpuPreferencesDataView, gpu::GpuPreferences> {
static bool enable_dawn_backend_validation(const gpu::GpuPreferences& prefs) {
return prefs.enable_dawn_backend_validation;
}
static bool disable_dawn_robustness(const gpu::GpuPreferences& prefs) {
return prefs.disable_dawn_robustness;
static const std::vector<std::string>& enabled_dawn_features_list(
const gpu::GpuPreferences& prefs) {
return prefs.enabled_dawn_features_list;
}
static const std::vector<std::string>& disabled_dawn_features_list(
const gpu::GpuPreferences& prefs) {
return prefs.disabled_dawn_features_list;
}
static bool enable_gpu_blocked_time_metric(const gpu::GpuPreferences& prefs) {
return prefs.enable_gpu_blocked_time_metric;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment