vk_resource_manager: Minor VKFenceWatch changes

This commit is contained in:
ReinUsesLisp 2019-02-24 04:19:04 -03:00
parent f7090bacc5
commit 281a8bf259
2 changed files with 7 additions and 7 deletions

View file

@ -125,12 +125,13 @@ void VKFence::Protect(VKResource* resource) {
protected_resources.push_back(resource); protected_resources.push_back(resource);
} }
void VKFence::Unprotect(const VKResource* resource) { void VKFence::Unprotect(VKResource* resource) {
const auto it = std::find(protected_resources.begin(), protected_resources.end(), resource); const auto it = std::find(protected_resources.begin(), protected_resources.end(), resource);
if (it != protected_resources.end()) { ASSERT(it != protected_resources.end());
resource->OnFenceRemoval(this);
protected_resources.erase(it); protected_resources.erase(it);
} }
}
VKFenceWatch::VKFenceWatch() = default; VKFenceWatch::VKFenceWatch() = default;
@ -141,12 +142,11 @@ VKFenceWatch::~VKFenceWatch() {
} }
void VKFenceWatch::Wait() { void VKFenceWatch::Wait() {
if (!fence) { if (fence == nullptr) {
return; return;
} }
fence->Wait(); fence->Wait();
fence->Unprotect(this); fence->Unprotect(this);
fence = nullptr;
} }
void VKFenceWatch::Watch(VKFence& new_fence) { void VKFenceWatch::Watch(VKFence& new_fence) {

View file

@ -63,7 +63,7 @@ public:
void Protect(VKResource* resource); void Protect(VKResource* resource);
/// Removes protection for a resource. /// Removes protection for a resource.
void Unprotect(const VKResource* resource); void Unprotect(VKResource* resource);
/// Retreives the fence. /// Retreives the fence.
operator vk::Fence() const { operator vk::Fence() const {