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:
parent
51f9987298
commit
df5a18d883
|
@ -109,7 +109,6 @@ namespace backend {
|
||||||
BindGroupLayoutBase blueprint(this, true);
|
BindGroupLayoutBase blueprint(this, true);
|
||||||
|
|
||||||
auto* result = mDevice->GetOrCreateBindGroupLayout(&blueprint, this);
|
auto* result = mDevice->GetOrCreateBindGroupLayout(&blueprint, this);
|
||||||
result->Reference();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ namespace backend {
|
||||||
// modified.
|
// modified.
|
||||||
auto iter = mCaches->bindGroupLayouts.find(const_cast<BindGroupLayoutBase*>(blueprint));
|
auto iter = mCaches->bindGroupLayouts.find(const_cast<BindGroupLayoutBase*>(blueprint));
|
||||||
if (iter != mCaches->bindGroupLayouts.end()) {
|
if (iter != mCaches->bindGroupLayouts.end()) {
|
||||||
|
(*iter)->Reference();
|
||||||
return *iter;
|
return *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue