swapchain: add rollback

This commit is contained in:
Vaxry 2024-07-04 23:13:23 +02:00
parent 8d1d10397a
commit d3bacb4600
2 changed files with 11 additions and 0 deletions

View file

@ -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_);

View file

@ -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;
}