From af510d7c6a54995964af36b9c8d875748dfb1130 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Tue, 7 Jun 2022 23:31:31 +0000 Subject: [PATCH] Use git hash as fingerprint for getting caching interfaces. - Also changes to use string_view for the constexpr hash. Bug: dawn:549 Change-Id: I1ded4994d501f0378d3fa8f5c16d07e3c566270f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92962 Reviewed-by: Austin Eng Commit-Queue: Loko Kung --- generator/templates/dawn/common/Version.h | 4 +++- src/dawn/native/Instance.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/generator/templates/dawn/common/Version.h b/generator/templates/dawn/common/Version.h index f9f67e726c..d8d5cdbb29 100644 --- a/generator/templates/dawn/common/Version.h +++ b/generator/templates/dawn/common/Version.h @@ -15,9 +15,11 @@ #ifndef COMMON_VERISON_AUTOGEN_H_ #define COMMON_VERISON_AUTOGEN_H_ +#include + namespace dawn { -static constexpr char kGitHash[] = "{{get_gitHash()}}"; +static constexpr std::string_view kGitHash("{{get_gitHash()}}"); } // namespace dawn diff --git a/src/dawn/native/Instance.cpp b/src/dawn/native/Instance.cpp index 8f06fb3921..3d8cce91e9 100644 --- a/src/dawn/native/Instance.cpp +++ b/src/dawn/native/Instance.cpp @@ -20,6 +20,7 @@ #include "dawn/common/GPUInfo.h" #include "dawn/common/Log.h" #include "dawn/common/SystemUtils.h" +#include "dawn/common/Version_autogen.h" #include "dawn/native/ChainUtils_autogen.h" #include "dawn/native/ErrorData.h" #include "dawn/native/Surface.h" @@ -94,9 +95,8 @@ BackendsBitset GetEnabledBackends() { } dawn::platform::CachingInterface* GetCachingInterface(dawn::platform::Platform* platform) { - if (platform != nullptr) { - return platform->GetCachingInterface(/*fingerprint*/ nullptr, - /*fingerprintSize*/ 0); + if (platform != nullptr && dawn::kGitHash.size() > 0) { + return platform->GetCachingInterface(dawn::kGitHash.data(), dawn::kGitHash.size()); } return nullptr; }