Skip to content

Commit

Permalink
swapchain: add rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jul 4, 2024
1 parent 8d1d103 commit d3bacb4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/aquamarine/allocator/Swapchain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ namespace Aquamarine {
Hyprutils::Memory::CSharedPointer<IBuffer> 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<IAllocator> allocator_, Hyprutils::Memory::CSharedPointer<IBackendImplementation> backendImpl_);

Expand Down
6 changes: 6 additions & 0 deletions src/allocator/Swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,9 @@ bool Aquamarine::CSwapchain::contains(Hyprutils::Memory::CSharedPointer<IBuffer>
const SSwapchainOptions& Aquamarine::CSwapchain::currentOptions() {
return options;
}

void Aquamarine::CSwapchain::rollback() {
lastAcquired--;
if (lastAcquired < 0)
lastAcquired = options.length - 1;
}

0 comments on commit d3bacb4

Please sign in to comment.