Pipe: fire-and-forget is async - mipmap, copies, XFB span and storage-block rows to kWaitNone, inproc creates and PBO readbacks stop waiting, and the default dual block lets a barriered verb cost one wait (FCL BSL: ~40 sync points/frame).

This commit is contained in:
2026-10-08 19:49:04 -04:00
parent 1771381057
commit 2fbcc22410
18 changed files with 234 additions and 64 deletions
@@ -2408,6 +2408,7 @@ namespace MobileGL::MG_Remote::Client {
return seq;
}
++m_recordWaits;
if (MG_Config::Ipc.WaitStats && RunAheadArmed()) ++g_waitCensus.recordWaits[static_cast<SizeT>(op)];
const BarrierWaitScope waiting;
const Uint64 waitBudgetMs = AppliedWaitBudgetMs(op, payload);
@@ -2793,6 +2794,9 @@ namespace MobileGL::MG_Remote::Client {
// is exactly "no record is being applied" and not merely "not decoding".
if (isBarrieredFill && !ApplyThreadIsInsideApplier()) return;
if (Server::ServerLoop::OnApplyThread()) return; // the applier owns the block
// P15: with two blocks the GL thread's fill writes the client block, which the
// applier never reads (the dual-block census is empty), so there is nothing to race.
if (isBarrieredFill && MG_Pipe::MGPipeBlocksAreDistinct()) return;
SessionFail(MGFatalFamily::RoleViolation, "MGPipe: Fatal{RoleViolation, \"gPipeInputs\"} - the GL thread touched "
"gPipeInputs (%s) on a RUN-AHEAD session %s. With the client running ahead "
"the block is the server's to read for as long as ANY record is in flight "
@@ -400,6 +400,8 @@ namespace MobileGL::MG_Remote::Client {
// is never the frame's critical path; a number close to the frame count means the
// credit is what paces this workload, which is what the device exit measures.
Uint64 PresentCreditWaits() const;
// P15: how many records this session waited on (applied or reply) after publishing.
Uint64 RecordWaits() const { return m_recordWaits; }
// §2.4, called by EmitPresent immediately before it encodes: pay the credit (parking
// if this client already has `MOBILEGL_IPC_PRESENT_CREDIT` presents in flight), then
@@ -630,6 +632,7 @@ namespace MobileGL::MG_Remote::Client {
Uint32 m_pendingDamageCount = 0;
Int32 m_pendingDamage[MG_Pipe::kMGPMaxDamageRects * 4] = {};
Uint64 m_presentCreditWaits = 0;
Uint64 m_recordWaits = 0;
// sm: the spawn client owns ONE end and two bells. Held here rather
// than in the transport because which bell is "mine" is the session's
+22
View File
@@ -643,6 +643,28 @@ namespace MobileGL::MG_Remote::Client {
// (PipeApply.h:298-304), so nobody re-sends those texels. So it takes the blocking
// path instead, which is the pre-window shape exactly.
const Uint32 window = session.LinkRetainsReplies() ? CreateWindowEffective() : 1u;
// P15: UNDER RUN-AHEAD A CREATE IS FIRE-AND-FORGET. The handle is the client's own
// allocation, and the server's accept is derivable: it declines only a reserved or
// out-of-table slot or a target with no table (all protocol corruption, trip-wired on
// the server) or a texture family with no consumer, which the client already knows
// and never emits for (P4aFamilyHasItsConsumer). Waiting for that answer was a
// blocking round trip per new object (FCL + BSL: 2-3 per frame).
// A link that retains answers (the stream arm) keeps its create window, which already
// defers the answer and reads it later; this is the arm without one (the shared pool).
if (window <= 1 && session.RunAheadArmed() && !CreateIsSuspect(payload->Resource)) {
Int32 status = Wire::ReplySink::kStatusError;
const Uint64 seq = session.EmitAndWaitTails(
MGPWireOp::ResourceCreate, payload, sizeof(*payload), nullptr, 0, nullptr, 0,
&status, nullptr, /*wantReply=*/false, /*willReadReply=*/false);
if (seq != Wire::kInvalidSeq) reply->Id = seq;
MG_Pipe::MGPipePostReply(*reply,
seq == Wire::kInvalidSeq ? Wire::ReplySink::kStatusDeclined
: Wire::ReplySink::kStatusOk,
seq == Wire::kInvalidSeq ? 0u : 1u);
++g_emitted;
if (seq == Wire::kInvalidSeq) ++g_declined;
return;
}
// THE WINDOW OFF RESTORES THE OLD SHAPE EXACTLY, and is the negative control for it.
// THE WINDOW OFF, THE SUSPECT LIST FULL, OR AN OBJECT THAT HAS ALREADY BEEN REFUSED:
// all four take the blocking branch, which is the pre-window shape - and on the device