Skip to content

Commit

Permalink
drm: only clear buffers when fullReconfigure succeeds (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikalco authored Jan 1, 2025
1 parent eecb74d commit f7082be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/allocator/GBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hypruti

if (!foundFormat) {
allocator->backend->log(AQ_LOG_ERROR, std::format("GBM: Failed to allocate a GBM buffer: format {} isn't supported by primary backend", fourccToName(attrs.format)));
bo = nullptr;
return;
}

Expand Down
11 changes: 8 additions & 3 deletions src/allocator/Swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ bool Aquamarine::CSwapchain::reconfigure(const SSwapchainOptions& options_) {
return true;
}

if ((options_.format == options.format || options_.format == DRM_FORMAT_INVALID) && options_.size == options.size && options_.length == options.length)
if ((options_.format == options.format || options_.format == DRM_FORMAT_INVALID) && options_.size == options.size && options_.length == options.length &&
buffers.size() == options.length)
return true; // no need to reconfigure

if ((options_.format == options.format || options_.format == DRM_FORMAT_INVALID) && options_.size == options.size) {
Expand Down Expand Up @@ -70,7 +71,9 @@ SP<IBuffer> Aquamarine::CSwapchain::next(int* age) {
}

bool Aquamarine::CSwapchain::fullReconfigure(const SSwapchainOptions& options_) {
buffers.clear();
std::vector<Hyprutils::Memory::CSharedPointer<IBuffer>> bfs;
bfs.reserve(options_.length);

for (size_t i = 0; i < options_.length; ++i) {
auto buf = allocator->acquire(
SAllocatorBufferParams{.size = options_.size, .format = options_.format, .scanout = options_.scanout, .cursor = options_.cursor, .multigpu = options_.multigpu},
Expand All @@ -79,9 +82,11 @@ bool Aquamarine::CSwapchain::fullReconfigure(const SSwapchainOptions& options_)
allocator->getBackend()->log(AQ_LOG_ERROR, "Swapchain: Failed acquiring a buffer");
return false;
}
buffers.emplace_back(buf);
bfs.emplace_back(buf);
}

buffers = std::move(bfs);

return true;
}

Expand Down

0 comments on commit f7082be

Please sign in to comment.