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

View file

@ -3,3 +3,7 @@
void IHLBuffer::sendRelease() { void IHLBuffer::sendRelease() {
resource->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 isSynchronous() = 0; // whether the updates to this buffer are synchronous, aka happen over cpu
virtual bool good() = 0; virtual bool good() = 0;
virtual void sendRelease(); virtual void sendRelease();
virtual void sendReleaseWithSurface(SP<CWLSurfaceResource>);
SP<CTexture> texture; SP<CTexture> texture;
bool opaque = false; bool opaque = false;

View file

@ -1,5 +1,9 @@
#include "WLBuffer.hpp" #include "WLBuffer.hpp"
#include "Buffer.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_) { CWLBufferResource::CWLBufferResource(SP<CWlBuffer> resource_) : resource(resource_) {
if (!good()) if (!good())
@ -27,6 +31,16 @@ void CWLBufferResource::sendRelease() {
resource->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() { wl_resource* CWLBufferResource::getResource() {
return resource->resource(); return resource->resource();
} }

View file

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