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 <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Shrek Shao <shrekshao@google.com> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
d181a3cf55
commit
9b34bece93
|
@ -42,15 +42,10 @@ class DAWN_PLATFORM_EXPORT CachingInterface {
|
||||||
// size returned. The second mode is used to query for the existence of
|
// 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 |key| where |valueOut| is nullptr and |valueSize| must be 0.
|
||||||
// The return size is non-zero if the |key| exists.
|
// The return size is non-zero if the |key| exists.
|
||||||
virtual size_t LoadData(const WGPUDevice device,
|
virtual size_t LoadData(const void* key, size_t keySize, void* valueOut, size_t valueSize) = 0;
|
||||||
const void* key,
|
|
||||||
size_t keySize,
|
|
||||||
void* valueOut,
|
|
||||||
size_t valueSize) = 0;
|
|
||||||
|
|
||||||
// StoreData puts a |value| in the cache which corresponds to the |key|.
|
// StoreData puts a |value| in the cache which corresponds to the |key|.
|
||||||
virtual void StoreData(const WGPUDevice device,
|
virtual void StoreData(const void* key,
|
||||||
const void* key,
|
|
||||||
size_t keySize,
|
size_t keySize,
|
||||||
const void* value,
|
const void* value,
|
||||||
size_t valueSize) = 0;
|
size_t valueSize) = 0;
|
||||||
|
|
|
@ -70,11 +70,11 @@ CachedBlob BlobCache::LoadInternal(const CacheKey& key) {
|
||||||
if (mCache == nullptr) {
|
if (mCache == nullptr) {
|
||||||
return result;
|
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) {
|
if (expectedSize > 0) {
|
||||||
result.Reset(expectedSize);
|
result.Reset(expectedSize);
|
||||||
const size_t actualSize =
|
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);
|
ASSERT(expectedSize == actualSize);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -86,7 +86,7 @@ void BlobCache::StoreInternal(const CacheKey& key, size_t valueSize, const void*
|
||||||
if (mCache == nullptr) {
|
if (mCache == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mCache->StoreData(nullptr, key.data(), key.size(), value, valueSize);
|
mCache->StoreData(key.data(), key.size(), value, valueSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dawn::native
|
} // namespace dawn::native
|
||||||
|
|
|
@ -64,10 +64,6 @@ class BlobCache {
|
||||||
|
|
||||||
// Protects thread safety of access to mCache.
|
// Protects thread safety of access to mCache.
|
||||||
std::mutex mMutex;
|
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;
|
dawn::platform::CachingInterface* mCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ size_t CachingInterfaceMock::GetNumEntries() const {
|
||||||
return mCache.size();
|
return mCache.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CachingInterfaceMock::LoadDataDefault(const WGPUDevice device,
|
size_t CachingInterfaceMock::LoadDataDefault(const void* key,
|
||||||
const void* key,
|
|
||||||
size_t keySize,
|
size_t keySize,
|
||||||
void* value,
|
void* value,
|
||||||
size_t valueSize) {
|
size_t valueSize) {
|
||||||
|
@ -63,8 +62,7 @@ size_t CachingInterfaceMock::LoadDataDefault(const WGPUDevice device,
|
||||||
return entry->second.size();
|
return entry->second.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CachingInterfaceMock::StoreDataDefault(const WGPUDevice device,
|
void CachingInterfaceMock::StoreDataDefault(const void* key,
|
||||||
const void* key,
|
|
||||||
size_t keySize,
|
size_t keySize,
|
||||||
const void* value,
|
const void* value,
|
||||||
size_t valueSize) {
|
size_t valueSize) {
|
||||||
|
|
|
@ -47,26 +47,12 @@ class CachingInterfaceMock : public dawn::platform::CachingInterface {
|
||||||
// Returns the number of entries in the cache.
|
// Returns the number of entries in the cache.
|
||||||
size_t GetNumEntries() const;
|
size_t GetNumEntries() const;
|
||||||
|
|
||||||
MOCK_METHOD(size_t,
|
MOCK_METHOD(size_t, LoadData, (const void*, size_t, void*, size_t), (override));
|
||||||
LoadData,
|
MOCK_METHOD(void, StoreData, (const void*, size_t, const void*, size_t), (override));
|
||||||
(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));
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t LoadDataDefault(const WGPUDevice device,
|
size_t LoadDataDefault(const void* key, size_t keySize, void* value, size_t valueSize);
|
||||||
const void* key,
|
void StoreDataDefault(const void* key, size_t keySize, const void* value, size_t valueSize);
|
||||||
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);
|
|
||||||
|
|
||||||
bool mEnabled = true;
|
bool mEnabled = true;
|
||||||
size_t mHitCount = 0;
|
size_t mHitCount = 0;
|
||||||
|
|
Loading…
Reference in New Issue