Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / dom / webgpu / BindGroup.cpp
blobb3cd3d9d5e38dc4490b226bb4aa3911467c8afdb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/dom/WebGPUBinding.h"
7 #include "BindGroup.h"
8 #include "ipc/WebGPUChild.h"
10 #include "Device.h"
12 namespace mozilla::webgpu {
14 GPU_IMPL_CYCLE_COLLECTION(BindGroup, mParent)
15 GPU_IMPL_JS_WRAP(BindGroup)
17 BindGroup::BindGroup(Device* const aParent, RawId aId)
18 : ChildOf(aParent), mId(aId) {
19 MOZ_RELEASE_ASSERT(aId);
22 BindGroup::~BindGroup() { Cleanup(); }
24 void BindGroup::Cleanup() {
25 if (!mValid) {
26 return;
28 mValid = false;
30 auto bridge = mParent->GetBridge();
31 if (!bridge) {
32 return;
35 if (bridge->CanSend()) {
36 bridge->SendBindGroupDrop(mId);
39 wgpu_client_free_bind_group_id(bridge->GetClient(), mId);
42 } // namespace mozilla::webgpu