[MG_Pipe, MG_Impl, MG_Remote, MG_Backend] (Disaggregated): P5e id - the barriered seam, the allocator guard and the two scopes

- CONTRACT-P5E §2.1's predicate gets its two names in MG_Pipe/PipeApply.h:
  MGPipeBarriered(op, payload, st) and MGPipeApplierCurrentRecordIsBarriered(),
  with MGPipeApplierState::CurrentRecordBarriered as the per-record flag that
  PipeApplier::ApplyOne stamps before every decode. The body answers TRUE for
  every record until ra lands the wait rule, so lockstep is unchanged and this
  package alters no behaviour; ra rebases onto that line rather than adding it.
  Package c0e owns the final declaration of both names - the overlap is one hunk.
- §4.4: MGPipeRefuseAllocatorFromApplyThread now exempts a probe only inside a
  named scope AND while the record being applied is barriered. The client's wait
  is the whole of what makes an apply-thread frontend probe safe; behind an
  unbarriered record the allocator's free list and lifetimeId -> slot map are
  moving under the read, so the value is wrong by construction - there is no
  "count it" arm and MOBILEGL_IPC_STRICT_ERRORS is not consulted.
- MGPipeApplierIsUnbarrieredApply() and
  MGPipeRefuseFrontendKeyedRegistryFromUnbarrieredApply() are the non-allocator
  half of the same rule, for the surfaces that answer from a frontend SharedPtr
  without calling the allocator (SlotTables.h's state note and its reader).
- Ruling 12: MGPipeReverseAnnouncementScope -> MagmaP7AllocatorDebtScope, keyed
  on MG_Config::ActiveBackendType == DirectVulkan. Magma's four apply-thread
  allocator debts move onto it (VulkanRenderer's two hidden-resource shutdowns
  and the named-blit endpoint resolve, ResourceTracker's GPU-write
  announcement); an Espryt probe can no longer borrow Magma's exemption by
  constructing its scope.
- BufferImpl::HandleOfBuffer is Espryt's debt, not Magma's, so it moves to
  MGPipeFrontendKeyedRegistryScope - which the Magma-keyed scope would not have
  exempted at all. It retires when vi/sb carry the handle into
  EnsureBufferResourceForHandle / IsBufferDrawCleanByHandle.
This commit is contained in:
2026-09-18 06:34:48 -04:00
parent 2fde70341d
commit f40a57cc96
8 changed files with 252 additions and 44 deletions
@@ -4551,7 +4551,12 @@ void main() {
// delete, so the scope admits the probe as named debt rather than letting the guard
// Fatal at server teardown. P7 gives these resources storage that is not a frontend
// object.
const MG_Pipe::MGPipeFrontendKeyedRegistryScope frontendKeyedRegistry;
//
// P5e (id), ruling 12: one of Magma's FOUR apply-thread allocator debts, and the scope
// is now named after that debt rather than after the frontend-keyed registry - Espryt's
// half of which P5e is retiring, while this one waits for P7. The exemption is keyed on
// a DirectVulkan server, which is what this file always is.
const MG_Pipe::MagmaP7AllocatorDebtScope magmaP7AllocatorDebt;
#endif
m_blitResources = {};
}
@@ -4630,8 +4635,9 @@ void main() {
#if MOBILEGL_BUILD_DISAGGREGATED
// Same shape as ShutdownBlitResources above: the hidden depth-mipmap program is a
// frontend object created and destroyed by the server backend on the apply thread, and
// its destructor's lifetime-id probe is admitted here as named debt.
const MG_Pipe::MGPipeFrontendKeyedRegistryScope frontendKeyedRegistry;
// its destructor's lifetime-id probe is admitted here as named debt - Magma's, P7's to
// retire, which is what the scope's P5e name says (ruling 12).
const MG_Pipe::MagmaP7AllocatorDebtScope magmaP7AllocatorDebt;
#endif
m_depthMipmapResources = {};
}
@@ -8974,8 +8980,11 @@ void main() {
// the resolution here is frontend-keyed - the handle was minted over the frontend
// object's lifetime id, and the two probes below (the client allocator's slot entry
// and the frontend context's framebuffer pool) are named debt inside the scope, the
// same shape as Espryt's StateForHandle arm: P3b/P4b retire it by carrying the object
// identity in the record.
// same shape as Espryt's StateForHandle arm: P7 retires it by carrying the object
// identity in the record. P5e (id), ruling 12: the third of Magma's four debts, so the
// scope it rides in is MagmaP7AllocatorDebtScope. Magma stays lockstep for the whole of
// P5e (CONTRACT-P5E §6.1), so the record being applied here is always barriered and the
// exemption still holds.
if (MG_Config::Transport != MG_Config::TransportMode::Monolith) {
auto& applierState = MG_Pipe::MGPipeApplier();
const MG_Pipe::MGPipeHandle readHandle = applierState.VerbBlitReadFbo;
@@ -8983,7 +8992,7 @@ void main() {
if (!MG_Pipe::MGPipeHandleIsNull(readHandle) || !MG_Pipe::MGPipeHandleIsNull(drawHandle)) {
const auto resolveEndpoint = [](MG_Pipe::MGPipeHandle handle)
-> SharedPtr<MG_State::GLState::FramebufferObject> {
const MG_Pipe::MGPipeFrontendKeyedRegistryScope frontendKeyedRegistry;
const MG_Pipe::MagmaP7AllocatorDebtScope magmaP7AllocatorDebt;
if (handle == MG_Pipe::kMGPipeDefaultFramebuffer) {
return MG_State::pGLContext ? MG_State::pGLContext->GetFramebufferObject(0) : nullptr;
}