mirror of
https://github.com/hyprwm/aquamarine.git
synced 2024-11-17 03:46:00 +01:00
drm: drop buffers from KMS on .destroy
This commit is contained in:
parent
d69569698e
commit
ef43e5174b
3 changed files with 20 additions and 2 deletions
|
@ -86,12 +86,19 @@ namespace Aquamarine {
|
|||
Hyprutils::Memory::CWeakPointer<CDRMBackend> backend;
|
||||
std::array<uint32_t, 4> boHandles = {0, 0, 0, 0};
|
||||
|
||||
// true if the original buffer is gone and this has been released.
|
||||
bool dead = false;
|
||||
|
||||
private:
|
||||
CDRMFB(Hyprutils::Memory::CSharedPointer<IBuffer> buffer_, Hyprutils::Memory::CWeakPointer<CDRMBackend> backend_);
|
||||
uint32_t submitBuffer();
|
||||
void import();
|
||||
|
||||
bool dropped = false, handlesClosed = false;
|
||||
|
||||
struct {
|
||||
Hyprutils::Signal::CHyprSignalListener destroyBuffer;
|
||||
} listeners;
|
||||
};
|
||||
|
||||
struct SDRMLayer {
|
||||
|
|
|
@ -53,8 +53,7 @@ static SDRMFormat guessFormatFrom(std::vector<SDRMFormat> formats, bool cursor)
|
|||
}
|
||||
|
||||
Aquamarine::CGBMBuffer::CGBMBuffer(const SAllocatorBufferParams& params, Hyprutils::Memory::CWeakPointer<CGBMAllocator> allocator_,
|
||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) :
|
||||
allocator(allocator_) {
|
||||
Hyprutils::Memory::CSharedPointer<CSwapchain> swapchain) : allocator(allocator_) {
|
||||
if (!allocator)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1308,6 +1308,11 @@ bool Aquamarine::CDRMOutput::commitState(bool onlyTest) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (drmFB->dead) {
|
||||
backend->backend->log(AQ_LOG_ERROR, "drm: KMS buffer is dead?!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isNew && backend->primary) {
|
||||
// this is not a new buffer, and we are not on a primary GPU, which means
|
||||
// this buffer lives on the primary. We need to re-import it to update
|
||||
|
@ -1507,6 +1512,13 @@ void Aquamarine::CDRMFB::import() {
|
|||
|
||||
// FIXME: why does this implode when it doesnt on wlroots or kwin?
|
||||
// closeHandles();
|
||||
|
||||
listeners.destroyBuffer = buffer->events.destroy.registerListener([this](std::any d) {
|
||||
drop();
|
||||
dead = true;
|
||||
id = 0;
|
||||
boHandles = {0, 0, 0, 0};
|
||||
});
|
||||
}
|
||||
|
||||
void Aquamarine::CDRMFB::reimport() {
|
||||
|
|
Loading…
Reference in a new issue