Refactors Destroy to be upward calls instead of overriding.
- Fixes all class and implementations to call upwards when necessary.
- Makes DestroyImpl full virtual at ApiObjectBase.
- Fixes mock classes to call default DestroyImpl upwards on mock calls.
- Adds back D3D12 optimization for buffer destruction.
Bug: dawn:628, dawn:1189
Change-Id: Id2c2c6483dc7ed93daf8e4648af26ac1307e3d90
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71243
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn_native/ObjectBase.h b/src/dawn_native/ObjectBase.h
index c234da0..5c91628 100644
--- a/src/dawn_native/ObjectBase.h
+++ b/src/dawn_native/ObjectBase.h
@@ -60,12 +60,8 @@
// by the owning device.
bool IsAlive() const;
- // Allow virtual overriding of actual destroy call in order to allow for re-using of base
- // destruction oerations. Classes that override this function should almost always call this
- // class's implementation in the override. This needs to be public because it can be called
- // from the device owning the object. Returns true iff destruction occurs. Upon any re-calls
- // of the function it will return false to indicate no further operations should be taken.
- virtual bool Destroy();
+ // This needs to be public because it can be called from the device owning the object.
+ void Destroy();
// Dawn API
void APISetLabel(const char* label);
@@ -84,12 +80,11 @@
void DeleteThis() override;
void TrackInDevice();
- // Thread-safe manner to mark an object as destroyed. Returns true iff the call was the
- // "winning" attempt to destroy the object. This is useful when sub-classes may have extra
- // pre-destruction steps that need to occur only once, i.e. Buffer needs to be unmapped
- // before being destroyed.
- bool MarkDestroyed();
- virtual void DestroyImpl();
+ // Sub-classes may override this function multiple times. Whenever overriding this function,
+ // however, users should be sure to call their parent's version in the new override to make
+ // sure that all destroy functionality is kept. This function is guaranteed to only be
+ // called once through the exposed Destroy function.
+ virtual void DestroyImpl() = 0;
private:
virtual void SetLabelImpl();