Adds device-side cache key generation.

- Note that the device-side cache key will be prepended to object cache keys to prevent incompatible adapter/device cache clashes.
- Adds a new template file to auto=generate these cache serializers based on arguments.

Bug: dawn:549
Change-Id: I24b9d11eb38c579acfcc173a5dced9e1b649cf2c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86081
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
This commit is contained in:
Loko Kung
2022-04-12 23:50:56 +00:00
committed by Dawn LUCI CQ
parent 792873ecb6
commit c083d65a0c
7 changed files with 160 additions and 26 deletions

View File

@@ -177,6 +177,9 @@ namespace dawn::native {
: mInstance(adapter->GetInstance()), mAdapter(adapter), mNextPipelineCompatibilityToken(1) {
ASSERT(descriptor != nullptr);
AdapterProperties adapterProperties;
adapter->APIGetProperties(&adapterProperties);
const DawnTogglesDeviceDescriptor* togglesDesc = nullptr;
FindInChain(descriptor->nextInChain, &togglesDesc);
if (togglesDesc != nullptr) {
@@ -184,10 +187,11 @@ namespace dawn::native {
}
ApplyFeatures(descriptor);
DawnCacheDeviceDescriptor defaultCacheDesc = {};
const DawnCacheDeviceDescriptor* cacheDesc = nullptr;
FindInChain(descriptor->nextInChain, &cacheDesc);
if (cacheDesc != nullptr) {
mCacheIsolationKey = cacheDesc->isolationKey;
if (cacheDesc == nullptr) {
cacheDesc = &defaultCacheDesc;
}
if (descriptor->requiredLimits != nullptr) {
@@ -202,6 +206,12 @@ namespace dawn::native {
if (descriptor->label != nullptr && strlen(descriptor->label) != 0) {
mLabel = descriptor->label;
}
// Record the cache key from the properties. Note that currently, if a new extension
// descriptor is added (and probably handled here), the cache key recording needs to be
// updated.
mDeviceCacheKey.Record(adapterProperties, mEnabledFeatures.featuresBitSet,
mEnabledToggles.toggleBitset, cacheDesc);
}
DeviceBase::DeviceBase() : mState(State::Alive) {
@@ -1789,8 +1799,8 @@ namespace dawn::native {
return PipelineCompatibilityToken(mNextPipelineCompatibilityToken++);
}
const std::string& DeviceBase::GetCacheIsolationKey() const {
return mCacheIsolationKey;
const CacheKey& DeviceBase::GetCacheKey() const {
return mDeviceCacheKey;
}
const std::string& DeviceBase::GetLabel() const {