summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/Sampler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/Sampler.cpp')
-rw-r--r--dom/webgpu/Sampler.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/dom/webgpu/Sampler.cpp b/dom/webgpu/Sampler.cpp
index 6ee5f3c41f..6abd8ca357 100644
--- a/dom/webgpu/Sampler.cpp
+++ b/dom/webgpu/Sampler.cpp
@@ -22,13 +22,21 @@ Sampler::Sampler(Device* const aParent, RawId aId)
Sampler::~Sampler() { Cleanup(); }
void Sampler::Cleanup() {
- if (mValid && mParent) {
- mValid = false;
- auto bridge = mParent->GetBridge();
- if (bridge && bridge->IsOpen()) {
- bridge->SendSamplerDrop(mId);
- }
+ if (!mValid) {
+ return;
}
+
+ mValid = false;
+ auto bridge = mParent->GetBridge();
+ if (!bridge) {
+ return;
+ }
+
+ if (bridge->CanSend()) {
+ bridge->SendSamplerDrop(mId);
+ }
+
+ wgpu_client_free_sampler_id(bridge->GetClient(), mId);
}
} // namespace mozilla::webgpu