diff options
Diffstat (limited to 'dom/webgpu/ComputePipeline.cpp')
-rw-r--r-- | dom/webgpu/ComputePipeline.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/dom/webgpu/ComputePipeline.cpp b/dom/webgpu/ComputePipeline.cpp index ca50c5583a..ecd43289f3 100644 --- a/dom/webgpu/ComputePipeline.cpp +++ b/dom/webgpu/ComputePipeline.cpp @@ -27,17 +27,28 @@ ComputePipeline::ComputePipeline(Device* const aParent, RawId aId, ComputePipeline::~ComputePipeline() { Cleanup(); } void ComputePipeline::Cleanup() { - if (mValid && mParent) { - mValid = false; - auto bridge = mParent->GetBridge(); - if (bridge && bridge->IsOpen()) { - bridge->SendComputePipelineDrop(mId); - if (mImplicitPipelineLayoutId) { - bridge->SendImplicitLayoutDrop(mImplicitPipelineLayoutId, - mImplicitBindGroupLayoutIds); - } + if (mValid) { + return; + } + mValid = false; + + auto bridge = mParent->GetBridge(); + if (bridge->CanSend()) { + bridge->SendComputePipelineDrop(mId); + if (mImplicitPipelineLayoutId) { + bridge->SendImplicitLayoutDrop(mImplicitPipelineLayoutId, + mImplicitBindGroupLayoutIds); } } + + if (mImplicitPipelineLayoutId) { + wgpu_client_free_pipeline_layout_id(bridge->GetClient(), + mImplicitPipelineLayoutId); + } + + for (const auto& id : mImplicitBindGroupLayoutIds) { + wgpu_client_free_bind_group_layout_id(bridge->GetClient(), id); + } } already_AddRefed<BindGroupLayout> ComputePipeline::GetBindGroupLayout( |