From 9b34bece939e69c20a01d830d60135ca48cd492b Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Tue, 3 May 2022 02:53:33 +0000 Subject: [PATCH] Removes device from load/store in caching interface. - No longer needed since the device information should be stored in the cache key. Bug: dawn:549 Change-Id: I7c4e31e61df93ba317bc6eeb6a84074585f7eed2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88365 Reviewed-by: Austin Eng Kokoro: Kokoro Reviewed-by: Shrek Shao Commit-Queue: Austin Eng --- include/dawn/platform/DawnPlatform.h | 9 ++------ src/dawn/native/BlobCache.cpp | 6 ++--- src/dawn/native/BlobCache.h | 4 ---- .../end2end/mocks/CachingInterfaceMock.cpp | 6 ++--- .../end2end/mocks/CachingInterfaceMock.h | 22 ++++--------------- 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/include/dawn/platform/DawnPlatform.h b/include/dawn/platform/DawnPlatform.h index 610cc05a3a..5c616d1bbc 100644 --- a/include/dawn/platform/DawnPlatform.h +++ b/include/dawn/platform/DawnPlatform.h @@ -42,15 +42,10 @@ class DAWN_PLATFORM_EXPORT CachingInterface { // size returned. The second mode is used to query for the existence of // the |key| where |valueOut| is nullptr and |valueSize| must be 0. // The return size is non-zero if the |key| exists. - virtual size_t LoadData(const WGPUDevice device, - const void* key, - size_t keySize, - void* valueOut, - size_t valueSize) = 0; + virtual size_t LoadData(const void* key, size_t keySize, void* valueOut, size_t valueSize) = 0; // StoreData puts a |value| in the cache which corresponds to the |key|. - virtual void StoreData(const WGPUDevice device, - const void* key, + virtual void StoreData(const void* key, size_t keySize, const void* value, size_t valueSize) = 0; diff --git a/src/dawn/native/BlobCache.cpp b/src/dawn/native/BlobCache.cpp index 9e27d2d084..9ec4750244 100644 --- a/src/dawn/native/BlobCache.cpp +++ b/src/dawn/native/BlobCache.cpp @@ -70,11 +70,11 @@ CachedBlob BlobCache::LoadInternal(const CacheKey& key) { if (mCache == nullptr) { return result; } - const size_t expectedSize = mCache->LoadData(nullptr, key.data(), key.size(), nullptr, 0); + const size_t expectedSize = mCache->LoadData(key.data(), key.size(), nullptr, 0); if (expectedSize > 0) { result.Reset(expectedSize); const size_t actualSize = - mCache->LoadData(nullptr, key.data(), key.size(), result.Data(), expectedSize); + mCache->LoadData(key.data(), key.size(), result.Data(), expectedSize); ASSERT(expectedSize == actualSize); } return result; @@ -86,7 +86,7 @@ void BlobCache::StoreInternal(const CacheKey& key, size_t valueSize, const void* if (mCache == nullptr) { return; } - mCache->StoreData(nullptr, key.data(), key.size(), value, valueSize); + mCache->StoreData(key.data(), key.size(), value, valueSize); } } // namespace dawn::native diff --git a/src/dawn/native/BlobCache.h b/src/dawn/native/BlobCache.h index f4fb965a0a..8565429799 100644 --- a/src/dawn/native/BlobCache.h +++ b/src/dawn/native/BlobCache.h @@ -64,10 +64,6 @@ class BlobCache { // Protects thread safety of access to mCache. std::mutex mMutex; - - // TODO(dawn:549): Current CachingInterface declaration requires passing a device to each - // call, but this might be unnecessary. This class just passes nullptr for those calls - // right now. Eventually we can just change the interface to be more generic. dawn::platform::CachingInterface* mCache; }; diff --git a/src/dawn/tests/end2end/mocks/CachingInterfaceMock.cpp b/src/dawn/tests/end2end/mocks/CachingInterfaceMock.cpp index 846743769d..8507e9cffb 100644 --- a/src/dawn/tests/end2end/mocks/CachingInterfaceMock.cpp +++ b/src/dawn/tests/end2end/mocks/CachingInterfaceMock.cpp @@ -41,8 +41,7 @@ size_t CachingInterfaceMock::GetNumEntries() const { return mCache.size(); } -size_t CachingInterfaceMock::LoadDataDefault(const WGPUDevice device, - const void* key, +size_t CachingInterfaceMock::LoadDataDefault(const void* key, size_t keySize, void* value, size_t valueSize) { @@ -63,8 +62,7 @@ size_t CachingInterfaceMock::LoadDataDefault(const WGPUDevice device, return entry->second.size(); } -void CachingInterfaceMock::StoreDataDefault(const WGPUDevice device, - const void* key, +void CachingInterfaceMock::StoreDataDefault(const void* key, size_t keySize, const void* value, size_t valueSize) { diff --git a/src/dawn/tests/end2end/mocks/CachingInterfaceMock.h b/src/dawn/tests/end2end/mocks/CachingInterfaceMock.h index 8cb1e1cfbe..cc61d80fc2 100644 --- a/src/dawn/tests/end2end/mocks/CachingInterfaceMock.h +++ b/src/dawn/tests/end2end/mocks/CachingInterfaceMock.h @@ -47,26 +47,12 @@ class CachingInterfaceMock : public dawn::platform::CachingInterface { // Returns the number of entries in the cache. size_t GetNumEntries() const; - MOCK_METHOD(size_t, - LoadData, - (const WGPUDevice, const void*, size_t, void*, size_t), - (override)); - MOCK_METHOD(void, - StoreData, - (const WGPUDevice, const void*, size_t, const void*, size_t), - (override)); + MOCK_METHOD(size_t, LoadData, (const void*, size_t, void*, size_t), (override)); + MOCK_METHOD(void, StoreData, (const void*, size_t, const void*, size_t), (override)); private: - size_t LoadDataDefault(const WGPUDevice device, - const void* key, - size_t keySize, - void* value, - size_t valueSize); - void StoreDataDefault(const WGPUDevice device, - const void* key, - size_t keySize, - const void* value, - size_t valueSize); + size_t LoadDataDefault(const void* key, size_t keySize, void* value, size_t valueSize); + void StoreDataDefault(const void* key, size_t keySize, const void* value, size_t valueSize); bool mEnabled = true; size_t mHitCount = 0;