Adds typing to cache keys to avoid clashes.

Bug: dawn:549
Change-Id: Ic3c737e62ae3bfcd1b20d923373a66f380d96149
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86401
Reviewed-by: Shrek Shao <shrekshao@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Loko Kung 2022-04-21 02:04:57 +00:00 committed by Dawn LUCI CQ
parent 65426d9325
commit cf078766c2
3 changed files with 8 additions and 0 deletions

View File

@ -46,6 +46,8 @@ namespace dawn::native {
public: public:
using std::vector<uint8_t>::vector; using std::vector<uint8_t>::vector;
enum class Type { ComputePipeline, RenderPipeline };
template <typename T> template <typename T>
CacheKey& Record(const T& t) { CacheKey& Record(const T& t) {
CacheKeySerializer<T>::Serialize(this, t); CacheKeySerializer<T>::Serialize(this, t);

View File

@ -48,6 +48,9 @@ namespace dawn::native {
descriptor->compute.constants}}) { descriptor->compute.constants}}) {
SetContentHash(ComputeContentHash()); SetContentHash(ComputeContentHash());
TrackInDevice(); TrackInDevice();
// Initialize the cache key to include the cache type and device information.
GetCacheKey()->Record(CacheKey::Type::ComputePipeline, device->GetCacheKey());
} }
ComputePipelineBase::ComputePipelineBase(DeviceBase* device) : PipelineBase(device) { ComputePipelineBase::ComputePipelineBase(DeviceBase* device) : PipelineBase(device) {

View File

@ -629,6 +629,9 @@ namespace dawn::native {
SetContentHash(ComputeContentHash()); SetContentHash(ComputeContentHash());
TrackInDevice(); TrackInDevice();
// Initialize the cache key to include the cache type and device information.
GetCacheKey()->Record(CacheKey::Type::RenderPipeline, device->GetCacheKey());
} }
RenderPipelineBase::RenderPipelineBase(DeviceBase* device) : PipelineBase(device) { RenderPipelineBase::RenderPipelineBase(DeviceBase* device) : PipelineBase(device) {