Enable blob cache without requiring WGSL writer This CL enable using blob cache without WGSL writer, as currently tint program is no longer contained in the cache key (get replaced by shader module hash) so we don't need WGSL writer to stream program any more. Bug: 42240459 Change-Id: I422248c684b0a10bee75ad54f170d40a33152c17 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/239214 Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@microsoft.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index b49e6d5..242e900 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp
@@ -339,19 +339,13 @@ cacheDesc.functionUserdata = GetPlatform()->GetCachingInterface(); } - // Disable caching if the toggle is passed, or the WGSL writer is not enabled. - // TODO(crbug.com/dawn/1481): Shader caching currently has a dependency on the WGSL writer to - // generate cache keys. We can lift the dependency once we also cache frontend parsing, - // transformations, and reflection. -#if TINT_BUILD_WGSL_WRITER + // Disable caching if the DisableBlobCache toggle is enabled. if (IsToggleEnabled(Toggle::DisableBlobCache)) { -#else - { -#endif cacheDesc.loadDataFunction = nullptr; cacheDesc.storeDataFunction = nullptr; cacheDesc.functionUserdata = nullptr; } + mBlobCache = std::make_unique<BlobCache>(cacheDesc); if (descriptor->requiredLimits != nullptr) {
diff --git a/src/dawn/native/TintUtils.cpp b/src/dawn/native/TintUtils.cpp index 86374ae..c2b8d3d 100644 --- a/src/dawn/native/TintUtils.cpp +++ b/src/dawn/native/TintUtils.cpp
@@ -185,18 +185,4 @@ return map; } -// static -template <> -void stream::Stream<tint::Program>::Write(stream::Sink* sink, const tint::Program& p) { -#if TINT_BUILD_WGSL_WRITER - tint::wgsl::writer::Options options{}; - StreamIn(sink, tint::wgsl::writer::Generate(p, options)->wgsl); -#else - // TODO(crbug.com/dawn/1481): We shouldn't need to write back to WGSL if we have a CacheKey - // built from the initial shader module input. Then, we would never need to parse the program - // and write back out to WGSL. - DAWN_UNREACHABLE(); -#endif -} - } // namespace dawn::native