mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-17 06:53:22 +09:00
[Feature] (SharedImage): a glFlush publishes an image producer's accesses, so Xwayland's glamor gets implicit sync
This commit is contained in:
@@ -1586,6 +1586,13 @@ namespace MobileGL::MG_Remote::Server {
|
||||
if (backend == nullptr) return false;
|
||||
return backend->SetCurrentDamageRegion(DamageOfRecord(op.DamageCount, op.Damage));
|
||||
}
|
||||
case MG_Pipe::kMGPSharedImageFlush: {
|
||||
// The answer is posted after the fence is published: the client commits the buffer to
|
||||
// its compositor only after this returns, so the compositor's session finds the write.
|
||||
MG_Backend::BackendObject* backend = ServerLoopInstance().Backend();
|
||||
if (backend == nullptr) return false;
|
||||
return backend->PublishSharedImageAccesses();
|
||||
}
|
||||
case MG_Pipe::kMGPSharedImageAttach: {
|
||||
SI::ImageRef image = holder.Get(op.ImageId);
|
||||
if (image == nullptr) return false;
|
||||
|
||||
@@ -394,6 +394,15 @@ namespace MobileGL::MG_Remote::Server::SharedImages {
|
||||
m_images.clear();
|
||||
}
|
||||
|
||||
void ReadTracker::PublishFrameAsWrite(int fence) {
|
||||
for (const auto& [id, image] : m_images) {
|
||||
PublishWrite(*image, Dup(fence));
|
||||
PublishRead(*image, Dup(fence));
|
||||
}
|
||||
CloseFd(fence);
|
||||
m_images.clear();
|
||||
}
|
||||
|
||||
void SessionHolder::Hold(const ImageRef& image) {
|
||||
if (image == nullptr) return;
|
||||
const std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
@@ -134,6 +134,12 @@ namespace MobileGL::MG_Remote::Server::SharedImages {
|
||||
void NoteRead(const ImageRef& image);
|
||||
// Takes ownership of `fence` (a sync_file for the frame, -1 if it has completed).
|
||||
void PublishFrame(int fence);
|
||||
// IMPLICIT SYNC BY FLUSH: a session that renders into images as well as sampling them, with
|
||||
// no swap and no explicit write (an X server's glamor) ends its frame at glFlush. Every image
|
||||
// it used since its last boundary gets `fence` both as a write - the generation moves, so the
|
||||
// next reader waits for it - and as a read, so the next writer waits for it too. Takes
|
||||
// ownership of `fence` (-1: the work has completed; the generation still moves).
|
||||
void PublishFrameAsWrite(int fence);
|
||||
SizeT Pending() const { return m_images.size(); }
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user