[Refactor] (P13 W5 S3): the latch twin and Magma's shared-image binding take their guards; the dual-block diagnostics stay transport.

This commit is contained in:
2026-10-06 12:03:10 -04:00
parent b13af729e4
commit 17e36589fa
5 changed files with 25 additions and 6 deletions
@@ -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<unsigned long long>(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) {
+2 -2
View File
@@ -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 {
+1 -1
View File
@@ -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)
+7 -1
View File
@@ -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;
+5 -2
View File
@@ -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