mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-04 12:16:10 +00:00
Don't leak default created objects
Sometimes NXT provides default objects for parts of the pipelines, for example a default pipeline layout. This objects were create with code like: device->CreateFooBuilder()->GetResult(); and stored in a Ref<>. This caused the object to have on external reference and two internal references and not get destroyed when the Ref<> goes out. Call Release on these objects to remove the external reference and fix the leak. Was found via the Vulkan validation layers that were complaining that a VkPipelineLayout was leaked.
This commit is contained in:
parent
348fb1b223
commit
d15177d84e
@ -32,6 +32,8 @@ namespace backend {
|
||||
->GetDevice()
|
||||
->CreatePipelineLayoutBuilder()
|
||||
->GetResult();
|
||||
// Remove the external ref objects are created with
|
||||
mLayout->Release();
|
||||
}
|
||||
|
||||
auto FillPushConstants = [](const ShaderModuleBase* module, PushConstantInfo* info) {
|
||||
|
@ -89,9 +89,13 @@ namespace backend {
|
||||
// the device
|
||||
if (!mInputState) {
|
||||
mInputState = mDevice->CreateInputStateBuilder()->GetResult();
|
||||
// Remove the external ref objects are created with
|
||||
mInputState->Release();
|
||||
}
|
||||
if (!mDepthStencilState) {
|
||||
mDepthStencilState = mDevice->CreateDepthStencilStateBuilder()->GetResult();
|
||||
// Remove the external ref objects are created with
|
||||
mDepthStencilState->Release();
|
||||
}
|
||||
if (!mRenderPass) {
|
||||
HandleError("Pipeline render pass not set");
|
||||
@ -109,6 +113,8 @@ namespace backend {
|
||||
for (uint32_t attachmentSlot :
|
||||
IterateBitSet(subpassInfo.colorAttachmentsSet & ~mBlendStatesSet)) {
|
||||
mBlendStates[attachmentSlot] = mDevice->CreateBlendStateBuilder()->GetResult();
|
||||
// Remove the external ref objects are created with
|
||||
mBlendStates[attachmentSlot]->Release();
|
||||
}
|
||||
|
||||
return mDevice->CreateRenderPipeline(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user