mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-17 15:03:25 +09:00
[Fix] (EGL, SharedImage): real EGL native fences publish a dma-buf producer's writes, so Chrome's GPU process frames reach the compositor.
This commit is contained in:
@@ -1480,6 +1480,20 @@ namespace MobileGL::MG_Remote::Server {
|
||||
return true;
|
||||
}
|
||||
|
||||
ServerVerbSink::OwnedFd& ServerVerbSink::OwnedFd::operator=(OwnedFd&& other) noexcept {
|
||||
if (this != &other) Reset(std::exchange(other.fd, -1));
|
||||
return *this;
|
||||
}
|
||||
|
||||
ServerVerbSink::OwnedFd::~OwnedFd() { Reset(-1); }
|
||||
|
||||
void ServerVerbSink::OwnedFd::Reset(int next) {
|
||||
#if !defined(_WIN32)
|
||||
if (fd >= 0) ::close(fd);
|
||||
#endif
|
||||
fd = next;
|
||||
}
|
||||
|
||||
// P14 S1. THE RING'S DOOR INTO THE SESSION'S CONTEXT TABLE.
|
||||
//
|
||||
// The record carries the client's current context token and this is where a session's
|
||||
@@ -1593,6 +1607,38 @@ namespace MobileGL::MG_Remote::Server {
|
||||
if (backend == nullptr) return false;
|
||||
return backend->PublishSharedImageAccesses();
|
||||
}
|
||||
case MG_Pipe::kMGPSharedImageNativeFence: {
|
||||
// A descriptor of the session's work, and an image writer's flush (MGPipeTypes.h). Like
|
||||
// an Allocate's, the descriptor goes out BEFORE the reply is posted.
|
||||
MG_Backend::BackendObject* backend = ServerLoopInstance().Backend();
|
||||
if (backend == nullptr) return false;
|
||||
int fence = -1;
|
||||
if (!backend->ExportNativeFence(&fence)) return false;
|
||||
#if !defined(_WIN32)
|
||||
if (fence >= 0) {
|
||||
m_lastNativeFence.Reset(::dup(fence));
|
||||
} else if (m_lastNativeFence.fd >= 0) {
|
||||
fence = ::dup(m_lastNativeFence.fd);
|
||||
}
|
||||
#endif
|
||||
reply.Format = 0;
|
||||
if (fence < 0) return true;
|
||||
Transport::ITransport* transport = session->ControlTransport();
|
||||
MG_Pipe::MGPSharedImageFdOffer offer{MG_Pipe::kMGPSharedImageFdMagic, 1, seq, 0, 0};
|
||||
const MobileGLResult shared = transport != nullptr
|
||||
? transport->ShareFd(fence, MobileGLByteSpan{&offer, sizeof(offer)})
|
||||
: MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
#if !defined(_WIN32)
|
||||
::close(fence);
|
||||
#endif
|
||||
if (shared != MOBILEGL_OK) {
|
||||
MGLOG_E_ONCE("MG_Remote server: a native fence could not be sent on the aux socket (rc=%d)",
|
||||
static_cast<int>(shared));
|
||||
return false;
|
||||
}
|
||||
reply.Format = MG_Pipe::kMGPNativeFenceFdFollows;
|
||||
return true;
|
||||
}
|
||||
case MG_Pipe::kMGPSharedImageAttach: {
|
||||
SI::ImageRef image = holder.Get(op.ImageId);
|
||||
if (image == nullptr) return false;
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "../Wire/PipeWireCodec.h"
|
||||
|
||||
#include <deque>
|
||||
#include <utility>
|
||||
|
||||
namespace MobileGL::MG_Remote::Server {
|
||||
|
||||
@@ -413,6 +414,20 @@ namespace MobileGL::MG_Remote::Server {
|
||||
Vector<GLint> m_multiBaseVertices;
|
||||
LastDrawRecord m_lastDraw{};
|
||||
Uint64 m_drawRecords = 0;
|
||||
// The newest native fence (shared_image NativeFence) this session handed out, kept so a
|
||||
// later fence with nothing left to export still answers with a descriptor: by then this
|
||||
// one has signaled (the backend waited the work out), and a signaled sync_file stays so.
|
||||
struct OwnedFd {
|
||||
int fd = -1;
|
||||
OwnedFd() = default;
|
||||
OwnedFd(const OwnedFd&) = delete;
|
||||
OwnedFd& operator=(const OwnedFd&) = delete;
|
||||
OwnedFd(OwnedFd&& other) noexcept : fd(std::exchange(other.fd, -1)) {}
|
||||
OwnedFd& operator=(OwnedFd&& other) noexcept;
|
||||
~OwnedFd();
|
||||
void Reset(int next);
|
||||
};
|
||||
OwnedFd m_lastNativeFence;
|
||||
};
|
||||
|
||||
class PipeApplier {
|
||||
|
||||
Reference in New Issue
Block a user