Only mark objects as cached right before inserting into the cache

This fixes bugs where we try to uncache objects that fail creation.

Bug: dawn:249
Change-Id: Ic60b3ce702dfdda18baa6d263911885a43d3cda7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12820
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2019-10-30 00:20:03 +00:00
committed by Commit Bot service account
parent fe221ac089
commit 84bcf44fae
20 changed files with 135 additions and 89 deletions

View File

@@ -52,10 +52,8 @@ namespace dawn_native {
// SamplerBase
SamplerBase::SamplerBase(DeviceBase* device,
const SamplerDescriptor* descriptor,
bool blueprint)
: ObjectBase(device),
SamplerBase::SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor)
: CachedObject(device),
mAddressModeU(descriptor->addressModeU),
mAddressModeV(descriptor->addressModeV),
mAddressModeW(descriptor->addressModeW),
@@ -64,17 +62,15 @@ namespace dawn_native {
mMipmapFilter(descriptor->mipmapFilter),
mLodMinClamp(descriptor->lodMinClamp),
mLodMaxClamp(descriptor->lodMaxClamp),
mCompareFunction(descriptor->compare),
mIsBlueprint(blueprint) {
mCompareFunction(descriptor->compare) {
}
SamplerBase::SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag)
: ObjectBase(device, tag) {
: CachedObject(device, tag) {
}
SamplerBase::~SamplerBase() {
// Do not uncache the actual cached object if we are a blueprint
if (!mIsBlueprint && !IsError()) {
if (IsCachedReference()) {
GetDevice()->UncacheSampler(this);
}
}