This commit is contained in:
Vaxry 2024-07-06 19:09:20 +02:00
parent e36c1e9bfa
commit c9fdf622b6
6 changed files with 24 additions and 3 deletions

View file

@ -157,7 +157,7 @@ bool CDRMSyncobjManagerResource::good() {
}
CDRMSyncobjProtocol::CDRMSyncobjProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
drmFD = fcntl(g_pCompositor->m_iDRMFD, F_DUPFD_CLOEXEC, 0);
drmFD = g_pCompositor->m_iDRMFD;
}
void CDRMSyncobjProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {

View file

@ -414,7 +414,7 @@ void CWLSurfaceResource::commitPendingState() {
// release the buffer if it's synchronous as update() has done everything thats needed
// so we can let the app know we're done.
if (current.buffer->isSynchronous()) {
current.buffer->sendRelease();
current.buffer->sendReleaseWithSurface(self.lock());
bufferReleased = true;
}
}
@ -442,7 +442,7 @@ void CWLSurfaceResource::commitPendingState() {
// for async buffers, we can only release the buffer once we are unrefing it from current.
if (previousBuffer && !previousBuffer->isSynchronous() && !bufferReleased) {
previousBuffer->sendRelease();
previousBuffer->sendReleaseWithSurface(self.lock());
bufferReleased = true;
}
}

View file

@ -3,3 +3,7 @@
void IHLBuffer::sendRelease() {
resource->sendRelease();
}
void IHLBuffer::sendReleaseWithSurface(SP<CWLSurfaceResource> surf) {
resource->sendReleaseWithSurface(surf);
}

View file

@ -17,6 +17,7 @@ class IHLBuffer : public Aquamarine::IBuffer {
virtual bool isSynchronous() = 0; // whether the updates to this buffer are synchronous, aka happen over cpu
virtual bool good() = 0;
virtual void sendRelease();
virtual void sendReleaseWithSurface(SP<CWLSurfaceResource>);
SP<CTexture> texture;
bool opaque = false;

View file

@ -1,5 +1,9 @@
#include "WLBuffer.hpp"
#include "Buffer.hpp"
#include "../core/Compositor.hpp"
#include "../DRMSyncobj.hpp"
#include "../../helpers/sync/SyncTimeline.hpp"
#include <xf86drm.h>
CWLBufferResource::CWLBufferResource(SP<CWlBuffer> resource_) : resource(resource_) {
if (!good())
@ -27,6 +31,16 @@ void CWLBufferResource::sendRelease() {
resource->sendRelease();
}
void CWLBufferResource::sendReleaseWithSurface(SP<CWLSurfaceResource> surf) {
sendRelease();
if (!surf->syncobj)
return;
if (drmSyncobjTimelineSignal(g_pCompositor->m_iDRMFD, &surf->syncobj->releaseTimeline->timeline->handle, &surf->syncobj->releasePoint, 1))
Debug::log(ERR, "sendReleaseWithSurface: drmSyncobjTimelineSignal failed");
}
wl_resource* CWLBufferResource::getResource() {
return resource->resource();
}

View file

@ -8,6 +8,7 @@
#include "../../helpers/signal/Signal.hpp"
class IHLBuffer;
class CWLSurfaceResource;
class CWLBufferResource {
public:
@ -16,6 +17,7 @@ class CWLBufferResource {
bool good();
void sendRelease();
void sendReleaseWithSurface(SP<CWLSurfaceResource>);
wl_resource* getResource();
WP<IHLBuffer> buffer;