Fix BindGroupLayout caused by caching.

When a BGL was first created in the cache, it started with an external
refcount of 1 and we then referenced again in
BindGroupLayoutBuilder::GetResultImpl, causing a leak.

Fix this by referencing in the cache lookup only if the BGL already
exists.
This commit is contained in:
Corentin Wallez 2018-04-17 16:35:23 -04:00 committed by Corentin Wallez
parent 51f9987298
commit df5a18d883
2 changed files with 1 additions and 1 deletions

View File

@ -109,7 +109,6 @@ namespace backend {
BindGroupLayoutBase blueprint(this, true);
auto* result = mDevice->GetOrCreateBindGroupLayout(&blueprint, this);
result->Reference();
return result;
}

View File

@ -82,6 +82,7 @@ namespace backend {
// modified.
auto iter = mCaches->bindGroupLayouts.find(const_cast<BindGroupLayoutBase*>(blueprint));
if (iter != mCaches->bindGroupLayouts.end()) {
(*iter)->Reference();
return *iter;
}