Remove MVKSignalable class as redundant to MVKRefCountedDeviceObject.

This commit is contained in:
Bill Hollings 2018-11-13 20:27:30 +01:00
parent 946cdd0d45
commit ac087a1e55
3 changed files with 31 additions and 35 deletions

View File

@ -649,17 +649,37 @@ protected:
#pragma mark -
#pragma mark MVKRefCountedDeviceObject
/** Represents a device-spawned object that can live past destruction by the client. */
/**
* Represents a device-spawned object that supports basic reference counting.
*
* An object of this type will automatically be deleted iff it has been destroyed
* by the client, and all references have been released. An object of this type is
* therefore allowed to live past its destruction by the client, until it is no
* longer referenced by other objects.
*/
class MVKRefCountedDeviceObject : public MVKBaseDeviceObject {
public:
/** Increments the object reference count by one. */
/**
* Called when this instance has been retained as a reference by another object,
* indicating that this instance will not be deleted until that reference is released.
*/
void retain();
/** Decrements the object reference count by one. */
/**
* Called when this instance has been released as a reference from another object.
* Once all references have been released, this object is free to be deleted.
* If the destroy() function has already been called on this instance by the time
* this function is called, this instance will be deleted.
*/
void release();
/**
* Marks this instance as destroyed. If all previous references to this instance
* have been released, this instance will be deleted, otherwise deletion of this
* instance will automatically be deferred until all references have been released.
*/
void destroy() override;
#pragma mark Construction

View File

@ -993,14 +993,14 @@ void MVKSwapchainImage::signal(MVKSwapchainSignaler& signaler) {
// Tell the semaphore and fence that they are being tracked for future signaling.
void MVKSwapchainImage::markAsTracked(MVKSwapchainSignaler& signaler) {
if (signaler.first) { signaler.first->wasAddedToSignaler(); }
if (signaler.second) { signaler.second->wasAddedToSignaler(); }
if (signaler.first) { signaler.first->retain(); }
if (signaler.second) { signaler.second->retain(); }
}
// Tell the semaphore and fence that they are no longer being tracked for future signaling.
void MVKSwapchainImage::unmarkAsTracked(MVKSwapchainSignaler& signaler) {
if (signaler.first) { signaler.first->wasRemovedFromSignaler(); }
if (signaler.second) { signaler.second->wasRemovedFromSignaler(); }
if (signaler.first) { signaler.first->release(); }
if (signaler.second) { signaler.second->release(); }
}
const MVKSwapchainImageAvailability* MVKSwapchainImage::getAvailability() {

View File

@ -97,35 +97,11 @@ private:
};
#pragma mark -
#pragma mark MVKSignalable
/** Abstract class for Vulkan semaphores and fences. */
class MVKSignalable : public MVKRefCountedDeviceObject {
public:
/* Called when this object has been added to a tracker for later signaling. */
void wasAddedToSignaler() { retain(); }
/**
* Called when this object has been removed from a tracker for later signaling.
* If this object was destroyed while this signal was pending, it will now be deleted.
*/
void wasRemovedFromSignaler() { release(); }
#pragma mark Construction
MVKSignalable(MVKDevice* device) : MVKRefCountedDeviceObject(device) {}
};
#pragma mark -
#pragma mark MVKSemaphore
/** Represents a Vulkan semaphore. */
class MVKSemaphore : public MVKSignalable {
class MVKSemaphore : public MVKRefCountedDeviceObject {
public:
@ -146,7 +122,7 @@ public:
#pragma mark Construction
MVKSemaphore(MVKDevice* device, const VkSemaphoreCreateInfo* pCreateInfo)
: MVKSignalable(device), _blocker(false, 1) {}
: MVKRefCountedDeviceObject(device), _blocker(false, 1) {}
protected:
MVKSemaphoreImpl _blocker;
@ -157,7 +133,7 @@ protected:
#pragma mark MVKFence
/** Represents a Vulkan fence. */
class MVKFence : public MVKSignalable {
class MVKFence : public MVKRefCountedDeviceObject {
public:
@ -190,7 +166,7 @@ public:
#pragma mark Construction
MVKFence(MVKDevice* device, const VkFenceCreateInfo* pCreateInfo) : MVKSignalable(device),
MVKFence(MVKDevice* device, const VkFenceCreateInfo* pCreateInfo) : MVKRefCountedDeviceObject(device),
_isSignaled(mvkAreFlagsEnabled(pCreateInfo->flags, VK_FENCE_CREATE_SIGNALED_BIT)) {}
~MVKFence() override;