From 22b862e052c2ac14be19fa4562a5da6a94066449 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Thu, 26 Apr 2018 11:03:53 -0400 Subject: [PATCH] Fix some leaking builder objects in common backend. Delete the TextureBuilder created in SwapChainBase::GetNextTexture(). Delete the InputStateBuilder and DepthStencilStateBuilder created in RenderPipelineBuilder::GetResultImpl(). --- src/backend/PipelineLayout.cpp | 4 +++- src/backend/RenderPipeline.cpp | 8 ++++++-- src/backend/SwapChain.cpp | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/PipelineLayout.cpp b/src/backend/PipelineLayout.cpp index 39eecde50a..d8040e2360 100644 --- a/src/backend/PipelineLayout.cpp +++ b/src/backend/PipelineLayout.cpp @@ -59,9 +59,11 @@ namespace backend { // the device once we have a cache of BGL for (size_t group = 0; group < kMaxBindGroups; ++group) { if (!mBindGroupLayouts[group]) { - mBindGroupLayouts[group] = mDevice->CreateBindGroupLayoutBuilder()->GetResult(); + auto builder = mDevice->CreateBindGroupLayoutBuilder(); + mBindGroupLayouts[group] = builder->GetResult(); // Remove the external ref objects are created with mBindGroupLayouts[group]->Release(); + builder->Release(); } } diff --git a/src/backend/RenderPipeline.cpp b/src/backend/RenderPipeline.cpp index dd7d06ca3d..0c21b71ea9 100644 --- a/src/backend/RenderPipeline.cpp +++ b/src/backend/RenderPipeline.cpp @@ -88,14 +88,18 @@ namespace backend { // TODO(cwallez@chromium.org): the layout should be required, and put the default objects in // the device if (!mInputState) { - mInputState = mDevice->CreateInputStateBuilder()->GetResult(); + auto builder = mDevice->CreateInputStateBuilder(); + mInputState = builder->GetResult(); // Remove the external ref objects are created with mInputState->Release(); + builder->Release(); } if (!mDepthStencilState) { - mDepthStencilState = mDevice->CreateDepthStencilStateBuilder()->GetResult(); + auto builder = mDevice->CreateDepthStencilStateBuilder(); + mDepthStencilState = builder->GetResult(); // Remove the external ref objects are created with mDepthStencilState->Release(); + builder->Release(); } if (!mRenderPass) { HandleError("Pipeline render pass not set"); diff --git a/src/backend/SwapChain.cpp b/src/backend/SwapChain.cpp index 2eaf7b6609..75ccc5b61c 100644 --- a/src/backend/SwapChain.cpp +++ b/src/backend/SwapChain.cpp @@ -68,6 +68,7 @@ namespace backend { auto* texture = GetNextTextureImpl(builder); mLastNextTexture = texture; + builder->Release(); return texture; }