From 17e36589fafe18185ee7fc40906004e86a93112c Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Tue, 6 Oct 2026 12:03:10 -0400 Subject: [PATCH] [Refactor] (P13 W5 S3): the latch twin and Magma's shared-image binding take their guards; the dual-block diagnostics stay transport. --- .../DirectVulkan/Renderer/VkTextureManager.cpp | 10 ++++++++++ MobileGL/MG_Backend/MGPipe/PipeInputs.cpp | 4 ++-- MobileGL/MG_Impl/Pipe/PipeFill.cpp | 2 +- MobileGL/MG_Pipe/PipeApply.cpp | 8 +++++++- MobileGL/MG_Pipe/PipeSessionFail.h | 7 +++++-- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp b/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp index a573dabc..173a74e5 100644 --- a/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp @@ -2153,6 +2153,7 @@ namespace MobileGL::MG_Backend::DirectVulkan { resource.yuvSource.reset(); resource.yuvConvertedFrame = 0; } +#if MOBILEGL_BUILD_DISAGGREGATED if (record.SharedImageId != 0 && !m_syncingYuvTextureStorage) { const auto yuv = MG_Remote::Server::SharedImages::Find(record.SharedImageId); if (yuv != nullptr && MG_Remote::Server::SharedImages::FourccIsYuv(yuv->Fourcc)) { @@ -2169,6 +2170,7 @@ namespace MobileGL::MG_Backend::DirectVulkan { return true; } } +#endif // Level 0 is a shared image: bind its buffer. An image that cannot be bound here leaves // the texture the storage its NULL-data definition asked for, below. if (record.SharedImageId != 0 && !m_syncingYuvTextureStorage) { @@ -2958,6 +2960,7 @@ namespace MobileGL::MG_Backend::DirectVulkan { image = ImportedSharedImage{}; } +#if MOBILEGL_BUILD_DISAGGREGATED VkTextureManager::SharedImageBind VkTextureManager::SyncWireSharedImage( const MG_Pipe::MGPipeResourceRecord& record, TextureResource& resource, Bool requireStorage) { const MG_Pipe::MGPResourceDesc& desc = record.Desc; @@ -3031,6 +3034,13 @@ namespace MobileGL::MG_Backend::DirectVulkan { desc.Resource.Gen, static_cast(id), image->Width, image->Height); return SharedImageBind::Bound; } +#else + // P13 W5: a library without a transport allocates no shared image, so no record names one. + VkTextureManager::SharedImageBind VkTextureManager::SyncWireSharedImage( + const MG_Pipe::MGPipeResourceRecord&, TextureResource&, Bool) { + return SharedImageBind::Unresolved; + } +#endif VkTextureManager::TextureResource* VkTextureManager::SyncTextureResourceByHandle( MG_Pipe::MGPipeHandle handle, Bool renderbuffer, Bool requireStorage) { diff --git a/MobileGL/MG_Backend/MGPipe/PipeInputs.cpp b/MobileGL/MG_Backend/MGPipe/PipeInputs.cpp index 89236b7c..80b56129 100644 --- a/MobileGL/MG_Backend/MGPipe/PipeInputs.cpp +++ b/MobileGL/MG_Backend/MGPipe/PipeInputs.cpp @@ -47,7 +47,7 @@ namespace MobileGL::MG_Pipe { return std::nullopt; } -#if MOBILEGL_BUILD_RECORD_ARM +#if MOBILEGL_BUILD_DISAGGREGATED // ================================================================================ // P5: the server's verb stamp, the residual-pull counter, and the four-way read verdict // ================================================================================ @@ -594,7 +594,7 @@ namespace MobileGL::MG_Pipe { if (ownership == MGPipeFieldOwnership::kBarrierPulled) CountBarrierPull(field, gPipeInputs.CurrentVerb()); } -#endif // MOBILEGL_BUILD_RECORD_ARM +#endif // MOBILEGL_BUILD_DISAGGREGATED #if MOBILEGL_PIPE_VERIFY namespace { diff --git a/MobileGL/MG_Impl/Pipe/PipeFill.cpp b/MobileGL/MG_Impl/Pipe/PipeFill.cpp index a095b0c9..78ff0e9a 100644 --- a/MobileGL/MG_Impl/Pipe/PipeFill.cpp +++ b/MobileGL/MG_Impl/Pipe/PipeFill.cpp @@ -2227,7 +2227,7 @@ namespace MobileGL::MG_Pipe { // a server-stamped verb, so InvalidateCompileEnv keeps being reachable from backend // initialisation - the case the exemption was written for - and every monolith lane, split // build included, behaves as it does today. -#if MOBILEGL_BUILD_RECORD_ARM +#if MOBILEGL_BUILD_DISAGGREGATED #define MGP_STICKY_FORWARD_PULL(Field) MGPipeStickyForwardPull(MGPipeInputField::Field) #else #define MGP_STICKY_FORWARD_PULL(Field) ((void)0) diff --git a/MobileGL/MG_Pipe/PipeApply.cpp b/MobileGL/MG_Pipe/PipeApply.cpp index 9a98ea6c..bab2675b 100644 --- a/MobileGL/MG_Pipe/PipeApply.cpp +++ b/MobileGL/MG_Pipe/PipeApply.cpp @@ -225,7 +225,7 @@ namespace MobileGL::MG_Pipe { #endif // MOBILEGL_BUILD_RECORD_ARM -#if MOBILEGL_BUILD_DISAGGREGATED +#if MOBILEGL_BUILD_RECORD_ARM namespace { MGPipeSessionLatchHook g_sessionLatchHook = nullptr; MGPipeSessionLatchArmedHook g_sessionLatchArmedHook = nullptr; @@ -240,6 +240,9 @@ namespace MobileGL::MG_Pipe { bool MGPipeSessionLatchArmed() { return g_sessionLatchArmedHook != nullptr && g_sessionLatchArmedHook(); } +#endif // MOBILEGL_BUILD_RECORD_ARM + +#if MOBILEGL_BUILD_DISAGGREGATED bool MGPipeDebugDeviceLossDue() { long at = 0; if (const char* value = std::getenv("MOBILEGL_DEBUG_INJECT_DEVICE_LOST_AT")) { @@ -317,6 +320,9 @@ namespace MobileGL::MG_Pipe { return true; } +#endif // MOBILEGL_BUILD_DISAGGREGATED + +#if MOBILEGL_BUILD_RECORD_ARM bool MGPipeSessionLatch(MGPipeFatalFamily family, const char* fmt, ...) { char line[512]; va_list args; diff --git a/MobileGL/MG_Pipe/PipeSessionFail.h b/MobileGL/MG_Pipe/PipeSessionFail.h index 899a1d6f..dbde4ce1 100644 --- a/MobileGL/MG_Pipe/PipeSessionFail.h +++ b/MobileGL/MG_Pipe/PipeSessionFail.h @@ -56,7 +56,7 @@ namespace MobileGL::MG_Pipe { UnmigratedVerb, // A call that reached an arm this build did not compile, or ran on the wrong role. RoleViolation, -#if MOBILEGL_BUILD_DISAGGREGATED +#if MOBILEGL_BUILD_RECORD_ARM // A malformed peer record rejected by the server-side applier. ProtocolCorruption, // The GPU device a session's backend renders with is lost (a GPU fault or hang the driver @@ -125,7 +125,7 @@ namespace MobileGL::MG_Pipe { // Whether the calling session already latched (false with no hook). bool MGPipeRecordLatched(); -#if MOBILEGL_BUILD_DISAGGREGATED +#if MOBILEGL_BUILD_RECORD_ARM // ---- THE LATCH TWIN: A LOST GPU DEVICE ENDS ITS SESSION, NOT THE PROCESS ---------------- // // MGPipeSessionFail is for a verb the backend cannot honour, and it does not return. A device @@ -155,6 +155,9 @@ namespace MobileGL::MG_Pipe { __attribute__((format(printf, 2, 3))) #endif MGPipeSessionLatch(MGPipeFatalFamily family, const char* fmt, ...); +#endif + +#if MOBILEGL_BUILD_DISAGGREGATED // A DEBUG KNOB THAT MAKES ONE DEVICE CHECK REPORT A LOSS, so the containment above can be // driven without a GPU that faults on demand. MOBILEGL_DEBUG_INJECT_DEVICE_LOST_AT=N (or, on