[Refactor] (P13 W5 S3): the apply side's backend comes through MG_Backend's ApplyRoleBackend hook, which ServerLoop installs.

This commit is contained in:
2026-10-06 12:13:37 -04:00
parent bb45648c41
commit 7f194a8579
4 changed files with 45 additions and 1 deletions
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
#include <MG_Backend/Record/ApplyRoleBackend.h>
#include "VertexInputStateFactory.h"
#include "MagmaPipeArms.h"
#include "MG_Util/Converters/MGToStr/DataTypeConverter.h"
@@ -464,7 +465,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
attr.IsBgra, attr.IsLong);
auto conversion = VertexStreamConversion::None;
if (format == VK_FORMAT_UNDEFINED && type == DataType::Float64) {
const auto* backend = MG_Remote::Server::ServerLoopInstance().Backend();
const auto* backend = MG_Backend::ApplyRoleBackend();
if (backend && backend->GetDynamicParameters().SupportsFloat64VertexAttributes) {
// Exactly the monolith arm's answer for the same state: with native fp64
// the module KEPT its 64-bit inputs (DemoteFloat64Pass did not run), so
@@ -0,0 +1,27 @@
// MobileGL - MobileGL/MG_Backend/Record/ApplyRoleBackend.h
// Copyright (c) 2025-2026 MobileGL-Dev
// Licensed under the GNU Lesser General Public License v3.0:
// https://www.gnu.org/licenses/gpl-3.0.txt
// https://www.gnu.org/licenses/lgpl-3.0.txt
// SPDX-License-Identifier: LGPL-3.0-only
// End of Source File Header
// P13 W5: WHOSE BACKEND ANSWERS A CAPABILITY QUESTION ON THE APPLY SIDE. Under a transport the
// server's own backend (ServerLoop's) is the authority for the records it applies; the record arm
// asked MG_Remote for it by name, which a library without MG_Remote cannot. The answer now comes
// through this hook, which ServerLoop.cpp installs at static init. Without it - a library without
// a transport - the answer is null, which is exactly what a monolith process got before (a
// monolith has no server loop, so its server backend was always null).
#pragma once
namespace MobileGL::MG_Backend {
class BackendObject;
using ApplyRoleBackendHook = BackendObject* (*)();
inline constinit ApplyRoleBackendHook gApplyRoleBackendHook = nullptr;
inline BackendObject* ApplyRoleBackend() {
return gApplyRoleBackendHook != nullptr ? gApplyRoleBackendHook() : nullptr;
}
} // namespace MobileGL::MG_Backend
+13
View File
@@ -9,6 +9,7 @@
// P5 package v1: the apply thread, its affinity, its parking, and the EGL ownership move.
#include "ServerLoop.h"
#include <MG_Backend/Record/ApplyRoleBackend.h>
#include "ApplyThreadPolicy.h"
#include "SessionRuntime.h"
#include <MG_Remote/FatalFunnel.h>
@@ -1460,6 +1461,18 @@ namespace MobileGL::MG_Remote::Server {
return instance;
}
// P13 W5: the record arm asks for the apply side's backend through MG_Backend's hook
// (Record/ApplyRoleBackend.h), which has no MG_Remote to name. Installed at static init so it
// answers from the first record on, exactly as the direct ServerLoopInstance().Backend() did.
namespace {
[[maybe_unused]] const bool g_applyRoleBackendHookInstalled = [] {
MG_Backend::gApplyRoleBackendHook = []() -> MG_Backend::BackendObject* {
return ServerLoopInstance().Backend();
};
return true;
}();
} // namespace
// ---------------------------------------------------------------------------------
// The control-frame dispatch and the twelve EGL forwarders (P5f, package fc)
// ---------------------------------------------------------------------------------
@@ -66,6 +66,9 @@ namespace MobileGL::MG_State::GLState {
if (!MG_Record::PersistentMapTracker::OnServerRole()) return;
FatalLegacyBufferArmFromApplyThread(accessor);
}
#else
// P13 W5: no transport, no apply thread to refuse.
inline void RefuseLegacyBufferArmFromApplyThread(const char*) {}
#endif
}