diff --git a/include/aquamarine/allocator/Swapchain.hpp b/include/aquamarine/allocator/Swapchain.hpp index efc7217..3bf2074 100644 --- a/include/aquamarine/allocator/Swapchain.hpp +++ b/include/aquamarine/allocator/Swapchain.hpp @@ -24,6 +24,11 @@ namespace Aquamarine { Hyprutils::Memory::CSharedPointer next(int* age); const SSwapchainOptions& currentOptions(); + // rolls the buffers back, marking the last consumed as the next valid. + // useful if e.g. a commit fails and we don't wanna write to the previous buffer that is + // in use. + void rollback(); + private: CSwapchain(Hyprutils::Memory::CSharedPointer allocator_, Hyprutils::Memory::CSharedPointer backendImpl_); diff --git a/src/allocator/Swapchain.cpp b/src/allocator/Swapchain.cpp index f268f92..633d38a 100644 --- a/src/allocator/Swapchain.cpp +++ b/src/allocator/Swapchain.cpp @@ -114,3 +114,9 @@ bool Aquamarine::CSwapchain::contains(Hyprutils::Memory::CSharedPointer const SSwapchainOptions& Aquamarine::CSwapchain::currentOptions() { return options; } + +void Aquamarine::CSwapchain::rollback() { + lastAcquired--; + if (lastAcquired < 0) + lastAcquired = options.length - 1; +}