[viewer] Add `disable_tint_symbol_renaming` option
This is a command-line option for Viewer, limited to the Graphite-Dawn
backend, that disables Tint's internal symbol-renaming pass on
cross-compiled WGSL code. Symbol renaming remains enabled by default.
Change-Id: If1f3c83522f0843d68ec5086412d55bc13f11da1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/848736
Commit-Queue: Arman Uguray <armansito@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 5e5fd6e..79b9161 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -250,6 +250,11 @@
static DEFINE_string(pathstrategy, "default",
"Path renderer strategy to use. Allowed values are " PATHSTRATEGY_STR ".");
+#if defined(SK_DAWN)
+static DEFINE_bool(disable_tint_symbol_renaming,
+ false,
+ "Disable Tint WGSL symbol renaming when using Dawn");
+#endif
#endif
#if defined(SK_BUILD_FOR_ANDROID)
@@ -567,6 +572,9 @@
#if defined(SK_GRAPHITE)
displayParams.fGraphiteContextOptions.fPriv.fPathRendererStrategy =
get_path_renderer_strategy_type(FLAGS_pathstrategy[0]);
+#if defined(SK_DAWN)
+ displayParams.fDisableTintSymbolRenaming = FLAGS_disable_tint_symbol_renaming;
+#endif
#endif
fWindow->setRequestedDisplayParams(displayParams);
fDisplay = fWindow->getRequestedDisplayParams();
diff --git a/tools/window/DisplayParams.h b/tools/window/DisplayParams.h
index 4a747ed..b06570d 100644
--- a/tools/window/DisplayParams.h
+++ b/tools/window/DisplayParams.h
@@ -61,6 +61,9 @@
GrContextOptions fGrContextOptions;
#if defined(SK_GRAPHITE)
GraphiteContextOptions fGraphiteContextOptions;
+#if defined(SK_DAWN)
+ bool fDisableTintSymbolRenaming = false;
+#endif
#endif
SkSurfaceProps fSurfaceProps;
bool fDisableVsync;
diff --git a/tools/window/GraphiteDawnWindowContext.cpp b/tools/window/GraphiteDawnWindowContext.cpp
index c078c2a..b91e401 100644
--- a/tools/window/GraphiteDawnWindowContext.cpp
+++ b/tools/window/GraphiteDawnWindowContext.cpp
@@ -124,17 +124,17 @@
DawnProcTable backendProcs = dawn::native::GetProcs();
dawnProcSetProcs(&backendProcs);
- static constexpr const char* kToggles[] = {
+ static constexpr const char* kAdapterToggles[] = {
"allow_unsafe_apis", // Needed for dual-source blending, BufferMapExtendedUsages.
"use_user_defined_labels_in_backend",
};
- wgpu::DawnTogglesDescriptor togglesDesc;
- togglesDesc.enabledToggleCount = std::size(kToggles);
- togglesDesc.enabledToggles = kToggles;
+ wgpu::DawnTogglesDescriptor adapterTogglesDesc;
+ adapterTogglesDesc.enabledToggleCount = std::size(kAdapterToggles);
+ adapterTogglesDesc.enabledToggles = kAdapterToggles;
wgpu::RequestAdapterOptions adapterOptions;
adapterOptions.backendType = type;
- adapterOptions.nextInChain = &togglesDesc;
+ adapterOptions.nextInChain = &adapterTogglesDesc;
std::vector<dawn::native::Adapter> adapters = fInstance->EnumerateAdapters(&adapterOptions);
if (adapters.empty()) {
@@ -183,6 +183,21 @@
}
};
+ wgpu::DawnTogglesDescriptor deviceTogglesDesc;
+
+ if (fDisplayParams.fDisableTintSymbolRenaming) {
+ static constexpr const char* kOptionalDeviceToggles[] = {
+ "disable_symbol_renaming",
+ };
+ deviceTogglesDesc.enabledToggleCount = std::size(kOptionalDeviceToggles);
+ deviceTogglesDesc.enabledToggles = kOptionalDeviceToggles;
+
+ // Insert the toggles descriptor ahead of any existing entries in the chain that might have
+ // been added above.
+ deviceTogglesDesc.nextInChain = deviceDescriptor.nextInChain;
+ deviceDescriptor.nextInChain = &deviceTogglesDesc;
+ }
+
auto device = adapter.CreateDevice(&deviceDescriptor);
if (!device) {
return nullptr;