Remove SPIR-V option from Graphite Dawn backend.
Now that the WGSL backend is enabled and stable, we no longer need
support for the SPIR-V reader compatibility path for fragment and
vertex shaders.
Change-Id: I95621567ad259fec730f8d2a2aea6ea502a09e11
Bug: b/40044196
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/752898
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index c7d8af9..3a4dae9 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -2093,9 +2093,7 @@
GraphiteSink::GraphiteSink(const SkCommandLineConfigGraphite* config)
: fContextType(config->getContextType())
, fColorType(config->getColorType())
- , fAlphaType(config->getAlphaType()) {
- fBaseContextOptions.fEnableWGSL = config->getWGSL();
-}
+ , fAlphaType(config->getAlphaType()) {}
Result GraphiteSink::draw(const Src& src,
SkBitmap* dst,
diff --git a/include/gpu/graphite/ContextOptions.h b/include/gpu/graphite/ContextOptions.h
index 9cfb854..b37d2a5 100644
--- a/include/gpu/graphite/ContextOptions.h
+++ b/include/gpu/graphite/ContextOptions.h
@@ -75,13 +75,6 @@
bool fAllowMultipleGlyphCacheTextures = true;
bool fSupportBilerpFromGlyphAtlas = false;
- /**
- * In the Dawn backend, controls SkSL compilation to native code. When false, we emit SPIR-V and
- * rely on Tint's SPIR-V Reader. When true, we emit native WGSL.
- * TODO(b/40044196): once WGSL is stable, remove this flag and always emit WGSL.
- */
- bool fEnableWGSL = true;
-
static constexpr size_t kDefaultContextBudget = 256 * (1 << 20);
/**
* What is the budget for GPU resources allocated and held by the Context.
diff --git a/src/gpu/graphite/dawn/DawnCaps.cpp b/src/gpu/graphite/dawn/DawnCaps.cpp
index 9ee8af6..caae265 100644
--- a/src/gpu/graphite/dawn/DawnCaps.cpp
+++ b/src/gpu/graphite/dawn/DawnCaps.cpp
@@ -284,7 +284,6 @@
device.HasFeature(wgpu::FeatureName::MSAARenderToSingleSampled);
fTransientAttachmentSupport = device.HasFeature(wgpu::FeatureName::TransientAttachments);
- fEnableWGSL = options.fEnableWGSL;
}
void DawnCaps::initShaderCaps() {
diff --git a/src/gpu/graphite/dawn/DawnCaps.h b/src/gpu/graphite/dawn/DawnCaps.h
index ca5f370..79ffced 100644
--- a/src/gpu/graphite/dawn/DawnCaps.h
+++ b/src/gpu/graphite/dawn/DawnCaps.h
@@ -46,9 +46,6 @@
Shareable,
GraphiteResourceKey*) const override;
uint64_t getRenderPassDescKey(const RenderPassDesc& renderPassDesc) const;
- bool enableWGSL() const {
- return fEnableWGSL;
- }
static constexpr size_t kFormatCnt = 14;
@@ -115,7 +112,6 @@
void setColorType(SkColorType, std::initializer_list<wgpu::TextureFormat> formats);
bool fTransientAttachmentSupport = false;
- bool fEnableWGSL = false;
};
} // namespace skgpu::graphite
diff --git a/src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp b/src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp
index 55d588d..1e8f52f 100644
--- a/src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp
+++ b/src/gpu/graphite/dawn/DawnGraphicsPipeline.cpp
@@ -238,25 +238,6 @@
const GraphicsPipelineDesc& pipelineDesc,
const RenderPassDesc& renderPassDesc) {
const DawnCaps& caps = *static_cast<const DawnCaps*>(sharedContext->caps());
- const bool enableWGSL = caps.enableWGSL();
-
- using SkSLCompileFn = bool (*)(SkSL::Compiler*,
- const std::string&,
- SkSL::ProgramKind,
- const SkSL::ProgramSettings&,
- std::string*,
- SkSL::Program::Interface*,
- ShaderErrorHandler*);
- const SkSLCompileFn kSkSLCompileFn = enableWGSL ? SkSLToWGSL
- : SkSLToSPIRV;
-
- using DawnCompileFn = bool (*)(const DawnSharedContext* sharedContext,
- const std::string&,
- wgpu::ShaderModule* module,
- ShaderErrorHandler*);
- const DawnCompileFn kDawnCompileFn = enableWGSL ? DawnCompileWGSLShaderModule
- : DawnCompileSPIRVShaderModule;
-
const auto& device = sharedContext->device();
SkSL::Program::Interface vsInterface, fsInterface;
@@ -289,16 +270,16 @@
bool hasFragment = !fsSkSL.empty();
if (hasFragment) {
- if (!kSkSLCompileFn(compiler,
- fsSkSL,
- SkSL::ProgramKind::kGraphiteFragment,
- settings,
- &fsCode,
- &fsInterface,
- errorHandler)) {
+ if (!SkSLToWGSL(compiler,
+ fsSkSL,
+ SkSL::ProgramKind::kGraphiteFragment,
+ settings,
+ &fsCode,
+ &fsInterface,
+ errorHandler)) {
return {};
}
- if (!kDawnCompileFn(sharedContext, fsCode, &fsModule, errorHandler)) {
+ if (!DawnCompileWGSLShaderModule(sharedContext, fsCode, &fsModule, errorHandler)) {
return {};
}
}
@@ -307,16 +288,16 @@
step,
useShadingSsboIndex,
localCoordsNeeded);
- if (!kSkSLCompileFn(compiler,
- vsSkSL,
- SkSL::ProgramKind::kGraphiteVertex,
- settings,
- &vsCode,
- &vsInterface,
- errorHandler)) {
+ if (!SkSLToWGSL(compiler,
+ vsSkSL,
+ SkSL::ProgramKind::kGraphiteVertex,
+ settings,
+ &vsCode,
+ &vsInterface,
+ errorHandler)) {
return {};
}
- if (!kDawnCompileFn(sharedContext, vsCode, &vsModule, errorHandler)) {
+ if (!DawnCompileWGSLShaderModule(sharedContext, vsCode, &vsModule, errorHandler)) {
return {};
}
@@ -558,13 +539,12 @@
}
#if defined(GRAPHITE_TEST_UTILS)
- GraphicsPipeline::PipelineInfo pipelineInfo = {
- pipelineDesc.renderStepID(),
- pipelineDesc.paintParamsID(),
- std::move(vsSkSL),
- std::move(fsSkSL),
- enableWGSL ? std::move(vsCode) : std::string("SPIR-V disassembly not available"),
- enableWGSL ? std::move(fsCode) : std::string("SPIR-V disassembly not available")};
+ GraphicsPipeline::PipelineInfo pipelineInfo = {pipelineDesc.renderStepID(),
+ pipelineDesc.paintParamsID(),
+ std::move(vsSkSL),
+ std::move(fsSkSL),
+ std::move(vsCode),
+ std::move(fsCode)};
GraphicsPipeline::PipelineInfo* pipelineInfoPtr = &pipelineInfo;
#else
GraphicsPipeline::PipelineInfo* pipelineInfoPtr = nullptr;
diff --git a/tests/SkSLTest.cpp b/tests/SkSLTest.cpp
index f7620ef..9fe6078 100644
--- a/tests/SkSLTest.cpp
+++ b/tests/SkSLTest.cpp
@@ -358,11 +358,6 @@
#if defined(SK_DAWN)
if (ctx->backend() == skgpu::BackendApi::kDawn) {
- // We always force-enable WGSL via `force_wgsl_in_dawn` below. Dawn's SPIR-V Reader has
- // known limitations that we will bump into otherwise (some of our tests cause it to emit
- // malformed WGSL).
- SkASSERT(static_cast<const skgpu::graphite::DawnCaps*>(ctx->priv().caps())->enableWGSL());
-
// If this is a test that requires the GPU to generate NaN values, we don't run it in Dawn.
// (WGSL/Dawn does not support infinity or NaN even if the GPU natively does.)
if (flags & SkSLTestFlag::UsesNaN) {
@@ -563,16 +558,12 @@
type == skgpu::ContextType::kDawn;
}
-static void force_wgsl_in_dawn(skgpu::graphite::ContextOptions* options) {
- options->fEnableWGSL = true;
-}
-
#define DEF_GRAPHITE_SKSL_TEST(flags, ctsEnforcement, name, path) \
DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(SkSL##name##_Graphite, \
is_native_context_or_dawn, \
r, \
context, \
- force_wgsl_in_dawn, \
+ /*opt_filter=*/nullptr, \
is_gpu(flags), \
ctsEnforcement) { \
test_graphite(r, context, path, flags); \
diff --git a/tests/sksl/wgsl/PixelLocalStorage.wgsl b/tests/sksl/wgsl/PixelLocalStorage.wgsl
index 1e944a3..216ecdc 100644
--- a/tests/sksl/wgsl/PixelLocalStorage.wgsl
+++ b/tests/sksl/wgsl/PixelLocalStorage.wgsl
@@ -1,6 +1,6 @@
### Compilation failed:
-error: :2:1 error: chromium_experimental_pixel_local requires TINT_ENABLE_LOCAL_STORAGE_EXTENSION
+error: :2:1 error: chromium_experimental_pixel_local requires TINT_ENABLE_PIXEL_LOCAL_EXTENSION
enable chromium_experimental_pixel_local;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tools/flags/CommonFlagsConfig.cpp b/tools/flags/CommonFlagsConfig.cpp
index 582e02e..fe55563 100644
--- a/tools/flags/CommonFlagsConfig.cpp
+++ b/tools/flags/CommonFlagsConfig.cpp
@@ -137,13 +137,13 @@
{ "grd3d", "graphite", "api=direct3d" },
#endif
#ifdef SK_DAWN
- { "grdawn", "graphite", "api=dawn,wgsl=true" },
- { "grdawn_d3d11", "graphite", "api=dawn_d3d11,wgsl=true" },
- { "grdawn_d3d12", "graphite", "api=dawn_d3d12,wgsl=true" },
- { "grdawn_mtl", "graphite", "api=dawn_mtl,wgsl=true" },
- { "grdawn_vk", "graphite", "api=dawn_vk,wgsl=true" },
- { "grdawn_gl", "graphite", "api=dawn_gl,wgsl=true" },
- { "grdawn_gles", "graphite", "api=dawn_gles,wgsl=true" },
+ { "grdawn", "graphite", "api=dawn" },
+ { "grdawn_d3d11", "graphite", "api=dawn_d3d11" },
+ { "grdawn_d3d12", "graphite", "api=dawn_d3d12" },
+ { "grdawn_mtl", "graphite", "api=dawn_mtl" },
+ { "grdawn_vk", "graphite", "api=dawn_vk" },
+ { "grdawn_gl", "graphite", "api=dawn_gl" },
+ { "grdawn_gles", "graphite", "api=dawn_gles" },
#endif
#ifdef SK_METAL
{ "grmtl", "graphite", "api=metal" },
@@ -685,7 +685,6 @@
ContextType contextType = skgpu::ContextType::kMetal;
SkColorType colorType = kRGBA_8888_SkColorType;
SkAlphaType alphaType = kPremul_SkAlphaType;
- bool wgsl = false;
bool parseSucceeded = false;
ExtendedOptions extendedOptions(options, &parseSucceeded);
@@ -694,13 +693,12 @@
}
bool validOptions = extendedOptions.get_option_graphite_api("api", &contextType) &&
- extendedOptions.get_option_gpu_color("color", &colorType, &alphaType) &&
- extendedOptions.get_option_bool("wgsl", &wgsl);
+ extendedOptions.get_option_gpu_color("color", &colorType, &alphaType);
if (!validOptions) {
return nullptr;
}
- return new SkCommandLineConfigGraphite(tag, vias, contextType, colorType, alphaType, wgsl);
+ return new SkCommandLineConfigGraphite(tag, vias, contextType, colorType, alphaType);
}
#endif
diff --git a/tools/flags/CommonFlagsConfig.h b/tools/flags/CommonFlagsConfig.h
index 845e779..7188cd3f 100644
--- a/tools/flags/CommonFlagsConfig.h
+++ b/tools/flags/CommonFlagsConfig.h
@@ -119,26 +119,22 @@
const skia_private::TArray<SkString>& viaParts,
ContextType contextType,
SkColorType colorType,
- SkAlphaType alphaType,
- bool wgsl)
+ SkAlphaType alphaType)
: SkCommandLineConfig(tag, SkString("graphite"), viaParts)
, fContextType(contextType)
, fColorType(colorType)
- , fAlphaType(alphaType)
- , fWGSL(wgsl) {}
+ , fAlphaType(alphaType) {}
const SkCommandLineConfigGraphite* asConfigGraphite() const override { return this; }
ContextType getContextType() const { return fContextType; }
SkColorType getColorType() const { return fColorType; }
SkAlphaType getAlphaType() const { return fAlphaType; }
- bool getWGSL() const { return fWGSL; }
private:
ContextType fContextType;
SkColorType fColorType;
SkAlphaType fAlphaType;
- bool fWGSL;
};
#endif // SK_GRAPHITE