summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-19 06:13:32 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-12-19 20:31:34 +0100
commit6ddffa010a86698543e2d0ecc07d1b93d8700e53 (patch)
treefa706a001d3ec81c919479ec2785f5b95ed0a8ea /src/video_core
parentvk_device: Add entry to catch device losses (diff)
downloadyuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.tar
yuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.tar.gz
yuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.tar.bz2
yuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.tar.lz
yuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.tar.xz
yuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.tar.zst
yuzu-6ddffa010a86698543e2d0ecc07d1b93d8700e53.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_vulkan/vk_resource_manager.cpp24
-rw-r--r--src/video_core/renderer_vulkan/vk_resource_manager.h8
2 files changed, 32 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/vk_resource_manager.cpp b/src/video_core/renderer_vulkan/vk_resource_manager.cpp
index a0ca5f2ae..aa145de5c 100644
--- a/src/video_core/renderer_vulkan/vk_resource_manager.cpp
+++ b/src/video_core/renderer_vulkan/vk_resource_manager.cpp
@@ -142,8 +142,32 @@ void VKFence::Unprotect(VKResource* resource) {
protected_resources.erase(it);
}
+void VKFence::RedirectProtection(VKResource* old_resource, VKResource* new_resource) noexcept {
+ std::replace(std::begin(protected_resources), std::end(protected_resources), old_resource,
+ new_resource);
+}
+
VKFenceWatch::VKFenceWatch() = default;
+VKFenceWatch::VKFenceWatch(VKFence& initial_fence) {
+ Watch(initial_fence);
+}
+
+VKFenceWatch::VKFenceWatch(VKFenceWatch&& rhs) noexcept {
+ fence = std::exchange(rhs.fence, nullptr);
+ if (fence) {
+ fence->RedirectProtection(&rhs, this);
+ }
+}
+
+VKFenceWatch& VKFenceWatch::operator=(VKFenceWatch&& rhs) noexcept {
+ fence = std::exchange(rhs.fence, nullptr);
+ if (fence) {
+ fence->RedirectProtection(&rhs, this);
+ }
+ return *this;
+}
+
VKFenceWatch::~VKFenceWatch() {
if (fence) {
fence->Unprotect(this);
diff --git a/src/video_core/renderer_vulkan/vk_resource_manager.h b/src/video_core/renderer_vulkan/vk_resource_manager.h
index 08ee86fa6..3a9683f95 100644
--- a/src/video_core/renderer_vulkan/vk_resource_manager.h
+++ b/src/video_core/renderer_vulkan/vk_resource_manager.h
@@ -65,6 +65,9 @@ public:
/// Removes protection for a resource.
void Unprotect(VKResource* resource);
+ /// Redirects one protected resource to a new address.
+ void RedirectProtection(VKResource* old_resource, VKResource* new_resource) noexcept;
+
/// Retreives the fence.
operator vk::Fence() const {
return *handle;
@@ -97,8 +100,13 @@ private:
class VKFenceWatch final : public VKResource {
public:
explicit VKFenceWatch();
+ VKFenceWatch(VKFence& initial_fence);
+ VKFenceWatch(VKFenceWatch&&) noexcept;
+ VKFenceWatch(const VKFenceWatch&) = delete;
~VKFenceWatch() override;
+ VKFenceWatch& operator=(VKFenceWatch&&) noexcept;
+
/// Waits for the fence to be released.
void Wait();