mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-20 16:31:57 +09:00
Compare commits
6
Commits
e6c51d0711
...
c5e1e59048
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5e1e59048 | ||
|
|
78b7d6beac | ||
|
|
a96875bf3f | ||
|
|
fe27380ab8 | ||
|
|
52ffc6a7f2 | ||
|
|
810b9b7a9f |
@@ -1111,6 +1111,9 @@ jobs:
|
||||
# and not a phase one - which is the whole reason both lanes exist.
|
||||
ctest --output-on-failure -L integration-spawn --no-tests=error -j 4 --output-junit "${RUNNER_TEMP}/spawn-baseline.xml"
|
||||
python3 ../scripts/ci/junit_tally.py "${RUNNER_TEMP}/spawn-baseline.xml" --require-spawn-ran
|
||||
ctest --show-only=json-v1 -L '^integration-tcp$' > "${RUNNER_TEMP}/tcp-discovery.json"
|
||||
ctest --output-on-failure -L '^integration-tcp$' --no-tests=error -j 4 --output-junit "${RUNNER_TEMP}/tcp-baseline.xml"
|
||||
python3 ../scripts/ci/junit_tally.py "${RUNNER_TEMP}/tcp-baseline.xml" --require-tcp-ran --require-run-ahead --discovery "${RUNNER_TEMP}/tcp-discovery.json"
|
||||
|
||||
# Both full transport runs are hard gates. The per-case comparison below
|
||||
# remains diagnostic because explicit mechanism controls retain their own mode.
|
||||
@@ -2940,6 +2943,9 @@ jobs:
|
||||
- name: The MGPipe generators' checks can still fail
|
||||
run: python3 scripts/gen_pipe.py --self-test
|
||||
|
||||
- name: The link seam owns physical storage and keeps link dispatch out of callers
|
||||
run: python3 scripts/ci/link_seam_purity.py --self-test
|
||||
|
||||
# The same question for the symbol tool the P1 gate is written in terms of.
|
||||
- name: The symbol report's buckets and gates can still fail
|
||||
run: python3 scripts/symbol_report.py --self-test
|
||||
@@ -3015,7 +3021,10 @@ jobs:
|
||||
# feat/disaggregated trigger at the top of this file. It costs a couple of seconds and needs
|
||||
# no build.
|
||||
- name: The split and retrace negative controls still reject a red that is not theirs (R-16)
|
||||
run: bash scripts/ci/control_smoke_test.sh
|
||||
run: |
|
||||
bash scripts/ci/control_smoke_test.sh
|
||||
python3 scripts/ci/test_trace_infrastructure.py
|
||||
python3 scripts/ci/tcp_lane_tools_test.py
|
||||
|
||||
# A GATE as of P3a (G5). "pool 与延迟释放原样搬" (ROADMAP.md:19) is meant literally: the
|
||||
# buffer pool, the deferred-release drain and the three persistently mapped rings move
|
||||
|
||||
@@ -592,6 +592,9 @@ endif()
|
||||
if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
message(STATUS "MobileGL: disaggregated transport ON, appending MG_Remote sources")
|
||||
list(APPEND SOURCE_FILES
|
||||
MobileGL/MG_Remote/Transport/ShmLink.cpp
|
||||
MobileGL/MG_Remote/Transport/LinkMetrics.cpp
|
||||
MobileGL/MG_Remote/Transport/StreamLink.cpp
|
||||
MobileGL/MG_Remote/Transport/Ring.cpp
|
||||
MobileGL/MG_Remote/Transport/Doorbell.cpp
|
||||
MobileGL/MG_Remote/Transport/ShmSegment.cpp
|
||||
@@ -603,6 +606,7 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
MobileGL/MG_Remote/Transport/FdPassing.cpp
|
||||
MobileGL/MG_Remote/Transport/InProcessTransport.cpp
|
||||
MobileGL/MG_Remote/Transport/SocketTransport.cpp
|
||||
MobileGL/MG_Remote/Transport/ControlInbox.cpp
|
||||
# Keeps MG_Util/Debug/Log.h - and through it the GL frontend's
|
||||
# umbrella header - out of the header-only wire code (WireLog.h).
|
||||
MobileGL/MG_Remote/Transport/WireLog.cpp
|
||||
|
||||
@@ -471,6 +471,9 @@ namespace MobileGL::MG_Config {
|
||||
// SPLIT variant already carry it, and an environment variable that nothing parses is
|
||||
// indistinguishable from one that is parsed and ignored.
|
||||
String ServerPath;
|
||||
// Control endpoint and data-plane selection are independent of topology.
|
||||
String Control = "fork"; // fork | unix:<path> | tcp://host:port
|
||||
String Data = "auto"; // auto | shm | stream
|
||||
// MOBILEGL_IPC_RING_MB: SEG_CMD size. A RECORD MAY BE AT MOST HALF OF THIS
|
||||
// (RingProducer::MaxRecordBytes), so 8 MiB caps one record at 4 MiB; R-10 makes the
|
||||
// codec publish a max-record-bytes counter rather than assume that is enough.
|
||||
|
||||
@@ -378,6 +378,8 @@ namespace MobileGL::MG_ConfigLoader {
|
||||
inline void InitIpc() {
|
||||
auto& ipc = MG_Config::Ipc;
|
||||
QueryEnvVariable("MOBILEGL_IPC_SERVER_PATH", ipc.ServerPath, "");
|
||||
QueryEnvVariable("MOBILEGL_IPC_CONTROL", ipc.Control, "fork");
|
||||
QueryEnvVariable("MOBILEGL_IPC_DATA", ipc.Data, "auto");
|
||||
// Both ring floors are 1 MiB, not 0: a ring caps ONE record at half its size, and
|
||||
// the catalogue's largest fixed payload (MGPFramebufferState, 304 bytes) plus a
|
||||
// create_shader_state archive already needs far more than a toy ring. The ceilings
|
||||
|
||||
@@ -332,13 +332,13 @@ namespace MobileGL {
|
||||
};
|
||||
|
||||
struct DynamicBackendParameters {
|
||||
SizeT UniformBufferOffsetAlignment = 256;
|
||||
Uint64 UniformBufferOffsetAlignment = 256;
|
||||
// GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT, which is a SEPARATE limit from the
|
||||
// uniform one and is routinely larger: Adreno 830 reports 32 for uniform buffers and
|
||||
// 64 for storage buffers. Answering the storage query with the uniform value let an
|
||||
// application bind a storage range at an offset the driver cannot address, which it
|
||||
// accepted without error and then wrote somewhere else entirely.
|
||||
SizeT ShaderStorageBufferOffsetAlignment = 256;
|
||||
Uint64 ShaderStorageBufferOffsetAlignment = 256;
|
||||
// GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT. 1.0 means the backend cannot filter anisotropically,
|
||||
// which is also why the extension is not advertised in that case.
|
||||
Float MaxTextureMaxAnisotropy = 1.0f;
|
||||
@@ -460,8 +460,8 @@ namespace MobileGL {
|
||||
// VulkanRenderer::SelectProvokingVertexMode out of VK_EXT_provoking_vertex,
|
||||
// provokingVertexModePerPipeline and the topology, so no single convention is true
|
||||
// of the backend.
|
||||
GLenum LayerProvokingVertex = GL_UNDEFINED_VERTEX;
|
||||
GLenum ViewportIndexProvokingVertex = GL_UNDEFINED_VERTEX;
|
||||
Uint32 LayerProvokingVertex = GL_UNDEFINED_VERTEX;
|
||||
Uint32 ViewportIndexProvokingVertex = GL_UNDEFINED_VERTEX;
|
||||
Int MaxViewportWidth = 16384;
|
||||
Int MaxViewportHeight = 16384;
|
||||
Float ViewportBoundsRangeMin = 0.0f;
|
||||
@@ -558,7 +558,7 @@ namespace MobileGL {
|
||||
Bool SupportsTessellationPointSize = true;
|
||||
// The geometry-stage twin (OpCapability GeometryPointSize).
|
||||
Bool SupportsGeometryPointSize = true;
|
||||
SizeT MaxShaderStorageBlockSize = 128 * 1024 * 1024;
|
||||
Uint64 MaxShaderStorageBlockSize = 128 * 1024 * 1024;
|
||||
Uint32 SubgroupSize = 0;
|
||||
Uint32 SubgroupSupportedStages = 0;
|
||||
Uint32 SubgroupSupportedFeatures = 0;
|
||||
|
||||
@@ -120,7 +120,12 @@ MOBILEGL_GL_API void glFinish() {
|
||||
MobileGL::MG_Pipe::MGPipeClientFinish();
|
||||
#endif
|
||||
}
|
||||
MOBILEGL_GL_API void glFlush() { MGLOG_D("Implementing function: %s(...)", __FUNCTION__); }
|
||||
MOBILEGL_GL_API void glFlush() {
|
||||
MGLOG_D("Implementing function: %s(...)", __FUNCTION__);
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
MobileGL::MG_Pipe::MGPipeClientFlush();
|
||||
#endif
|
||||
}
|
||||
DECLARE_GL_FUNCTION_HEAD(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferRenderbuffer, target, attachment, renderbuffertarget, renderbuffer)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferTexture2D, target, attachment, textarget, texture, level)
|
||||
DECLARE_GL_FUNCTION_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FrontFace, mode)
|
||||
|
||||
@@ -1251,6 +1251,14 @@ namespace MobileGL::MG_Pipe {
|
||||
|
||||
// P5e (ra), CONTRACT-P5E §2.5. Declared in PipeMutation.h; see there for why it is not a
|
||||
// ClientSession call at the GL entry point.
|
||||
void MGPipeClientFlush() {
|
||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||
if (MG_Remote::Client::RunsAsTheServerRole()) return;
|
||||
if (MG_Remote::Client::ClientSession* session = MG_Remote::Client::ClientSession::Active()) {
|
||||
session->Flush();
|
||||
}
|
||||
}
|
||||
|
||||
void MGPipeClientFinish() {
|
||||
if (MG_Config::Transport == MG_Config::TransportMode::Monolith) return;
|
||||
if (MG_Remote::Client::RunsAsTheServerRole()) return;
|
||||
|
||||
@@ -600,11 +600,11 @@ namespace MobileGL::MG_Pipe {
|
||||
// so only a non-empty run goes through the bounds-checked resolve.
|
||||
if (bytes.Size != 0) {
|
||||
auto* session = MG_Remote::Client::ClientSession::Active();
|
||||
const void* resolved =
|
||||
session == nullptr
|
||||
? nullptr
|
||||
: session->Segments().Resolve(MG_Remote::Wire::kSegEvent, bytes.Offset,
|
||||
bytes.Size);
|
||||
const void* resolved = nullptr;
|
||||
if (session && session->DataLink()) {
|
||||
session->DataLink()->ResolveSpan(MG_Remote::Transport::LinkSegment::Event,
|
||||
{bytes.Offset, bytes.Size}, &resolved);
|
||||
}
|
||||
if (resolved == nullptr) {
|
||||
MGLOG_F("MGPipe: Fatal{ProtocolCorruption, \"OnBufferWriteback.Offset\"} - "
|
||||
"the writeback blobref's {%llu + %llu} does not resolve inside the "
|
||||
|
||||
@@ -2003,6 +2003,38 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
"MOBILEGL_IPC_SERVER_PATH=${MGL_ITEST_SPLIT_SERVER_PATH}" "MGITEST_SPLIT_LANE=1"
|
||||
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV})
|
||||
|
||||
# A single supervisor serves one session at a time. Fixture teardown also reaps a
|
||||
# child left behind by a failed client; the resource lock serializes this lane.
|
||||
set(MOBILEGL_ITEST_TCP_ENDPOINT "tcp://127.0.0.1:40613" CACHE STRING "Loopback TCP integration endpoint")
|
||||
set(MOBILEGL_ITEST_TCP_DEVICE_ENDPOINT "" CACHE STRING "Optional device TCP integration endpoint")
|
||||
set(MOBILEGL_ITEST_TCP_DEVICE_TOKEN "" CACHE STRING "Token for the device TCP integration endpoint")
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
set(MGL_TCP_FIXTURE "${CMAKE_SOURCE_DIR}/scripts/ci/tcp_server_fixture.py")
|
||||
set(MGL_TCP_STATE "${CMAKE_CURRENT_BINARY_DIR}/tcp-server.json")
|
||||
add_test(NAME TcpServer.Start COMMAND "${Python3_EXECUTABLE}" "${MGL_TCP_FIXTURE}"
|
||||
start --server "${MGL_ITEST_SPLIT_SERVER_PATH}" --endpoint "${MOBILEGL_ITEST_TCP_ENDPOINT}"
|
||||
--state "${MGL_TCP_STATE}")
|
||||
add_test(NAME TcpServer.Stop COMMAND "${Python3_EXECUTABLE}" "${MGL_TCP_FIXTURE}"
|
||||
stop --state "${MGL_TCP_STATE}")
|
||||
set_tests_properties(TcpServer.Start PROPERTIES FIXTURES_SETUP mobilegl-tcp TIMEOUT 20)
|
||||
set_tests_properties(TcpServer.Stop PROPERTIES FIXTURES_CLEANUP mobilegl-tcp TIMEOUT 20)
|
||||
add_test(NAME TcpLane.AccountingControls COMMAND "${Python3_EXECUTABLE}"
|
||||
"${CMAKE_SOURCE_DIR}/scripts/ci/tcp_lane_tools_test.py")
|
||||
set_tests_properties(TcpLane.AccountingControls PROPERTIES LABELS unit TIMEOUT 20)
|
||||
mgl_itest_join_environment(MGL_ITEST_GLES_TCP_ENVIRONMENT
|
||||
"MOBILEGL_BACKEND_TYPE=DirectGLES" "MOBILEGL_TRANSPORT=spawn"
|
||||
"MOBILEGL_IPC_CONTROL=${MOBILEGL_ITEST_TCP_ENDPOINT}" "MOBILEGL_IPC_DATA=stream"
|
||||
"MOBILEGL_IPC_REQUIRE_SAME_BUILD=1" "MOBILEGL_IPC_LOG_FORWARD=1" "MOBILEGL_IPC_TOKEN="
|
||||
"MGITEST_SPLIT_LANE=1" "MGITEST_TCP_LANE=1" "MOBILEGL_ITEST_REQUIRE_GPU=1"
|
||||
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV})
|
||||
mgl_itest_join_environment(MGL_ITEST_GLES_TCPDEVICE_ENVIRONMENT
|
||||
"MOBILEGL_BACKEND_TYPE=DirectGLES" "MOBILEGL_TRANSPORT=spawn"
|
||||
"MOBILEGL_IPC_CONTROL=${MOBILEGL_ITEST_TCP_DEVICE_ENDPOINT}" "MOBILEGL_IPC_DATA=stream"
|
||||
"MOBILEGL_IPC_REQUIRE_SAME_BUILD=1" "MOBILEGL_IPC_LOG_FORWARD=1"
|
||||
"MOBILEGL_IPC_TOKEN=${MOBILEGL_ITEST_TCP_DEVICE_TOKEN}"
|
||||
"MGITEST_SPLIT_LANE=1" "MGITEST_TCP_LANE=1" "MOBILEGL_ITEST_REQUIRE_GPU=1"
|
||||
${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV})
|
||||
|
||||
# scenarioFilter, a PREFIX TAIL (empty for most; "F1." and "Ct." for the two per-slot loops,
|
||||
# which name their sub-lane in the test name), then zero or more EXTRA LABEL STEMS. A stem is
|
||||
# suffixed with the arm's own name (`integration-clientarrays` becomes `-split` on one arm and
|
||||
@@ -2017,9 +2049,20 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
set(MGL_SPLIT_ARM_TEST_LISTS "")
|
||||
set(MGL_SPLIT_ARM_INDEX 0)
|
||||
macro(mgl_itest_register_split_arms scenarioFilter prefixTail)
|
||||
foreach(mglItestArm IN ITEMS Split Spawn)
|
||||
set(mglItestArms Split Spawn Tcp)
|
||||
if(MOBILEGL_ITEST_TCP_DEVICE_ENDPOINT)
|
||||
list(APPEND mglItestArms TcpDevice)
|
||||
endif()
|
||||
foreach(mglItestArm IN LISTS mglItestArms)
|
||||
string(TOLOWER "${mglItestArm}" mglItestArmLower)
|
||||
string(TOUPPER "${mglItestArm}" mglItestArmUpper)
|
||||
set(mglItestArmProperties)
|
||||
if(mglItestArm STREQUAL "Tcp")
|
||||
set(mglItestArmProperties FIXTURES_REQUIRED mobilegl-tcp RESOURCE_LOCK mobilegl-tcp)
|
||||
elseif(mglItestArm STREQUAL "TcpDevice")
|
||||
set(mglItestArmLower tcp-device)
|
||||
set(mglItestArmProperties RESOURCE_LOCK mobilegl-tcp-device)
|
||||
endif()
|
||||
set(mglItestArmLabels "integration-gpu\\;integration-${mglItestArmLower}")
|
||||
foreach(mglItestExtra IN ITEMS ${ARGN})
|
||||
set(mglItestArmLabels "${mglItestArmLabels}\\;${mglItestExtra}-${mglItestArmLower}")
|
||||
@@ -2042,6 +2085,7 @@ if (MOBILEGL_BUILD_DISAGGREGATED)
|
||||
LABELS "${mglItestArmLabels}"
|
||||
TIMEOUT ${MGL_ITEST_TIMEOUT}
|
||||
ENVIRONMENT "${MGL_ITEST_GLES_${mglItestArmUpper}_ENVIRONMENT}"
|
||||
${mglItestArmProperties}
|
||||
)
|
||||
list(APPEND MGL_SPLIT_ARM_TEST_LISTS "MGL_SPLIT_ARM_TESTS_${MGL_SPLIT_ARM_INDEX}")
|
||||
math(EXPR MGL_SPLIT_ARM_INDEX "${MGL_SPLIT_ARM_INDEX} + 1")
|
||||
|
||||
@@ -327,7 +327,18 @@ namespace MGITest {
|
||||
// has thought of. Only then does the parent do the real bring-up.
|
||||
//
|
||||
// Returns an empty string when the platform survived a full bring-up.
|
||||
bool RemoteConnectRequested() {
|
||||
const char* control = std::getenv("MOBILEGL_IPC_CONTROL");
|
||||
return control != nullptr && std::strncmp(control, "tcp://", 6) == 0;
|
||||
}
|
||||
|
||||
std::string PreflightBringUp() {
|
||||
// Connect already isolates driver setup in the server's session
|
||||
// child. A local pre-flight would consume a remote session, then
|
||||
// race its teardown and make the actual test receive Refuse{Busy}.
|
||||
if (RemoteConnectRequested()) {
|
||||
return {};
|
||||
}
|
||||
#if !MGITEST_HAVE_FORK_PREFLIGHT
|
||||
// No fork(): let the in-process bring-up speak for itself, which is
|
||||
// what this module did before. Windows/macOS are not CI targets for
|
||||
@@ -585,7 +596,9 @@ namespace MGITest {
|
||||
// That is a real result, not a machine without a GPU, so say so: it
|
||||
// means something is different between the two attempts (a leaked
|
||||
// exclusive device, an environment the child did not have).
|
||||
m_skipReason = reason + " - although an identical bring-up in a forked pre-flight child succeeded";
|
||||
m_skipReason = reason + (RemoteConnectRequested()
|
||||
? " - remote TCP bring-up failed"
|
||||
: " - although an identical bring-up in a forked pre-flight child succeeded");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#if !defined(__ANDROID__)
|
||||
#include <MG_State/GLState/BufferState/BufferObject.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_Util/Metrics/PipeStats.h>
|
||||
#include <Config.h>
|
||||
#define MGITEST_PERSISTENT_MAP_PEEK_LIVE 1
|
||||
#endif
|
||||
|
||||
@@ -27,6 +29,19 @@
|
||||
|
||||
namespace MGITest {
|
||||
|
||||
bool PeekSeparateClientMapStats(unsigned long long* acquisitions, unsigned long long* pushedBytes) {
|
||||
#if defined(MGITEST_PERSISTENT_MAP_PEEK_LIVE) && MOBILEGL_BUILD_DISAGGREGATED && MOBILEGL_PIPE_PUSH
|
||||
if (MobileGL::MG_Config::Transport != MobileGL::MG_Config::TransportMode::Spawn) return false;
|
||||
namespace Stats = MobileGL::MG_Util::PipeStats;
|
||||
*acquisitions = Stats::TotalCalls(Stats::CallClass::MapPersistentRoundtrips);
|
||||
*pushedBytes = Stats::TotalBytes(Stats::ByteClass::PersistentMapPush);
|
||||
return true;
|
||||
#else
|
||||
(void)acquisitions; (void)pushedBytes;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PersistentMapPeekAvailable() {
|
||||
#if defined(MGITEST_PERSISTENT_MAP_PEEK_LIVE)
|
||||
return true;
|
||||
|
||||
@@ -58,4 +58,8 @@ namespace MGITest {
|
||||
// Same contract as above: false means "could not look".
|
||||
bool PeekBufferIsLivePersistentMap(unsigned int bufferName, bool* outLive);
|
||||
|
||||
// Separate-process clients own these counters; the remote Present window
|
||||
// belongs to the server and cannot report client map acquisitions or bytes.
|
||||
bool PeekSeparateClientMapStats(unsigned long long* acquisitions, unsigned long long* pushedBytes);
|
||||
|
||||
} // namespace MGITest
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
extern "C" void MGPipeSyncPeerLog();
|
||||
#endif
|
||||
|
||||
namespace MGITest::PipeStatsWindow {
|
||||
|
||||
// P6: MOBILEGL_LOG_FILE_PATH IS A BASE NAME, NOT A FILE. The library writes one log per
|
||||
@@ -121,6 +125,9 @@ namespace MGITest::PipeStatsWindow {
|
||||
}
|
||||
|
||||
inline LogMark MarkLaneLog() {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
MGPipeSyncPeerLog();
|
||||
#endif
|
||||
return LogMark{FileSizeOrZero(LibraryLogPath()), FileSizeOrZero(ServerLibraryLogPath())};
|
||||
}
|
||||
|
||||
@@ -131,6 +138,9 @@ namespace MGITest::PipeStatsWindow {
|
||||
// which is the most expensive possible way to be wrong: it accuses the product of a defect
|
||||
// that the reader itself invented.
|
||||
inline std::string ReadLaneLogSince(const LogMark& mark) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
MGPipeSyncPeerLog();
|
||||
#endif
|
||||
return ReadFileSince(LibraryLogPath(), mark.client)
|
||||
+ ReadFileSince(ServerLibraryLogPath(), mark.server);
|
||||
}
|
||||
@@ -164,7 +174,7 @@ namespace MGITest::PipeStatsWindow {
|
||||
// "the stats channel never reached the process". Concatenated, Last() takes whichever role
|
||||
// emitted the final summary.
|
||||
inline Window LastFromLaneLog() {
|
||||
return Last(ReadWholeFile(LibraryLogPath()) + ReadWholeFile(ServerLibraryLogPath()));
|
||||
return Last(ReadLaneLog());
|
||||
}
|
||||
|
||||
// One counter out of that line, by its short name ("mpr", "draws", "csom"), or -1 when the
|
||||
|
||||
@@ -23,7 +23,11 @@
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#if defined(__linux__)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -152,6 +156,18 @@ namespace MGITest {
|
||||
RecordProperty("split_transport", state.transportName);
|
||||
RecordProperty("split_implemented_verbs", static_cast<int>(state.implementedVerbs));
|
||||
RecordProperty("split_emit_seq_at_setup", static_cast<int>(state.emitSeq));
|
||||
#if defined(__linux__)
|
||||
if (std::getenv("MGITEST_TCP_LANE")) {
|
||||
// Connect must never silently launch a local server. The
|
||||
// companion log gate proves the remote Welcome pid/endpoint.
|
||||
std::ifstream children("/proc/self/task/" + std::to_string(::getpid()) + "/children");
|
||||
ASSERT_TRUE(children.good()) << "TCP topology proof cannot read /proc children";
|
||||
int child = 0;
|
||||
ASSERT_FALSE(static_cast<bool>(children >> child))
|
||||
<< "Dial=Connect created a local server child: " << child;
|
||||
RecordProperty("tcp_local_children", 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// A scenario starts from a clean slate but shares the context (and so
|
||||
// the renderer's memos) with every other scenario in this process -
|
||||
|
||||
@@ -18,6 +18,15 @@ foreach(listName IN ITEMS @MGL_SPLIT_ARM_TEST_LISTS@)
|
||||
foreach(entry IN LISTS ${listName})
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
||||
if(entry MATCHES "TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MGITEST_STRICT_ARMING_LANE=1;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||
elseif(entry MATCHES "PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MGITEST_PMAP_LANE=1;MGITEST_PERSISTENT_MAP_ARM=emulated;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||
elseif(entry MATCHES "CtWireScenario\\.")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT "MOBILEGL_TEST_SERVER_COUNTERS=1")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
foreach(entry IN LISTS MGL_SPLIT_PA_STRICT_DRAW_TESTS MGL_SPLIT_PA_STRICT_DISPATCH_TESTS)
|
||||
@@ -28,6 +37,13 @@ foreach(scenario @MGL_SPLIT_SMALL_RING_SCENARIOS@)
|
||||
foreach(entry IN LISTS MGL_SPLIT_SMALL_${scenario}_TESTS)
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MOBILEGL_LOG_FILE_PATH=@CMAKE_CURRENT_BINARY_DIR@/split-logs/${entry}.log")
|
||||
if(entry MATCHES "TriangleScenario.TheServerStampedAVerbBoundaryOnThisDrawingFrame$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MGITEST_STRICT_ARMING_LANE=1;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||
elseif(entry MATCHES "PersistentCoherentMapScenario.TheMapLandsInTheArmItsLaneDeclares$")
|
||||
set_tests_properties("${entry}" PROPERTIES ENVIRONMENT
|
||||
"MGITEST_PMAP_LANE=1;MGITEST_PERSISTENT_MAP_ARM=emulated;MOBILEGL_PIPE_STATS=1;MOBILEGL_PIPE_STATS_PERIOD=1")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
# d1's entries are covered by MGL_SPLIT_ARM_TESTS above (P6 `t6`).
|
||||
|
||||
@@ -48,7 +48,8 @@ def paths(document):
|
||||
props = {p["name"]: p["value"] for p in test.get("properties", [])}
|
||||
values = [v.split("=", 1)[1] for v in props.get("ENVIRONMENT", [])
|
||||
if v.startswith("MOBILEGL_LOG_FILE_PATH=")]
|
||||
is_split = test["name"].startswith(("DirectGLES.Split.", "DirectVulkan.Split."))
|
||||
is_split = test["name"].startswith(("DirectGLES.Split.", "DirectVulkan.Split.",
|
||||
"DirectGLES.Spawn.", "DirectGLES.Tcp.", "DirectGLES.TcpDevice."))
|
||||
if is_split and (len(values) != 1 or not values[0]):
|
||||
raise ValueError(f"{test['name']}: requires exactly one nonempty MOBILEGL_LOG_FILE_PATH")
|
||||
for value in values:
|
||||
|
||||
@@ -55,24 +55,30 @@ namespace {
|
||||
return MobileGL::MG_Remote::Server::ServerSessionInstance().Applier().Verbs();
|
||||
}
|
||||
|
||||
// P6 `t6`: THE COUNTERS BELOW LIVE IN THE SERVER'S PROCESS, and under spawn that is not
|
||||
// this one.
|
||||
//
|
||||
// ServerVerbs() reads PipeApplier's in-process tallies. Under inproc the applier is a thread
|
||||
// here and the numbers are this process's own; under spawn it is a thread in a DIFFERENT
|
||||
// process and this process's copy stays 0 forever - so these cases would fail asserting a
|
||||
// fact about somebody else's memory, which is a harness limit and not a product defect.
|
||||
//
|
||||
// SKIPPED BY NAME RATHER THAN EXCLUDED FROM THE LANE. Exit gate 9.2 asks that
|
||||
// integration-spawn's case-name SET equal integration-split's, and a case dropped from the
|
||||
// registration would make the two sets differ silently - the exact drift the shared
|
||||
// registration macro exists to prevent. A skip keeps the name, states the reason, and is
|
||||
// counted as a skip rather than as coverage.
|
||||
//
|
||||
// WHAT WOULD RETIRE IT: cross-process telemetry, which is also what `t6`'s S8 needs for
|
||||
// SessionFaultCount() over a whole run. Until that exists this is the honest answer.
|
||||
bool ServerCountersAreObservableHere() {
|
||||
return MobileGL::MG_Config::Transport != MobileGL::MG_Config::TransportMode::Spawn;
|
||||
// Inproc reads its local sink. A separate-process session snapshots that
|
||||
// same sink on LogFlush, after the client fences its complete command prefix.
|
||||
// TCP forwards the server log; unix+shm reads the server's local role file.
|
||||
struct CounterSnapshot {
|
||||
bool valid = false;
|
||||
MobileGL::Uint64 resets = 0, serial = 0, deaths = 0;
|
||||
};
|
||||
|
||||
CounterSnapshot ServerCounters() {
|
||||
if (MobileGL::MG_Config::Transport != MobileGL::MG_Config::TransportMode::Spawn) {
|
||||
return {true, ServerVerbs().ApplierResets(), ServerVerbs().ExpectedApplierResetSerial(),
|
||||
ServerVerbs().ObjectDeaths()};
|
||||
}
|
||||
MGPipeSyncPeerLog();
|
||||
const std::string log = PipeStatsWindow::ReadWholeFile(PipeStatsWindow::ServerLibraryLogPath());
|
||||
const auto at = log.rfind("MGPipe server counters:");
|
||||
if (at == std::string::npos) return {};
|
||||
const PipeStatsWindow::Window window{true, log.substr(at, log.find('\n', at) - at)};
|
||||
const auto resets = PipeStatsWindow::CounterOrAbsent(window, "resets");
|
||||
const auto serial = PipeStatsWindow::CounterOrAbsent(window, "reset-serial");
|
||||
const auto deaths = PipeStatsWindow::CounterOrAbsent(window, "deaths");
|
||||
if (resets < 0 || serial < 0 || deaths < 0) return {};
|
||||
return {true, static_cast<MobileGL::Uint64>(resets), static_cast<MobileGL::Uint64>(serial),
|
||||
static_cast<MobileGL::Uint64>(deaths)};
|
||||
}
|
||||
|
||||
class CtWireScenario : public ScenarioTest {
|
||||
@@ -116,24 +122,20 @@ namespace {
|
||||
|
||||
TEST_F(CtWireScenario, ApplierResetCrossesAtThePrimedEdgeInSerialOrder) {
|
||||
if (!Ready()) return;
|
||||
if (!ServerCountersAreObservableHere()) {
|
||||
GTEST_SKIP() << "transport=spawn: the applier's counters are in the SERVER's process "
|
||||
"and this one's copy is 0 by construction. The record still crosses - "
|
||||
"the retrace lane is what proves that - but this case asserts on a "
|
||||
"tally only an in-process applier can publish.";
|
||||
}
|
||||
// The first verb of the process primes the tracker; the edge is the producer. The
|
||||
// clear also gives the case its pixels, so a lane that emitted nothing is red twice
|
||||
// (here and in the fixture's emit-ordinal rule).
|
||||
glClearColor(0.2f, 0.4f, 0.6f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
EXPECT_GE(ServerVerbs().ApplierResets(), 1u)
|
||||
const auto counters = ServerCounters();
|
||||
ASSERT_TRUE(counters.valid) << "server control-record telemetry missing";
|
||||
EXPECT_GE(counters.resets, 1u)
|
||||
<< "the FreshlyPrimed edge emitted no applier_reset; the server's g_applier was "
|
||||
"never reset for this session";
|
||||
// The serial sequence is the session's own count (§1: asserted, never dispatched
|
||||
// on): every record the sink accepted carried the serial it expected, or the counter
|
||||
// and the accepted tally would disagree.
|
||||
EXPECT_EQ(ServerVerbs().ExpectedApplierResetSerial(), ServerVerbs().ApplierResets())
|
||||
EXPECT_EQ(counters.serial, counters.resets)
|
||||
<< "an applier_reset record was dropped or replayed on the wire";
|
||||
|
||||
GLubyte pixel[4]{};
|
||||
@@ -169,12 +171,9 @@ namespace {
|
||||
// The object dies unbound so the destructor - and the death record - fire at the
|
||||
// delete, and the tally is read AFTER the EmitAndWait the delete blocked on.
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if (!ServerCountersAreObservableHere()) {
|
||||
GTEST_SKIP() << "transport=spawn: ObjectDeaths is the SERVER process's tally and this "
|
||||
"process's copy never moves. The death record itself crosses; what "
|
||||
"cannot cross today is the counter that would prove it here.";
|
||||
}
|
||||
const MobileGL::Uint64 deathsBefore = ServerVerbs().ObjectDeaths();
|
||||
const auto beforeCounters = ServerCounters();
|
||||
ASSERT_TRUE(beforeCounters.valid) << "server object-death telemetry missing";
|
||||
const MobileGL::Uint64 deathsBefore = beforeCounters.deaths;
|
||||
glDeleteTextures(1, &texture);
|
||||
// THE FENCE, the framebuffer case's exactly (MOBILEGL_IPC_BATCH_WAITS, default on):
|
||||
// object_death is a kCtxObject value-class record, published WITHOUT waiting for its
|
||||
@@ -183,7 +182,9 @@ namespace {
|
||||
// clock-free spin changed that timing, then failed 1 in 5. A clear is kCtxVerb and
|
||||
// still waits, and its wait covers the death.
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
EXPECT_GT(ServerVerbs().ObjectDeaths(), deathsBefore)
|
||||
const auto afterCounters = ServerCounters();
|
||||
ASSERT_TRUE(afterCounters.valid) << "server object-death telemetry missing";
|
||||
EXPECT_GT(afterCounters.deaths, deathsBefore)
|
||||
<< "the texture's death produced no object_death record; the server's twin was "
|
||||
"never told to let go";
|
||||
|
||||
@@ -230,12 +231,9 @@ namespace {
|
||||
// Die unbound, framebuffer first so the attachment's own death is a separate record.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
if (!ServerCountersAreObservableHere()) {
|
||||
GTEST_SKIP() << "transport=spawn: ObjectDeaths is the SERVER process's tally and this "
|
||||
"process's copy never moves. The death record itself crosses; what "
|
||||
"cannot cross today is the counter that would prove it here.";
|
||||
}
|
||||
const MobileGL::Uint64 deathsBefore = ServerVerbs().ObjectDeaths();
|
||||
const auto beforeCounters = ServerCounters();
|
||||
ASSERT_TRUE(beforeCounters.valid) << "server object-death telemetry missing";
|
||||
const MobileGL::Uint64 deathsBefore = beforeCounters.deaths;
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
// THE FENCE (MOBILEGL_IPC_BATCH_WAITS, default on): object_death is a kCtxObject
|
||||
// value-class record - published WITHOUT waiting for its own apply (production-safe:
|
||||
@@ -243,7 +241,9 @@ namespace {
|
||||
// server-side counter this assertion reads only moves at apply time, so it needs a
|
||||
// wait boundary: a clear is kCtxVerb and still waits, and its wait covers the death.
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
EXPECT_GT(ServerVerbs().ObjectDeaths(), deathsBefore)
|
||||
const auto afterCounters = ServerCounters();
|
||||
ASSERT_TRUE(afterCounters.valid) << "server object-death telemetry missing";
|
||||
EXPECT_GT(afterCounters.deaths, deathsBefore)
|
||||
<< "the framebuffer's death produced no object_death record - and no other "
|
||||
"opcode can carry it";
|
||||
glDeleteRenderbuffers(1, &renderbuffer);
|
||||
|
||||
@@ -466,6 +466,8 @@ void main() { oColor = vec4(vColor, 1.0); }
|
||||
}
|
||||
|
||||
Gl().EndFrame(); // close the setup window; SetUp's own store and map go in it
|
||||
unsigned long long acquisitionsBefore = 0, pushedBefore = 0;
|
||||
const bool separateClientStats = PeekSeparateClientMapStats(&acquisitionsBefore, &pushedBefore);
|
||||
|
||||
// One acquisition inside the counted window: one fresh immutable store, mapped once.
|
||||
const CoherentStore store = MakeCoherentlyMappedQuadStore();
|
||||
@@ -500,7 +502,16 @@ void main() { oColor = vec4(vColor, 1.0); }
|
||||
"not reach the process, or nothing reached PipeStats::OnPresent.";
|
||||
RecordProperty("stats_line", window.line.c_str());
|
||||
|
||||
const long long roundtrips = PipeStatsWindow::CounterOrAbsent(window, "mpr");
|
||||
unsigned long long acquisitionsAfter = 0, pushedAfter = 0;
|
||||
if (separateClientStats) {
|
||||
ASSERT_TRUE(PeekSeparateClientMapStats(&acquisitionsAfter, &pushedAfter));
|
||||
ASSERT_GE(acquisitionsAfter, acquisitionsBefore);
|
||||
ASSERT_GE(pushedAfter, pushedBefore);
|
||||
RecordProperty("stats_counter_owner", "client process totals over the counted workload");
|
||||
}
|
||||
const long long roundtrips = separateClientStats
|
||||
? static_cast<long long>(acquisitionsAfter - acquisitionsBefore)
|
||||
: PipeStatsWindow::CounterOrAbsent(window, "mpr");
|
||||
ASSERT_GE(roundtrips, 0) << "the summary line carries no mpr= field: " << window.line;
|
||||
EXPECT_EQ(roundtrips, kExpectedRoundtrips)
|
||||
<< "one PERSISTENT|WRITE|COHERENT map of one freshly defined store is ONE acquisition "
|
||||
@@ -523,7 +534,9 @@ void main() { oColor = vec4(vColor, 1.0); }
|
||||
// cross-check. Deriving the arm from pmap would have made "the push was never wired" and
|
||||
// "the store was adopted" the same reading, and they are different defects with different
|
||||
// owners.
|
||||
const double pushedBytes = PipeStatsWindow::CounterAsDoubleOrAbsent(window, "pmap");
|
||||
const double pushedBytes = separateClientStats
|
||||
? static_cast<double>(pushedAfter - pushedBefore)
|
||||
: PipeStatsWindow::CounterAsDoubleOrAbsent(window, "pmap");
|
||||
ASSERT_GE(pushedBytes, 0.0) << "the summary line carries no pmap= field: " << window.line;
|
||||
RecordProperty("persistent_map_push_bytes_per_frame", std::to_string(pushedBytes).c_str());
|
||||
RecordProperty("map_persistent_roundtrips", std::to_string(roundtrips).c_str());
|
||||
|
||||
@@ -175,10 +175,8 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPBlobRef RendererInfo;
|
||||
};
|
||||
static_assert(std::is_trivially_copyable_v<MGPCaps>, "MGPCaps must be trivially copyable");
|
||||
// Stated as a COMPOSITION rather than a literal: DynamicBackendParameters still carries
|
||||
// SizeT fields, so its literal size is ABI-dependent until P0.5 moves the caps block
|
||||
// into MGPipeValueTypes.h with fixed-width members. The assertion still fires on any
|
||||
// padding introduced between the members below.
|
||||
// Stated as a composition to catch padding between the wire members.
|
||||
// P6.5: all dynamic scalar widths are explicit; member offsets are in the wire digest.
|
||||
static_assert(sizeof(MGPCaps) == sizeof(DynamicBackendParameters) + 8 + 24 + 24,
|
||||
"MGPCaps gained padding or a member; update the wire format");
|
||||
|
||||
|
||||
@@ -263,6 +263,8 @@ namespace MobileGL::MG_Pipe {
|
||||
// monolith transport, and on a lockstep one (there the client waited out every command it
|
||||
// issued before it could reach the call).
|
||||
void MGPipeClientFinish();
|
||||
// Submit a stream link's published prefix; never wait for appliedSeq.
|
||||
void MGPipeClientFlush();
|
||||
#endif
|
||||
|
||||
void MGPipeEmitResourceCreate(MG_State::GLState::BufferObject& buffer);
|
||||
|
||||
@@ -321,6 +321,10 @@ namespace MobileGL::MG_Pipe {
|
||||
MGPReplySlot reply = MGPipeMintReplySlot();
|
||||
MGP_ResourceSubData(&record, bytes, byteCount, regions, record.RegionCount, &reply);
|
||||
const Bool accepted = MGPipeTakeReplyBool(reply, "resource_subdata");
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// A cancelled wire upload is declined even when no server reply was requested.
|
||||
if (MGPipeInstalledArm() == MGPipeRouteArm::kClientWire) return accepted;
|
||||
#endif
|
||||
return MGPipeSubDataWantsItsReply(record) ? accepted : true;
|
||||
}
|
||||
inline void MGPipeRouteBufferSubDataResident(const MGPSubData& record, const void* bytes,
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// MobileGL - P6.5 wire compatibility facts. Generated member coverage is checked by gen_pipe.py.
|
||||
#pragma once
|
||||
#include "MGPipe.h"
|
||||
#include "MGPipeRenderStateSpans.h"
|
||||
|
||||
namespace MobileGL::MG_Pipe {
|
||||
#include "generated/PipeWireLayout.inc"
|
||||
|
||||
static_assert(sizeof(Bool) == 1 && sizeof(Float) == 4 && sizeof(Int32) == 4,
|
||||
"wire scalar representation is unsupported");
|
||||
static_assert(sizeof(RenderStateParameters) == 1168, "render-state wire blob changed");
|
||||
|
||||
constexpr void WireMixNumber(Uint64& hash, Uint64 value) {
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
hash ^= (value >> (i * 8)) & 255;
|
||||
hash *= 1099511628211ull;
|
||||
}
|
||||
}
|
||||
constexpr void WireMixName(Uint64& hash, const char* name) {
|
||||
do {
|
||||
hash ^= static_cast<unsigned char>(*name);
|
||||
hash *= 1099511628211ull;
|
||||
} while (*name++ != '\0');
|
||||
}
|
||||
constexpr Uint64 WireMemberLayoutDigest(const WireLayoutMember* fields, SizeT count) {
|
||||
Uint64 hash = 1469598103934665603ull;
|
||||
for (SizeT i = 0; i < count; ++i) {
|
||||
WireMixName(hash, fields[i].Name);
|
||||
WireMixNumber(hash, fields[i].Offset);
|
||||
WireMixNumber(hash, fields[i].Size);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
inline constexpr Uint64 kMGPipeWireMemberLayoutDigest = WireMemberLayoutDigest(
|
||||
kMGPipeWireLayoutMembers, sizeof(kMGPipeWireLayoutMembers) / sizeof(WireLayoutMember));
|
||||
|
||||
constexpr Uint64 WireCatalogueDigest() {
|
||||
Uint64 hash = 1469598103934665603ull;
|
||||
for (const auto& call : kMGPipeWireCallLayouts) {
|
||||
WireMixName(hash, call.Name);
|
||||
WireMixName(hash, call.Payload);
|
||||
WireMixNumber(hash, call.Op);
|
||||
WireMixNumber(hash, call.Flags);
|
||||
WireMixNumber(hash, call.Wait);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
inline constexpr Uint64 kMGPipeWireCatalogueDigest = WireCatalogueDigest();
|
||||
constexpr Uint64 WireRenderStateDigest() {
|
||||
Uint64 hash = 1469598103934665603ull;
|
||||
WireMixNumber(hash, kMGPipeRenderStateChunkTableVersion);
|
||||
for (SizeT boundary : kMGPipeRenderStateChunkBoundaries) WireMixNumber(hash, boundary);
|
||||
return hash;
|
||||
}
|
||||
} // namespace MobileGL::MG_Pipe
|
||||
@@ -0,0 +1,756 @@
|
||||
// MobileGL - MobileGL/MG_Pipe/generated/PipeWireLayout.inc
|
||||
// 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
|
||||
|
||||
// P6.5: wire layout and ordered catalogue.
|
||||
//
|
||||
// GENERATED by scripts/gen_pipe.py from PipeFields.def and PipeCalls.def - DO NOT EDIT.
|
||||
// Regenerate with `python3 scripts/gen_pipe.py`; CI runs it and diffs the result.
|
||||
// This file is included from MG_Pipe/MGPipe.h inside namespace MobileGL::MG_Pipe.
|
||||
|
||||
struct WireLayoutMember { const char* Name; Uint64 Offset; Uint64 Size; };
|
||||
inline constexpr WireLayoutMember kMGPipeWireLayoutMembers[] = {
|
||||
{"MGPBlobRef", 0, sizeof(MGPBlobRef)},
|
||||
{"MGPBlobRef.Offset", offsetof(MGPBlobRef, Offset), sizeof(((MGPBlobRef*)nullptr)->Offset)},
|
||||
{"MGPBlobRef.Size", offsetof(MGPBlobRef, Size), sizeof(((MGPBlobRef*)nullptr)->Size)},
|
||||
{"MGPBlobRef.Seg", offsetof(MGPBlobRef, Seg), sizeof(((MGPBlobRef*)nullptr)->Seg)},
|
||||
{"MGPRange", 0, sizeof(MGPRange)},
|
||||
{"MGPRange.Offset", offsetof(MGPRange, Offset), sizeof(((MGPRange*)nullptr)->Offset)},
|
||||
{"MGPRange.Size", offsetof(MGPRange, Size), sizeof(((MGPRange*)nullptr)->Size)},
|
||||
{"MGPBox", 0, sizeof(MGPBox)},
|
||||
{"MGPBox.X", offsetof(MGPBox, X), sizeof(((MGPBox*)nullptr)->X)},
|
||||
{"MGPBox.Y", offsetof(MGPBox, Y), sizeof(((MGPBox*)nullptr)->Y)},
|
||||
{"MGPBox.Z", offsetof(MGPBox, Z), sizeof(((MGPBox*)nullptr)->Z)},
|
||||
{"MGPBox.W", offsetof(MGPBox, W), sizeof(((MGPBox*)nullptr)->W)},
|
||||
{"MGPBox.H", offsetof(MGPBox, H), sizeof(((MGPBox*)nullptr)->H)},
|
||||
{"MGPBox.D", offsetof(MGPBox, D), sizeof(((MGPBox*)nullptr)->D)},
|
||||
{"MGPReplySlot", 0, sizeof(MGPReplySlot)},
|
||||
{"MGPReplySlot.Id", offsetof(MGPReplySlot, Id), sizeof(((MGPReplySlot*)nullptr)->Id)},
|
||||
{"MGPStateChunk", 0, sizeof(MGPStateChunk)},
|
||||
{"MGPStateChunk.Offset", offsetof(MGPStateChunk, Offset), sizeof(((MGPStateChunk*)nullptr)->Offset)},
|
||||
{"MGPStateChunk.Length", offsetof(MGPStateChunk, Length), sizeof(((MGPStateChunk*)nullptr)->Length)},
|
||||
{"MGPHandleOnly", 0, sizeof(MGPHandleOnly)},
|
||||
{"MGPHandleOnly.Handle", offsetof(MGPHandleOnly, Handle), sizeof(((MGPHandleOnly*)nullptr)->Handle)},
|
||||
{"MGPHandleOnly.Kind", offsetof(MGPHandleOnly, Kind), sizeof(((MGPHandleOnly*)nullptr)->Kind)},
|
||||
{"MGPCaps", 0, sizeof(MGPCaps)},
|
||||
{"MGPCaps.Dynamic", offsetof(MGPCaps, Dynamic), sizeof(((MGPCaps*)nullptr)->Dynamic)},
|
||||
{"MGPCaps.CallMask", offsetof(MGPCaps, CallMask), sizeof(((MGPCaps*)nullptr)->CallMask)},
|
||||
{"MGPCaps.FormatCapabilities", offsetof(MGPCaps, FormatCapabilities), sizeof(((MGPCaps*)nullptr)->FormatCapabilities)},
|
||||
{"MGPCaps.RendererInfo", offsetof(MGPCaps, RendererInfo), sizeof(((MGPCaps*)nullptr)->RendererInfo)},
|
||||
{"MGPResourceDesc", 0, sizeof(MGPResourceDesc)},
|
||||
{"MGPResourceDesc.Resource", offsetof(MGPResourceDesc, Resource), sizeof(((MGPResourceDesc*)nullptr)->Resource)},
|
||||
{"MGPResourceDesc.Target", offsetof(MGPResourceDesc, Target), sizeof(((MGPResourceDesc*)nullptr)->Target)},
|
||||
{"MGPResourceDesc.StorageKind", offsetof(MGPResourceDesc, StorageKind), sizeof(((MGPResourceDesc*)nullptr)->StorageKind)},
|
||||
{"MGPResourceDesc.BindMask", offsetof(MGPResourceDesc, BindMask), sizeof(((MGPResourceDesc*)nullptr)->BindMask)},
|
||||
{"MGPResourceDesc.InternalFormat", offsetof(MGPResourceDesc, InternalFormat), sizeof(((MGPResourceDesc*)nullptr)->InternalFormat)},
|
||||
{"MGPResourceDesc.Width", offsetof(MGPResourceDesc, Width), sizeof(((MGPResourceDesc*)nullptr)->Width)},
|
||||
{"MGPResourceDesc.Height", offsetof(MGPResourceDesc, Height), sizeof(((MGPResourceDesc*)nullptr)->Height)},
|
||||
{"MGPResourceDesc.Depth", offsetof(MGPResourceDesc, Depth), sizeof(((MGPResourceDesc*)nullptr)->Depth)},
|
||||
{"MGPResourceDesc.ArrayLayers", offsetof(MGPResourceDesc, ArrayLayers), sizeof(((MGPResourceDesc*)nullptr)->ArrayLayers)},
|
||||
{"MGPResourceDesc.Levels", offsetof(MGPResourceDesc, Levels), sizeof(((MGPResourceDesc*)nullptr)->Levels)},
|
||||
{"MGPResourceDesc.Samples", offsetof(MGPResourceDesc, Samples), sizeof(((MGPResourceDesc*)nullptr)->Samples)},
|
||||
{"MGPResourceDesc.FixedSampleLocations", offsetof(MGPResourceDesc, FixedSampleLocations), sizeof(((MGPResourceDesc*)nullptr)->FixedSampleLocations)},
|
||||
{"MGPResourceDesc.Immutable", offsetof(MGPResourceDesc, Immutable), sizeof(((MGPResourceDesc*)nullptr)->Immutable)},
|
||||
{"MGPResourceDesc.Usage", offsetof(MGPResourceDesc, Usage), sizeof(((MGPResourceDesc*)nullptr)->Usage)},
|
||||
{"MGPResourceDesc.StorageFlags", offsetof(MGPResourceDesc, StorageFlags), sizeof(((MGPResourceDesc*)nullptr)->StorageFlags)},
|
||||
{"MGPResourceDesc.HasDefinedContent", offsetof(MGPResourceDesc, HasDefinedContent), sizeof(((MGPResourceDesc*)nullptr)->HasDefinedContent)},
|
||||
{"MGPResourceDesc.ImageBindableHint", offsetof(MGPResourceDesc, ImageBindableHint), sizeof(((MGPResourceDesc*)nullptr)->ImageBindableHint)},
|
||||
{"MGPResourceDesc.HasRespecifiedLevel", offsetof(MGPResourceDesc, HasRespecifiedLevel), sizeof(((MGPResourceDesc*)nullptr)->HasRespecifiedLevel)},
|
||||
{"MGPResourceDesc.GlNameForDiag", offsetof(MGPResourceDesc, GlNameForDiag), sizeof(((MGPResourceDesc*)nullptr)->GlNameForDiag)},
|
||||
{"MGPResourceDesc.RespecifiedUploadTarget", offsetof(MGPResourceDesc, RespecifiedUploadTarget), sizeof(((MGPResourceDesc*)nullptr)->RespecifiedUploadTarget)},
|
||||
{"MGPResourceDesc.RespecifiedLevel", offsetof(MGPResourceDesc, RespecifiedLevel), sizeof(((MGPResourceDesc*)nullptr)->RespecifiedLevel)},
|
||||
{"MGPResourceDesc.ViewOf", offsetof(MGPResourceDesc, ViewOf), sizeof(((MGPResourceDesc*)nullptr)->ViewOf)},
|
||||
{"MGPResourceDesc.BufferForTexBuffer", offsetof(MGPResourceDesc, BufferForTexBuffer), sizeof(((MGPResourceDesc*)nullptr)->BufferForTexBuffer)},
|
||||
{"MGPResourceDesc.BufOffset", offsetof(MGPResourceDesc, BufOffset), sizeof(((MGPResourceDesc*)nullptr)->BufOffset)},
|
||||
{"MGPResourceDesc.BufSize", offsetof(MGPResourceDesc, BufSize), sizeof(((MGPResourceDesc*)nullptr)->BufSize)},
|
||||
{"MGPFenceWait", 0, sizeof(MGPFenceWait)},
|
||||
{"MGPFenceWait.Fence", offsetof(MGPFenceWait, Fence), sizeof(((MGPFenceWait*)nullptr)->Fence)},
|
||||
{"MGPFenceWait.TimeoutNs", offsetof(MGPFenceWait, TimeoutNs), sizeof(((MGPFenceWait*)nullptr)->TimeoutNs)},
|
||||
{"MGPFenceWait.Flags", offsetof(MGPFenceWait, Flags), sizeof(((MGPFenceWait*)nullptr)->Flags)},
|
||||
{"MGPQueryDesc", 0, sizeof(MGPQueryDesc)},
|
||||
{"MGPQueryDesc.Query", offsetof(MGPQueryDesc, Query), sizeof(((MGPQueryDesc*)nullptr)->Query)},
|
||||
{"MGPQueryDesc.Kind", offsetof(MGPQueryDesc, Kind), sizeof(((MGPQueryDesc*)nullptr)->Kind)},
|
||||
{"MGPQueryDesc.Stream", offsetof(MGPQueryDesc, Stream), sizeof(((MGPQueryDesc*)nullptr)->Stream)},
|
||||
{"MGPQueryResultRequest", 0, sizeof(MGPQueryResultRequest)},
|
||||
{"MGPQueryResultRequest.Query", offsetof(MGPQueryResultRequest, Query), sizeof(((MGPQueryResultRequest*)nullptr)->Query)},
|
||||
{"MGPQueryResultRequest.Wait", offsetof(MGPQueryResultRequest, Wait), sizeof(((MGPQueryResultRequest*)nullptr)->Wait)},
|
||||
{"MGPTimestampRequest", 0, sizeof(MGPTimestampRequest)},
|
||||
{"MGPTimestampRequest.Reserved", offsetof(MGPTimestampRequest, Reserved), sizeof(((MGPTimestampRequest*)nullptr)->Reserved)},
|
||||
{"MGPRenderStateDesc", 0, sizeof(MGPRenderStateDesc)},
|
||||
{"MGPRenderStateDesc.Cso", offsetof(MGPRenderStateDesc, Cso), sizeof(((MGPRenderStateDesc*)nullptr)->Cso)},
|
||||
{"MGPRenderStateDesc.BaseCso", offsetof(MGPRenderStateDesc, BaseCso), sizeof(((MGPRenderStateDesc*)nullptr)->BaseCso)},
|
||||
{"MGPRenderStateDesc.ChunkMask", offsetof(MGPRenderStateDesc, ChunkMask), sizeof(((MGPRenderStateDesc*)nullptr)->ChunkMask)},
|
||||
{"MGPRenderStateDesc.Blob", offsetof(MGPRenderStateDesc, Blob), sizeof(((MGPRenderStateDesc*)nullptr)->Blob)},
|
||||
{"MGPBindRenderState", 0, sizeof(MGPBindRenderState)},
|
||||
{"MGPBindRenderState.Cso", offsetof(MGPBindRenderState, Cso), sizeof(((MGPBindRenderState*)nullptr)->Cso)},
|
||||
{"MGPBindRenderState.Version", offsetof(MGPBindRenderState, Version), sizeof(((MGPBindRenderState*)nullptr)->Version)},
|
||||
{"MGPBindRenderState.PipelineVersion", offsetof(MGPBindRenderState, PipelineVersion), sizeof(((MGPBindRenderState*)nullptr)->PipelineVersion)},
|
||||
{"MGPDynamicState", 0, sizeof(MGPDynamicState)},
|
||||
{"MGPDynamicState.ChunkMask", offsetof(MGPDynamicState, ChunkMask), sizeof(((MGPDynamicState*)nullptr)->ChunkMask)},
|
||||
{"MGPDynamicState.Version", offsetof(MGPDynamicState, Version), sizeof(((MGPDynamicState*)nullptr)->Version)},
|
||||
{"MGPDynamicState.Blob", offsetof(MGPDynamicState, Blob), sizeof(((MGPDynamicState*)nullptr)->Blob)},
|
||||
{"MGPVertexElements", 0, sizeof(MGPVertexElements)},
|
||||
{"MGPVertexElements.Cso", offsetof(MGPVertexElements, Cso), sizeof(((MGPVertexElements*)nullptr)->Cso)},
|
||||
{"MGPVertexElements.AttributeCount", offsetof(MGPVertexElements, AttributeCount), sizeof(((MGPVertexElements*)nullptr)->AttributeCount)},
|
||||
{"MGPVertexElements.BindingPointCount", offsetof(MGPVertexElements, BindingPointCount), sizeof(((MGPVertexElements*)nullptr)->BindingPointCount)},
|
||||
{"MGPVertexElements.Blob", offsetof(MGPVertexElements, Blob), sizeof(((MGPVertexElements*)nullptr)->Blob)},
|
||||
{"MGPSamplerDesc", 0, sizeof(MGPSamplerDesc)},
|
||||
{"MGPSamplerDesc.Cso", offsetof(MGPSamplerDesc, Cso), sizeof(((MGPSamplerDesc*)nullptr)->Cso)},
|
||||
{"MGPSamplerDesc.Parameters", offsetof(MGPSamplerDesc, Parameters), sizeof(((MGPSamplerDesc*)nullptr)->Parameters)},
|
||||
{"MGPSamplerView", 0, sizeof(MGPSamplerView)},
|
||||
{"MGPSamplerView.Cso", offsetof(MGPSamplerView, Cso), sizeof(((MGPSamplerView*)nullptr)->Cso)},
|
||||
{"MGPSamplerView.Texture", offsetof(MGPSamplerView, Texture), sizeof(((MGPSamplerView*)nullptr)->Texture)},
|
||||
{"MGPSamplerView.InternalFormat", offsetof(MGPSamplerView, InternalFormat), sizeof(((MGPSamplerView*)nullptr)->InternalFormat)},
|
||||
{"MGPSamplerView.Target", offsetof(MGPSamplerView, Target), sizeof(((MGPSamplerView*)nullptr)->Target)},
|
||||
{"MGPSamplerView.MinLevel", offsetof(MGPSamplerView, MinLevel), sizeof(((MGPSamplerView*)nullptr)->MinLevel)},
|
||||
{"MGPSamplerView.NumLevels", offsetof(MGPSamplerView, NumLevels), sizeof(((MGPSamplerView*)nullptr)->NumLevels)},
|
||||
{"MGPSamplerView.MinLayer", offsetof(MGPSamplerView, MinLayer), sizeof(((MGPSamplerView*)nullptr)->MinLayer)},
|
||||
{"MGPSamplerView.NumLayers", offsetof(MGPSamplerView, NumLayers), sizeof(((MGPSamplerView*)nullptr)->NumLayers)},
|
||||
{"MGPSamplerView.Samples", offsetof(MGPSamplerView, Samples), sizeof(((MGPSamplerView*)nullptr)->Samples)},
|
||||
{"MGPSamplerView.FixedSampleLocations", offsetof(MGPSamplerView, FixedSampleLocations), sizeof(((MGPSamplerView*)nullptr)->FixedSampleLocations)},
|
||||
{"MGPTextureParams", 0, sizeof(MGPTextureParams)},
|
||||
{"MGPTextureParams.Res", offsetof(MGPTextureParams, Res), sizeof(((MGPTextureParams*)nullptr)->Res)},
|
||||
{"MGPTextureParams.BuiltinSampler", offsetof(MGPTextureParams, BuiltinSampler), sizeof(((MGPTextureParams*)nullptr)->BuiltinSampler)},
|
||||
{"MGPTextureParams.BaseLevel", offsetof(MGPTextureParams, BaseLevel), sizeof(((MGPTextureParams*)nullptr)->BaseLevel)},
|
||||
{"MGPTextureParams.MaxLevel", offsetof(MGPTextureParams, MaxLevel), sizeof(((MGPTextureParams*)nullptr)->MaxLevel)},
|
||||
{"MGPTextureParams.Swizzle", offsetof(MGPTextureParams, Swizzle), sizeof(((MGPTextureParams*)nullptr)->Swizzle)},
|
||||
{"MGPTextureParams.DepthStencilMode", offsetof(MGPTextureParams, DepthStencilMode), sizeof(((MGPTextureParams*)nullptr)->DepthStencilMode)},
|
||||
{"MGPTextureParams.ForceResync", offsetof(MGPTextureParams, ForceResync), sizeof(((MGPTextureParams*)nullptr)->ForceResync)},
|
||||
{"MGPTextureParams.SamplerResync", offsetof(MGPTextureParams, SamplerResync), sizeof(((MGPTextureParams*)nullptr)->SamplerResync)},
|
||||
{"MGPTextureParams.MinLod", offsetof(MGPTextureParams, MinLod), sizeof(((MGPTextureParams*)nullptr)->MinLod)},
|
||||
{"MGPTextureParams.MaxLod", offsetof(MGPTextureParams, MaxLod), sizeof(((MGPTextureParams*)nullptr)->MaxLod)},
|
||||
{"MGPTextureParams.LodBias", offsetof(MGPTextureParams, LodBias), sizeof(((MGPTextureParams*)nullptr)->LodBias)},
|
||||
{"MGPProgramDesc", 0, sizeof(MGPProgramDesc)},
|
||||
{"MGPProgramDesc.Cso", offsetof(MGPProgramDesc, Cso), sizeof(((MGPProgramDesc*)nullptr)->Cso)},
|
||||
{"MGPProgramDesc.StageMask", offsetof(MGPProgramDesc, StageMask), sizeof(((MGPProgramDesc*)nullptr)->StageMask)},
|
||||
{"MGPProgramDesc.GlobalUboSize", offsetof(MGPProgramDesc, GlobalUboSize), sizeof(((MGPProgramDesc*)nullptr)->GlobalUboSize)},
|
||||
{"MGPProgramDesc.ReservedNumSamplesOffset", offsetof(MGPProgramDesc, ReservedNumSamplesOffset), sizeof(((MGPProgramDesc*)nullptr)->ReservedNumSamplesOffset)},
|
||||
{"MGPProgramDesc.SpirvStatus", offsetof(MGPProgramDesc, SpirvStatus), sizeof(((MGPProgramDesc*)nullptr)->SpirvStatus)},
|
||||
{"MGPProgramDesc.NativeFloat64", offsetof(MGPProgramDesc, NativeFloat64), sizeof(((MGPProgramDesc*)nullptr)->NativeFloat64)},
|
||||
{"MGPProgramDesc.PointSizeDemoted", offsetof(MGPProgramDesc, PointSizeDemoted), sizeof(((MGPProgramDesc*)nullptr)->PointSizeDemoted)},
|
||||
{"MGPProgramDesc.EnableSpirvValidation", offsetof(MGPProgramDesc, EnableSpirvValidation), sizeof(((MGPProgramDesc*)nullptr)->EnableSpirvValidation)},
|
||||
{"MGPProgramDesc.LinkStatus", offsetof(MGPProgramDesc, LinkStatus), sizeof(((MGPProgramDesc*)nullptr)->LinkStatus)},
|
||||
{"MGPProgramDesc.Spirv", offsetof(MGPProgramDesc, Spirv), sizeof(((MGPProgramDesc*)nullptr)->Spirv)},
|
||||
{"MGPProgramDesc.Reflection", offsetof(MGPProgramDesc, Reflection), sizeof(((MGPProgramDesc*)nullptr)->Reflection)},
|
||||
{"MGPSurface", 0, sizeof(MGPSurface)},
|
||||
{"MGPSurface.Res", offsetof(MGPSurface, Res), sizeof(((MGPSurface*)nullptr)->Res)},
|
||||
{"MGPSurface.InternalFormat", offsetof(MGPSurface, InternalFormat), sizeof(((MGPSurface*)nullptr)->InternalFormat)},
|
||||
{"MGPSurface.Kind", offsetof(MGPSurface, Kind), sizeof(((MGPSurface*)nullptr)->Kind)},
|
||||
{"MGPSurface.Layered", offsetof(MGPSurface, Layered), sizeof(((MGPSurface*)nullptr)->Layered)},
|
||||
{"MGPSurface.Level", offsetof(MGPSurface, Level), sizeof(((MGPSurface*)nullptr)->Level)},
|
||||
{"MGPSurface.Layer", offsetof(MGPSurface, Layer), sizeof(((MGPSurface*)nullptr)->Layer)},
|
||||
{"MGPSurface.UploadTarget", offsetof(MGPSurface, UploadTarget), sizeof(((MGPSurface*)nullptr)->UploadTarget)},
|
||||
{"MGPSurface.TextureTarget", offsetof(MGPSurface, TextureTarget), sizeof(((MGPSurface*)nullptr)->TextureTarget)},
|
||||
{"MGPFramebufferState", 0, sizeof(MGPFramebufferState)},
|
||||
{"MGPFramebufferState.Fbo", offsetof(MGPFramebufferState, Fbo), sizeof(((MGPFramebufferState*)nullptr)->Fbo)},
|
||||
{"MGPFramebufferState.Color", offsetof(MGPFramebufferState, Color), sizeof(((MGPFramebufferState*)nullptr)->Color)},
|
||||
{"MGPFramebufferState.Depth", offsetof(MGPFramebufferState, Depth), sizeof(((MGPFramebufferState*)nullptr)->Depth)},
|
||||
{"MGPFramebufferState.Stencil", offsetof(MGPFramebufferState, Stencil), sizeof(((MGPFramebufferState*)nullptr)->Stencil)},
|
||||
{"MGPFramebufferState.ReadSurface", offsetof(MGPFramebufferState, ReadSurface), sizeof(((MGPFramebufferState*)nullptr)->ReadSurface)},
|
||||
{"MGPFramebufferState.DrawBuffers", offsetof(MGPFramebufferState, DrawBuffers), sizeof(((MGPFramebufferState*)nullptr)->DrawBuffers)},
|
||||
{"MGPFramebufferState.Width", offsetof(MGPFramebufferState, Width), sizeof(((MGPFramebufferState*)nullptr)->Width)},
|
||||
{"MGPFramebufferState.Height", offsetof(MGPFramebufferState, Height), sizeof(((MGPFramebufferState*)nullptr)->Height)},
|
||||
{"MGPFramebufferState.Layers", offsetof(MGPFramebufferState, Layers), sizeof(((MGPFramebufferState*)nullptr)->Layers)},
|
||||
{"MGPFramebufferState.Samples", offsetof(MGPFramebufferState, Samples), sizeof(((MGPFramebufferState*)nullptr)->Samples)},
|
||||
{"MGPFramebufferState.FixedSampleLocations", offsetof(MGPFramebufferState, FixedSampleLocations), sizeof(((MGPFramebufferState*)nullptr)->FixedSampleLocations)},
|
||||
{"MGPFramebufferState.IsDefault", offsetof(MGPFramebufferState, IsDefault), sizeof(((MGPFramebufferState*)nullptr)->IsDefault)},
|
||||
{"MGPFramebufferState.Complete", offsetof(MGPFramebufferState, Complete), sizeof(((MGPFramebufferState*)nullptr)->Complete)},
|
||||
{"MGPFramebufferState.Target", offsetof(MGPFramebufferState, Target), sizeof(((MGPFramebufferState*)nullptr)->Target)},
|
||||
{"MGPFramebufferState.ContentHash", offsetof(MGPFramebufferState, ContentHash), sizeof(((MGPFramebufferState*)nullptr)->ContentHash)},
|
||||
{"MGPVertexBuffer", 0, sizeof(MGPVertexBuffer)},
|
||||
{"MGPVertexBuffer.Res", offsetof(MGPVertexBuffer, Res), sizeof(((MGPVertexBuffer*)nullptr)->Res)},
|
||||
{"MGPVertexBuffer.Offset", offsetof(MGPVertexBuffer, Offset), sizeof(((MGPVertexBuffer*)nullptr)->Offset)},
|
||||
{"MGPVertexBuffer.Stride", offsetof(MGPVertexBuffer, Stride), sizeof(((MGPVertexBuffer*)nullptr)->Stride)},
|
||||
{"MGPVertexBuffer.Divisor", offsetof(MGPVertexBuffer, Divisor), sizeof(((MGPVertexBuffer*)nullptr)->Divisor)},
|
||||
{"MGPVertexBuffer.BindingIndex", offsetof(MGPVertexBuffer, BindingIndex), sizeof(((MGPVertexBuffer*)nullptr)->BindingIndex)},
|
||||
{"MGPVertexBuffers", 0, sizeof(MGPVertexBuffers)},
|
||||
{"MGPVertexBuffers.Start", offsetof(MGPVertexBuffers, Start), sizeof(((MGPVertexBuffers*)nullptr)->Start)},
|
||||
{"MGPVertexBuffers.Count", offsetof(MGPVertexBuffers, Count), sizeof(((MGPVertexBuffers*)nullptr)->Count)},
|
||||
{"MGPVertexBuffers.BaseInstance", offsetof(MGPVertexBuffers, BaseInstance), sizeof(((MGPVertexBuffers*)nullptr)->BaseInstance)},
|
||||
{"MGPVertexBuffers.ContentHash", offsetof(MGPVertexBuffers, ContentHash), sizeof(((MGPVertexBuffers*)nullptr)->ContentHash)},
|
||||
{"MGPIndexBuffer", 0, sizeof(MGPIndexBuffer)},
|
||||
{"MGPIndexBuffer.Res", offsetof(MGPIndexBuffer, Res), sizeof(((MGPIndexBuffer*)nullptr)->Res)},
|
||||
{"MGPIndexBuffer.Offset", offsetof(MGPIndexBuffer, Offset), sizeof(((MGPIndexBuffer*)nullptr)->Offset)},
|
||||
{"MGPIndexBuffer.IndexSize", offsetof(MGPIndexBuffer, IndexSize), sizeof(((MGPIndexBuffer*)nullptr)->IndexSize)},
|
||||
{"MGPIndirectBuffers", 0, sizeof(MGPIndirectBuffers)},
|
||||
{"MGPIndirectBuffers.DrawIndirect", offsetof(MGPIndirectBuffers, DrawIndirect), sizeof(((MGPIndirectBuffers*)nullptr)->DrawIndirect)},
|
||||
{"MGPIndirectBuffers.Parameter", offsetof(MGPIndirectBuffers, Parameter), sizeof(((MGPIndirectBuffers*)nullptr)->Parameter)},
|
||||
{"MGPBoundView", 0, sizeof(MGPBoundView)},
|
||||
{"MGPBoundView.View", offsetof(MGPBoundView, View), sizeof(((MGPBoundView*)nullptr)->View)},
|
||||
{"MGPBoundView.Texture", offsetof(MGPBoundView, Texture), sizeof(((MGPBoundView*)nullptr)->Texture)},
|
||||
{"MGPBoundView.Unit", offsetof(MGPBoundView, Unit), sizeof(((MGPBoundView*)nullptr)->Unit)},
|
||||
{"MGPSamplerViews", 0, sizeof(MGPSamplerViews)},
|
||||
{"MGPSamplerViews.Start", offsetof(MGPSamplerViews, Start), sizeof(((MGPSamplerViews*)nullptr)->Start)},
|
||||
{"MGPSamplerViews.Count", offsetof(MGPSamplerViews, Count), sizeof(((MGPSamplerViews*)nullptr)->Count)},
|
||||
{"MGPSamplerViews.ContentHash", offsetof(MGPSamplerViews, ContentHash), sizeof(((MGPSamplerViews*)nullptr)->ContentHash)},
|
||||
{"MGPSamplerStates", 0, sizeof(MGPSamplerStates)},
|
||||
{"MGPSamplerStates.Start", offsetof(MGPSamplerStates, Start), sizeof(((MGPSamplerStates*)nullptr)->Start)},
|
||||
{"MGPSamplerStates.Count", offsetof(MGPSamplerStates, Count), sizeof(((MGPSamplerStates*)nullptr)->Count)},
|
||||
{"MGPSamplerStates.ContentHash", offsetof(MGPSamplerStates, ContentHash), sizeof(((MGPSamplerStates*)nullptr)->ContentHash)},
|
||||
{"MGPImageView", 0, sizeof(MGPImageView)},
|
||||
{"MGPImageView.Res", offsetof(MGPImageView, Res), sizeof(((MGPImageView*)nullptr)->Res)},
|
||||
{"MGPImageView.Unit", offsetof(MGPImageView, Unit), sizeof(((MGPImageView*)nullptr)->Unit)},
|
||||
{"MGPImageView.InternalFormat", offsetof(MGPImageView, InternalFormat), sizeof(((MGPImageView*)nullptr)->InternalFormat)},
|
||||
{"MGPImageView.Layer", offsetof(MGPImageView, Layer), sizeof(((MGPImageView*)nullptr)->Layer)},
|
||||
{"MGPImageView.Level", offsetof(MGPImageView, Level), sizeof(((MGPImageView*)nullptr)->Level)},
|
||||
{"MGPImageView.Layered", offsetof(MGPImageView, Layered), sizeof(((MGPImageView*)nullptr)->Layered)},
|
||||
{"MGPImageView.Access", offsetof(MGPImageView, Access), sizeof(((MGPImageView*)nullptr)->Access)},
|
||||
{"MGPShaderImages", 0, sizeof(MGPShaderImages)},
|
||||
{"MGPShaderImages.Start", offsetof(MGPShaderImages, Start), sizeof(((MGPShaderImages*)nullptr)->Start)},
|
||||
{"MGPShaderImages.Count", offsetof(MGPShaderImages, Count), sizeof(((MGPShaderImages*)nullptr)->Count)},
|
||||
{"MGPShaderImages.ContentHash", offsetof(MGPShaderImages, ContentHash), sizeof(((MGPShaderImages*)nullptr)->ContentHash)},
|
||||
{"MGPBufferRange", 0, sizeof(MGPBufferRange)},
|
||||
{"MGPBufferRange.Res", offsetof(MGPBufferRange, Res), sizeof(((MGPBufferRange*)nullptr)->Res)},
|
||||
{"MGPBufferRange.Offset", offsetof(MGPBufferRange, Offset), sizeof(((MGPBufferRange*)nullptr)->Offset)},
|
||||
{"MGPBufferRange.Size", offsetof(MGPBufferRange, Size), sizeof(((MGPBufferRange*)nullptr)->Size)},
|
||||
{"MGPShaderBuffers", 0, sizeof(MGPShaderBuffers)},
|
||||
{"MGPShaderBuffers.Class", offsetof(MGPShaderBuffers, Class), sizeof(((MGPShaderBuffers*)nullptr)->Class)},
|
||||
{"MGPShaderBuffers.Start", offsetof(MGPShaderBuffers, Start), sizeof(((MGPShaderBuffers*)nullptr)->Start)},
|
||||
{"MGPShaderBuffers.Count", offsetof(MGPShaderBuffers, Count), sizeof(((MGPShaderBuffers*)nullptr)->Count)},
|
||||
{"MGPShaderBuffers.WritableMask", offsetof(MGPShaderBuffers, WritableMask), sizeof(((MGPShaderBuffers*)nullptr)->WritableMask)},
|
||||
{"MGPShaderBuffers.HostSpanCount", offsetof(MGPShaderBuffers, HostSpanCount), sizeof(((MGPShaderBuffers*)nullptr)->HostSpanCount)},
|
||||
{"MGPShaderBuffers.ContentHash", offsetof(MGPShaderBuffers, ContentHash), sizeof(((MGPShaderBuffers*)nullptr)->ContentHash)},
|
||||
{"MGPStreamOutputTargets", 0, sizeof(MGPStreamOutputTargets)},
|
||||
{"MGPStreamOutputTargets.Count", offsetof(MGPStreamOutputTargets, Count), sizeof(((MGPStreamOutputTargets*)nullptr)->Count)},
|
||||
{"MGPStreamOutputTargets.Generation", offsetof(MGPStreamOutputTargets, Generation), sizeof(((MGPStreamOutputTargets*)nullptr)->Generation)},
|
||||
{"MGPStreamOutputTargets.ContentHash", offsetof(MGPStreamOutputTargets, ContentHash), sizeof(((MGPStreamOutputTargets*)nullptr)->ContentHash)},
|
||||
{"MGPGlobalConstants", 0, sizeof(MGPGlobalConstants)},
|
||||
{"MGPGlobalConstants.ShaderCso", offsetof(MGPGlobalConstants, ShaderCso), sizeof(((MGPGlobalConstants*)nullptr)->ShaderCso)},
|
||||
{"MGPGlobalConstants.Version", offsetof(MGPGlobalConstants, Version), sizeof(((MGPGlobalConstants*)nullptr)->Version)},
|
||||
{"MGPGlobalConstants.Blob", offsetof(MGPGlobalConstants, Blob), sizeof(((MGPGlobalConstants*)nullptr)->Blob)},
|
||||
{"MGPAttribValue", 0, sizeof(MGPAttribValue)},
|
||||
{"MGPAttribValue.Location", offsetof(MGPAttribValue, Location), sizeof(((MGPAttribValue*)nullptr)->Location)},
|
||||
{"MGPAttribValue.ValueClass", offsetof(MGPAttribValue, ValueClass), sizeof(((MGPAttribValue*)nullptr)->ValueClass)},
|
||||
{"MGPAttribValue.FloatView", offsetof(MGPAttribValue, FloatView), sizeof(((MGPAttribValue*)nullptr)->FloatView)},
|
||||
{"MGPAttribValue.IntView", offsetof(MGPAttribValue, IntView), sizeof(((MGPAttribValue*)nullptr)->IntView)},
|
||||
{"MGPAttribValue.UintView", offsetof(MGPAttribValue, UintView), sizeof(((MGPAttribValue*)nullptr)->UintView)},
|
||||
{"MGPVertexAttribDefaults", 0, sizeof(MGPVertexAttribDefaults)},
|
||||
{"MGPVertexAttribDefaults.Mask", offsetof(MGPVertexAttribDefaults, Mask), sizeof(((MGPVertexAttribDefaults*)nullptr)->Mask)},
|
||||
{"MGPVertexAttribDefaults.Count", offsetof(MGPVertexAttribDefaults, Count), sizeof(((MGPVertexAttribDefaults*)nullptr)->Count)},
|
||||
{"MGPPixelPackState", 0, sizeof(MGPPixelPackState)},
|
||||
{"MGPPixelPackState.Pack", offsetof(MGPPixelPackState, Pack), sizeof(((MGPPixelPackState*)nullptr)->Pack)},
|
||||
{"MGPPatchState", 0, sizeof(MGPPatchState)},
|
||||
{"MGPPatchState.Vertices", offsetof(MGPPatchState, Vertices), sizeof(((MGPPatchState*)nullptr)->Vertices)},
|
||||
{"MGPPatchState.Outer", offsetof(MGPPatchState, Outer), sizeof(((MGPPatchState*)nullptr)->Outer)},
|
||||
{"MGPPatchState.Inner", offsetof(MGPPatchState, Inner), sizeof(((MGPPatchState*)nullptr)->Inner)},
|
||||
{"ResidualValueBlock", 0, sizeof(ResidualValueBlock)},
|
||||
{"ResidualValueBlock.CapabilityBits", offsetof(ResidualValueBlock, CapabilityBits), sizeof(((ResidualValueBlock*)nullptr)->CapabilityBits)},
|
||||
{"MGPResidualValueState", 0, sizeof(MGPResidualValueState)},
|
||||
{"MGPResidualValueState.Version", offsetof(MGPResidualValueState, Version), sizeof(((MGPResidualValueState*)nullptr)->Version)},
|
||||
{"MGPResidualValueState.Blob", offsetof(MGPResidualValueState, Blob), sizeof(((MGPResidualValueState*)nullptr)->Blob)},
|
||||
{"MGPSubRegion", 0, sizeof(MGPSubRegion)},
|
||||
{"MGPSubRegion.X", offsetof(MGPSubRegion, X), sizeof(((MGPSubRegion*)nullptr)->X)},
|
||||
{"MGPSubRegion.Y", offsetof(MGPSubRegion, Y), sizeof(((MGPSubRegion*)nullptr)->Y)},
|
||||
{"MGPSubRegion.Z", offsetof(MGPSubRegion, Z), sizeof(((MGPSubRegion*)nullptr)->Z)},
|
||||
{"MGPSubRegion.W", offsetof(MGPSubRegion, W), sizeof(((MGPSubRegion*)nullptr)->W)},
|
||||
{"MGPSubRegion.H", offsetof(MGPSubRegion, H), sizeof(((MGPSubRegion*)nullptr)->H)},
|
||||
{"MGPSubRegion.D", offsetof(MGPSubRegion, D), sizeof(((MGPSubRegion*)nullptr)->D)},
|
||||
{"MGPSubRegion.SrcOffset", offsetof(MGPSubRegion, SrcOffset), sizeof(((MGPSubRegion*)nullptr)->SrcOffset)},
|
||||
{"MGPSubRegion.SrcRowStride", offsetof(MGPSubRegion, SrcRowStride), sizeof(((MGPSubRegion*)nullptr)->SrcRowStride)},
|
||||
{"MGPSubRegion.SrcSliceStride", offsetof(MGPSubRegion, SrcSliceStride), sizeof(((MGPSubRegion*)nullptr)->SrcSliceStride)},
|
||||
{"MGPSubData", 0, sizeof(MGPSubData)},
|
||||
{"MGPSubData.Res", offsetof(MGPSubData, Res), sizeof(((MGPSubData*)nullptr)->Res)},
|
||||
{"MGPSubData.Target", offsetof(MGPSubData, Target), sizeof(((MGPSubData*)nullptr)->Target)},
|
||||
{"MGPSubData.Level", offsetof(MGPSubData, Level), sizeof(((MGPSubData*)nullptr)->Level)},
|
||||
{"MGPSubData.SourceIsVerbatimLevelShadow", offsetof(MGPSubData, SourceIsVerbatimLevelShadow), sizeof(((MGPSubData*)nullptr)->SourceIsVerbatimLevelShadow)},
|
||||
{"MGPSubData.HasLiveHostWrites", offsetof(MGPSubData, HasLiveHostWrites), sizeof(((MGPSubData*)nullptr)->HasLiveHostWrites)},
|
||||
{"MGPSubData.UnionBox", offsetof(MGPSubData, UnionBox), sizeof(((MGPSubData*)nullptr)->UnionBox)},
|
||||
{"MGPSubData.RegionCount", offsetof(MGPSubData, RegionCount), sizeof(((MGPSubData*)nullptr)->RegionCount)},
|
||||
{"MGPSubData.Blob", offsetof(MGPSubData, Blob), sizeof(((MGPSubData*)nullptr)->Blob)},
|
||||
{"MGPSubData.LevelWidth", offsetof(MGPSubData, LevelWidth), sizeof(((MGPSubData*)nullptr)->LevelWidth)},
|
||||
{"MGPSubData.LevelHeight", offsetof(MGPSubData, LevelHeight), sizeof(((MGPSubData*)nullptr)->LevelHeight)},
|
||||
{"MGPSubData.LevelDepth", offsetof(MGPSubData, LevelDepth), sizeof(((MGPSubData*)nullptr)->LevelDepth)},
|
||||
{"MGPSubData.LevelPad", offsetof(MGPSubData, LevelPad), sizeof(((MGPSubData*)nullptr)->LevelPad)},
|
||||
{"MGPSubDataComplete", 0, sizeof(MGPSubDataComplete)},
|
||||
{"MGPSubDataComplete.Res", offsetof(MGPSubDataComplete, Res), sizeof(((MGPSubDataComplete*)nullptr)->Res)},
|
||||
{"MGPSubDataComplete.Target", offsetof(MGPSubDataComplete, Target), sizeof(((MGPSubDataComplete*)nullptr)->Target)},
|
||||
{"MGPSubDataComplete.FirstLevel", offsetof(MGPSubDataComplete, FirstLevel), sizeof(((MGPSubDataComplete*)nullptr)->FirstLevel)},
|
||||
{"MGPSubDataComplete.LevelCount", offsetof(MGPSubDataComplete, LevelCount), sizeof(((MGPSubDataComplete*)nullptr)->LevelCount)},
|
||||
{"MGPSubDataComplete.PullSerial", offsetof(MGPSubDataComplete, PullSerial), sizeof(((MGPSubDataComplete*)nullptr)->PullSerial)},
|
||||
{"MGPFlushRange", 0, sizeof(MGPFlushRange)},
|
||||
{"MGPFlushRange.Res", offsetof(MGPFlushRange, Res), sizeof(((MGPFlushRange*)nullptr)->Res)},
|
||||
{"MGPFlushRange.Offset", offsetof(MGPFlushRange, Offset), sizeof(((MGPFlushRange*)nullptr)->Offset)},
|
||||
{"MGPFlushRange.Size", offsetof(MGPFlushRange, Size), sizeof(((MGPFlushRange*)nullptr)->Size)},
|
||||
{"MGPFlushRange.AccessFlags", offsetof(MGPFlushRange, AccessFlags), sizeof(((MGPFlushRange*)nullptr)->AccessFlags)},
|
||||
{"MGPReadback", 0, sizeof(MGPReadback)},
|
||||
{"MGPReadback.Res", offsetof(MGPReadback, Res), sizeof(((MGPReadback*)nullptr)->Res)},
|
||||
{"MGPReadback.Offset", offsetof(MGPReadback, Offset), sizeof(((MGPReadback*)nullptr)->Offset)},
|
||||
{"MGPReadback.Size", offsetof(MGPReadback, Size), sizeof(((MGPReadback*)nullptr)->Size)},
|
||||
{"MGPCopyRegion", 0, sizeof(MGPCopyRegion)},
|
||||
{"MGPCopyRegion.Src", offsetof(MGPCopyRegion, Src), sizeof(((MGPCopyRegion*)nullptr)->Src)},
|
||||
{"MGPCopyRegion.Dst", offsetof(MGPCopyRegion, Dst), sizeof(((MGPCopyRegion*)nullptr)->Dst)},
|
||||
{"MGPCopyRegion.SrcBox", offsetof(MGPCopyRegion, SrcBox), sizeof(((MGPCopyRegion*)nullptr)->SrcBox)},
|
||||
{"MGPCopyRegion.DstX", offsetof(MGPCopyRegion, DstX), sizeof(((MGPCopyRegion*)nullptr)->DstX)},
|
||||
{"MGPCopyRegion.DstY", offsetof(MGPCopyRegion, DstY), sizeof(((MGPCopyRegion*)nullptr)->DstY)},
|
||||
{"MGPCopyRegion.DstZ", offsetof(MGPCopyRegion, DstZ), sizeof(((MGPCopyRegion*)nullptr)->DstZ)},
|
||||
{"MGPCopyRegion.SrcTarget", offsetof(MGPCopyRegion, SrcTarget), sizeof(((MGPCopyRegion*)nullptr)->SrcTarget)},
|
||||
{"MGPCopyRegion.DstTarget", offsetof(MGPCopyRegion, DstTarget), sizeof(((MGPCopyRegion*)nullptr)->DstTarget)},
|
||||
{"MGPCopyRegion.SrcLevel", offsetof(MGPCopyRegion, SrcLevel), sizeof(((MGPCopyRegion*)nullptr)->SrcLevel)},
|
||||
{"MGPCopyRegion.DstLevel", offsetof(MGPCopyRegion, DstLevel), sizeof(((MGPCopyRegion*)nullptr)->DstLevel)},
|
||||
{"MGPCopyRegion.SrcGlName", offsetof(MGPCopyRegion, SrcGlName), sizeof(((MGPCopyRegion*)nullptr)->SrcGlName)},
|
||||
{"MGPCopyRegion.DstGlName", offsetof(MGPCopyRegion, DstGlName), sizeof(((MGPCopyRegion*)nullptr)->DstGlName)},
|
||||
{"MGPBlit", 0, sizeof(MGPBlit)},
|
||||
{"MGPBlit.ReadFbo", offsetof(MGPBlit, ReadFbo), sizeof(((MGPBlit*)nullptr)->ReadFbo)},
|
||||
{"MGPBlit.DrawFbo", offsetof(MGPBlit, DrawFbo), sizeof(((MGPBlit*)nullptr)->DrawFbo)},
|
||||
{"MGPBlit.SrcX0", offsetof(MGPBlit, SrcX0), sizeof(((MGPBlit*)nullptr)->SrcX0)},
|
||||
{"MGPBlit.SrcY0", offsetof(MGPBlit, SrcY0), sizeof(((MGPBlit*)nullptr)->SrcY0)},
|
||||
{"MGPBlit.SrcX1", offsetof(MGPBlit, SrcX1), sizeof(((MGPBlit*)nullptr)->SrcX1)},
|
||||
{"MGPBlit.SrcY1", offsetof(MGPBlit, SrcY1), sizeof(((MGPBlit*)nullptr)->SrcY1)},
|
||||
{"MGPBlit.DstX0", offsetof(MGPBlit, DstX0), sizeof(((MGPBlit*)nullptr)->DstX0)},
|
||||
{"MGPBlit.DstY0", offsetof(MGPBlit, DstY0), sizeof(((MGPBlit*)nullptr)->DstY0)},
|
||||
{"MGPBlit.DstX1", offsetof(MGPBlit, DstX1), sizeof(((MGPBlit*)nullptr)->DstX1)},
|
||||
{"MGPBlit.DstY1", offsetof(MGPBlit, DstY1), sizeof(((MGPBlit*)nullptr)->DstY1)},
|
||||
{"MGPBlit.Mask", offsetof(MGPBlit, Mask), sizeof(((MGPBlit*)nullptr)->Mask)},
|
||||
{"MGPBlit.Filter", offsetof(MGPBlit, Filter), sizeof(((MGPBlit*)nullptr)->Filter)},
|
||||
{"MGPClear", 0, sizeof(MGPClear)},
|
||||
{"MGPClear.Fbo", offsetof(MGPClear, Fbo), sizeof(((MGPClear*)nullptr)->Fbo)},
|
||||
{"MGPClear.Kind", offsetof(MGPClear, Kind), sizeof(((MGPClear*)nullptr)->Kind)},
|
||||
{"MGPClear.DrawBufferIndex", offsetof(MGPClear, DrawBufferIndex), sizeof(((MGPClear*)nullptr)->DrawBufferIndex)},
|
||||
{"MGPClear.BufferMask", offsetof(MGPClear, BufferMask), sizeof(((MGPClear*)nullptr)->BufferMask)},
|
||||
{"MGPClear.ValueClass", offsetof(MGPClear, ValueClass), sizeof(((MGPClear*)nullptr)->ValueClass)},
|
||||
{"MGPClear.ColorValue", offsetof(MGPClear, ColorValue), sizeof(((MGPClear*)nullptr)->ColorValue)},
|
||||
{"MGPClear.DepthValue", offsetof(MGPClear, DepthValue), sizeof(((MGPClear*)nullptr)->DepthValue)},
|
||||
{"MGPClear.StencilValue", offsetof(MGPClear, StencilValue), sizeof(((MGPClear*)nullptr)->StencilValue)},
|
||||
{"MGPMipPlan", 0, sizeof(MGPMipPlan)},
|
||||
{"MGPMipPlan.Res", offsetof(MGPMipPlan, Res), sizeof(((MGPMipPlan*)nullptr)->Res)},
|
||||
{"MGPMipPlan.Target", offsetof(MGPMipPlan, Target), sizeof(((MGPMipPlan*)nullptr)->Target)},
|
||||
{"MGPMipPlan.BaseLevel", offsetof(MGPMipPlan, BaseLevel), sizeof(((MGPMipPlan*)nullptr)->BaseLevel)},
|
||||
{"MGPMipPlan.LevelCount", offsetof(MGPMipPlan, LevelCount), sizeof(((MGPMipPlan*)nullptr)->LevelCount)},
|
||||
{"MGPReadbackInfo", 0, sizeof(MGPReadbackInfo)},
|
||||
{"MGPReadbackInfo.Res", offsetof(MGPReadbackInfo, Res), sizeof(((MGPReadbackInfo*)nullptr)->Res)},
|
||||
{"MGPReadbackInfo.Box", offsetof(MGPReadbackInfo, Box), sizeof(((MGPReadbackInfo*)nullptr)->Box)},
|
||||
{"MGPReadbackInfo.Format", offsetof(MGPReadbackInfo, Format), sizeof(((MGPReadbackInfo*)nullptr)->Format)},
|
||||
{"MGPReadbackInfo.Type", offsetof(MGPReadbackInfo, Type), sizeof(((MGPReadbackInfo*)nullptr)->Type)},
|
||||
{"MGPReadbackInfo.Target", offsetof(MGPReadbackInfo, Target), sizeof(((MGPReadbackInfo*)nullptr)->Target)},
|
||||
{"MGPReadbackInfo.Level", offsetof(MGPReadbackInfo, Level), sizeof(((MGPReadbackInfo*)nullptr)->Level)},
|
||||
{"MGPReadbackInfo.DstOffset", offsetof(MGPReadbackInfo, DstOffset), sizeof(((MGPReadbackInfo*)nullptr)->DstOffset)},
|
||||
{"MGPReadbackInfo.DstSize", offsetof(MGPReadbackInfo, DstSize), sizeof(((MGPReadbackInfo*)nullptr)->DstSize)},
|
||||
{"MGPDrawInfo", 0, sizeof(MGPDrawInfo)},
|
||||
{"MGPDrawInfo.Mode", offsetof(MGPDrawInfo, Mode), sizeof(((MGPDrawInfo*)nullptr)->Mode)},
|
||||
{"MGPDrawInfo.IndexSize", offsetof(MGPDrawInfo, IndexSize), sizeof(((MGPDrawInfo*)nullptr)->IndexSize)},
|
||||
{"MGPDrawInfo.Flags", offsetof(MGPDrawInfo, Flags), sizeof(((MGPDrawInfo*)nullptr)->Flags)},
|
||||
{"MGPDrawInfo.InstanceCount", offsetof(MGPDrawInfo, InstanceCount), sizeof(((MGPDrawInfo*)nullptr)->InstanceCount)},
|
||||
{"MGPDrawInfo.StartInstance", offsetof(MGPDrawInfo, StartInstance), sizeof(((MGPDrawInfo*)nullptr)->StartInstance)},
|
||||
{"MGPDrawInfo.RestartIndex", offsetof(MGPDrawInfo, RestartIndex), sizeof(((MGPDrawInfo*)nullptr)->RestartIndex)},
|
||||
{"MGPDrawInfo.DrawIdOffset", offsetof(MGPDrawInfo, DrawIdOffset), sizeof(((MGPDrawInfo*)nullptr)->DrawIdOffset)},
|
||||
{"MGPDrawInfo.IndexResource", offsetof(MGPDrawInfo, IndexResource), sizeof(((MGPDrawInfo*)nullptr)->IndexResource)},
|
||||
{"MGPDrawInfo.MinIndex", offsetof(MGPDrawInfo, MinIndex), sizeof(((MGPDrawInfo*)nullptr)->MinIndex)},
|
||||
{"MGPDrawInfo.MaxIndex", offsetof(MGPDrawInfo, MaxIndex), sizeof(((MGPDrawInfo*)nullptr)->MaxIndex)},
|
||||
{"MGPDrawInfo.XfbCpuCapturedVertices", offsetof(MGPDrawInfo, XfbCpuCapturedVertices), sizeof(((MGPDrawInfo*)nullptr)->XfbCpuCapturedVertices)},
|
||||
{"MGPDrawInfo.NumDraws", offsetof(MGPDrawInfo, NumDraws), sizeof(((MGPDrawInfo*)nullptr)->NumDraws)},
|
||||
{"MGPDrawRange", 0, sizeof(MGPDrawRange)},
|
||||
{"MGPDrawRange.Start", offsetof(MGPDrawRange, Start), sizeof(((MGPDrawRange*)nullptr)->Start)},
|
||||
{"MGPDrawRange.Count", offsetof(MGPDrawRange, Count), sizeof(((MGPDrawRange*)nullptr)->Count)},
|
||||
{"MGPDrawRange.IndexBias", offsetof(MGPDrawRange, IndexBias), sizeof(((MGPDrawRange*)nullptr)->IndexBias)},
|
||||
{"MGPDrawIndirect", 0, sizeof(MGPDrawIndirect)},
|
||||
{"MGPDrawIndirect.Buffer", offsetof(MGPDrawIndirect, Buffer), sizeof(((MGPDrawIndirect*)nullptr)->Buffer)},
|
||||
{"MGPDrawIndirect.ParameterBuffer", offsetof(MGPDrawIndirect, ParameterBuffer), sizeof(((MGPDrawIndirect*)nullptr)->ParameterBuffer)},
|
||||
{"MGPDrawIndirect.Offset", offsetof(MGPDrawIndirect, Offset), sizeof(((MGPDrawIndirect*)nullptr)->Offset)},
|
||||
{"MGPDrawIndirect.ParameterOffset", offsetof(MGPDrawIndirect, ParameterOffset), sizeof(((MGPDrawIndirect*)nullptr)->ParameterOffset)},
|
||||
{"MGPDrawIndirect.Stride", offsetof(MGPDrawIndirect, Stride), sizeof(((MGPDrawIndirect*)nullptr)->Stride)},
|
||||
{"MGPDrawIndirect.DrawCount", offsetof(MGPDrawIndirect, DrawCount), sizeof(((MGPDrawIndirect*)nullptr)->DrawCount)},
|
||||
{"MGPGridInfo", 0, sizeof(MGPGridInfo)},
|
||||
{"MGPGridInfo.GridX", offsetof(MGPGridInfo, GridX), sizeof(((MGPGridInfo*)nullptr)->GridX)},
|
||||
{"MGPGridInfo.GridY", offsetof(MGPGridInfo, GridY), sizeof(((MGPGridInfo*)nullptr)->GridY)},
|
||||
{"MGPGridInfo.GridZ", offsetof(MGPGridInfo, GridZ), sizeof(((MGPGridInfo*)nullptr)->GridZ)},
|
||||
{"MGPGridInfo.BlockX", offsetof(MGPGridInfo, BlockX), sizeof(((MGPGridInfo*)nullptr)->BlockX)},
|
||||
{"MGPGridInfo.BlockY", offsetof(MGPGridInfo, BlockY), sizeof(((MGPGridInfo*)nullptr)->BlockY)},
|
||||
{"MGPGridInfo.BlockZ", offsetof(MGPGridInfo, BlockZ), sizeof(((MGPGridInfo*)nullptr)->BlockZ)},
|
||||
{"MGPGridInfo.IndirectBuffer", offsetof(MGPGridInfo, IndirectBuffer), sizeof(((MGPGridInfo*)nullptr)->IndirectBuffer)},
|
||||
{"MGPGridInfo.IndirectOffset", offsetof(MGPGridInfo, IndirectOffset), sizeof(((MGPGridInfo*)nullptr)->IndirectOffset)},
|
||||
{"MGPGridInfo.IsIndirect", offsetof(MGPGridInfo, IsIndirect), sizeof(((MGPGridInfo*)nullptr)->IsIndirect)},
|
||||
{"MGPMemoryBarrier", 0, sizeof(MGPMemoryBarrier)},
|
||||
{"MGPMemoryBarrier.Bits", offsetof(MGPMemoryBarrier, Bits), sizeof(((MGPMemoryBarrier*)nullptr)->Bits)},
|
||||
{"MGPMemoryBarrier.ByRegion", offsetof(MGPMemoryBarrier, ByRegion), sizeof(((MGPMemoryBarrier*)nullptr)->ByRegion)},
|
||||
{"MGPStreamOutputBegin", 0, sizeof(MGPStreamOutputBegin)},
|
||||
{"MGPStreamOutputBegin.PrimitiveMode", offsetof(MGPStreamOutputBegin, PrimitiveMode), sizeof(((MGPStreamOutputBegin*)nullptr)->PrimitiveMode)},
|
||||
{"MGPStreamOutputBegin.CaptureProgram", offsetof(MGPStreamOutputBegin, CaptureProgram), sizeof(((MGPStreamOutputBegin*)nullptr)->CaptureProgram)},
|
||||
{"MGPStreamOutputBegin.LifetimeId", offsetof(MGPStreamOutputBegin, LifetimeId), sizeof(((MGPStreamOutputBegin*)nullptr)->LifetimeId)},
|
||||
{"MGPStreamOutputBegin.Targets", offsetof(MGPStreamOutputBegin, Targets), sizeof(((MGPStreamOutputBegin*)nullptr)->Targets)},
|
||||
{"MGPXfbAccounting", 0, sizeof(MGPXfbAccounting)},
|
||||
{"MGPXfbAccounting.CapturedVertices", offsetof(MGPXfbAccounting, CapturedVertices), sizeof(((MGPXfbAccounting*)nullptr)->CapturedVertices)},
|
||||
{"MGPXfbAccounting.PrimitivesWritten", offsetof(MGPXfbAccounting, PrimitivesWritten), sizeof(((MGPXfbAccounting*)nullptr)->PrimitivesWritten)},
|
||||
{"MGPXfbAccounting.PrimitiveMode", offsetof(MGPXfbAccounting, PrimitiveMode), sizeof(((MGPXfbAccounting*)nullptr)->PrimitiveMode)},
|
||||
{"MGPStreamOutputControl", 0, sizeof(MGPStreamOutputControl)},
|
||||
{"MGPStreamOutputControl.Reserved", offsetof(MGPStreamOutputControl, Reserved), sizeof(((MGPStreamOutputControl*)nullptr)->Reserved)},
|
||||
{"MGPFlush", 0, sizeof(MGPFlush)},
|
||||
{"MGPFlush.Flags", offsetof(MGPFlush, Flags), sizeof(((MGPFlush*)nullptr)->Flags)},
|
||||
{"MGPPresent", 0, sizeof(MGPPresent)},
|
||||
{"MGPPresent.FrameSerial", offsetof(MGPPresent, FrameSerial), sizeof(((MGPPresent*)nullptr)->FrameSerial)},
|
||||
{"MGPSwapInterval", 0, sizeof(MGPSwapInterval)},
|
||||
{"MGPSwapInterval.Interval", offsetof(MGPSwapInterval, Interval), sizeof(((MGPSwapInterval*)nullptr)->Interval)},
|
||||
{"MGPSurfaceInfo", 0, sizeof(MGPSurfaceInfo)},
|
||||
{"MGPSurfaceInfo.Width", offsetof(MGPSurfaceInfo, Width), sizeof(((MGPSurfaceInfo*)nullptr)->Width)},
|
||||
{"MGPSurfaceInfo.Height", offsetof(MGPSurfaceInfo, Height), sizeof(((MGPSurfaceInfo*)nullptr)->Height)},
|
||||
{"MGPSurfaceInfo.InternalFormat", offsetof(MGPSurfaceInfo, InternalFormat), sizeof(((MGPSurfaceInfo*)nullptr)->InternalFormat)},
|
||||
{"MGPSurfaceInfo.Samples", offsetof(MGPSurfaceInfo, Samples), sizeof(((MGPSurfaceInfo*)nullptr)->Samples)},
|
||||
{"MGPSurfaceInfo.Layers", offsetof(MGPSurfaceInfo, Layers), sizeof(((MGPSurfaceInfo*)nullptr)->Layers)},
|
||||
{"MGPSurfaceInfo.IsDefault", offsetof(MGPSurfaceInfo, IsDefault), sizeof(((MGPSurfaceInfo*)nullptr)->IsDefault)},
|
||||
{"MGPImageBind", 0, sizeof(MGPImageBind)},
|
||||
{"MGPImageBind.Res", offsetof(MGPImageBind, Res), sizeof(((MGPImageBind*)nullptr)->Res)},
|
||||
{"MGPImageBind.Unit", offsetof(MGPImageBind, Unit), sizeof(((MGPImageBind*)nullptr)->Unit)},
|
||||
{"MGPImageBind.GlName", offsetof(MGPImageBind, GlName), sizeof(((MGPImageBind*)nullptr)->GlName)},
|
||||
{"MGPImageBind.Level", offsetof(MGPImageBind, Level), sizeof(((MGPImageBind*)nullptr)->Level)},
|
||||
{"MGPImageBind.Layer", offsetof(MGPImageBind, Layer), sizeof(((MGPImageBind*)nullptr)->Layer)},
|
||||
{"MGPImageBind.Access", offsetof(MGPImageBind, Access), sizeof(((MGPImageBind*)nullptr)->Access)},
|
||||
{"MGPImageBind.Format", offsetof(MGPImageBind, Format), sizeof(((MGPImageBind*)nullptr)->Format)},
|
||||
{"MGPImageBind.Layered", offsetof(MGPImageBind, Layered), sizeof(((MGPImageBind*)nullptr)->Layered)},
|
||||
{"MGPPatchParameter", 0, sizeof(MGPPatchParameter)},
|
||||
{"MGPPatchParameter.Pname", offsetof(MGPPatchParameter, Pname), sizeof(((MGPPatchParameter*)nullptr)->Pname)},
|
||||
{"MGPPatchParameter.Value", offsetof(MGPPatchParameter, Value), sizeof(((MGPPatchParameter*)nullptr)->Value)},
|
||||
{"MGPStreamOutputBind", 0, sizeof(MGPStreamOutputBind)},
|
||||
{"MGPStreamOutputBind.GlName", offsetof(MGPStreamOutputBind, GlName), sizeof(((MGPStreamOutputBind*)nullptr)->GlName)},
|
||||
{"MGPStreamOutputBind.LifetimeId", offsetof(MGPStreamOutputBind, LifetimeId), sizeof(((MGPStreamOutputBind*)nullptr)->LifetimeId)},
|
||||
{"MGPStorageBlockBinding", 0, sizeof(MGPStorageBlockBinding)},
|
||||
{"MGPStorageBlockBinding.ShaderCso", offsetof(MGPStorageBlockBinding, ShaderCso), sizeof(((MGPStorageBlockBinding*)nullptr)->ShaderCso)},
|
||||
{"MGPStorageBlockBinding.GlName", offsetof(MGPStorageBlockBinding, GlName), sizeof(((MGPStorageBlockBinding*)nullptr)->GlName)},
|
||||
{"MGPStorageBlockBinding.Binding", offsetof(MGPStorageBlockBinding, Binding), sizeof(((MGPStorageBlockBinding*)nullptr)->Binding)},
|
||||
{"MGPStorageBlockBinding.Name", offsetof(MGPStorageBlockBinding, Name), sizeof(((MGPStorageBlockBinding*)nullptr)->Name)},
|
||||
{"MGPCopyFromFramebuffer", 0, sizeof(MGPCopyFromFramebuffer)},
|
||||
{"MGPCopyFromFramebuffer.Dst", offsetof(MGPCopyFromFramebuffer, Dst), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Dst)},
|
||||
{"MGPCopyFromFramebuffer.Target", offsetof(MGPCopyFromFramebuffer, Target), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Target)},
|
||||
{"MGPCopyFromFramebuffer.Level", offsetof(MGPCopyFromFramebuffer, Level), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Level)},
|
||||
{"MGPCopyFromFramebuffer.InternalFormat", offsetof(MGPCopyFromFramebuffer, InternalFormat), sizeof(((MGPCopyFromFramebuffer*)nullptr)->InternalFormat)},
|
||||
{"MGPCopyFromFramebuffer.X", offsetof(MGPCopyFromFramebuffer, X), sizeof(((MGPCopyFromFramebuffer*)nullptr)->X)},
|
||||
{"MGPCopyFromFramebuffer.Y", offsetof(MGPCopyFromFramebuffer, Y), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Y)},
|
||||
{"MGPCopyFromFramebuffer.Width", offsetof(MGPCopyFromFramebuffer, Width), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Width)},
|
||||
{"MGPCopyFromFramebuffer.Height", offsetof(MGPCopyFromFramebuffer, Height), sizeof(((MGPCopyFromFramebuffer*)nullptr)->Height)},
|
||||
{"MGPCopyFromFramebuffer.XOffset", offsetof(MGPCopyFromFramebuffer, XOffset), sizeof(((MGPCopyFromFramebuffer*)nullptr)->XOffset)},
|
||||
{"MGPCopyFromFramebuffer.YOffset", offsetof(MGPCopyFromFramebuffer, YOffset), sizeof(((MGPCopyFromFramebuffer*)nullptr)->YOffset)},
|
||||
{"MGPCopyFromFramebuffer.SubImage", offsetof(MGPCopyFromFramebuffer, SubImage), sizeof(((MGPCopyFromFramebuffer*)nullptr)->SubImage)},
|
||||
{"MGPApplierReset", 0, sizeof(MGPApplierReset)},
|
||||
{"MGPApplierReset.ContextSerial", offsetof(MGPApplierReset, ContextSerial), sizeof(((MGPApplierReset*)nullptr)->ContextSerial)},
|
||||
{"MGPContextValues", 0, sizeof(MGPContextValues)},
|
||||
{"MGPContextValues.ActiveTextureUnit", offsetof(MGPContextValues, ActiveTextureUnit), sizeof(((MGPContextValues*)nullptr)->ActiveTextureUnit)},
|
||||
{"MGPContextValues.MaxTouchedTextureUnit", offsetof(MGPContextValues, MaxTouchedTextureUnit), sizeof(((MGPContextValues*)nullptr)->MaxTouchedTextureUnit)},
|
||||
{"MGPContextValues.TouchedBufferBindingPointCount", offsetof(MGPContextValues, TouchedBufferBindingPointCount), sizeof(((MGPContextValues*)nullptr)->TouchedBufferBindingPointCount)},
|
||||
{"MGPContextValues.IsTransformFeedbackActive", offsetof(MGPContextValues, IsTransformFeedbackActive), sizeof(((MGPContextValues*)nullptr)->IsTransformFeedbackActive)},
|
||||
{"MGPContextValues.IsTransformFeedbackPaused", offsetof(MGPContextValues, IsTransformFeedbackPaused), sizeof(((MGPContextValues*)nullptr)->IsTransformFeedbackPaused)},
|
||||
{"MGPContextValues.TransformFeedbackGeneration", offsetof(MGPContextValues, TransformFeedbackGeneration), sizeof(((MGPContextValues*)nullptr)->TransformFeedbackGeneration)},
|
||||
{"MGPContextValues.BoundTransformFeedbackLifetimeId", offsetof(MGPContextValues, BoundTransformFeedbackLifetimeId), sizeof(((MGPContextValues*)nullptr)->BoundTransformFeedbackLifetimeId)},
|
||||
{"MGPContextValues.TransformFeedbackCapturedVertices", offsetof(MGPContextValues, TransformFeedbackCapturedVertices), sizeof(((MGPContextValues*)nullptr)->TransformFeedbackCapturedVertices)},
|
||||
{"MGPProgramBindings", 0, sizeof(MGPProgramBindings)},
|
||||
{"MGPProgramBindings.Cso", offsetof(MGPProgramBindings, Cso), sizeof(((MGPProgramBindings*)nullptr)->Cso)},
|
||||
{"MGPProgramBindings.Signature", offsetof(MGPProgramBindings, Signature), sizeof(((MGPProgramBindings*)nullptr)->Signature)},
|
||||
{"MGPProgramBindings.BlockBindingCount", offsetof(MGPProgramBindings, BlockBindingCount), sizeof(((MGPProgramBindings*)nullptr)->BlockBindingCount)},
|
||||
{"MGPProgramBindings.SamplerUnitCount", offsetof(MGPProgramBindings, SamplerUnitCount), sizeof(((MGPProgramBindings*)nullptr)->SamplerUnitCount)},
|
||||
{"MGPProgramBindings.StorageOverrideCount", offsetof(MGPProgramBindings, StorageOverrideCount), sizeof(((MGPProgramBindings*)nullptr)->StorageOverrideCount)},
|
||||
{"MGPProgramSamplerUnit", 0, sizeof(MGPProgramSamplerUnit)},
|
||||
{"MGPProgramSamplerUnit.Location", offsetof(MGPProgramSamplerUnit, Location), sizeof(((MGPProgramSamplerUnit*)nullptr)->Location)},
|
||||
{"MGPProgramSamplerUnit.Unit", offsetof(MGPProgramSamplerUnit, Unit), sizeof(((MGPProgramSamplerUnit*)nullptr)->Unit)},
|
||||
{"MGPProgramStorageOverride", 0, sizeof(MGPProgramStorageOverride)},
|
||||
{"MGPProgramStorageOverride.Name", offsetof(MGPProgramStorageOverride, Name), sizeof(((MGPProgramStorageOverride*)nullptr)->Name)},
|
||||
{"MGPProgramStorageOverride.Binding", offsetof(MGPProgramStorageOverride, Binding), sizeof(((MGPProgramStorageOverride*)nullptr)->Binding)},
|
||||
{"RenderStateParameters", 0, sizeof(RenderStateParameters)},
|
||||
{"RenderStateParameters.Viewports", offsetof(RenderStateParameters, Viewports), sizeof(((RenderStateParameters*)nullptr)->Viewports)},
|
||||
{"RenderStateParameters.LineWidth", offsetof(RenderStateParameters, LineWidth), sizeof(((RenderStateParameters*)nullptr)->LineWidth)},
|
||||
{"RenderStateParameters.PointSize", offsetof(RenderStateParameters, PointSize), sizeof(((RenderStateParameters*)nullptr)->PointSize)},
|
||||
{"RenderStateParameters.PatchVertices", offsetof(RenderStateParameters, PatchVertices), sizeof(((RenderStateParameters*)nullptr)->PatchVertices)},
|
||||
{"RenderStateParameters.PatchDefaultOuterLevel", offsetof(RenderStateParameters, PatchDefaultOuterLevel), sizeof(((RenderStateParameters*)nullptr)->PatchDefaultOuterLevel)},
|
||||
{"RenderStateParameters.PatchDefaultInnerLevel", offsetof(RenderStateParameters, PatchDefaultInnerLevel), sizeof(((RenderStateParameters*)nullptr)->PatchDefaultInnerLevel)},
|
||||
{"RenderStateParameters.PolygonOffsetFactor", offsetof(RenderStateParameters, PolygonOffsetFactor), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetFactor)},
|
||||
{"RenderStateParameters.PolygonOffsetUnits", offsetof(RenderStateParameters, PolygonOffsetUnits), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetUnits)},
|
||||
{"RenderStateParameters.PolygonOffsetClamp", offsetof(RenderStateParameters, PolygonOffsetClamp), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetClamp)},
|
||||
{"RenderStateParameters.ClipOrigin", offsetof(RenderStateParameters, ClipOrigin), sizeof(((RenderStateParameters*)nullptr)->ClipOrigin)},
|
||||
{"RenderStateParameters.ClipDepthMode", offsetof(RenderStateParameters, ClipDepthMode), sizeof(((RenderStateParameters*)nullptr)->ClipDepthMode)},
|
||||
{"RenderStateParameters.BlendStates", offsetof(RenderStateParameters, BlendStates), sizeof(((RenderStateParameters*)nullptr)->BlendStates)},
|
||||
{"RenderStateParameters.LogicOp", offsetof(RenderStateParameters, LogicOp), sizeof(((RenderStateParameters*)nullptr)->LogicOp)},
|
||||
{"RenderStateParameters.DepthTestEnabled", offsetof(RenderStateParameters, DepthTestEnabled), sizeof(((RenderStateParameters*)nullptr)->DepthTestEnabled)},
|
||||
{"RenderStateParameters.DepthFunc", offsetof(RenderStateParameters, DepthFunc), sizeof(((RenderStateParameters*)nullptr)->DepthFunc)},
|
||||
{"RenderStateParameters.DepthMask", offsetof(RenderStateParameters, DepthMask), sizeof(((RenderStateParameters*)nullptr)->DepthMask)},
|
||||
{"RenderStateParameters.ColorMasks", offsetof(RenderStateParameters, ColorMasks), sizeof(((RenderStateParameters*)nullptr)->ColorMasks)},
|
||||
{"RenderStateParameters.FramebufferSrgbEnabled", offsetof(RenderStateParameters, FramebufferSrgbEnabled), sizeof(((RenderStateParameters*)nullptr)->FramebufferSrgbEnabled)},
|
||||
{"RenderStateParameters.DepthClampEnabled", offsetof(RenderStateParameters, DepthClampEnabled), sizeof(((RenderStateParameters*)nullptr)->DepthClampEnabled)},
|
||||
{"RenderStateParameters.TextureCubeMapSeamlessEnabled", offsetof(RenderStateParameters, TextureCubeMapSeamlessEnabled), sizeof(((RenderStateParameters*)nullptr)->TextureCubeMapSeamlessEnabled)},
|
||||
{"RenderStateParameters.ClearColor", offsetof(RenderStateParameters, ClearColor), sizeof(((RenderStateParameters*)nullptr)->ClearColor)},
|
||||
{"RenderStateParameters.ClearDepth", offsetof(RenderStateParameters, ClearDepth), sizeof(((RenderStateParameters*)nullptr)->ClearDepth)},
|
||||
{"RenderStateParameters.ClearStencil", offsetof(RenderStateParameters, ClearStencil), sizeof(((RenderStateParameters*)nullptr)->ClearStencil)},
|
||||
{"RenderStateParameters.BlendColor", offsetof(RenderStateParameters, BlendColor), sizeof(((RenderStateParameters*)nullptr)->BlendColor)},
|
||||
{"RenderStateParameters.DepthRanges", offsetof(RenderStateParameters, DepthRanges), sizeof(((RenderStateParameters*)nullptr)->DepthRanges)},
|
||||
{"RenderStateParameters.SampleCoverageValue", offsetof(RenderStateParameters, SampleCoverageValue), sizeof(((RenderStateParameters*)nullptr)->SampleCoverageValue)},
|
||||
{"RenderStateParameters.SampleCoverageInvert", offsetof(RenderStateParameters, SampleCoverageInvert), sizeof(((RenderStateParameters*)nullptr)->SampleCoverageInvert)},
|
||||
{"RenderStateParameters.SampleMaskValue", offsetof(RenderStateParameters, SampleMaskValue), sizeof(((RenderStateParameters*)nullptr)->SampleMaskValue)},
|
||||
{"RenderStateParameters.MinSampleShadingValue", offsetof(RenderStateParameters, MinSampleShadingValue), sizeof(((RenderStateParameters*)nullptr)->MinSampleShadingValue)},
|
||||
{"RenderStateParameters.StencilStates", offsetof(RenderStateParameters, StencilStates), sizeof(((RenderStateParameters*)nullptr)->StencilStates)},
|
||||
{"RenderStateParameters.CullFaceEnabled", offsetof(RenderStateParameters, CullFaceEnabled), sizeof(((RenderStateParameters*)nullptr)->CullFaceEnabled)},
|
||||
{"RenderStateParameters.CullFaceModeSetting", offsetof(RenderStateParameters, CullFaceModeSetting), sizeof(((RenderStateParameters*)nullptr)->CullFaceModeSetting)},
|
||||
{"RenderStateParameters.FrontFaceModeSetting", offsetof(RenderStateParameters, FrontFaceModeSetting), sizeof(((RenderStateParameters*)nullptr)->FrontFaceModeSetting)},
|
||||
{"RenderStateParameters.ProvokingVertexModeSetting", offsetof(RenderStateParameters, ProvokingVertexModeSetting), sizeof(((RenderStateParameters*)nullptr)->ProvokingVertexModeSetting)},
|
||||
{"RenderStateParameters.LineSmoothHint", offsetof(RenderStateParameters, LineSmoothHint), sizeof(((RenderStateParameters*)nullptr)->LineSmoothHint)},
|
||||
{"RenderStateParameters.PolygonSmoothHint", offsetof(RenderStateParameters, PolygonSmoothHint), sizeof(((RenderStateParameters*)nullptr)->PolygonSmoothHint)},
|
||||
{"RenderStateParameters.TextureCompressionHint", offsetof(RenderStateParameters, TextureCompressionHint), sizeof(((RenderStateParameters*)nullptr)->TextureCompressionHint)},
|
||||
{"RenderStateParameters.FragmentShaderDerivativeHint", offsetof(RenderStateParameters, FragmentShaderDerivativeHint), sizeof(((RenderStateParameters*)nullptr)->FragmentShaderDerivativeHint)},
|
||||
{"RenderStateParameters.PointFadeThresholdSize", offsetof(RenderStateParameters, PointFadeThresholdSize), sizeof(((RenderStateParameters*)nullptr)->PointFadeThresholdSize)},
|
||||
{"RenderStateParameters.PointSpriteCoordOrigin", offsetof(RenderStateParameters, PointSpriteCoordOrigin), sizeof(((RenderStateParameters*)nullptr)->PointSpriteCoordOrigin)},
|
||||
{"RenderStateParameters.ClampReadColor", offsetof(RenderStateParameters, ClampReadColor), sizeof(((RenderStateParameters*)nullptr)->ClampReadColor)},
|
||||
{"RenderStateParameters.PolygonModeFront", offsetof(RenderStateParameters, PolygonModeFront), sizeof(((RenderStateParameters*)nullptr)->PolygonModeFront)},
|
||||
{"RenderStateParameters.PolygonModeBack", offsetof(RenderStateParameters, PolygonModeBack), sizeof(((RenderStateParameters*)nullptr)->PolygonModeBack)},
|
||||
{"RenderStateParameters.PrimitiveRestartIndex", offsetof(RenderStateParameters, PrimitiveRestartIndex), sizeof(((RenderStateParameters*)nullptr)->PrimitiveRestartIndex)},
|
||||
{"RenderStateParameters.ColorLogicOpEnabled", offsetof(RenderStateParameters, ColorLogicOpEnabled), sizeof(((RenderStateParameters*)nullptr)->ColorLogicOpEnabled)},
|
||||
{"RenderStateParameters.DebugOutputEnabled", offsetof(RenderStateParameters, DebugOutputEnabled), sizeof(((RenderStateParameters*)nullptr)->DebugOutputEnabled)},
|
||||
{"RenderStateParameters.DebugOutputSynchronousEnabled", offsetof(RenderStateParameters, DebugOutputSynchronousEnabled), sizeof(((RenderStateParameters*)nullptr)->DebugOutputSynchronousEnabled)},
|
||||
{"RenderStateParameters.DitherEnabled", offsetof(RenderStateParameters, DitherEnabled), sizeof(((RenderStateParameters*)nullptr)->DitherEnabled)},
|
||||
{"RenderStateParameters.LineSmoothEnabled", offsetof(RenderStateParameters, LineSmoothEnabled), sizeof(((RenderStateParameters*)nullptr)->LineSmoothEnabled)},
|
||||
{"RenderStateParameters.MultisampleEnabled", offsetof(RenderStateParameters, MultisampleEnabled), sizeof(((RenderStateParameters*)nullptr)->MultisampleEnabled)},
|
||||
{"RenderStateParameters.PolygonOffsetFillEnabled", offsetof(RenderStateParameters, PolygonOffsetFillEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetFillEnabled)},
|
||||
{"RenderStateParameters.PolygonOffsetLineEnabled", offsetof(RenderStateParameters, PolygonOffsetLineEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetLineEnabled)},
|
||||
{"RenderStateParameters.PolygonOffsetPointEnabled", offsetof(RenderStateParameters, PolygonOffsetPointEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonOffsetPointEnabled)},
|
||||
{"RenderStateParameters.PolygonSmoothEnabled", offsetof(RenderStateParameters, PolygonSmoothEnabled), sizeof(((RenderStateParameters*)nullptr)->PolygonSmoothEnabled)},
|
||||
{"RenderStateParameters.PrimitiveRestartEnabled", offsetof(RenderStateParameters, PrimitiveRestartEnabled), sizeof(((RenderStateParameters*)nullptr)->PrimitiveRestartEnabled)},
|
||||
{"RenderStateParameters.PrimitiveRestartFixedIndexEnabled", offsetof(RenderStateParameters, PrimitiveRestartFixedIndexEnabled), sizeof(((RenderStateParameters*)nullptr)->PrimitiveRestartFixedIndexEnabled)},
|
||||
{"RenderStateParameters.RasterizerDiscardEnabled", offsetof(RenderStateParameters, RasterizerDiscardEnabled), sizeof(((RenderStateParameters*)nullptr)->RasterizerDiscardEnabled)},
|
||||
{"RenderStateParameters.SampleAlphaToCoverageEnabled", offsetof(RenderStateParameters, SampleAlphaToCoverageEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleAlphaToCoverageEnabled)},
|
||||
{"RenderStateParameters.SampleAlphaToOneEnabled", offsetof(RenderStateParameters, SampleAlphaToOneEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleAlphaToOneEnabled)},
|
||||
{"RenderStateParameters.SampleCoverageEnabled", offsetof(RenderStateParameters, SampleCoverageEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleCoverageEnabled)},
|
||||
{"RenderStateParameters.SampleMaskEnabled", offsetof(RenderStateParameters, SampleMaskEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleMaskEnabled)},
|
||||
{"RenderStateParameters.SampleShadingEnabled", offsetof(RenderStateParameters, SampleShadingEnabled), sizeof(((RenderStateParameters*)nullptr)->SampleShadingEnabled)},
|
||||
{"RenderStateParameters.StencilTestEnabled", offsetof(RenderStateParameters, StencilTestEnabled), sizeof(((RenderStateParameters*)nullptr)->StencilTestEnabled)},
|
||||
{"RenderStateParameters.ProgramPointSizeEnabled", offsetof(RenderStateParameters, ProgramPointSizeEnabled), sizeof(((RenderStateParameters*)nullptr)->ProgramPointSizeEnabled)},
|
||||
{"RenderStateParameters.ScissorTestEnabledMask", offsetof(RenderStateParameters, ScissorTestEnabledMask), sizeof(((RenderStateParameters*)nullptr)->ScissorTestEnabledMask)},
|
||||
{"RenderStateParameters.ScissorBoxes", offsetof(RenderStateParameters, ScissorBoxes), sizeof(((RenderStateParameters*)nullptr)->ScissorBoxes)},
|
||||
{"RenderStateParameters.ScissorBoxWrittenMask", offsetof(RenderStateParameters, ScissorBoxWrittenMask), sizeof(((RenderStateParameters*)nullptr)->ScissorBoxWrittenMask)},
|
||||
{"RenderStateParameters.ClipDistanceEnabledMask", offsetof(RenderStateParameters, ClipDistanceEnabledMask), sizeof(((RenderStateParameters*)nullptr)->ClipDistanceEnabledMask)},
|
||||
{"PixelStoreParameters", 0, sizeof(PixelStoreParameters)},
|
||||
{"PixelStoreParameters.SwapBytes", offsetof(PixelStoreParameters, SwapBytes), sizeof(((PixelStoreParameters*)nullptr)->SwapBytes)},
|
||||
{"PixelStoreParameters.LSBFirst", offsetof(PixelStoreParameters, LSBFirst), sizeof(((PixelStoreParameters*)nullptr)->LSBFirst)},
|
||||
{"PixelStoreParameters.RowLength", offsetof(PixelStoreParameters, RowLength), sizeof(((PixelStoreParameters*)nullptr)->RowLength)},
|
||||
{"PixelStoreParameters.ImageHeight", offsetof(PixelStoreParameters, ImageHeight), sizeof(((PixelStoreParameters*)nullptr)->ImageHeight)},
|
||||
{"PixelStoreParameters.SkipPixels", offsetof(PixelStoreParameters, SkipPixels), sizeof(((PixelStoreParameters*)nullptr)->SkipPixels)},
|
||||
{"PixelStoreParameters.SkipRows", offsetof(PixelStoreParameters, SkipRows), sizeof(((PixelStoreParameters*)nullptr)->SkipRows)},
|
||||
{"PixelStoreParameters.SkipImages", offsetof(PixelStoreParameters, SkipImages), sizeof(((PixelStoreParameters*)nullptr)->SkipImages)},
|
||||
{"PixelStoreParameters.Alignment", offsetof(PixelStoreParameters, Alignment), sizeof(((PixelStoreParameters*)nullptr)->Alignment)},
|
||||
{"SamplerParameters", 0, sizeof(SamplerParameters)},
|
||||
{"SamplerParameters.wrapS", offsetof(SamplerParameters, wrapS), sizeof(((SamplerParameters*)nullptr)->wrapS)},
|
||||
{"SamplerParameters.wrapT", offsetof(SamplerParameters, wrapT), sizeof(((SamplerParameters*)nullptr)->wrapT)},
|
||||
{"SamplerParameters.wrapR", offsetof(SamplerParameters, wrapR), sizeof(((SamplerParameters*)nullptr)->wrapR)},
|
||||
{"SamplerParameters.minFilter", offsetof(SamplerParameters, minFilter), sizeof(((SamplerParameters*)nullptr)->minFilter)},
|
||||
{"SamplerParameters.magFilter", offsetof(SamplerParameters, magFilter), sizeof(((SamplerParameters*)nullptr)->magFilter)},
|
||||
{"SamplerParameters.mipmapMode", offsetof(SamplerParameters, mipmapMode), sizeof(((SamplerParameters*)nullptr)->mipmapMode)},
|
||||
{"SamplerParameters.minLod", offsetof(SamplerParameters, minLod), sizeof(((SamplerParameters*)nullptr)->minLod)},
|
||||
{"SamplerParameters.maxLod", offsetof(SamplerParameters, maxLod), sizeof(((SamplerParameters*)nullptr)->maxLod)},
|
||||
{"SamplerParameters.lodBias", offsetof(SamplerParameters, lodBias), sizeof(((SamplerParameters*)nullptr)->lodBias)},
|
||||
{"SamplerParameters.maxAnisotropy", offsetof(SamplerParameters, maxAnisotropy), sizeof(((SamplerParameters*)nullptr)->maxAnisotropy)},
|
||||
{"SamplerParameters.compareFunc", offsetof(SamplerParameters, compareFunc), sizeof(((SamplerParameters*)nullptr)->compareFunc)},
|
||||
{"SamplerParameters.compareMode", offsetof(SamplerParameters, compareMode), sizeof(((SamplerParameters*)nullptr)->compareMode)},
|
||||
{"SamplerParameters.borderColor", offsetof(SamplerParameters, borderColor), sizeof(((SamplerParameters*)nullptr)->borderColor)},
|
||||
{"SamplerParameters.borderColorI", offsetof(SamplerParameters, borderColorI), sizeof(((SamplerParameters*)nullptr)->borderColorI)},
|
||||
{"SamplerParameters.borderColorUI", offsetof(SamplerParameters, borderColorUI), sizeof(((SamplerParameters*)nullptr)->borderColorUI)},
|
||||
{"SamplerParameters.borderColorForm", offsetof(SamplerParameters, borderColorForm), sizeof(((SamplerParameters*)nullptr)->borderColorForm)},
|
||||
{"PerBufferBlendState", 0, sizeof(PerBufferBlendState)},
|
||||
{"PerBufferBlendState.Enabled", offsetof(PerBufferBlendState, Enabled), sizeof(((PerBufferBlendState*)nullptr)->Enabled)},
|
||||
{"PerBufferBlendState.SrcFactorRGB", offsetof(PerBufferBlendState, SrcFactorRGB), sizeof(((PerBufferBlendState*)nullptr)->SrcFactorRGB)},
|
||||
{"PerBufferBlendState.DstFactorRGB", offsetof(PerBufferBlendState, DstFactorRGB), sizeof(((PerBufferBlendState*)nullptr)->DstFactorRGB)},
|
||||
{"PerBufferBlendState.SrcFactorAlpha", offsetof(PerBufferBlendState, SrcFactorAlpha), sizeof(((PerBufferBlendState*)nullptr)->SrcFactorAlpha)},
|
||||
{"PerBufferBlendState.DstFactorAlpha", offsetof(PerBufferBlendState, DstFactorAlpha), sizeof(((PerBufferBlendState*)nullptr)->DstFactorAlpha)},
|
||||
{"PerBufferBlendState.ColorEquation", offsetof(PerBufferBlendState, ColorEquation), sizeof(((PerBufferBlendState*)nullptr)->ColorEquation)},
|
||||
{"PerBufferBlendState.AlphaEquation", offsetof(PerBufferBlendState, AlphaEquation), sizeof(((PerBufferBlendState*)nullptr)->AlphaEquation)},
|
||||
{"StencilFaceState", 0, sizeof(StencilFaceState)},
|
||||
{"StencilFaceState.Func", offsetof(StencilFaceState, Func), sizeof(((StencilFaceState*)nullptr)->Func)},
|
||||
{"StencilFaceState.Ref", offsetof(StencilFaceState, Ref), sizeof(((StencilFaceState*)nullptr)->Ref)},
|
||||
{"StencilFaceState.ValueMask", offsetof(StencilFaceState, ValueMask), sizeof(((StencilFaceState*)nullptr)->ValueMask)},
|
||||
{"StencilFaceState.WriteMask", offsetof(StencilFaceState, WriteMask), sizeof(((StencilFaceState*)nullptr)->WriteMask)},
|
||||
{"StencilFaceState.FailOp", offsetof(StencilFaceState, FailOp), sizeof(((StencilFaceState*)nullptr)->FailOp)},
|
||||
{"StencilFaceState.PassDepthFailOp", offsetof(StencilFaceState, PassDepthFailOp), sizeof(((StencilFaceState*)nullptr)->PassDepthFailOp)},
|
||||
{"StencilFaceState.PassDepthPassOp", offsetof(StencilFaceState, PassDepthPassOp), sizeof(((StencilFaceState*)nullptr)->PassDepthPassOp)},
|
||||
{"DynamicBackendParameters", 0, sizeof(DynamicBackendParameters)},
|
||||
{"DynamicBackendParameters.UniformBufferOffsetAlignment", offsetof(DynamicBackendParameters, UniformBufferOffsetAlignment), sizeof(((DynamicBackendParameters*)nullptr)->UniformBufferOffsetAlignment)},
|
||||
{"DynamicBackendParameters.ShaderStorageBufferOffsetAlignment", offsetof(DynamicBackendParameters, ShaderStorageBufferOffsetAlignment), sizeof(((DynamicBackendParameters*)nullptr)->ShaderStorageBufferOffsetAlignment)},
|
||||
{"DynamicBackendParameters.MaxTextureMaxAnisotropy", offsetof(DynamicBackendParameters, MaxTextureMaxAnisotropy), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureMaxAnisotropy)},
|
||||
{"DynamicBackendParameters.AliasedLineWidthRangeMin", offsetof(DynamicBackendParameters, AliasedLineWidthRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->AliasedLineWidthRangeMin)},
|
||||
{"DynamicBackendParameters.AliasedLineWidthRangeMax", offsetof(DynamicBackendParameters, AliasedLineWidthRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->AliasedLineWidthRangeMax)},
|
||||
{"DynamicBackendParameters.SmoothLineWidthRangeMin", offsetof(DynamicBackendParameters, SmoothLineWidthRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->SmoothLineWidthRangeMin)},
|
||||
{"DynamicBackendParameters.SmoothLineWidthRangeMax", offsetof(DynamicBackendParameters, SmoothLineWidthRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->SmoothLineWidthRangeMax)},
|
||||
{"DynamicBackendParameters.SmoothLineWidthGranularity", offsetof(DynamicBackendParameters, SmoothLineWidthGranularity), sizeof(((DynamicBackendParameters*)nullptr)->SmoothLineWidthGranularity)},
|
||||
{"DynamicBackendParameters.PointSizeRangeMin", offsetof(DynamicBackendParameters, PointSizeRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->PointSizeRangeMin)},
|
||||
{"DynamicBackendParameters.PointSizeRangeMax", offsetof(DynamicBackendParameters, PointSizeRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->PointSizeRangeMax)},
|
||||
{"DynamicBackendParameters.PointSizeGranularity", offsetof(DynamicBackendParameters, PointSizeGranularity), sizeof(((DynamicBackendParameters*)nullptr)->PointSizeGranularity)},
|
||||
{"DynamicBackendParameters.Max3DTextureSize", offsetof(DynamicBackendParameters, Max3DTextureSize), sizeof(((DynamicBackendParameters*)nullptr)->Max3DTextureSize)},
|
||||
{"DynamicBackendParameters.MaxArrayTextureLayers", offsetof(DynamicBackendParameters, MaxArrayTextureLayers), sizeof(((DynamicBackendParameters*)nullptr)->MaxArrayTextureLayers)},
|
||||
{"DynamicBackendParameters.MaxCubeMapTextureSize", offsetof(DynamicBackendParameters, MaxCubeMapTextureSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxCubeMapTextureSize)},
|
||||
{"DynamicBackendParameters.MaxFramebufferWidth", offsetof(DynamicBackendParameters, MaxFramebufferWidth), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferWidth)},
|
||||
{"DynamicBackendParameters.MaxFramebufferHeight", offsetof(DynamicBackendParameters, MaxFramebufferHeight), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferHeight)},
|
||||
{"DynamicBackendParameters.MaxFramebufferLayers", offsetof(DynamicBackendParameters, MaxFramebufferLayers), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferLayers)},
|
||||
{"DynamicBackendParameters.MaxRenderbufferSize", offsetof(DynamicBackendParameters, MaxRenderbufferSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxRenderbufferSize)},
|
||||
{"DynamicBackendParameters.MaxTextureSize", offsetof(DynamicBackendParameters, MaxTextureSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureSize)},
|
||||
{"DynamicBackendParameters.MaxColorTextureSamples", offsetof(DynamicBackendParameters, MaxColorTextureSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxColorTextureSamples)},
|
||||
{"DynamicBackendParameters.MaxDepthTextureSamples", offsetof(DynamicBackendParameters, MaxDepthTextureSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxDepthTextureSamples)},
|
||||
{"DynamicBackendParameters.MaxFramebufferSamples", offsetof(DynamicBackendParameters, MaxFramebufferSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxFramebufferSamples)},
|
||||
{"DynamicBackendParameters.MaxIntegerSamples", offsetof(DynamicBackendParameters, MaxIntegerSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxIntegerSamples)},
|
||||
{"DynamicBackendParameters.MaxSamples", offsetof(DynamicBackendParameters, MaxSamples), sizeof(((DynamicBackendParameters*)nullptr)->MaxSamples)},
|
||||
{"DynamicBackendParameters.MaxSampleMaskWords", offsetof(DynamicBackendParameters, MaxSampleMaskWords), sizeof(((DynamicBackendParameters*)nullptr)->MaxSampleMaskWords)},
|
||||
{"DynamicBackendParameters.MaxPatchVertices", offsetof(DynamicBackendParameters, MaxPatchVertices), sizeof(((DynamicBackendParameters*)nullptr)->MaxPatchVertices)},
|
||||
{"DynamicBackendParameters.MaxTessGenLevel", offsetof(DynamicBackendParameters, MaxTessGenLevel), sizeof(((DynamicBackendParameters*)nullptr)->MaxTessGenLevel)},
|
||||
{"DynamicBackendParameters.MinProgramTextureGatherOffset", offsetof(DynamicBackendParameters, MinProgramTextureGatherOffset), sizeof(((DynamicBackendParameters*)nullptr)->MinProgramTextureGatherOffset)},
|
||||
{"DynamicBackendParameters.MaxProgramTextureGatherOffset", offsetof(DynamicBackendParameters, MaxProgramTextureGatherOffset), sizeof(((DynamicBackendParameters*)nullptr)->MaxProgramTextureGatherOffset)},
|
||||
{"DynamicBackendParameters.MaxTextureImageUnits", offsetof(DynamicBackendParameters, MaxTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureImageUnits)},
|
||||
{"DynamicBackendParameters.MaxVertexTextureImageUnits", offsetof(DynamicBackendParameters, MaxVertexTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexTextureImageUnits)},
|
||||
{"DynamicBackendParameters.MaxComputeTextureImageUnits", offsetof(DynamicBackendParameters, MaxComputeTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeTextureImageUnits)},
|
||||
{"DynamicBackendParameters.MaxCombinedTextureImageUnits", offsetof(DynamicBackendParameters, MaxCombinedTextureImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedTextureImageUnits)},
|
||||
{"DynamicBackendParameters.MaxVertexAttribs", offsetof(DynamicBackendParameters, MaxVertexAttribs), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexAttribs)},
|
||||
{"DynamicBackendParameters.MaxComputeShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxComputeShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxCombinedShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxCombinedShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxVertexShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxVertexShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxTessControlShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxTessControlShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxTessControlShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxTessEvaluationShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxTessEvaluationShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxTessEvaluationShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxGeometryShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxGeometryShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxGeometryShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxFragmentShaderStorageBlocks", offsetof(DynamicBackendParameters, MaxFragmentShaderStorageBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentShaderStorageBlocks)},
|
||||
{"DynamicBackendParameters.MaxComputeUniformBlocks", offsetof(DynamicBackendParameters, MaxComputeUniformBlocks), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeUniformBlocks)},
|
||||
{"DynamicBackendParameters.MaxComputeWorkGroupInvocations", offsetof(DynamicBackendParameters, MaxComputeWorkGroupInvocations), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeWorkGroupInvocations)},
|
||||
{"DynamicBackendParameters.MaxComputeWorkGroupCount", offsetof(DynamicBackendParameters, MaxComputeWorkGroupCount), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeWorkGroupCount)},
|
||||
{"DynamicBackendParameters.MaxComputeWorkGroupSize", offsetof(DynamicBackendParameters, MaxComputeWorkGroupSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeWorkGroupSize)},
|
||||
{"DynamicBackendParameters.MaxShaderStorageBufferBindings", offsetof(DynamicBackendParameters, MaxShaderStorageBufferBindings), sizeof(((DynamicBackendParameters*)nullptr)->MaxShaderStorageBufferBindings)},
|
||||
{"DynamicBackendParameters.MaxTextureBufferSize", offsetof(DynamicBackendParameters, MaxTextureBufferSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxTextureBufferSize)},
|
||||
{"DynamicBackendParameters.TextureBufferOffsetAlignment", offsetof(DynamicBackendParameters, TextureBufferOffsetAlignment), sizeof(((DynamicBackendParameters*)nullptr)->TextureBufferOffsetAlignment)},
|
||||
{"DynamicBackendParameters.MaxUniformBufferBindings", offsetof(DynamicBackendParameters, MaxUniformBufferBindings), sizeof(((DynamicBackendParameters*)nullptr)->MaxUniformBufferBindings)},
|
||||
{"DynamicBackendParameters.MaxUniformBlockSize", offsetof(DynamicBackendParameters, MaxUniformBlockSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxUniformBlockSize)},
|
||||
{"DynamicBackendParameters.MaxImageUnits", offsetof(DynamicBackendParameters, MaxImageUnits), sizeof(((DynamicBackendParameters*)nullptr)->MaxImageUnits)},
|
||||
{"DynamicBackendParameters.MaxCombinedImageUniforms", offsetof(DynamicBackendParameters, MaxCombinedImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedImageUniforms)},
|
||||
{"DynamicBackendParameters.MaxVertexImageUniforms", offsetof(DynamicBackendParameters, MaxVertexImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxVertexImageUniforms)},
|
||||
{"DynamicBackendParameters.MaxGeometryImageUniforms", offsetof(DynamicBackendParameters, MaxGeometryImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxGeometryImageUniforms)},
|
||||
{"DynamicBackendParameters.MaxFragmentImageUniforms", offsetof(DynamicBackendParameters, MaxFragmentImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentImageUniforms)},
|
||||
{"DynamicBackendParameters.MaxComputeImageUniforms", offsetof(DynamicBackendParameters, MaxComputeImageUniforms), sizeof(((DynamicBackendParameters*)nullptr)->MaxComputeImageUniforms)},
|
||||
{"DynamicBackendParameters.MaxDrawBuffers", offsetof(DynamicBackendParameters, MaxDrawBuffers), sizeof(((DynamicBackendParameters*)nullptr)->MaxDrawBuffers)},
|
||||
{"DynamicBackendParameters.MaxColorAttachments", offsetof(DynamicBackendParameters, MaxColorAttachments), sizeof(((DynamicBackendParameters*)nullptr)->MaxColorAttachments)},
|
||||
{"DynamicBackendParameters.MaxClipDistances", offsetof(DynamicBackendParameters, MaxClipDistances), sizeof(((DynamicBackendParameters*)nullptr)->MaxClipDistances)},
|
||||
{"DynamicBackendParameters.MaxCullDistances", offsetof(DynamicBackendParameters, MaxCullDistances), sizeof(((DynamicBackendParameters*)nullptr)->MaxCullDistances)},
|
||||
{"DynamicBackendParameters.MaxCombinedClipAndCullDistances", offsetof(DynamicBackendParameters, MaxCombinedClipAndCullDistances), sizeof(((DynamicBackendParameters*)nullptr)->MaxCombinedClipAndCullDistances)},
|
||||
{"DynamicBackendParameters.MaxViewports", offsetof(DynamicBackendParameters, MaxViewports), sizeof(((DynamicBackendParameters*)nullptr)->MaxViewports)},
|
||||
{"DynamicBackendParameters.LayerProvokingVertex", offsetof(DynamicBackendParameters, LayerProvokingVertex), sizeof(((DynamicBackendParameters*)nullptr)->LayerProvokingVertex)},
|
||||
{"DynamicBackendParameters.ViewportIndexProvokingVertex", offsetof(DynamicBackendParameters, ViewportIndexProvokingVertex), sizeof(((DynamicBackendParameters*)nullptr)->ViewportIndexProvokingVertex)},
|
||||
{"DynamicBackendParameters.MaxViewportWidth", offsetof(DynamicBackendParameters, MaxViewportWidth), sizeof(((DynamicBackendParameters*)nullptr)->MaxViewportWidth)},
|
||||
{"DynamicBackendParameters.MaxViewportHeight", offsetof(DynamicBackendParameters, MaxViewportHeight), sizeof(((DynamicBackendParameters*)nullptr)->MaxViewportHeight)},
|
||||
{"DynamicBackendParameters.ViewportBoundsRangeMin", offsetof(DynamicBackendParameters, ViewportBoundsRangeMin), sizeof(((DynamicBackendParameters*)nullptr)->ViewportBoundsRangeMin)},
|
||||
{"DynamicBackendParameters.ViewportBoundsRangeMax", offsetof(DynamicBackendParameters, ViewportBoundsRangeMax), sizeof(((DynamicBackendParameters*)nullptr)->ViewportBoundsRangeMax)},
|
||||
{"DynamicBackendParameters.ViewportSubpixelBits", offsetof(DynamicBackendParameters, ViewportSubpixelBits), sizeof(((DynamicBackendParameters*)nullptr)->ViewportSubpixelBits)},
|
||||
{"DynamicBackendParameters.MinFragmentInterpolationOffset", offsetof(DynamicBackendParameters, MinFragmentInterpolationOffset), sizeof(((DynamicBackendParameters*)nullptr)->MinFragmentInterpolationOffset)},
|
||||
{"DynamicBackendParameters.MaxFragmentInterpolationOffset", offsetof(DynamicBackendParameters, MaxFragmentInterpolationOffset), sizeof(((DynamicBackendParameters*)nullptr)->MaxFragmentInterpolationOffset)},
|
||||
{"DynamicBackendParameters.FragmentInterpolationOffsetBits", offsetof(DynamicBackendParameters, FragmentInterpolationOffsetBits), sizeof(((DynamicBackendParameters*)nullptr)->FragmentInterpolationOffsetBits)},
|
||||
{"DynamicBackendParameters.SupportsWideLines", offsetof(DynamicBackendParameters, SupportsWideLines), sizeof(((DynamicBackendParameters*)nullptr)->SupportsWideLines)},
|
||||
{"DynamicBackendParameters.SupportsDistinctDepthStencilAttachments", offsetof(DynamicBackendParameters, SupportsDistinctDepthStencilAttachments), sizeof(((DynamicBackendParameters*)nullptr)->SupportsDistinctDepthStencilAttachments)},
|
||||
{"DynamicBackendParameters.PerLayerFramebufferAttachmentTargets", offsetof(DynamicBackendParameters, PerLayerFramebufferAttachmentTargets), sizeof(((DynamicBackendParameters*)nullptr)->PerLayerFramebufferAttachmentTargets)},
|
||||
{"DynamicBackendParameters.SupportsShaderFloat64", offsetof(DynamicBackendParameters, SupportsShaderFloat64), sizeof(((DynamicBackendParameters*)nullptr)->SupportsShaderFloat64)},
|
||||
{"DynamicBackendParameters.SupportsFloat64VertexAttributes", offsetof(DynamicBackendParameters, SupportsFloat64VertexAttributes), sizeof(((DynamicBackendParameters*)nullptr)->SupportsFloat64VertexAttributes)},
|
||||
{"DynamicBackendParameters.SupportsTessellationPointSize", offsetof(DynamicBackendParameters, SupportsTessellationPointSize), sizeof(((DynamicBackendParameters*)nullptr)->SupportsTessellationPointSize)},
|
||||
{"DynamicBackendParameters.SupportsGeometryPointSize", offsetof(DynamicBackendParameters, SupportsGeometryPointSize), sizeof(((DynamicBackendParameters*)nullptr)->SupportsGeometryPointSize)},
|
||||
{"DynamicBackendParameters.MaxShaderStorageBlockSize", offsetof(DynamicBackendParameters, MaxShaderStorageBlockSize), sizeof(((DynamicBackendParameters*)nullptr)->MaxShaderStorageBlockSize)},
|
||||
{"DynamicBackendParameters.SubgroupSize", offsetof(DynamicBackendParameters, SubgroupSize), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupSize)},
|
||||
{"DynamicBackendParameters.SubgroupSupportedStages", offsetof(DynamicBackendParameters, SubgroupSupportedStages), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupSupportedStages)},
|
||||
{"DynamicBackendParameters.SubgroupSupportedFeatures", offsetof(DynamicBackendParameters, SubgroupSupportedFeatures), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupSupportedFeatures)},
|
||||
{"DynamicBackendParameters.SubgroupQuadOperationsInAllStages", offsetof(DynamicBackendParameters, SubgroupQuadOperationsInAllStages), sizeof(((DynamicBackendParameters*)nullptr)->SubgroupQuadOperationsInAllStages)},
|
||||
{"DynamicBackendParameters.GpuVendor", offsetof(DynamicBackendParameters, GpuVendor), sizeof(((DynamicBackendParameters*)nullptr)->GpuVendor)},
|
||||
{"MGHostSpan", 0, sizeof(MGHostSpan)},
|
||||
{"MGHostSpan.Ptr", offsetof(MGHostSpan, Ptr), sizeof(((MGHostSpan*)nullptr)->Ptr)},
|
||||
{"MGHostSpan.Seg", offsetof(MGHostSpan, Seg), sizeof(((MGHostSpan*)nullptr)->Seg)},
|
||||
{"MGHostSpan.Size", offsetof(MGHostSpan, Size), sizeof(((MGHostSpan*)nullptr)->Size)},
|
||||
{"MGHostSpan.Offset", offsetof(MGHostSpan, Offset), sizeof(((MGHostSpan*)nullptr)->Offset)},
|
||||
{"MGPVertexAttribWire", 0, sizeof(MGPVertexAttribWire)},
|
||||
{"MGPVertexAttribWire.Offset", offsetof(MGPVertexAttribWire, Offset), sizeof(((MGPVertexAttribWire*)nullptr)->Offset)},
|
||||
{"MGPVertexAttribWire.Stride", offsetof(MGPVertexAttribWire, Stride), sizeof(((MGPVertexAttribWire*)nullptr)->Stride)},
|
||||
{"MGPVertexAttribWire.Type", offsetof(MGPVertexAttribWire, Type), sizeof(((MGPVertexAttribWire*)nullptr)->Type)},
|
||||
{"MGPVertexAttribWire.Size", offsetof(MGPVertexAttribWire, Size), sizeof(((MGPVertexAttribWire*)nullptr)->Size)},
|
||||
{"MGPVertexAttribWire.Enabled", offsetof(MGPVertexAttribWire, Enabled), sizeof(((MGPVertexAttribWire*)nullptr)->Enabled)},
|
||||
{"MGPVertexAttribWire.Normalized", offsetof(MGPVertexAttribWire, Normalized), sizeof(((MGPVertexAttribWire*)nullptr)->Normalized)},
|
||||
{"MGPVertexAttribWire.IsInteger", offsetof(MGPVertexAttribWire, IsInteger), sizeof(((MGPVertexAttribWire*)nullptr)->IsInteger)},
|
||||
{"MGPVertexAttribWire.IsLong", offsetof(MGPVertexAttribWire, IsLong), sizeof(((MGPVertexAttribWire*)nullptr)->IsLong)},
|
||||
{"MGPVertexAttribWire.IsBgra", offsetof(MGPVertexAttribWire, IsBgra), sizeof(((MGPVertexAttribWire*)nullptr)->IsBgra)},
|
||||
{"MGPVertexAttribWire.BindingIndex", offsetof(MGPVertexAttribWire, BindingIndex), sizeof(((MGPVertexAttribWire*)nullptr)->BindingIndex)},
|
||||
{"MGPVertexBindingPointWire", 0, sizeof(MGPVertexBindingPointWire)},
|
||||
{"MGPVertexBindingPointWire.Offset", offsetof(MGPVertexBindingPointWire, Offset), sizeof(((MGPVertexBindingPointWire*)nullptr)->Offset)},
|
||||
{"MGPVertexBindingPointWire.Stride", offsetof(MGPVertexBindingPointWire, Stride), sizeof(((MGPVertexBindingPointWire*)nullptr)->Stride)},
|
||||
{"MGPVertexBindingPointWire.Divisor", offsetof(MGPVertexBindingPointWire, Divisor), sizeof(((MGPVertexBindingPointWire*)nullptr)->Divisor)},
|
||||
{"MGPipeHandle", 0, sizeof(MGPipeHandle)},
|
||||
{"MGPipeHandle.Slot", offsetof(MGPipeHandle, Slot), sizeof(((MGPipeHandle*)nullptr)->Slot)},
|
||||
{"MGPipeHandle.Gen", offsetof(MGPipeHandle, Gen), sizeof(((MGPipeHandle*)nullptr)->Gen)},
|
||||
{"MGPWireRecHeader", 0, sizeof(MGPWireRecHeader)},
|
||||
{"MGPWireRecHeader.Op", offsetof(MGPWireRecHeader, Op), sizeof(((MGPWireRecHeader*)nullptr)->Op)},
|
||||
{"MGPWireRecHeader.Flags", offsetof(MGPWireRecHeader, Flags), sizeof(((MGPWireRecHeader*)nullptr)->Flags)},
|
||||
{"MGPWireRecHeader.Size", offsetof(MGPWireRecHeader, Size), sizeof(((MGPWireRecHeader*)nullptr)->Size)},
|
||||
};
|
||||
struct WireCallLayout { const char* Name; const char* Payload; Uint64 Op; Uint64 Flags; Uint64 Wait; };
|
||||
inline constexpr WireCallLayout kMGPipeWireCallLayouts[] = {
|
||||
{"GetCaps", "MGPCaps", static_cast<Uint64>(MGPWireOp::GetCaps), static_cast<Uint64>(kReplySlot | kHasBlob), static_cast<Uint64>(kWaitReply)},
|
||||
{"ResourceCreate", "MGPResourceDesc", static_cast<Uint64>(MGPWireOp::ResourceCreate), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"ResourceRespecify", "MGPResourceDesc", static_cast<Uint64>(MGPWireOp::ResourceRespecify), static_cast<Uint64>(kNeedsAck | kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"ResourceDestroy", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::ResourceDestroy), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"MapPersistent", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::MapPersistent), static_cast<Uint64>(kReplySlot | kOptional), static_cast<Uint64>(kWaitReply)},
|
||||
{"UnmapPersistent", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::UnmapPersistent), static_cast<Uint64>(kOptional), static_cast<Uint64>(kWaitNone)},
|
||||
{"FenceCreate", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::FenceCreate), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"FenceStatus", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::FenceStatus), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"FenceWait", "MGPFenceWait", static_cast<Uint64>(MGPWireOp::FenceWait), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"FenceDestroy", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::FenceDestroy), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"QueryCreate", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryCreate), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"QueryBegin", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryBegin), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"QueryEnd", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryEnd), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"QueryAvailable", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::QueryAvailable), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"QueryResult", "MGPQueryResultRequest", static_cast<Uint64>(MGPWireOp::QueryResult), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"QueryDestroy", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::QueryDestroy), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"CreateRenderState", "MGPRenderStateDesc", static_cast<Uint64>(MGPWireOp::CreateRenderState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"BindRenderState", "MGPBindRenderState", static_cast<Uint64>(MGPWireOp::BindRenderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteRenderState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteRenderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"CreateVertexElements", "MGPVertexElements", static_cast<Uint64>(MGPWireOp::CreateVertexElements), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"BindVertexElements", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::BindVertexElements), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteVertexElements", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteVertexElements), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"CreateSamplerState", "MGPSamplerDesc", static_cast<Uint64>(MGPWireOp::CreateSamplerState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteSamplerState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteSamplerState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"CreateSamplerView", "MGPSamplerView", static_cast<Uint64>(MGPWireOp::CreateSamplerView), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteSamplerView", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteSamplerView), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"CreateShaderState", "MGPProgramDesc", static_cast<Uint64>(MGPWireOp::CreateShaderState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"BindShaderState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::BindShaderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteShaderState", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::DeleteShaderState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetDynamicState", "MGPDynamicState", static_cast<Uint64>(MGPWireOp::SetDynamicState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetFramebufferState", "MGPFramebufferState", static_cast<Uint64>(MGPWireOp::SetFramebufferState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetVertexBuffers", "MGPVertexBuffers", static_cast<Uint64>(MGPWireOp::SetVertexBuffers), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetIndexBuffer", "MGPIndexBuffer", static_cast<Uint64>(MGPWireOp::SetIndexBuffer), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetIndirectBuffers", "MGPIndirectBuffers", static_cast<Uint64>(MGPWireOp::SetIndirectBuffers), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetSamplerViews", "MGPSamplerViews", static_cast<Uint64>(MGPWireOp::SetSamplerViews), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"BindSamplerStates", "MGPSamplerStates", static_cast<Uint64>(MGPWireOp::BindSamplerStates), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetShaderImages", "MGPShaderImages", static_cast<Uint64>(MGPWireOp::SetShaderImages), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetShaderBuffers", "MGPShaderBuffers", static_cast<Uint64>(MGPWireOp::SetShaderBuffers), static_cast<Uint64>(kVarTail | kHostSpan), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetStreamOutputTargets", "MGPStreamOutputTargets", static_cast<Uint64>(MGPWireOp::SetStreamOutputTargets), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetGlobalConstants", "MGPGlobalConstants", static_cast<Uint64>(MGPWireOp::SetGlobalConstants), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetVertexAttribDefaults", "MGPVertexAttribDefaults", static_cast<Uint64>(MGPWireOp::SetVertexAttribDefaults), static_cast<Uint64>(kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetPixelPackState", "MGPPixelPackState", static_cast<Uint64>(MGPWireOp::SetPixelPackState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetPatchState", "MGPPatchState", static_cast<Uint64>(MGPWireOp::SetPatchState), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetDrawProgram", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::SetDrawProgram), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetDispatchProgram", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::SetDispatchProgram), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetResidualValueState", "MGPResidualValueState", static_cast<Uint64>(MGPWireOp::SetResidualValueState), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetTextureParams", "MGPTextureParams", static_cast<Uint64>(MGPWireOp::SetTextureParams), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"ResourceSubData", "MGPSubData", static_cast<Uint64>(MGPWireOp::ResourceSubData), static_cast<Uint64>(kHasBlob | kVarTail | kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"BufferSubDataResident", "MGPSubData", static_cast<Uint64>(MGPWireOp::BufferSubDataResident), static_cast<Uint64>(kHasBlob | kOptional), static_cast<Uint64>(kWaitNone)},
|
||||
{"ResourceSubDataComplete", "MGPSubDataComplete", static_cast<Uint64>(MGPWireOp::ResourceSubDataComplete), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"ResourceFlushRange", "MGPFlushRange", static_cast<Uint64>(MGPWireOp::ResourceFlushRange), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"ResourceReadback", "MGPReadback", static_cast<Uint64>(MGPWireOp::ResourceReadback), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"ResourceCopyRegion", "MGPCopyRegion", static_cast<Uint64>(MGPWireOp::ResourceCopyRegion), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"GenerateMipmap", "MGPMipPlan", static_cast<Uint64>(MGPWireOp::GenerateMipmap), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"GetTextureImage", "MGPReadbackInfo", static_cast<Uint64>(MGPWireOp::GetTextureImage), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"Blit", "MGPBlit", static_cast<Uint64>(MGPWireOp::Blit), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"Clear", "MGPClear", static_cast<Uint64>(MGPWireOp::Clear), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"ReadPixels", "MGPReadbackInfo", static_cast<Uint64>(MGPWireOp::ReadPixels), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"DrawVbo", "MGPDrawInfo", static_cast<Uint64>(MGPWireOp::DrawVbo), static_cast<Uint64>(kHostSpan | kVarTail), static_cast<Uint64>(kWaitNone)},
|
||||
{"LaunchGrid", "MGPGridInfo", static_cast<Uint64>(MGPWireOp::LaunchGrid), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"MemoryBarrier", "MGPMemoryBarrier", static_cast<Uint64>(MGPWireOp::MemoryBarrier), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"BeginStreamOutput", "MGPStreamOutputBegin", static_cast<Uint64>(MGPWireOp::BeginStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"EndStreamOutput", "MGPXfbAccounting", static_cast<Uint64>(MGPWireOp::EndStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"PauseStreamOutput", "MGPStreamOutputControl", static_cast<Uint64>(MGPWireOp::PauseStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"ResumeStreamOutput", "MGPStreamOutputControl", static_cast<Uint64>(MGPWireOp::ResumeStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"Flush", "MGPFlush", static_cast<Uint64>(MGPWireOp::Flush), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"Present", "MGPPresent", static_cast<Uint64>(MGPWireOp::Present), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitPresent)},
|
||||
{"SetSwapInterval", "MGPSwapInterval", static_cast<Uint64>(MGPWireOp::SetSwapInterval), static_cast<Uint64>(kOptional), static_cast<Uint64>(kWaitNone)},
|
||||
{"QueryTimestamp", "MGPTimestampRequest", static_cast<Uint64>(MGPWireOp::QueryTimestamp), static_cast<Uint64>(kReplySlot), static_cast<Uint64>(kWaitReply)},
|
||||
{"QueryCounter", "MGPQueryDesc", static_cast<Uint64>(MGPWireOp::QueryCounter), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"FenceWaitServer", "MGPFenceWait", static_cast<Uint64>(MGPWireOp::FenceWaitServer), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"BindShaderImage", "MGPImageBind", static_cast<Uint64>(MGPWireOp::BindShaderImage), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"PatchParameter", "MGPPatchParameter", static_cast<Uint64>(MGPWireOp::PatchParameter), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"BindStreamOutput", "MGPStreamOutputBind", static_cast<Uint64>(MGPWireOp::BindStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"SetStorageBlockBinding", "MGPStorageBlockBinding", static_cast<Uint64>(MGPWireOp::SetStorageBlockBinding), static_cast<Uint64>(kHasBlob), static_cast<Uint64>(kWaitApplied)},
|
||||
{"CopyFramebufferToTexture", "MGPCopyFromFramebuffer", static_cast<Uint64>(MGPWireOp::CopyFramebufferToTexture), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"ApplierReset", "MGPApplierReset", static_cast<Uint64>(MGPWireOp::ApplierReset), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitApplied)},
|
||||
{"ObjectDeath", "MGPHandleOnly", static_cast<Uint64>(MGPWireOp::ObjectDeath), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetContextValues", "MGPContextValues", static_cast<Uint64>(MGPWireOp::SetContextValues), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
{"SetProgramBindings", "MGPProgramBindings", static_cast<Uint64>(MGPWireOp::SetProgramBindings), static_cast<Uint64>(kVarTail | kHostSpan), static_cast<Uint64>(kWaitNone)},
|
||||
{"DeleteStreamOutput", "MGPStreamOutputBind", static_cast<Uint64>(MGPWireOp::DeleteStreamOutput), static_cast<Uint64>(kNone), static_cast<Uint64>(kWaitNone)},
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
# P6.5 第一波:TCP 控制与 stream 数据
|
||||
|
||||
2026-09-22。依据 `docs/Disaggregated/ROADMAP.md` 的「立即的下一项」。本文件记录实现所需的协议细节;验收结果单独记入阶段报告,不能用本文件代替运行证据。
|
||||
|
||||
## 范围与配置
|
||||
|
||||
本波实现 POSIX client/server 的全 TCP 连接;主验收形态是 WSL x86_64 client 与 Redmi aarch64 server。保留 inproc 与 fork/UNIX 的共享段路径。Windows client、TCP 控制加共享段、压缩、内容去重、异步 reply、真实窗口均不在本波。
|
||||
|
||||
`MOBILEGL_TRANSPORT=spawn` 表示两进程拓扑。`MOBILEGL_IPC_CONTROL` 选择 `fork`(默认)、`unix:<path>` 或 `tcp://host:port`,`MOBILEGL_IPC_DATA=auto|shm|stream` 选择数据面。本波 TCP 只接受 stream,fork/UNIX 只接受 shm;不支持的显式组合具名拒绝。Connect 不启动本地子进程,实际 server pid 来自 Welcome。
|
||||
|
||||
TCP 两条连接依次为控制和数据。每条均设置 NODELAY、KEEPALIVE,Linux/Android 另设置 KEEPIDLE=2、KEEPINTVL=1、KEEPCNT=3、USER_TIMEOUT=5000。网络错误和 EOF 才触发 peer-hung-up;apply 超时不是 device loss。无 `MOBILEGL_IPC_TOKEN` 的 listener 仅能绑定 loopback;错令牌返回 Refuse,不打印令牌值。
|
||||
|
||||
## 握手与布局
|
||||
|
||||
Hello/Welcome 追加 `wireFingerprint`、`LinkTerms`,Hello 带 dial 与 token,Welcome 带实际 backend。原 union 标签不重排;Refuse 与 LogFlush 追加。Refuse 是正常的拒绝结果,不能改成 ABI mismatch abort。
|
||||
|
||||
wire 指纹覆盖 PipeFields 逐成员名称/offset/size、按序 opcode/payload/flags/WaitClass、记录头、句柄、render-state 字段表、blob codec 版本、协议版本、字节序、指针宽度与 caps/dynamic-parameters 布局。build stamp 单独比较:Fork 必须相同,Connect 不同只警告,`MOBILEGL_IPC_REQUIRE_SAME_BUILD=1` 则拒绝。窗口尺寸由 server 陈述,不进入布局指纹。DynamicBackendParameters 使用定宽整数;没有借机改 GLFunctionsTable ABI。
|
||||
|
||||
启动必须收到并采用真实的首个 CapsSnapshot,之后才能锁存 run-ahead 并宣布 session started。
|
||||
后台控制 reader 尚未把 caps 放入 inbox,不能解释成 server 不支持能力;也不能先用 placeholder
|
||||
永久锁成 lockstep,再期待后来的快照自动提升。后续快照仍只允许 demotion,缺少首 caps 是有界启动失败。
|
||||
|
||||
program archive 在 split 构建使用 v2,头中校验真实序列化 schema 摘要,且版本和摘要进入握手指纹。v1 的宿主对象大小 echo 在 Linux 是 1056,在 Android 是 0,不能用于跨端兼容判定;libstdc++ 与 libc++ 的字符串/容器布局不相同,即使两端都是 LP64。payload 按字段序列化,schema 递归覆盖字段名、次序和类型,不包含容器宿主 sizeof/offsetof。宿主大小编译绊线保留为本地维护检查;非 split 路径保留 v1,G1 不因此让步。
|
||||
|
||||
## 数据面与生命周期
|
||||
|
||||
ILink 拥有数据面存储与端点。ShmLink 保留映射、reply slot pool 和现有 ring 实现;StreamLink 拥有私有镜像。session 只缓存端点/进度指针;reserve/pop 仍使用原有非虚 ring 操作。测试兼容的原始 ring 构造入口和启动时的 descriptor 交付不作为生产链路选择入口。
|
||||
|
||||
数据帧含 MGLD magic、长度、kind、两个 64-bit 字段及 payload。Stage 在引用它的 Cmd 之前发送;Cmd/Event 按逻辑 cursor 严格顺序接收并检查容量。接收线程先写数据,再 release 发布 head/水位。每侧数据连接有一个独立 reader;发送在调用线程串行进行,不引入无界发送队列。
|
||||
|
||||
进度保留单调、`>=`、只能晚不能早的规则。Progress 必须包含 **cmdRetiredTail**:FreeBytes 依赖退役尾,只有 applied tail 不能回收 borrowed record,也不能保证环回绕。event credit 以 ClientProgress 返回。越窗、非法方向、倒退水位是 ProtocolCorruption。
|
||||
|
||||
server 在 park 前、Reply 之后、present/completion 变化时冲刷进度,并按 64 条记录/1 ms 合并普通进度。client 每个等待点先 Flush。Stream reply 使用 seq 标识的消息邮箱;已经观察到 applied 却没有相应 reply 必须拒绝,不能永久等待。ShmLink 保留旧 slot 语义。
|
||||
|
||||
Present 与 `glFlush` 也是 client 的发送边界:将已经发布的批次交给对端,保持 run-ahead,不新增 apply 等待。单靠下一次 credit wait 冲刷,会让最后一帧在 client 随后空闲时永久留在本地,credit=3 时还会把前三帧积在发送端。
|
||||
|
||||
已经丢失连接或在 stage/cmd 空间等待中观察到真实挂断时,编码器取消本次及后续发射:不复制新 blob、不增加 wire seq,返回 DECLINED,并保留本地 reply ticket 的合法性。只因超时不能闩 device loss;stage 空间等待使用与 barrier 一致的 120 秒上限,让传输层有时间报告半开连接的失败。
|
||||
|
||||
两条 TCP 连接之间没有到达顺序保证。因此 surface RPC 前先等待此前提交的命令;SurfaceReply 另携带 **eventHead**。server 冲刷事件后发回复,client 等数据 reader 收到该 head 后才完成 RPC。仅按两个 send 的先后推断 SurfaceChanged 已到达是错误的。
|
||||
|
||||
## 控制、日志和进程
|
||||
|
||||
client 的专用控制 reader 直接落盘 LogLine,其他控制消息进入有界 inbox,避免 GL 线程等数据时 server 因日志 socket 写满而停住。server 同时写本地日志并前送;client 写自己的 `<base>.server.log`。`MGPipeSyncPeerLog()` 先同步命令,再以 LogFlush/ack 对齐日志观察点。正常的无远端情形是 no-op,损坏的 ack 不能静默成功。
|
||||
|
||||
supervisor 接受连接后 fork,每会话独立进程,父进程不创建 backend/EGL;同时只允许一会话,第二个返回 Busy。父进程关闭自己的 socket 副本时 **不调用 shutdown**,否则会关闭 child 仍使用的连接。后端由 Hello 请求,显式 server 环境钉住的后端不匹配则拒绝。server 子进程保留 P6 的 PipeStats Init/Shutdown。
|
||||
|
||||
正常 client 结束请求时只先关闭控制 socket 的写半边,等 server 完成 backend 销毁、最终日志和进程退出后的 EOF,再完成本地关闭。否则连续的独立 client 会抢到前一会话仍在清理的时间窗。Busy 拒绝在读取 Hello 后发送,避免带未读请求直接 close 引发 TCP RST,丢掉已经排队的 Refuse。
|
||||
|
||||
trace flavour 的前台 MobileGLServerService 从 nativeLibraryDir 启动可执行 server,设置服务端角色与反递归标志,持 wake lock。`am force-stop` 终止该包的服务进程。
|
||||
|
||||
## 带宽和测量口径
|
||||
|
||||
第一波不启用压缩或内容去重。P6 gate 8 的 rd12 stage 中位/均值是 816,248 / 1,534,555 B/帧,60 fps 对应约 49 / 92 MB/s;OpenRA 短样本均值明显受加载尖峰影响。该数据已经说明 Wi-Fi 可能成为瓶颈,但没有压缩率、额外 CPU 或纹理重复率证据,不能据此选定压缩算法,也不能宣称已满足 60 fps。
|
||||
|
||||
`MOBILEGL_PIPE_STATS=1` 下,P65LinkMetrics 记录逐帧 reply 次数、RTT 固定桶、stage bytes、wall time 与 client thread CPU。p50/p99 为桶上界;回复的测量包含必要的发送、排队与 apply,不能冒充空载网络 ping。Stage 字节/帧除以 wall time 是负载流量;链路吞吐另用真实 TCP 64 MiB 突发测量。与 PipeStats 的同源字节计数是独立观测,不能相加。
|
||||
|
||||
## 验收中的两处澄清
|
||||
|
||||
- 车道 parity 比较 DirectGLES 的可比用例集合,而不是不同标签下的总条数;当前基线是 102 条。TCP 每条还需真实 `control=tcp data=stream server=... pid=N` 证明与本地零子进程断言。fixture 不算用例通过数,禁止用 EGL 启动失败的 SKIP 代替通过。
|
||||
- lf 文档列出的四个 arming 场景中,UnlocatedIoBlock、PrimitivesGeneratedNoXfb、PointSizeDemotion 的 marker 来自 server;关闭日志前送应让对应断言变红。PipeVerifyArming 的 marker 来自 **client PipeFill**,关闭 server 前送本来就不应使它变红;它应继续通过,作为角色分离对照。不得伪造一个 server marker 来满足错误的负控预期。
|
||||
@@ -0,0 +1,158 @@
|
||||
# CONTRACT-P7 — Magma(DirectVulkan)全量走完拆分路径
|
||||
|
||||
权威:本文,与 `CONTRACT-P5.md`(表 0、字节载体、字段归属、R-1…R-17)、`CONTRACT-P5C.md`(规则 E、两个具名豁免、`SEG_EVENT`、守卫)、`CONTRACT-P5E.md`(规则 F、等待规则)、`CONTRACT-MAGMA-RUNAHEAD.md`、`CONTRACT-P6.md`(规则 G/H、死亡漏斗、§12 记录债)、`CONTRACT-P65.md`(两轴传输、布局指纹、`LinkTerms`)并列;与它们不一致处以本文为准,§10 逐条列出。基线:`feat/disaggregated @ 78b7d6be`。`file:line` 均在该提交上读取;路径在 `MobileGL/` 下,除非以 `docs/` 开头。
|
||||
|
||||
**怎么改。** 集成者的文件。wave 2 的实现包(A / B / C / D / E / F,§9)需要改行时经集成者;包从第一天起就对着下面的行编译。
|
||||
|
||||
**写自什么。** [`notes/p7/PLAN-PH-P34B-P7.md`](../../docs/Disaggregated/notes/p7/PLAN-PH-P34B-P7.md)(三行逐项审计,66 个代理,每个 done / unnecessary 判定两名反驳者)与 [`notes/p7/INTEGRATOR-DECISIONS-P7.md`](../../docs/Disaggregated/notes/p7/INTEGRATOR-DECISIONS-P7.md)(ID-P7-1..11)。本文只写**规范**——树必须变成什么样、门怎么判;为什么这样定在裁定日志里。
|
||||
|
||||
---
|
||||
|
||||
## §0 P7 是什么,以及一条高于每一行的规则
|
||||
|
||||
P7 收官 = 五道出口门同时成立(§2–§7),而不是路线图 P7 行的交付列逐字做完。路线图行里两项**本阶段拒做**(ID-P7-5:`SetupDrawSnapshot` 探测字段塌 dirty mask、`VertexInputStateFactory` 内容寻址 CSO——它们是 monolith 路径上的性能项,`VulkanRenderer::SetupDraw` 在任何非 monolith 传输下分支到 `SetupWireDraw`,split 下不跑,且改它们动 pull `.text`),一项只做窄半(内部 shader 烘焙的 monolith 臂退役与直通 TCS 烘焙归 P13 / OQ-7 宽半)。
|
||||
|
||||
**规则 I — Magma 的 wire 臂上没有 `std::abort()`。** 树上每一处 `@P7` 具名拒绝今天都是 `MGLOG_F` + `std::abort()`,绕过 `Session::Fail`、不给对端 `SessionFault` 帧、普查门看不见。P7 之后,`MG_Backend/DirectVulkan` 下任何 wire 臂的拒绝只有两种形状:(a) **decline**——`MGLOG_E_ONCE` + 返回失败 + 与 monolith 臂相同的可观测(屏蔽属性、跳过 blit……);(b) **具名 Fatal**——经 `MG_Pipe` 的 `MGPipeSessionFailHook` 进 `MG_Remote::SessionFail`,带 `FatalFamilies.def` 里的家族词。`MG_Backend` 不 include `MG_Remote`(include 闭包门),hook 由 server 角色初始化安装。规则 I 的牙齿是 §3 的普查门:扩到 server 镜像后,`MG_Backend` 下裸 abort 的站点数只能下降。
|
||||
|
||||
**规则 J — 每个修复先在两进程臂上红一次。** wave 0 之前树上没有一条车道能让 Magma 两进程用例变红(四条 split 臂硬编码 `MOBILEGL_BACKEND_TYPE=DirectGLES`,`MG_IntegrationTest/CMakeLists.txt:2002/:2025/:2031`),所以 ID-P7-10:车道落地前不派 `@P7` 退役的活;落地后每个退役都带一条在 `integration-magma-spawn`(或 `-tcp`)上先红后绿的用例。
|
||||
|
||||
---
|
||||
|
||||
## §1 与前序契约的关系:什么已经不是 P7 的
|
||||
|
||||
| 项 | 谁做了 | 证据 |
|
||||
|---|---|---|
|
||||
| `DynamicBackendParameters` / `MGPCaps` / `RenderStateParameters` 定宽 + 布局指纹 | P6.5 wf(`fe27380a`) | `CONTRACT-P65.md` 「握手与布局」;`CONTRACT-P6.md:666` 仍记在 P7 名下,§10 更正 |
|
||||
| server buffer consumers、Android 旋转 blit | `38919d45` | `notes/p5f/magma-inproc-fix.md` |
|
||||
| Magma run-ahead、GPU 延迟退休、VAO 身份碰撞 | `194382c9` | `notes/p5f/magma-runahead.md`;`MG_Backend/Init.cpp:101` `kMGPipeMagmaRunAheadReady = true` |
|
||||
| packed-float mip 原生 blit、resolve、占位图像、copy-image 端点、XFB 捕获 span、纹理回读 | `ed507b1a..d56c0e83`(随 `e1bf3677` 合入) | `WirePlaceholderImages.inc`、`WireFramebuffer.inc:634-636` |
|
||||
| 颜色 blit 烘焙(仅 split 臂) | P5f fv | `Renderer/WireColorBlit.{vert,frag,inc}`、`WireColorBlitSpirv.h` |
|
||||
| D-B8 具名 UBO 的载体 | 直绑常驻 `VkBuffer` range 的备选已在树上 | `UniformManager.cpp:2375` 直绑分支;欠一次 `stage-ubo-named` 字节/帧测量后关 OQ-6 |
|
||||
|
||||
---
|
||||
|
||||
## §2 出口门 1:集成 + trace 在 Magma 的 push 与 split 下全绿
|
||||
|
||||
**2.1 车道形状(wave 0 包 L)。** `mgl_itest_register_split_arms` 获得后端维度;DirectVulkan × {Split(inproc), Spawn, Tcp} 三臂的环境为 `MGL_ITEST_VULKAN_{SPLIT,SPAWN,TCP}_ENVIRONMENT`(`MOBILEGL_BACKEND_TYPE=DirectVulkan` + monolith `DirectVulkan.` 臂已用的 ICD 钉)。两档标签:
|
||||
|
||||
- **gating**:`integration-magma-split`(inproc,含义不变)、`integration-magma-spawn`、`integration-magma-tcp`——今天 `integration-magma-split` 的 73 条(及 magma-buffers / magma-runahead / magma-caches 子标签)重铺三臂;三臂**同数绿**才算门 1 的集成半边成立。
|
||||
- **informational**:`integration-magma-{spawn,tcp}-all`——所有经共享宏注册的场景 × DirectVulkan × 两进程。首轮红名单是 wave 2 的工作清单;不进 CI 门,直到某条目连续绿后**按名**升入 gating(`test.yml` 的 require_green 名单)。
|
||||
|
||||
名集合纪律不变:`scripts/ci/spawn_lane_parity.py` 规范化后 split / spawn / tcp 三集合相等;G14 只增不删;每条目私有角色日志(`SplitLogPaths.cmake.in` 由宏累积)。
|
||||
|
||||
**2.2 臂证明。** Magma 两进程条目必须在 client 私有日志里同时有 `transport=spawn`(或 `control=tcp data=stream`)与 `backend=DirectVulkan`(或等价的 ConfigLoader 行)——一条 Magma 车道静默跑成 GLES 会满足其它所有门。`junit_tally.py` 的 `--require-spawn` / `--require-tcp-ran` 各加后端断言。
|
||||
|
||||
**2.3 死亡通知前提。** `MG_Remote/Client/WireTables.cpp:740` 只在 DirectGLES 下安装对象死亡通知,Magma 两进程 client 的 `ObjectDeaths` 恒为 0。改成后端无关(wave 0 L);Magma 自己的 `StateObjectDeathOps` 表(wave 2-C)落地前,`CtWireScenario` 的死亡用例在 Magma 臂上按名 skip 并列入 §12。
|
||||
|
||||
**2.4 trace 半边。** `retrace-split` 已是 39 case × 2 后端 × {inproc, spawn}(`test.yml:2449/:2470`);欠 `iterationrp × DirectVulkan` 的三个旋钮在 retrace-split 作业里与 `:2183` 同样导出(wave 0 L)。门 1 的 trace 半边 = 78 条 DirectVulkan split 行全部达阈值。
|
||||
|
||||
**2.5 门 1 的判据。** gating 三臂同数绿(【待填:L 包首轮的 73/73 × 3】)+ parity 通过 + retrace-split 78 条 DV 行达阈值 + informational 车道的红名单为空或每条按名归入 P8 / P9 / P13 并在 `notes/p7/` 有票。
|
||||
|
||||
---
|
||||
|
||||
## §3 `@P7` 具名拒绝:普查、退役与 decline
|
||||
|
||||
**3.1 普查数(钉住)。** 基线上 `grep -rn "@P7" MobileGL/ --include=*.cpp --include=*.inc --include=*.h` = **【待填:C 包实测;审计两次分别数得 14 串 / 13 语句与 15 处 / 4 文件——以 C 包的 `fatal_census.py --json` 为准】**处,全部在 `Renderer/UniformManager.cpp`、`Renderer/WireFramebuffer.inc`、`Renderer/WireDraw.inc`、`Renderer/VulkanRenderer.cpp`。另有两项 P7 归属但不带 `@P7` 字样:`Fatal{RoleViolation, "buffer-legacy-arm"}`(`WireDraw.inc:14/:204`)与「Magma 无 `StateObjectDeathOps`」(两条集成用例 skip)。
|
||||
|
||||
**3.2 退役表。** 「退役」= 实现该形状,与 monolith 臂同可观测;「decline」= 规则 I (a)。
|
||||
|
||||
| 名 | 站点 | 判定 | 形状 |
|
||||
|---|---|---|---|
|
||||
| `uniform-buffer-byte-tail` | `UniformManager.cpp:2391` | **退役**(真机 MC 报告 §5 的活边界) | 拷贝窗口外扩到 4 字节边界进 transient slice,再 `vkCmdCopyBuffer` 对齐内部到正确子字目的;`CopyWireBufferRangeToSlice` 扩 |
|
||||
| `copy-image-in-place` | `VulkanRenderer.cpp:10383` | **退役** | `srcImage == dstImage` 时单次转 `GENERAL`、两侧布局 GENERAL、一次写回;同 mip+layer 且矩形重叠 → decline(GL 未定义) |
|
||||
| `vertex-layout` | `WireDraw.inc:245`、`VertexInputStateFactory.cpp:439-500` | **拆分** | `buffer-window` 一种保留为协议错(经 hook 的具名 Fatal——它抓过 Redmi 的 VAO 哈希碰撞);其余六种形状/格式原因改 monolith 的「屏蔽该属性继续画」,`BuildWireVertexInput` 出 `unsupportedAttribMask` |
|
||||
| `default-color-blit-shape` | `WireFramebuffer.inc:601` | **退役** | 恒等变换回落 `vkCmdBlitImage` 臂(`:611-624`);非恒等旋转先 resolve/copy 进 scratch 2D RGBA 再 shader blit(复用 `:560-590` 的 scratch);四旋转之外 decline |
|
||||
| `multisample-blit-shape` / `-aspect` | `WireFramebuffer.inc:631/:641` | **退役** | shape:resolve 进 scratch 单采样再 `vkCmdBlitImage` 缩放/翻转;aspect:MS 深/模板 → 单采样用 `VK_KHR_depth_stencil_resolve`(`DynamicBackendParameters` 里查扩展)或 `texelFetch(sampler2DMS)` 写 `gl_FragDepth` 的 shader resolve;单采样 → MS 尺寸不同 decline |
|
||||
| `depth-stencil-mipmap` | `WireFramebuffer.inc:753` | **退役**(随烘焙 (A)) | `GenerateWireMipmap` 深度分支接 `WireDepthMipmap.{vert,frag}` 烘焙程序 |
|
||||
| `texel-buffer-native-format` | `UniformManager.cpp:1153` | decline | 可选:重打包回落 |
|
||||
| `unaligned-{texel,storage,atomic}-buffer-range` | `:1161/:1551/:1552` | decline 或拷入对齐 transient | 可选;SSBO 可写范围的 copyback 未定 |
|
||||
| `storage-buffer-native-range` / `uniform-block-native-range` | `UniformManager.cpp` | decline(钳/拆) | 可选 |
|
||||
| `uniform-buffer-dynamic-offset` | `:2400` | decline | 可选(>4 GiB) |
|
||||
| `vertex-format-conversion` | `WireDraw.inc:272` | decline | 可选:packed converter |
|
||||
| `buffer-legacy-arm` | `WireDraw.inc:14/:204` | 具名 Fatal 经 hook(`RoleViolation`) | 已是拒绝,只换漏斗 |
|
||||
|
||||
**3.3 普查门(wave 0 包 C)。** `scripts/ci/fatal_census.py` 的扫描根扩到 server 镜像(`MG_Remote`、`MG_Pipe`、`MG_Backend`、`MG_Impl/Pipe`、`MG_State`,MG_Test / MG_Benchmark / MG_IntegrationTest 除外);`abort_sites` 成为**向下棘轮**;每个 `Fatal{Word` 在 `FatalFamilies.def` 有行;`Refuse{Word}` 对 `protocol.fbs` `RefuseCode` 校验。baseline 数:【待填:C 包】。
|
||||
|
||||
---
|
||||
|
||||
## §4 出口门 4:184 符号棘轮下降 P7 的 101 个
|
||||
|
||||
**4.1 定义(wave 0 包 R,`scripts/link_ratchet.py`)。** 在 disaggregated 构建的对象树上:按 `notes/p6/a6-link-experiment-data.md` 的路径规则把 `MobileGL.dir` 下对象分 SERVER / FRONTEND / SHARED;集合 = (SERVER 未定义) − (SERVER 已定义) − (SHARED 已定义) ∩ (FRONTEND 已定义)。baseline 存**符号列表**(`scripts/data/link_ratchet_baseline.txt`),`--assert-monotone` 只对新增符号红,消失只提示重基线(ID-P7-7)。基线数:【待填:R 包;a6 为 184 = P7 101 / P3b-P4b 14 / 共有 60 / P6 自己 6】。
|
||||
|
||||
**4.2 P7 的目标。** `--bucket` 归到 DirectVulkan 引用对象的那一桶(a6 的 101)降到 **0**。唯一还在构造前端 `SamplerObject` / `ShaderObject` / `ProgramObject` 的 DirectVulkan 站点是 `VulkanRenderer.cpp:4526-4583 / 4624-4684`(monolith 臂的隐藏 blit / 深度 mip 程序),其 early-return 是运行时而非 `#if`,所以符号仍被引用。降到 0 的路径:在 **disaggregated 构建里** monolith 臂也改用烘焙模块(§5.2 的 (B')),pull 构建的代码逐语句原样——G1 不动。若 wave 3 实测某桶符号无法在不动 pull `.text` 的前提下消失,按名记入 §12 并在 baseline 里 `# P13` 标注,不算门 4 失败。
|
||||
|
||||
**4.3 与 P3b/P4b 的 14 个。** 不是 P7 的目标;棘轮落地后 P3b/P4b 的 Tier 1 才可调度。
|
||||
|
||||
---
|
||||
|
||||
## §5 内部 shader、反射归档与 resident 上传(wave 2-B / 2-C 的规范)
|
||||
|
||||
**5.1 烘焙 (A)(D)。** `WireDepthMipmap.{vert,frag}` + 生成的 `WireDepthMipmapSpirv.h` + `WireDepthMipmap.inc`(深度附件 render pass + pipeline),`GenerateWireMipmap`(`WireFramebuffer.inc:752-769`)深度分支接入;新鲜度门 `MOBILEGL_BAKED_INTERNAL_SHADERS`:MG_Test 用树内 glslang 重编每个签进树的 SPIR-V 头并逐字节比对,**表驱动**,覆盖 `MG_Util/SelfTest/DriverPostIterationRPWitnessSpv.h` 与 `PrimitivesGeneratedNoXfbProbeSpv.h`。
|
||||
**5.2 (B') disaggregated 构建的 monolith 臂改用烘焙模块**(§4.2 需要):`InitializeBlitResources` / `InitializeDepthMipmapResources` / `BlitWithShader` / `GenerateDepthMipmapWithShader` 在 `#if MOBILEGL_BUILD_DISAGGREGATED` 下走烘焙管线;`#else` 分支保留今天的代码逐语句原样。两处 `MagmaP7AllocatorDebtScope` 随之删除(先用临时断言证明它们在非 monolith 传输下从不武装)。
|
||||
**5.3 OQ-8。** `LinkArtifacts` 加有序 `storageBlocks{name, binding, dataSize}`(顺序 = stage 序 → 规范化描述符名 → binding,跨 stage 去重,与 `MagmaProgramSource.h:194-195` / `DirectVulkan.cpp:220-260` 今天的资源查询序相同),进 `Visit()`,archive codec 版本 +1(`wireFingerprint` 随之变);`MagmaProgramSource::EnsureStorageBlocks` 与 `DirectVulkan.cpp` 的 `GetProgramResourceCache` 都改读它;`g_programResourceCaches` 及其 rehash 悬挂风险随之删。单测:多 stage + 数组 SSBO + atomic-counter block 的索引序与 SPIRV-Reflect 逐项相同。
|
||||
**5.4 OQ-10。** `MG_Backend/Init.cpp` `InitServerRoleCommon` 按 **server 自己的 wire 资源表** 判 `SubDataResident != nullptr` 发布 `kCapResidentSubData`(不按后端枚举猜——ID-39 的教训);`RemoteClientTest.cpp:594` 改期望;integration-magma-buffers 与 integration-split 各一条白盒用例证明发出的是 `BufferSubDataResident(49)`;26.3 in-world 回归。
|
||||
**5.5 Magma `StateObjectDeathOps`。** 镜像 `DirectGLES/Managers.cpp:335-474` 的表,从 DirectVulkan 后端注册处安装;删六处 Magma 特判;`PipeSlotPeek` 断言死亡后槽位回落;red-once = 卸表看槽位泄漏断言红。
|
||||
|
||||
---
|
||||
|
||||
## §6 出口门 2:verify 零分歧
|
||||
|
||||
verify 今天只在 monolith 注册(`MG_IntegrationTest/CMakeLists.txt:1684-1760`)。门 2 = **verify × {monolith, split(inproc)} × Magma 零分歧**,且两条既有负控(`VERIFY_CORRUPT`、`POISON_OMIT`)在 split 臂上各红一次。前置债:verify+split 撞旧 `PipeRespecifyScope` 断言(`notes/p65/validation-status.md:118`)——放宽为「按 level 的 producer 各自覆盖其宣告范围」,正反单测各一。trace 侧:8 个 verify case × DirectVulkan × inproc 一轮,分歧计数 0。
|
||||
|
||||
---
|
||||
|
||||
## §7 出口门 3 与 5:真机与 CTS
|
||||
|
||||
**7.1 门 3 分母(ID-P7-4)。** `trace_cases.json` 的 CI split 子集 × DirectVulkan × `--use-pbuffer`,排除 `minecraft-1.21.4-rd12-odinlite-in-world` 与 `create-indirect`(OQ-17:`dev@81b17c0b` 起在 Adreno 830 上就坏);`iterationrp` 带 `apk.yml:460-462` 的三个 Magma 旋钮。
|
||||
**7.2 门 3 判据。** 同一 reboot-clean 会话内:monolith 对照 1.0;inproc **与** spawn(或 tcp)三遍 ≥ 各 case 现有阈值、OpenRA 1.0、三遍逐位相同(零翻转);`RUN_AHEAD=0` 对照臂一遍记录。证据目录 `docs/Disaggregated/notes/p7/device-window-<n>/`。定位实验顺序 E0–E6 见计划 §3 wave 1。
|
||||
**7.3 门 5。** 块:`KHR-GL46.texture_*`、`shader_image_*`、`packed_pixels`、`direct_state_access.*`、`uniform_buffer_object*`;caselist 入库 `tools/cts/caselists/p7-*.txt`(记 suite 版本);先 monolith × DirectVulkan 基线入库 `tools/cts/baselines/`,迁移落地后 inproc × DirectVulkan 比对:每块 pass 率差 ≤ 0.5 pp(Pass/(Pass+Fail),NS 不入分母),**新增 crash = 0 单独硬红**。完整 caselist(~56k)在合 `dev` 前跑,不在关键路径。
|
||||
|
||||
---
|
||||
|
||||
## §8 子系统分母与 40% 检查点
|
||||
|
||||
分母 9 项:(1) Magma 两进程车道 gating 三臂同数绿;(2) §3.2 的六个「退役」;(3) `StateObjectDeathOps`;(4) 烘焙 (A)(D);(5) OQ-8;(6) OQ-10;(7) verify×split;(8) 真机 ssim 1.0;(9) CTS 五块 ≤0.5 pp。**中点** = wave 2 的 A / B / C 三簇全部合入集成树之时;届时完成 < 4/9 → 停下重定基线(路线图唯一幸存的再基线绊线,此前没有分母、不可执行)。
|
||||
|
||||
---
|
||||
|
||||
## §9 wave 2 的文件分区与合并规则
|
||||
|
||||
| 簇 | 文件 | 内容 |
|
||||
|---|---|---|
|
||||
| A | `Renderer/UniformManager.cpp` | §3.2 的 UBO / SSBO / texel 对齐与 native-range 行 |
|
||||
| B | `Renderer/WireFramebuffer.inc`、`Renderer/VulkanRenderer.cpp`、新 `WireDepthMipmap.*` | copy-image、default-color-blit、multisample、深度 mip 烘焙 (A)(D)、(B')、AllocatorDebtScope |
|
||||
| C | `Renderer/VertexInputStateFactory.cpp`、`Renderer/WireDraw.inc`、`Renderer/VkBufferManager.cpp`、`MG_Backend/Init.cpp`、`Renderer/MagmaProgramSource.h`、`MG_State/.../ProgramArtifacts.h` | vertex-layout 拆分、`StateObjectDeathOps`、OQ-10、OQ-8 |
|
||||
| D | `MG_Backend/DirectGLES/*`、`MG_State/*`、`MG_Impl/Pipe/*`、`MG_IntegrationTest/*` | P3b/P4b 的 Espryt 项(与 A/B/C 零重叠) |
|
||||
| E | `docs/`、契约 | 已落地项更正、OQ 关闭、`MEASUREMENTS.md` §7.2 同名重跑 |
|
||||
| F | `MG_Remote/Transport/*`、`MG_Remote/Server/ServerMain.cpp`、`Handshake.h`、`Protocol/protocol.fbs` | Ph 小件(令牌、D11 五处、PH-8 单测) |
|
||||
|
||||
合并规则:集成者串行合并;每次合并后 gating 三臂 + `link_ratchet.py --assert-monotone` + G1 + parity;**棘轮上升的提交拒收**;每包一条 red-once 记在 `notes/p7/`;性能只记录不设门(ID-P7-9)。实现方 `opus`、审查方 `fable`(ID-P7-8)。
|
||||
|
||||
---
|
||||
|
||||
## §10 对前序契约的更正
|
||||
|
||||
1. `CONTRACT-P6.md:666`(§10.3)把 `DynamicBackendParameters` 定宽记在 P7 名下——已由 P6.5 wf 落地,P7 不再持有。
|
||||
2. `CONTRACT-P6.md` §12.1「棘轮在 CI 里重算 184 并断言只降」——由 wave 0 包 R 落地为 `scripts/link_ratchet.py`;「移交 P6.5」从未被 P6.5 接收,归 P7。
|
||||
3. `CONTRACT-P6.md` §12.2 D11 把五行中的三行分给 P6 `dl`——树上五处全部仍在原状态(`PipeApply.cpp:1575`、`PipeApplier.cpp:444`、`ProgramArtifactsCodec.cpp:309`、`StagedTextureStore.h:440`、`SlotTables.h:347/:371`);归 Ph(计划 §1.1 D11),wave 2-F 做。
|
||||
4. `CONTRACT-P6.md` §5.2「`Session::Fail` 在 P6 保持 `[[noreturn]]`」——Ph 的翻转按 ID-P7-1 重定界,不做 98 站点的字面翻转;`Server/StagedShadow.h:115`、`Server/StagedTextureStore.h:344` 两处旁路由 wave 0 包 C 收进漏斗。
|
||||
5. `ARCHITECTURE.md` §8.5「XFB scatter 在 client」——树上取的是 server staged shadow + `OnBufferWriteback`(P5c/P5f);`OnXfbScatterReady` 是死声明,删除。
|
||||
|
||||
---
|
||||
|
||||
## §11 不是 P7 的
|
||||
|
||||
- `SetupDrawSnapshot` dirty mask、`VertexInputStateFactory` 内容寻址 CSO(ID-P7-5)→ 优化阶段。
|
||||
- 内部 shader 烘焙的 pull 构建 monolith 臂退役(动 pull `.text`)、直通 TCS 烘焙(64 模块)→ P13 / OQ-7 宽半。
|
||||
- `MG_Util` 头/对象库拆分 → P13。
|
||||
- Ph 的 fuzz 臂 2(对端字节可达站点逐站点闩转换)、PH-6、PH-7 (4)(5) → P7 之后(计划 wave 5)。
|
||||
- P3b/P4b 的 CTS AFTER、Iris 普查的 P9 例外(`texture-remint-pull`)→ 各自阶段。
|
||||
|
||||
---
|
||||
|
||||
## §12 记录债
|
||||
|
||||
- Magma 两进程 client 在 `StateObjectDeathOps` 落地前 `ObjectDeaths=0`:`CtWireScenario` 死亡用例在 Magma 臂按名 skip(§2.3)。
|
||||
- 门 3 的「不确定」在 wave 1 E0 之前无法区分「同 case 多次结果不同」与「不同 case 各自低于阈值」;两个历史点值(0.988998 / 0.976494)无 per-case 归属。
|
||||
- `MEASUREMENTS.md` §7.2 的同名比对自 P5b 起未重跑;「22 → texture readback」「3 → query」两行债务的关闭以 wave 3 的重跑为准。
|
||||
- Android 模拟器 retrace 车道每轮 2–6 例 flaky(含 monolith 对照):门 1 的任何模拟器证据都先过「连续 N 轮绿」再算数。
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "CapsCodec.h"
|
||||
|
||||
#include "Protocol/mg_protocol_base.h"
|
||||
#include <MG_Pipe/PipeWireLayout.h>
|
||||
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
||||
|
||||
#include <MGGitHash.h>
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
@@ -461,43 +463,33 @@ namespace MobileGL::MG_Remote {
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
Transport::AbiFingerprintInputs CapsAbiFingerprintInputs() {
|
||||
// MGPCaps has only a COMPOSITIONAL size assertion (MGPipeTypes.h:145-146) because
|
||||
// DynamicBackendParameters still carries SizeT and GLenum members - P0.5's fixed-width
|
||||
// rewrite did not happen and P5 does not do it either (table 0's ABI row; the rewrite
|
||||
// is P7's account). So the caps block's literal size IS ABI-dependent, and this
|
||||
// fingerprint is what turns that from a latent hazard into a named refusal.
|
||||
//
|
||||
// The git stamp is in it because two builds of the same sizes can still disagree about
|
||||
// a FIELD ORDER, which no sizeof can see; P6's spawn is same-machine and same-binary,
|
||||
// so it inherits this unchanged rather than needing a looser rule.
|
||||
Transport::AbiFingerprintInputs inputs;
|
||||
inputs.DynamicParamsSize = sizeof(MG_Backend::DynamicBackendParameters);
|
||||
inputs.CapsSize = sizeof(MG_Pipe::MGPCaps);
|
||||
inputs.FunctionTableSize = sizeof(MG_Backend::GLFunctionsTable);
|
||||
inputs.FormatCapabilityTargets = static_cast<Uint64>(MG_Backend::kFormatCapabilityTargetCount);
|
||||
inputs.FormatCapabilityFormats = static_cast<Uint64>(MG_Backend::kFormatCapabilityFormatCount);
|
||||
inputs.MemberLayout = MG_Pipe::kMGPipeWireMemberLayoutDigest;
|
||||
inputs.CatalogueLayout = MG_Pipe::kMGPipeWireCatalogueDigest;
|
||||
inputs.RenderStateLayout = MG_Pipe::WireRenderStateDigest();
|
||||
inputs.FormatCapabilityTargets = MG_Backend::kFormatCapabilityTargetCount;
|
||||
inputs.FormatCapabilityFormats = MG_Backend::kFormatCapabilityFormatCount;
|
||||
inputs.FormatCapabilitiesCodecVersion = kFormatCapabilitiesCodecVersion;
|
||||
inputs.RendererInfoCodecVersion = kRendererInfoCodecVersion;
|
||||
inputs.ProgramArtifactsCodecVersion = MG_State::GLState::kProgramArtifactsCodecVersion;
|
||||
inputs.ProgramArtifactsSchema = MG_State::GLState::ProgramArtifactsSchemaFingerprint();
|
||||
inputs.OpCount = static_cast<Uint64>(MG_Pipe::MGPWireOp::kOpCount);
|
||||
// The declared protocol ABI, carried over from s1's version of this function at
|
||||
// integration (ID-33). The sizeofs above catch a struct that changed shape; this
|
||||
// catches a peer that changed the PROTOCOL while every struct stayed the same size,
|
||||
// which is the one break the rest of the mix is blind to.
|
||||
inputs.AbiVersion =
|
||||
static_cast<Uint32>(MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR));
|
||||
// MOBILEGL_BUILD_STAMP_VALUE, NOT GIT_COMMIT_HASH_SHORT (CONTRACT-P6 4.2). The old
|
||||
// macro is application-visible through glGetString(GL_VERSION) and may not move, and it
|
||||
// came from an execute_process with no RESULT_VARIABLE - so a tree git could not read
|
||||
// produced "" and every such build agreed with every other. The new pair separates the
|
||||
// VALUE from whether the build could name a commit at all.
|
||||
inputs.BuildStamp = MOBILEGL_BUILD_STAMP_VALUE;
|
||||
inputs.BuildStampPresent = MOBILEGL_BUILD_STAMP_PRESENT;
|
||||
inputs.AbiVersion = MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR);
|
||||
inputs.PointerBits = sizeof(void*) * 8;
|
||||
const Uint32 endian = 1;
|
||||
inputs.LittleEndian = *reinterpret_cast<const Uint8*>(&endian) == 1 ? 1u : 0u;
|
||||
return inputs;
|
||||
}
|
||||
|
||||
// ONE implementation, deliberately a one-liner: the wave-1 review (ID-46 finding 6) found a
|
||||
// second hand-rolled FNV loop here while the mixer under Transport/ had no production caller,
|
||||
// so the sensitivity test could not see this function change. Now it starts from here.
|
||||
Uint64 CapsAbiFingerprint() { return Transport::MixAbiFingerprint(CapsAbiFingerprintInputs()); }
|
||||
Uint64 WireFingerprint() {
|
||||
static const Uint64 fingerprint = Transport::MixAbiFingerprint(CapsAbiFingerprintInputs());
|
||||
return fingerprint;
|
||||
}
|
||||
// Compatibility spelling for existing wire tests and helper peers.
|
||||
Uint64 CapsAbiFingerprint() { return WireFingerprint(); }
|
||||
const char* BuildFingerprint() { return MOBILEGL_BUILD_STAMP_VALUE; }
|
||||
Bool BuildFingerprintPresent() { return MOBILEGL_BUILD_STAMP_PRESENT != 0; }
|
||||
|
||||
} // namespace MobileGL::MG_Remote
|
||||
|
||||
@@ -20,13 +20,7 @@
|
||||
// RendererInfo -> RendererInfo (MG_Util/Types.h:317): three Strings, an
|
||||
// Optional<String>, and a Vector<GLExtension> inside GLInfo.
|
||||
//
|
||||
// THE ABI RULING (table 0). MGPCaps has only a COMPOSITIONAL size assertion
|
||||
// (MGPipeTypes.h:145-146) because DynamicBackendParameters still carries SizeT and GLenum
|
||||
// members - P0.5's fixed-width rewrite did not happen. P5 does NOT rewrite it. Instead the
|
||||
// handshake asserts that both peers agree on sizeof(DynamicBackendParameters),
|
||||
// sizeof(MGPCaps) and the build fingerprint, and Fatal{AbiMismatch} otherwise. P6's spawn is
|
||||
// same-machine and same-binary, so it inherits this unchanged; the fixed-width rewrite is on
|
||||
// P7's account.
|
||||
// P6.5: wire layout and build identity are independent handshake facts.
|
||||
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
@@ -90,19 +84,11 @@ namespace MobileGL::MG_Remote {
|
||||
Bool EncodeRendererInfo(const RendererInfo& info, Vector<Uint8>& out);
|
||||
Bool DecodeRendererInfo(const void* bytes, Uint64 size, RendererInfo& out);
|
||||
|
||||
// ---- the ABI assertion the handshake carries ----------------------------------------
|
||||
//
|
||||
// The inputs, as this build sees them: sizeof(DynamicBackendParameters), sizeof(MGPCaps),
|
||||
// sizeof(GLFunctionsTable), the format-capability table's extents, the two caps-blob codec
|
||||
// versions, MGPWireOp::kOpCount, the protocol ABI version and the compile-time git stamp.
|
||||
// Public so that the sensitivity control can pin every one of them to the real value AND
|
||||
// perturb them one at a time through the same mixer the handshake uses.
|
||||
// Wire compatibility never includes a git stamp or local function-pointer tables.
|
||||
Transport::AbiFingerprintInputs CapsAbiFingerprintInputs();
|
||||
|
||||
// What Hello/Welcome carry and compare: EXACTLY Transport::MixAbiFingerprint(
|
||||
// CapsAbiFingerprintInputs()) - one implementation, no second hash (ID-46 finding 6). A
|
||||
// mismatch is Fatal{AbiMismatch} and never a downgrade, because every alternative silently
|
||||
// reads one struct as another.
|
||||
Uint64 CapsAbiFingerprint();
|
||||
Uint64 WireFingerprint();
|
||||
Uint64 CapsAbiFingerprint(); // legacy spelling of WireFingerprint
|
||||
const char* BuildFingerprint();
|
||||
Bool BuildFingerprintPresent();
|
||||
|
||||
} // namespace MobileGL::MG_Remote
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "ClientSession.h"
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
#include <MG_Remote/Handshake.h>
|
||||
#include <MG_Remote/Transport/LinkMetrics.h>
|
||||
|
||||
#include "../CapsCodec.h"
|
||||
#include "../Protocol/generated/protocol_generated.h"
|
||||
@@ -109,39 +111,6 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return ::MobileGL::Wire::GetCtrlEnvelope(bytes.data());
|
||||
}
|
||||
|
||||
// CONTRACT-P6 4.3: THE DECLARED PROTOCOL VERSION, WHICH THIS SIDE NEVER READ.
|
||||
//
|
||||
// Hello has carried abiMajor/abiMinor since P5 and the SERVER checks them, but the
|
||||
// client only ever compared the fingerprint - so the asymmetry was silent in the one
|
||||
// direction that matters for spawn, where the peer is a SEPARATE IMAGE the operator
|
||||
// chose with MOBILEGL_IPC_SERVER_PATH.
|
||||
//
|
||||
// The fingerprint mixes AbiVersion and would catch a mismatch anyway, but it catches it
|
||||
// as "struct shapes" - which sends the reader looking for a layout change that is not
|
||||
// there. Checking the version FIRST turns the same failure into the sentence that
|
||||
// explains it. Both handshake sites call this; there are two, and only one of them used
|
||||
// to be reachable, which is how the gap survived review.
|
||||
[[noreturn]] void FatalProtocolVersionMismatch(unsigned theirMajor, unsigned theirMinor,
|
||||
const char* theirStamp) {
|
||||
SessionFail(MGFatalFamily::AbiMismatch, "MGPipe: Fatal{AbiMismatch, \"protocol version\"} ours=%u.%u theirs=%u.%u "
|
||||
"ourBuild=%s theirBuild=%s - the peer speaks a different MGPipe protocol. "
|
||||
"Under spawn this is most often a stale MOBILEGL_IPC_SERVER_PATH pointing at "
|
||||
"a libMobileGLServer.so built from another tree.",
|
||||
static_cast<unsigned>(MOBILEGL_PROTOCOL_ABI_MAJOR),
|
||||
static_cast<unsigned>(MOBILEGL_PROTOCOL_ABI_MINOR), theirMajor, theirMinor,
|
||||
GIT_COMMIT_HASH_SHORT, theirStamp == nullptr ? "?" : theirStamp);
|
||||
}
|
||||
|
||||
[[noreturn]] void FatalAbiMismatch(const char* what, Uint64 ours, Uint64 theirs,
|
||||
const char* theirStamp) {
|
||||
SessionFail(MGFatalFamily::AbiMismatch, "MGPipe: Fatal{AbiMismatch, \"%s\"} ours=%llu theirs=%llu ourBuild=%s "
|
||||
"theirBuild=%s - never a downgrade: the caps block's size is ABI-dependent "
|
||||
"and every field past the first difference would be read at the wrong offset",
|
||||
what, static_cast<unsigned long long>(ours),
|
||||
static_cast<unsigned long long>(theirs), GIT_COMMIT_HASH_SHORT,
|
||||
theirStamp == nullptr ? "?" : theirStamp);
|
||||
}
|
||||
|
||||
// Guarded the same way ServerSession's helpers are: MG_Config::Ipc only exists
|
||||
// behind MOBILEGL_BUILD_DISAGGREGATED (Config.h), and this file is only compiled
|
||||
// there today - but the guard is what keeps that true if the source list ever
|
||||
@@ -227,9 +196,9 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// the queue's work is not the caller's budget being spent.
|
||||
const auto wait = producer.WaitForAppliedOrEventBacklog(seq, chunkMs);
|
||||
if (wait == Transport::SessionWait::Reached) {
|
||||
Transport::RingControl* control = producer.Control();
|
||||
if (control == nullptr ||
|
||||
Transport::Watermark::Reached(control->Progress.appliedSeq, seq)) {
|
||||
const auto* progress = producer.Progress();
|
||||
if (progress == nullptr ||
|
||||
Transport::Watermark::Reached(progress->appliedSeq, seq)) {
|
||||
return wait;
|
||||
}
|
||||
DrainEventRing(events);
|
||||
@@ -531,6 +500,11 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return *instance;
|
||||
}
|
||||
|
||||
ClientSession::ClientSession() {
|
||||
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ClientProducer);
|
||||
m_cmd = &m_link->CommandsOut(); m_events = &m_link->EventsIn();
|
||||
}
|
||||
|
||||
ClientSession::~ClientSession() {
|
||||
if (m_started) {
|
||||
Stop();
|
||||
@@ -580,13 +554,19 @@ namespace MobileGL::MG_Remote::Client {
|
||||
|
||||
// ---- 2. Hello. Sent before the server accepts: InProcessTransport queues whole
|
||||
// messages, so one thread can drive both halves of the handshake in order.
|
||||
const Uint64 fingerprint = CapsAbiFingerprint();
|
||||
const auto dial = ::MobileGL::Wire::DialMode::No;
|
||||
const auto dataPlane = ::MobileGL::Wire::DataPlane::SharedSegments;
|
||||
const Uint64 fingerprint = WireFingerprint();
|
||||
{
|
||||
::flatbuffers::FlatBufferBuilder builder(512);
|
||||
auto stamp = builder.CreateString(GIT_COMMIT_HASH_SHORT);
|
||||
auto stamp = builder.CreateString(BuildFingerprint());
|
||||
auto terms = ::MobileGL::Wire::CreateLinkTerms(builder, dataPlane);
|
||||
const char* tokenText = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||
auto token = builder.CreateString(tokenText == nullptr ? "" : tokenText);
|
||||
auto hello = ::MobileGL::Wire::CreateHello(
|
||||
builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR, stamp,
|
||||
/*backendType=*/0u, /*pid=*/SelfProcessId(), /*configBlob=*/0, fingerprint);
|
||||
static_cast<Uint32>(MG_Config::ActiveBackendType), SelfProcessId(), 0,
|
||||
fingerprint, fingerprint, terms, token, dial);
|
||||
auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
||||
builder, ::MobileGL::Wire::CtrlMsg::Hello, hello.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
||||
@@ -617,6 +597,10 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return received;
|
||||
}
|
||||
const ::MobileGL::Wire::CtrlEnvelope* envelope = ParseEnvelope(frame);
|
||||
if (LogPeerRefusal(envelope)) {
|
||||
Stop();
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
// msg_as_Welcome() IS PART OF THE GUARD - flatbuffers' Verifier::VerifyTable is
|
||||
// `return !table || table->Verify(*this)`, so a NULL union member verifies while
|
||||
// msg_type() still reports Welcome. See ServerSession::Accept for the same guard.
|
||||
@@ -634,16 +618,32 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// 4.3: the pid the SERVER stated, taken before any check can abort, so a Fatal line
|
||||
// can name it too.
|
||||
m_peerServerPid = static_cast<std::uint32_t>(welcome->serverPid());
|
||||
// The VERSION before the fingerprint: both would fire, and only one names the cause.
|
||||
if (welcome->abiMajor() != MOBILEGL_PROTOCOL_ABI_MAJOR ||
|
||||
welcome->abiMinor() != MOBILEGL_PROTOCOL_ABI_MINOR) {
|
||||
FatalProtocolVersionMismatch(static_cast<unsigned>(welcome->abiMajor()),
|
||||
static_cast<unsigned>(welcome->abiMinor()),
|
||||
theirStamp);
|
||||
const MobileGLResult compatible = ValidatePeerHandshake(*m_transport,
|
||||
welcome->abiMajor(), welcome->abiMinor(), welcome->wireFingerprint(), theirStamp, dial);
|
||||
if (compatible != MOBILEGL_OK) {
|
||||
Stop();
|
||||
return compatible;
|
||||
}
|
||||
if (welcome->abiFingerprint() != fingerprint) {
|
||||
FatalAbiMismatch("struct shapes", fingerprint, welcome->abiFingerprint(),
|
||||
theirStamp);
|
||||
const auto* terms = welcome->linkTerms();
|
||||
if (terms == nullptr || terms->dataPlane() != dataPlane ||
|
||||
terms->wireForm() != ::MobileGL::Wire::WireForm::StructImage ||
|
||||
terms->cmdWindowBytes() < Transport::kMinRingCapacity ||
|
||||
(terms->cmdWindowBytes() & (terms->cmdWindowBytes() - 1)) != 0 ||
|
||||
terms->stageWindowBytes() == 0 || terms->maxReplyBytes() == 0 ||
|
||||
terms->maxReplyBytes() > 0xFFFFFFFFull - sizeof(Transport::ReplySlotHeader) ||
|
||||
terms->eventWindowBytes() < Transport::kMinRingCapacity ||
|
||||
(terms->eventWindowBytes() & (terms->eventWindowBytes() - 1)) != 0) {
|
||||
const auto result = RefuseHandshake(*m_transport, ::MobileGL::Wire::RefuseCode::LinkTerms,
|
||||
"invalid server link terms");
|
||||
Stop();
|
||||
return result;
|
||||
}
|
||||
if (welcome->backendType() != static_cast<Uint32>(MG_Config::ActiveBackendType)) {
|
||||
const auto result = RefuseHandshake(*m_transport, ::MobileGL::Wire::RefuseCode::Backend,
|
||||
"server backend differs from request", static_cast<Uint32>(MG_Config::ActiveBackendType),
|
||||
welcome->backendType());
|
||||
Stop();
|
||||
return result;
|
||||
}
|
||||
// The four SegmentRefs are what a spawn client MAPS (P6). Under inproc the mapping
|
||||
// already exists, so what they are good for here is the cross-check that the two
|
||||
@@ -675,7 +675,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// under the client role; under `spawn` it becomes ShmSegment::Adopt of the fds the
|
||||
// server passed by SCM_RIGHTS, which is why nothing below this line knows which it was.
|
||||
const MobileGLResult attached =
|
||||
m_shm.AttachInProcess(server.Shm(), Transport::MemoryRole::Client);
|
||||
m_link->Memory().AttachInProcess(server.Shm(), Transport::MemoryRole::Client);
|
||||
if (attached != MOBILEGL_OK) {
|
||||
Stop();
|
||||
return attached;
|
||||
@@ -690,6 +690,35 @@ namespace MobileGL::MG_Remote::Client {
|
||||
if (m_started) {
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
const std::string configured(MG_Config::Ipc.Control.c_str());
|
||||
if (configured != "fork") {
|
||||
const bool tcp = configured.compare(0, 6, "tcp://") == 0;
|
||||
const bool unixSocket = configured.compare(0, 5, "unix:") == 0;
|
||||
const std::string data(MG_Config::Ipc.Data.c_str());
|
||||
if ((!tcp && !unixSocket) ||
|
||||
(data != "auto" && data != (tcp ? "stream" : "shm"))) {
|
||||
MGLOG_E("MG_Remote: Refuse{ProtocolMismatch} unsupported control/data pair %s/%s",
|
||||
configured.c_str(), data.c_str());
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
m_connectDial = true;
|
||||
const auto endpoint = tcp ? configured : configured.substr(5);
|
||||
std::unique_ptr<Transport::SocketTransport> socket;
|
||||
const auto connected = Transport::SocketTransport::ConnectTo(endpoint, kSpawnConnectTimeoutMs, socket);
|
||||
if (connected != MOBILEGL_OK) return connected;
|
||||
const auto started = StartOverSocket(std::move(socket));
|
||||
if (started == MOBILEGL_OK) {
|
||||
MGLOG_I("MG_Remote client: control=%s data=%s server=%s pid=%u dial=connect",
|
||||
tcp ? "tcp" : "unix", tcp ? "stream" : "shm",
|
||||
tcp ? endpoint.c_str() + 6 : endpoint.c_str(), m_peerServerPid);
|
||||
}
|
||||
return started;
|
||||
}
|
||||
if (MG_Config::Ipc.Data != "auto" && MG_Config::Ipc.Data != "shm") {
|
||||
MGLOG_E("MG_Remote: Refuse{ProtocolMismatch} fork requires shm data in P6.5 wave one");
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
m_connectDial = false;
|
||||
// A rendezvous nobody else can collide with. Independent processes need
|
||||
// a NAME; making it per-process-per-instant is what stops two runs on
|
||||
// one machine - which `ctest -j` produces by construction - finding each
|
||||
@@ -755,13 +784,20 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// ---- Hello. The same bytes as inproc; the fingerprint is still compared
|
||||
// for equality, because under Dial == Fork the child IS the same binary and
|
||||
// comparing it catches a stale MOBILEGL_IPC_SERVER_PATH (CONTRACT-P6 4.1).
|
||||
const Uint64 fingerprint = CapsAbiFingerprint();
|
||||
const auto dial = m_connectDial ? ::MobileGL::Wire::DialMode::Connect : ::MobileGL::Wire::DialMode::Fork;
|
||||
const auto dataPlane = m_socketTransport->IsTcp() ? ::MobileGL::Wire::DataPlane::Stream
|
||||
: ::MobileGL::Wire::DataPlane::SharedSegments;
|
||||
const Uint64 fingerprint = WireFingerprint();
|
||||
{
|
||||
::flatbuffers::FlatBufferBuilder builder(512);
|
||||
auto stamp = builder.CreateString(GIT_COMMIT_HASH_SHORT);
|
||||
auto stamp = builder.CreateString(BuildFingerprint());
|
||||
auto terms = ::MobileGL::Wire::CreateLinkTerms(builder, dataPlane);
|
||||
const char* tokenText = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||
auto token = builder.CreateString(tokenText == nullptr ? "" : tokenText);
|
||||
auto hello = ::MobileGL::Wire::CreateHello(
|
||||
builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR, stamp,
|
||||
/*backendType=*/0u, /*pid=*/SelfProcessId(), /*configBlob=*/0, fingerprint);
|
||||
static_cast<Uint32>(MG_Config::ActiveBackendType), SelfProcessId(), 0,
|
||||
fingerprint, fingerprint, terms, token, dial);
|
||||
auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
||||
builder, ::MobileGL::Wire::CtrlMsg::Hello, hello.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
||||
@@ -778,6 +814,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// own mapping, which a6 showed is vacuous against a real peer. Here the wire
|
||||
// values are the only values, which is what that check has to become on
|
||||
// every lane (CONTRACT-P6 4.4).
|
||||
Transport::SessionSegmentSizes negotiatedSizes;
|
||||
bool stream = false;
|
||||
Uint64 announced[4] = {0, 0, 0, 0};
|
||||
const Uint32 replySlotCount = Transport::kDefaultReplySlotCount;
|
||||
{
|
||||
@@ -791,6 +829,10 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return received;
|
||||
}
|
||||
const ::MobileGL::Wire::CtrlEnvelope* envelope = ParseEnvelope(frame);
|
||||
if (LogPeerRefusal(envelope)) {
|
||||
Stop();
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::Welcome ||
|
||||
envelope->msg_as_Welcome() == nullptr) {
|
||||
MGLOG_E("MG_Remote client: the spawned server first frame is not a verifiable "
|
||||
@@ -805,17 +847,39 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// 4.3: the pid the SERVER stated, taken before any check can abort, so a Fatal line
|
||||
// can name it too.
|
||||
m_peerServerPid = static_cast<std::uint32_t>(welcome->serverPid());
|
||||
// The VERSION before the fingerprint: both would fire, and only one names the cause.
|
||||
if (welcome->abiMajor() != MOBILEGL_PROTOCOL_ABI_MAJOR ||
|
||||
welcome->abiMinor() != MOBILEGL_PROTOCOL_ABI_MINOR) {
|
||||
FatalProtocolVersionMismatch(static_cast<unsigned>(welcome->abiMajor()),
|
||||
static_cast<unsigned>(welcome->abiMinor()),
|
||||
theirStamp);
|
||||
const MobileGLResult compatible = ValidatePeerHandshake(*m_transport,
|
||||
welcome->abiMajor(), welcome->abiMinor(), welcome->wireFingerprint(), theirStamp, dial);
|
||||
if (compatible != MOBILEGL_OK) {
|
||||
Stop();
|
||||
return compatible;
|
||||
}
|
||||
if (welcome->abiFingerprint() != fingerprint) {
|
||||
FatalAbiMismatch("struct shapes", fingerprint, welcome->abiFingerprint(),
|
||||
theirStamp);
|
||||
const auto* terms = welcome->linkTerms();
|
||||
if (terms == nullptr || terms->dataPlane() != dataPlane ||
|
||||
terms->wireForm() != ::MobileGL::Wire::WireForm::StructImage ||
|
||||
terms->cmdWindowBytes() < Transport::kMinRingCapacity ||
|
||||
(terms->cmdWindowBytes() & (terms->cmdWindowBytes() - 1)) != 0 ||
|
||||
terms->stageWindowBytes() == 0 || terms->maxReplyBytes() == 0 ||
|
||||
terms->maxReplyBytes() > 0xFFFFFFFFull - sizeof(Transport::ReplySlotHeader) ||
|
||||
terms->eventWindowBytes() < Transport::kMinRingCapacity ||
|
||||
(terms->eventWindowBytes() & (terms->eventWindowBytes() - 1)) != 0) {
|
||||
const auto result = RefuseHandshake(*m_transport, ::MobileGL::Wire::RefuseCode::LinkTerms,
|
||||
"invalid server link terms");
|
||||
Stop();
|
||||
return result;
|
||||
}
|
||||
if (welcome->backendType() != static_cast<Uint32>(MG_Config::ActiveBackendType)) {
|
||||
const auto result = RefuseHandshake(*m_transport, ::MobileGL::Wire::RefuseCode::Backend,
|
||||
"server backend differs from request", static_cast<Uint32>(MG_Config::ActiveBackendType),
|
||||
welcome->backendType());
|
||||
Stop();
|
||||
return result;
|
||||
}
|
||||
stream = terms->dataPlane() == ::MobileGL::Wire::DataPlane::Stream;
|
||||
negotiatedSizes.CmdRingBytes = terms->cmdWindowBytes();
|
||||
negotiatedSizes.StageBytes = terms->stageWindowBytes();
|
||||
negotiatedSizes.EventRingBytes = terms->eventWindowBytes();
|
||||
negotiatedSizes.ReplyBytes = (terms->maxReplyBytes() + sizeof(Transport::ReplySlotHeader)) *
|
||||
negotiatedSizes.ReplySlotCount;
|
||||
const ::MobileGL::Wire::SegmentRef* refs[4] = {welcome->cmdRing(), welcome->stageRing(),
|
||||
welcome->replyPool(),
|
||||
welcome->eventRing()};
|
||||
@@ -830,6 +894,14 @@ namespace MobileGL::MG_Remote::Client {
|
||||
}
|
||||
}
|
||||
|
||||
if (stream) {
|
||||
const auto attached = AttachStreamLink(m_socketTransport->TakeDataFd(), negotiatedSizes);
|
||||
if (attached != MOBILEGL_OK) { Stop(); return attached; }
|
||||
m_controlInbox = std::make_unique<Transport::ControlInbox>(*m_transport);
|
||||
Server::ServerLoopInstance().SetRemoteControlSink(&RemoteControlSinkThunk, this);
|
||||
return FinishStartup(&m_link->ConsumerBell(), &m_link->ProducerBell(), false);
|
||||
}
|
||||
|
||||
// ---- the four descriptors. THIS is the step inproc does not have, and the
|
||||
// reason SCM_RIGHTS is in this design at all: the segments are anonymous -
|
||||
// ASharedMemory_create has no filesystem name and memfd / shm_open+unlink
|
||||
@@ -894,14 +966,14 @@ namespace MobileGL::MG_Remote::Client {
|
||||
|
||||
// ---- adopt and map. The same Adopt + Map every inproc run has
|
||||
// exercised since P5; only the origin of the descriptor is new.
|
||||
const MobileGLResult adopted = m_shm.AdoptFromDescriptors(
|
||||
const MobileGLResult adopted = m_link->Memory().AdoptFromDescriptors(
|
||||
fds, announced, replySlotCount, Transport::MemoryRole::Client);
|
||||
if (adopted != MOBILEGL_OK) {
|
||||
closeAll();
|
||||
Stop();
|
||||
return adopted;
|
||||
}
|
||||
// The four segment descriptors now belong to m_shm. The two bells
|
||||
// The four segment descriptors now belong to m_link->Memory(). The two bells
|
||||
// belong to the doorbells, which own and close them.
|
||||
//
|
||||
// WHICH BELL IS WHICH IS THE SESSION'S KNOWLEDGE, exactly as under
|
||||
@@ -947,6 +1019,58 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return static_cast<ClientSession*>(user)->RunRemoteSurfaceControlFrame(frame);
|
||||
}
|
||||
|
||||
MobileGLResult ClientSession::ReceiveControlFrame(std::vector<Uint8>& frame, Uint32 timeoutMs) {
|
||||
return m_controlInbox ? m_controlInbox->Receive(frame, timeoutMs)
|
||||
: ReceiveEnvelope(*m_transport, frame, timeoutMs);
|
||||
}
|
||||
|
||||
void ClientSession::SyncPeerLog() {
|
||||
if (!m_started || !m_socketTransport || !m_transport || DeviceLost()) return;
|
||||
const auto submitted = m_producer.LastPublishedSeq();
|
||||
m_producer.PublishAndNotify(submitted);
|
||||
const auto wait = WaitForAppliedBudget(m_producer, *m_events, submitted, kRemoteControlTimeoutMs);
|
||||
if (wait == Transport::SessionWait::ShutDown) {
|
||||
if (const auto* bell = m_producer.SelfDoorbell(); bell && bell->PeerHungUp())
|
||||
LatchDeviceLost("log synchronization woke on a peer that had hung up");
|
||||
return;
|
||||
}
|
||||
if (wait != Transport::SessionWait::Reached) {
|
||||
SessionFail(MGFatalFamily::BarrierTimeout,
|
||||
"MGPipe: Fatal{BarrierTimeout, LogFlush} apply prefix was not completed");
|
||||
}
|
||||
DrainEventRing(*m_events);
|
||||
const std::lock_guard<std::mutex> lock(m_remoteControlMutex);
|
||||
const auto seq = ++m_logFlushSeq;
|
||||
flatbuffers::FlatBufferBuilder builder(64);
|
||||
auto flush = ::MobileGL::Wire::CreateLogFlush(builder, seq, false);
|
||||
auto envelope = ::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::LogFlush, flush.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
if (m_transport->SendFrame({builder.GetBufferPointer(), builder.GetSize()}) != MOBILEGL_OK) {
|
||||
LatchDeviceLost("control stream closed during LogFlush");
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
std::vector<Uint8> bytes;
|
||||
const auto received = ReceiveControlFrame(bytes, kRemoteControlTimeoutMs);
|
||||
if (received == MOBILEGL_ERR_TRANSPORT_CLOSED) {
|
||||
LatchDeviceLost("control stream closed during LogFlush");
|
||||
return;
|
||||
}
|
||||
if (received != MOBILEGL_OK)
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, LogFlush} no acknowledgement rc=%d", received);
|
||||
const auto* reply = ParseEnvelope(bytes);
|
||||
if (!reply)
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, LogFlush} malformed acknowledgement");
|
||||
if (const auto* ack = reply->msg_as_LogFlush()) {
|
||||
if (!ack->ack() || ack->seq() != seq) {
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, LogFlush} reply sequence mismatch");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (const auto* caps = reply->msg_as_CapsSnapshot()) AdoptCapsSnapshot(caps);
|
||||
}
|
||||
}
|
||||
|
||||
MobileGLResult ClientSession::RunRemoteSurfaceControlFrame(Server::SurfaceControlFrame& frame) {
|
||||
if (m_transport == nullptr) {
|
||||
return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
@@ -974,6 +1098,15 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// caller-serialised on the server's m_callerMutex under inproc; the same
|
||||
// discipline has to hold here or two replies race for one correlation.
|
||||
const std::lock_guard<std::mutex> lock(m_remoteControlMutex);
|
||||
// Control and data are independent ordered streams. Finish the old
|
||||
// command prefix before a surface operation can change its EGL tuple.
|
||||
if (m_started && m_link && !m_link->Capabilities().PublishIsDelivery) {
|
||||
const auto submitted = m_producer.LastPublishedSeq();
|
||||
m_producer.PublishAndNotify(submitted);
|
||||
if (WaitForAppliedBudget(m_producer, *m_events, submitted, kRemoteControlTimeoutMs) !=
|
||||
Transport::SessionWait::Reached) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
DrainEventRing(*m_events);
|
||||
}
|
||||
const MobileGLResult sent = m_transport->SendFrame(
|
||||
MobileGLByteSpan{builder.GetBufferPointer(), builder.GetSize()});
|
||||
if (sent != MOBILEGL_OK) {
|
||||
@@ -986,7 +1119,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
for (;;) {
|
||||
std::vector<Uint8> reply;
|
||||
const MobileGLResult received =
|
||||
ReceiveEnvelope(*m_transport, reply, kRemoteControlTimeoutMs);
|
||||
ReceiveControlFrame(reply, kRemoteControlTimeoutMs);
|
||||
if (received != MOBILEGL_OK) {
|
||||
// `dl` (D5b): THE EXPIRY IS NOT FATAL AND IT IS NOT ONE ANSWER. The transport
|
||||
// already distinguishes the two states this wait can end in, and the contract
|
||||
@@ -1063,6 +1196,10 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
MG_Remote::DecodeWireSurfaceReply(*wire, &frame);
|
||||
if (m_link) {
|
||||
const auto delivered = m_link->WaitForEventDelivery(frame.eventHead, kRemoteControlTimeoutMs);
|
||||
if (delivered != MOBILEGL_OK) return delivered;
|
||||
}
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
}
|
||||
@@ -1081,9 +1218,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
MobileGLResult ClientSession::FinishStartup(Transport::Doorbell* peerBell,
|
||||
Transport::Doorbell* selfBell,
|
||||
bool startApplyThreadHere) {
|
||||
Transport::RingControl* control = m_shm.CmdControl();
|
||||
m_cmd = Transport::RingProducer(control, m_shm.CmdRingBase(), m_shm.CmdRingCapacity(),
|
||||
Transport::RingCursorSet::Cmd);
|
||||
m_link->InitializeEndpoints();
|
||||
// NO STAGE RING. SEG_STAGE is package w1's encoder-local LINEAR ALLOCATOR:
|
||||
// a staged byte run carries no RingRecordHeader, nothing consumes SEG_STAGE,
|
||||
// and the allocator reclaims on retiredSeq. A RingProducer over
|
||||
@@ -1091,23 +1226,22 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// two tails, so FreeBytes() would fall to zero the first time the head
|
||||
// lapped the capacity and never recover - a guaranteed hang. See
|
||||
// RingControl's stage triple in Ring.h.
|
||||
if (!m_cmd.Valid()) {
|
||||
if (!m_cmd->Valid()) {
|
||||
Stop();
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
// PeerDoorbell() is the bell the SERVER parks on and this side rings; SelfDoorbell() is
|
||||
// this side's own. Which is which is the session's knowledge, not the transport's.
|
||||
m_producer.Attach(control, &m_cmd, peerBell, selfBell, SpinUsFromConfig());
|
||||
m_link->BindDoorbells(peerBell, selfBell);
|
||||
peerBell = &m_link->ConsumerBell(); selfBell = &m_link->ProducerBell();
|
||||
m_producer.Attach(*m_link, SpinUsFromConfig());
|
||||
|
||||
|
||||
m_replies = Transport::ReplySlotPool(m_shm.ReplyBase(), m_shm.ReplyBytes(),
|
||||
m_shm.ReplySlotCount());
|
||||
m_events = Transport::EventRingConsumer(m_shm.EventControl(), control,
|
||||
m_shm.EventRingBase(), m_shm.EventRingCapacity(),
|
||||
m_shm.EventSegmentBase());
|
||||
// P5e (ra, §2.6): the drain's other half. A server parked on a full SEG_EVENT is woken
|
||||
// by the drain that emptied it, not by the next thing this client happens to publish.
|
||||
m_events.SetServerDoorbell(peerBell);
|
||||
if (!m_replies.Valid() || !m_events.Valid()) {
|
||||
m_events->SetServerDoorbell(peerBell);
|
||||
m_events->SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
if (MaxReplyBytes() == 0 || !m_events->Valid()) {
|
||||
Stop();
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
@@ -1128,37 +1262,52 @@ namespace MobileGL::MG_Remote::Client {
|
||||
//
|
||||
// The Install calls themselves are package w1's and are named-Fatal stubs until w1
|
||||
// lands; see ServerSession::Accept for why they are called anyway.
|
||||
m_segments.Install(Wire::kSegCmd,
|
||||
Wire::SegmentView{m_shm.CmdRingBase(), m_shm.CmdRingCapacity()});
|
||||
m_segments.Install(Wire::kSegStage,
|
||||
Wire::SegmentView{m_shm.StageBase(), m_shm.StageBytes()});
|
||||
m_segments.Install(Wire::kSegReply,
|
||||
Wire::SegmentView{m_shm.ReplyBase(), m_shm.ReplyBytes()});
|
||||
m_segments.Install(Wire::kSegEvent,
|
||||
Wire::SegmentView{m_shm.EventSegmentBase(),
|
||||
m_shm.AnnouncedSize(Transport::SessionSegmentSlot::Event)});
|
||||
// nullptr for the stage producer, and that is the honest value: c0's
|
||||
// signature predates w1's ruling that SEG_STAGE is a linear allocator, and
|
||||
// the encoder reaches its bytes through the SegmentTable above. Handing it
|
||||
// a live RingProducer over a cursor triple nobody consumes would be the
|
||||
// half-wired shape this session exists not to have.
|
||||
m_encoder = Wire::PipeWireEncoder(control, &m_cmd, nullptr, &m_segments);
|
||||
m_segments.AttachLink(m_link.get());
|
||||
m_encoder = Wire::PipeWireEncoder(m_link.get(), &m_segments);
|
||||
m_encoder.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
m_encoder.SetStageRetirementDoorbell(m_producer.SelfDoorbell());
|
||||
m_encoder.SetStageWaitTimeoutMs(kBarrierTimeoutMs);
|
||||
m_encoder.SetCancellationState(&m_deviceLost, +[](void* self) {
|
||||
auto& session = *static_cast<ClientSession*>(self);
|
||||
auto* bell = session.m_producer.SelfDoorbell();
|
||||
if (bell && bell->PeerHungUp()) {
|
||||
session.LatchDeviceLost("staging observed a peer that had hung up");
|
||||
}
|
||||
return session.m_deviceLost.load(std::memory_order_acquire) || (bell && bell->Dead());
|
||||
}, this);
|
||||
|
||||
// P5e (ra, §2.6): the stage bell is a client wait and every client wait drains. The
|
||||
// encoder owns the park; the session owns SEG_EVENT, so the session lends it a drain.
|
||||
m_encoder.SetStageWaitHook(
|
||||
+[](void* self) { DrainEventRing(static_cast<ClientSession*>(self)->Events()); }, this);
|
||||
|
||||
// ---- 7. the first CapsSnapshot, if the server had a backend to publish one from.
|
||||
// ONE DRAIN, ONE ADOPTER (c1): PumpControlPlane below is the only thing in the client
|
||||
// that turns a CapsSnapshot into a CapsMirror generation, so R-12's "a second arrival
|
||||
// IS the invalidation" lives in exactly one place. s1's step here used to stop at
|
||||
// "the snapshot arrived and is verifiable"; it now goes all the way, through the same
|
||||
// function every later arrival goes through.
|
||||
if (PumpControlPlane() == 0) {
|
||||
MGLOG_W("MG_Remote client: the handshake carried no CapsSnapshot - the caps mirror is "
|
||||
"a PLACEHOLDER until one arrives. Every caps read until then answers a "
|
||||
"default and says so");
|
||||
// ---- 7. A real first snapshot belongs to startup, not to a later GL call.
|
||||
// Inproc already queued it; an independent control reader may still be
|
||||
// receiving it. Do not latch run-ahead against a placeholder: promotion
|
||||
// after this first decision is deliberately forbidden.
|
||||
{
|
||||
std::vector<Uint8> initialCaps;
|
||||
const auto received = ReceiveControlFrame(initialCaps, kHandshakeTimeoutMs);
|
||||
if (received != MOBILEGL_OK) {
|
||||
MGLOG_E("MG_Remote client: Refuse{InitialCapsSnapshot} no initial capabilities "
|
||||
"within %u ms (rc=%d); the session was not started",
|
||||
kHandshakeTimeoutMs, static_cast<int>(received));
|
||||
Stop();
|
||||
return received;
|
||||
}
|
||||
const auto* envelope = ParseEnvelope(initialCaps);
|
||||
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::CapsSnapshot ||
|
||||
envelope->msg_as_CapsSnapshot() == nullptr ||
|
||||
!AdoptCapsSnapshot(envelope->msg_as_CapsSnapshot())) {
|
||||
MGLOG_E("MG_Remote client: Refuse{InitialCapsSnapshot} first post-Welcome control "
|
||||
"frame is not a valid capabilities snapshot; the session was not started");
|
||||
Stop();
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
LatchRunAheadFromCaps();
|
||||
// A newer snapshot already queued may demote the initial decision.
|
||||
// LogLine frames on TCP were filtered by ControlInbox before this read.
|
||||
PumpControlPlane();
|
||||
}
|
||||
|
||||
// BOTH, AND m_started FIRST. `Active()` is what the integration lane's skip reads and
|
||||
@@ -1171,6 +1320,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// to be true before the pointer that grants access to it is published. `Stop()` takes
|
||||
// them down in the mirror order (m_started = false, then g_active = nullptr).
|
||||
m_started = true;
|
||||
Transport::LinkMetricsBegin();
|
||||
g_active = this;
|
||||
// D1c: THE SESSION-LIVE AND APPLY-THREAD FACTS, stated where they become true.
|
||||
//
|
||||
@@ -1239,6 +1389,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// monolith adapter runs is a defined no-op rather than a use-after-free.
|
||||
UninstallClientWireTables();
|
||||
if (!m_started) {
|
||||
m_controlInbox.reset();
|
||||
if (m_socketTransport) m_socketTransport->Shutdown();
|
||||
// Start's own failure paths land here with a half-built session. FIVE of them are
|
||||
// reached AFTER ServerSession::Accept has already returned OK, so tearing down
|
||||
// only the client half is not enough and gets three things wrong at once: the
|
||||
@@ -1249,7 +1401,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// still point at. The server closes FIRST, in the same order the started path
|
||||
// gets right, and only then do the transports go.
|
||||
m_producer.Detach();
|
||||
m_shm.Close();
|
||||
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ClientProducer);
|
||||
m_cmd = &m_link->CommandsOut(); m_events = &m_link->EventsIn();
|
||||
Server::ServerSessionInstance().Close();
|
||||
m_clientTransport.reset();
|
||||
m_serverTransport.reset();
|
||||
@@ -1264,8 +1417,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
//
|
||||
// 1. publish and let the server drain. Bounded: a lost record must be a red lane, not
|
||||
// a hung exit.
|
||||
Transport::RingControl* control = m_shm.CmdControl();
|
||||
if (control != nullptr) {
|
||||
if (m_link->Attached()) {
|
||||
// The PRODUCER's own last-published seq, not RingControl::submittedSeq. Ring.h:72-77
|
||||
// permits submittedSeq to be published lazily and Ring.h:243 encourages batching
|
||||
// the publish, so the shared watermark is allowed to lag the emitter - and a drain
|
||||
@@ -1288,9 +1440,30 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// kWaitForever (CondVarDoorbell::Kill): a Notify is consumed by one Park, after which
|
||||
// Doorbell::Wait re-tests a condition nothing published, finds the bell alive and
|
||||
// parks again, forever. InProcessChannel::Close kills both bells.
|
||||
// Request EOF starts remote backend destruction. Keep receiving until
|
||||
// peer EOF, so the next client cannot overtake that session's cleanup.
|
||||
if (m_socketTransport && !m_deviceLost.load(std::memory_order_acquire) &&
|
||||
m_socketTransport->ShutdownSend() == MOBILEGL_OK) {
|
||||
bool closed = false;
|
||||
if (m_controlInbox) closed = m_controlInbox->WaitClosed(kDrainTimeoutMs);
|
||||
else {
|
||||
const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(kDrainTimeoutMs);
|
||||
for (;;) {
|
||||
const auto left = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
deadline - std::chrono::steady_clock::now()).count();
|
||||
if (left <= 0) break;
|
||||
std::vector<Uint8> finalFrame;
|
||||
const auto result = ReceiveControlFrame(finalFrame, static_cast<Uint32>(left));
|
||||
if (result == MOBILEGL_ERR_TRANSPORT_CLOSED) { closed = true; break; }
|
||||
if (result != MOBILEGL_OK) break;
|
||||
}
|
||||
}
|
||||
if (!closed) MGLOG_W("MG_Remote client: remote teardown did not reach EOF within %u ms", kDrainTimeoutMs);
|
||||
}
|
||||
if (m_transport != nullptr) {
|
||||
m_transport->Shutdown();
|
||||
}
|
||||
m_controlInbox.reset();
|
||||
|
||||
// 3. JOIN, bounded - package v1's ServerLoop::Stop, which also destroys the server's
|
||||
// private BackendObject on that thread before it exits.
|
||||
@@ -1300,12 +1473,14 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// referenced by an unapplied record is a use-after-free the join is what prevents.
|
||||
LogMemory("teardown");
|
||||
LogWireLedger();
|
||||
Transport::LinkMetricsEnd();
|
||||
m_producer.Detach();
|
||||
m_encoder = Wire::PipeWireEncoder();
|
||||
m_events = Transport::EventRingConsumer();
|
||||
m_replies = Transport::ReplySlotPool();
|
||||
m_cmd = Transport::RingProducer();
|
||||
m_shm.Close();
|
||||
*m_events = Transport::EventRingConsumer();
|
||||
*m_cmd = Transport::RingProducer();
|
||||
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ClientProducer);
|
||||
m_cmd = &m_link->CommandsOut(); m_events = &m_link->EventsIn();
|
||||
m_link->Memory().Close();
|
||||
Server::ServerSessionInstance().Close();
|
||||
m_clientTransport.reset();
|
||||
m_serverTransport.reset();
|
||||
@@ -1412,17 +1587,30 @@ namespace MobileGL::MG_Remote::Client {
|
||||
Wire::WireOpName(op));
|
||||
}
|
||||
|
||||
const auto declineCancelled = [&] {
|
||||
if (statusOut) *statusOut = Wire::ReplySink::kStatusDeclined;
|
||||
return Wire::kInvalidSeq;
|
||||
};
|
||||
if (DeviceLost() || m_encoder.Cancelled()) return declineCancelled();
|
||||
const Bool rowCarriesReplySlot =
|
||||
(MG_Pipe::MGPipeCallFlagsFor(op) & static_cast<Uint32>(MG_Pipe::kReplySlot)) != 0;
|
||||
const Bool ownsReplySlot = rowCarriesReplySlot && wantReply;
|
||||
Uint64 seq = m_encoder.EncodeRecord(op, payload, payloadBytes, tails, tailCount);
|
||||
if (seq == Wire::kInvalidSeq) {
|
||||
if (DeviceLost() || m_encoder.Cancelled()) return declineCancelled();
|
||||
// EncodeRecord already refused individually oversized records. This one fits,
|
||||
// but appliedSeq may be ahead of retiredTail: wait for actual reclaimable space,
|
||||
// including the wrap pad. Prior EmitAndWait calls have published every record.
|
||||
Wire::WireRecordLayout layout{};
|
||||
Wire::MGPipeWireRecordLayout(op, payload, layout);
|
||||
const Uint64 toEnd = m_cmd.Capacity() - m_cmd.LocalHead() % m_cmd.Capacity();
|
||||
const Uint64 toEnd = m_cmd->Capacity() - m_cmd->LocalHead() % m_cmd->Capacity();
|
||||
const Uint64 needed = layout.TotalBytes + (toEnd < layout.TotalBytes ? toEnd : 0);
|
||||
const BarrierWaitScope waiting;
|
||||
const auto wait = m_producer.WaitForCmdSpace(needed, kBarrierTimeoutMs);
|
||||
if (wait == Transport::SessionWait::ShutDown) {
|
||||
(void)m_encoder.CheckCancellation();
|
||||
return declineCancelled();
|
||||
}
|
||||
if (wait != Transport::SessionWait::Reached) {
|
||||
SessionFail(MGFatalFamily::RetirementWaitFailed, "MGPipe: Fatal{RetirementWaitFailed, \"SEG_CMD\"} - %s needs %llu "
|
||||
"reclaimable bytes; the retirement wait ended on %s",
|
||||
@@ -1434,9 +1622,10 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// here without draining is the other half of the flow-control deadlock: the server
|
||||
// stops applying on a full event ring, so retiredSeq stops moving, so this wait
|
||||
// never completes. One drain on the way out closes it.
|
||||
DrainEventRing(m_events);
|
||||
DrainEventRing(*m_events);
|
||||
seq = m_encoder.EncodeRecord(op, payload, payloadBytes, tails, tailCount);
|
||||
if (seq == Wire::kInvalidSeq) {
|
||||
if (DeviceLost() || m_encoder.Cancelled()) return declineCancelled();
|
||||
SessionFail(MGFatalFamily::RingOverrun, "MGPipe: Fatal{RingOverrun, \"SEG_CMD\"} - %s refused after sufficient "
|
||||
"space retired", Wire::WireOpName(op));
|
||||
}
|
||||
@@ -1445,7 +1634,14 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// Publish the head, record submittedSeq, THEN ring - in that order, which is
|
||||
// SessionProducer's one job and RingTest.cpp:446's pin. Notify-then-publish loses the
|
||||
// wakeup.
|
||||
const auto replyMetricStart = Transport::LinkMetricsBeginReply(ownsReplySlot);
|
||||
m_producer.PublishAndNotify(seq);
|
||||
if (op == MG_Pipe::MGPWireOp::Present) {
|
||||
// A credit is permission to run ahead, not permission to retain the
|
||||
// last frame locally until another frame or a wait happens to arrive.
|
||||
Flush();
|
||||
Transport::LinkMetricsPresent();
|
||||
}
|
||||
|
||||
// Does this row own a reply slot? kMGPipeCallFlags IS THE SINGLE SOURCE OF TRUTH
|
||||
// (R-16 / ID-31) - fourteen rows now, because the four Bool acceptance entry points
|
||||
@@ -1456,9 +1652,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// The catalogue still says which rows CARRY a slot; a caller that passes false says it
|
||||
// will not read this one (resource_subdata's buffer half, §2.5 - the only such caller).
|
||||
// The server posts either way, so the wire is unchanged and the row keeps its flag.
|
||||
const Bool rowCarriesReplySlot =
|
||||
(MG_Pipe::MGPipeCallFlagsFor(op) & static_cast<Uint32>(MG_Pipe::kReplySlot)) != 0;
|
||||
const Bool ownsReplySlot = rowCarriesReplySlot && wantReply;
|
||||
|
||||
|
||||
// ---- THE P5e WAIT RULE (CONTRACT-P5E §2.3) ---------------------------------------
|
||||
//
|
||||
@@ -1564,7 +1758,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
const BarrierWaitScope waiting;
|
||||
const Uint64 waitBudgetMs = AppliedWaitBudgetMs(op, payload);
|
||||
const Transport::SessionWait wait =
|
||||
WaitForAppliedBudget(m_producer, m_events, seq, waitBudgetMs);
|
||||
WaitForAppliedBudget(m_producer, *m_events, seq, waitBudgetMs);
|
||||
if (wait == Transport::SessionWait::ShutDown) {
|
||||
// `dl`: SHUTDOWN IS TWO DIFFERENT EVENTS AND ONLY ONE IS A DEVICE LOSS. Stop() kills
|
||||
// this same bell to wake a parked applier, so an orderly exit arrives here too - and
|
||||
@@ -1599,12 +1793,14 @@ namespace MobileGL::MG_Remote::Client {
|
||||
static_cast<unsigned long long>(waitBudgetMs));
|
||||
}
|
||||
|
||||
Transport::LinkMetricsReplyApplied(replyMetricStart);
|
||||
|
||||
// THE REVERSE CHANNEL IS DRAINED HERE, and here is the only place it can be: under the
|
||||
// barrier this is the one instant at which the apply thread is known not to be inside
|
||||
// the applier, and MGPipeClientOnGpuWritten / OnBufferWriteback write frontend objects.
|
||||
// It is what gives AwaitBufferWriteback something to have waited FOR: b1's third state
|
||||
// clears when the writeback lands, and the writeback lands on this ring.
|
||||
DrainEventRing(m_events);
|
||||
DrainEventRing(*m_events);
|
||||
|
||||
if (!ownsReplySlot) {
|
||||
// P5e (ra, §2.3). A barriered record's apply has returned and this thread is the
|
||||
@@ -1716,7 +1912,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
if (target == 0) return;
|
||||
const BarrierWaitScope waiting;
|
||||
const Transport::SessionWait wait =
|
||||
WaitForAppliedBudget(m_producer, m_events, target, kBarrierTimeoutMs);
|
||||
WaitForAppliedBudget(m_producer, *m_events, target, kBarrierTimeoutMs);
|
||||
if (wait == Transport::SessionWait::ShutDown) {
|
||||
// `dl`: the same two-events distinction the verb barrier makes. Only a peer that
|
||||
// HUNG UP is a device loss; Stop() reaches this path too.
|
||||
@@ -1741,13 +1937,25 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// on: the server blocks only on a full event ring, the client blocks only on
|
||||
// watermarks the server advances, and every client wait drains - so at most one side
|
||||
// is parked at any instant.
|
||||
DrainEventRing(m_events);
|
||||
DrainEventRing(*m_events);
|
||||
ReleaseFillPins();
|
||||
#else
|
||||
(void)why;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ClientSession::Flush() {
|
||||
if (!m_started || !m_link) return;
|
||||
const auto result = m_link->Flush();
|
||||
if (result == MOBILEGL_ERR_TRANSPORT_CLOSED) {
|
||||
if (m_link->PeerHungUp()) LatchDeviceLost("published commands could not reach the disconnected peer");
|
||||
} else if (result != MOBILEGL_OK) {
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption,
|
||||
"MGPipe: Fatal{ProtocolCorruption, link flush} published commands were not delivered (rc=%d)",
|
||||
static_cast<int>(result));
|
||||
}
|
||||
}
|
||||
|
||||
void ClientSession::Finish() {
|
||||
// glFinish. Nothing goes on the wire - Flush and Finish have no record (ARCHITECTURE
|
||||
// §11) - and under lockstep there was nothing to do, because the client had already
|
||||
@@ -1786,12 +1994,12 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// swapping, and this waiter holds the only drain.
|
||||
wait = m_producer.WaitForPresentAckOrEventBacklog(awaited, kBarrierTimeoutMs);
|
||||
if (wait != Transport::SessionWait::Reached) break;
|
||||
Transport::RingControl* control = m_producer.Control();
|
||||
if (control == nullptr ||
|
||||
Transport::Watermark::Reached(control->Progress.presentAckSerial, awaited)) {
|
||||
const auto* progress = m_producer.Progress();
|
||||
if (progress == nullptr ||
|
||||
Transport::Watermark::Reached(progress->presentAckSerial, awaited)) {
|
||||
break;
|
||||
}
|
||||
DrainEventRing(m_events);
|
||||
DrainEventRing(*m_events);
|
||||
}
|
||||
if (wait == Transport::SessionWait::TimedOut) {
|
||||
SessionFail(MGFatalFamily::PresentCreditTimeout, "MGPipe: Fatal{PresentCreditTimeout} - present %llu waited %u ms for "
|
||||
@@ -1803,7 +2011,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
}
|
||||
// ShutDown is teardown and returns: the present did not happen, the same answer
|
||||
// the barrier gives on a dead doorbell.
|
||||
if (wait == Transport::SessionWait::Reached) DrainEventRing(m_events);
|
||||
if (wait == Transport::SessionWait::Reached) DrainEventRing(*m_events);
|
||||
}
|
||||
m_presentsSent = serial;
|
||||
return serial;
|
||||
@@ -1935,9 +2143,9 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// drains them would otherwise hold the GL thread here for ever, and a frame backlog
|
||||
// deeper than this is a finding rather than a steady state.
|
||||
for (Uint32 guard = 0; guard < kMaxControlFramesPerPump; ++guard) {
|
||||
if (m_transport->PeekFrameSize() == 0) break;
|
||||
if ((m_controlInbox ? m_controlInbox->Peek() : m_transport->PeekFrameSize()) == 0) break;
|
||||
std::vector<Uint8> frame;
|
||||
if (ReceiveEnvelope(*m_transport, frame, 0) != MOBILEGL_OK) break;
|
||||
if (ReceiveControlFrame(frame, 0) != MOBILEGL_OK) break;
|
||||
const ::MobileGL::Wire::CtrlEnvelope* envelope = ParseEnvelope(frame);
|
||||
if (envelope == nullptr) {
|
||||
MGLOG_E("MG_Remote client: an unverifiable control frame (%llu bytes) was dropped",
|
||||
@@ -1965,6 +2173,22 @@ namespace MobileGL::MG_Remote::Client {
|
||||
return adopted;
|
||||
}
|
||||
|
||||
MobileGLResult ClientSession::AttachStreamLink(int fd, const Transport::SessionSegmentSizes& sizes) {
|
||||
std::unique_ptr<Transport::ILink> link;
|
||||
const auto attached = Transport::CreateStreamLink(fd, sizes, Transport::TransportRoleTag::ClientProducer, link);
|
||||
if (attached != MOBILEGL_OK) return attached;
|
||||
AttachDataLink(std::move(link));
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
|
||||
void ClientSession::AttachDataLink(std::unique_ptr<Transport::ILink> link) {
|
||||
m_link = std::move(link);
|
||||
m_cmd = &m_link->CommandsOut(); m_events = &m_link->EventsIn();
|
||||
m_producer.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
m_encoder.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
m_events->SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
}
|
||||
|
||||
Transport::SessionProducer& ClientSession::Producer() { return m_producer; }
|
||||
|
||||
Transport::SessionWait ClientSession::WaitForApplied(Uint64 seq, Uint32 timeoutMs) {
|
||||
@@ -1973,38 +2197,48 @@ namespace MobileGL::MG_Remote::Client {
|
||||
|
||||
Bool ClientSession::ReadReply(Uint64 seq, void* outBytes, Uint64 outCapacity, Int32* outStatus,
|
||||
Uint64* outSize) {
|
||||
return m_replies.Read(seq, outBytes, outCapacity, outStatus, outSize);
|
||||
const void* bytes = nullptr; Uint64 size = 0; Int32 status = 0;
|
||||
if (m_link->ReadReply(seq, &status, &bytes, &size) != MOBILEGL_OK) return false;
|
||||
if (outStatus) *outStatus = status;
|
||||
if (outSize) *outSize = size;
|
||||
if (size > outCapacity || (size && !outBytes)) return false;
|
||||
if (size) std::memcpy(outBytes, bytes, static_cast<SizeT>(size));
|
||||
return true;
|
||||
}
|
||||
|
||||
Uint32 ClientSession::MaxReplyBytes() const { return m_replies.MaxReplyBytes(); }
|
||||
Uint32 ClientSession::MaxReplyBytes() const { return static_cast<Uint32>(m_link->Capabilities().MaxReplyBytes); }
|
||||
|
||||
Bool ClientSession::ReplyCanHold(Uint64 bytes) const { return m_replies.CanHold(bytes); }
|
||||
Bool ClientSession::ReplyCanHold(Uint64 bytes) const { return bytes <= MaxReplyBytes(); }
|
||||
|
||||
// ID-47. Forwarded verbatim so that the message, the boundary and the abort are the pool's
|
||||
// and are pinned once, in SessionTest, rather than re-derived per caller.
|
||||
void ClientSession::RequireReadPixelsReplyFits(Uint32 width, Uint32 height, Uint32 format,
|
||||
Uint32 type, Uint64 bytes) const {
|
||||
m_replies.RequireReadPixelsFits(width, height, format, type, bytes);
|
||||
if (!ReplyCanHold(bytes)) {
|
||||
SessionFail(MGFatalFamily::ReplyTooLarge,
|
||||
"MGPipe: Fatal{ReplyTooLarge, \"ReadPixels %ux%u 0x%04X/0x%04X %llu > %u\"}",
|
||||
width, height, format, type, static_cast<unsigned long long>(bytes), MaxReplyBytes());
|
||||
}
|
||||
}
|
||||
|
||||
Transport::EventRingConsumer& ClientSession::Events() { return m_events; }
|
||||
Transport::EventRingConsumer& ClientSession::Events() { return *m_events; }
|
||||
|
||||
Uint32 ClientSession::DrainPublishedEvents() {
|
||||
// Not gated on m_started on purpose: PumpControlPlane's own pre-start call during
|
||||
// Start() has its ring-consumer twin here, and DrainEventRing's Valid() check is
|
||||
// the whole guard either case needs.
|
||||
return DrainEventRing(m_events);
|
||||
return DrainEventRing(*m_events);
|
||||
}
|
||||
|
||||
Uint64 ClientSession::EventRingCapacityBytes() const { return m_shm.EventRingCapacity(); }
|
||||
Uint64 ClientSession::EventRingCapacityBytes() const { return m_link->Memory().EventRingCapacity(); }
|
||||
|
||||
Uint64 ClientSession::StageCapacityBytes() const { return m_shm.StageBytes(); }
|
||||
Uint64 ClientSession::StageCapacityBytes() const { return m_link->Memory().StageBytes(); }
|
||||
|
||||
Wire::SegmentTable& ClientSession::Segments() { return m_segments; }
|
||||
|
||||
Transport::RingControl* ClientSession::Control() { return m_shm.CmdControl(); }
|
||||
Transport::RingControl* ClientSession::Control() { return m_link->Memory().CmdControl(); }
|
||||
|
||||
Transport::SessionSegments& ClientSession::Shm() { return m_shm; }
|
||||
Transport::SessionSegments& ClientSession::Shm() { return m_link->Memory(); }
|
||||
|
||||
Transport::ITransport* ClientSession::Control_Plane() { return m_transport; }
|
||||
|
||||
@@ -2071,3 +2305,7 @@ namespace MobileGL::MG_Remote::Client {
|
||||
#undef MGP5_C0_STUB
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Client
|
||||
|
||||
extern "C" __attribute__((visibility("default"))) void MGPipeSyncPeerLog() {
|
||||
if (auto* session = MobileGL::MG_Remote::Client::ClientSession::Active()) session->SyncPeerLog();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
// defect P4a paid two contract corrections for, and "always accept" is ID-39's 66 lost uploads.
|
||||
|
||||
#pragma once
|
||||
#include "../Transport/ILink.h"
|
||||
#include "../Transport/ControlInbox.h"
|
||||
#include <Includes.h>
|
||||
|
||||
#include <atomic> // the device-lost latch is read off the GL thread
|
||||
@@ -96,7 +98,13 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// the server states its own pid, which IS ours, and that is the honest answer there.
|
||||
std::uint32_t PeerServerPid() const { return m_peerServerPid; }
|
||||
|
||||
ClientSession();
|
||||
~ClientSession();
|
||||
MobileGLResult AttachStreamLink(int dataFd, const Transport::SessionSegmentSizes& sizes);
|
||||
void AttachDataLink(std::unique_ptr<Transport::ILink> link);
|
||||
Transport::ILink* DataLink() const { return m_link.get(); }
|
||||
bool ConnectDial() const { return m_connectDial; }
|
||||
void SyncPeerLog();
|
||||
|
||||
// Builds the four segments, performs Hello/Welcome, takes the first CapsSnapshot, and
|
||||
// - for TransportMode::InProcess - starts the server role's apply thread. Returns a
|
||||
@@ -237,6 +245,9 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// true while a run-ahead queue still holds them, so under run-ahead glFinish becomes
|
||||
// exactly WaitForApplyToCatchUp + the drain that comes with it.
|
||||
void Finish();
|
||||
// Submit published commands without waiting for application. This is
|
||||
// glFlush's contract and the frame-submit boundary for Present.
|
||||
void Flush();
|
||||
|
||||
// The last seq this session published, whether or not it waited for it. The forced
|
||||
// waits above are defined against it.
|
||||
@@ -407,6 +418,11 @@ namespace MobileGL::MG_Remote::Client {
|
||||
void LogWireLedger() const;
|
||||
|
||||
private:
|
||||
MobileGLResult ReceiveControlFrame(std::vector<Uint8>& frame, Uint32 timeoutMs);
|
||||
std::unique_ptr<Transport::ControlInbox> m_controlInbox;
|
||||
std::unique_ptr<Transport::ILink> m_link;
|
||||
bool m_connectDial = false;
|
||||
std::uint64_t m_logFlushSeq = 0;
|
||||
// P5e (ra): the latch, taken from PumpControlPlane after every adoption. Private
|
||||
// because "when may run-ahead start" is this class's own rule and not a caller's.
|
||||
void LatchRunAheadFromCaps();
|
||||
@@ -439,11 +455,9 @@ namespace MobileGL::MG_Remote::Client {
|
||||
|
||||
std::unique_ptr<Transport::InProcessTransport> m_clientTransport;
|
||||
std::unique_ptr<Transport::InProcessTransport> m_serverTransport;
|
||||
Transport::SessionSegments m_shm;
|
||||
Transport::RingProducer m_cmd;
|
||||
Transport::RingProducer* m_cmd = nullptr;
|
||||
Transport::SessionProducer m_producer;
|
||||
Transport::EventRingConsumer m_events;
|
||||
Transport::ReplySlotPool m_replies;
|
||||
Transport::EventRingConsumer* m_events = nullptr;
|
||||
Transport::ITransport* m_transport = nullptr;
|
||||
Bool m_started = false;
|
||||
// Written by whichever thread first notices the hangup - the GL thread in the barrier,
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
// is legal under rule E (CONTRACT-P5C.md §5.2).
|
||||
#include <MG_Impl/Pipe/SlotAllocator.h>
|
||||
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
||||
#include <MG_State/GLState/StateObjectDeathNotice.h>
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
// P5e (pg): ID-87 asks this package for bytes-per-link measured rather than argued, and the
|
||||
// archive's byte count exists exactly once - here, where it is serialised.
|
||||
@@ -297,7 +298,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
const Uint64 seq = session.EmitAndWait(MGPWireOp::ResourceReadback, payload,
|
||||
sizeof(*payload), nullptr, 0, nullptr, 0,
|
||||
&status);
|
||||
reply->Id = seq;
|
||||
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||
MG_Pipe::MGPipePostReply(*reply, status, 0);
|
||||
++g_emitted;
|
||||
}
|
||||
@@ -317,7 +319,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
const Uint64 seq = session.EmitAndWait(MGPWireOp::ResourceCreate, payload,
|
||||
sizeof(*payload), nullptr, 0, nullptr, 0,
|
||||
&status);
|
||||
reply->Id = seq;
|
||||
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||
MG_Pipe::MGPipePostReply(*reply, status, status == 0 ? 1u : 0u);
|
||||
++g_emitted;
|
||||
if (status == 1) ++g_declined;
|
||||
@@ -330,7 +333,8 @@ namespace MobileGL::MG_Remote::Client {
|
||||
const Uint64 seq = session.EmitAndWait(MGPWireOp::SetTextureParams, payload,
|
||||
sizeof(*payload), nullptr, 0, nullptr, 0,
|
||||
&status);
|
||||
reply->Id = seq;
|
||||
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||
MG_Pipe::MGPipePostReply(*reply, status, status == 0 ? 1u : 0u);
|
||||
++g_emitted;
|
||||
if (status == 1) ++g_declined;
|
||||
@@ -369,11 +373,14 @@ namespace MobileGL::MG_Remote::Client {
|
||||
MGPWireOp::ResourceSubData, &record, sizeof(record),
|
||||
varTail != nullptr ? &tail : nullptr, varTail != nullptr ? 1u : 0u, nullptr, 0,
|
||||
&status, nullptr, wantReply);
|
||||
reply->Id = seq;
|
||||
MG_Pipe::MGPipePostReply(*reply, wantReply ? status : 0,
|
||||
(wantReply ? status == 0 : true) ? 1u : 0u);
|
||||
++g_emitted;
|
||||
if (wantReply && status == 1) ++g_declined;
|
||||
// Cancellation has no wire ordinal; retain the caller's nonzero local ticket.
|
||||
if (seq != Wire::kInvalidSeq) reply->Id = seq;
|
||||
const Int32 postedStatus = (seq == Wire::kInvalidSeq || status == Wire::ReplySink::kStatusDeclined)
|
||||
? Wire::ReplySink::kStatusDeclined
|
||||
: wantReply ? status : Wire::ReplySink::kStatusOk;
|
||||
MG_Pipe::MGPipePostReply(*reply, postedStatus, postedStatus == Wire::ReplySink::kStatusOk ? 1u : 0u);
|
||||
if (seq != Wire::kInvalidSeq) ++g_emitted;
|
||||
if (postedStatus == Wire::ReplySink::kStatusDeclined) ++g_declined;
|
||||
}
|
||||
|
||||
void Wire_BufferSubDataResident(const MG_Pipe::MGPSubData* payload, const void* blobBytes,
|
||||
@@ -712,9 +719,30 @@ namespace MobileGL::MG_Remote::Client {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
void WireStateObjectDestroyed(MG_Pipe::MGPipeKind kind, Uint64 lifetimeId) {
|
||||
(void)EmitObjectDeathRecord(kind, lifetimeId);
|
||||
}
|
||||
|
||||
const MG_State::GLState::StateObjectDeathOps kClientStateObjectDeathOps = {
|
||||
.OnDestroyed = &WireStateObjectDestroyed,
|
||||
};
|
||||
}
|
||||
|
||||
void InstallClientWireTables() {
|
||||
using namespace MG_Pipe;
|
||||
|
||||
// DirectGLES normally installs this notice while creating its handle
|
||||
// backend. An independent client never creates that backend: without a
|
||||
// client emitter, NotifyAndFree silently drops object_death before
|
||||
// freeing the slot. Keep inproc's existing backend dispatcher, and give
|
||||
// the remote client the same wire delivery without a local twin table.
|
||||
if (MG_Config::Transport == MG_Config::TransportMode::Spawn &&
|
||||
MG_Config::ActiveBackendType == BackendType::DirectGLES &&
|
||||
MG_State::GLState::GetStateObjectDeathOps() == nullptr) {
|
||||
MG_State::GLState::SetStateObjectDeathOps(&kClientStateObjectDeathOps);
|
||||
}
|
||||
|
||||
// A fresh install means the routed tables are live again: a Start after a previous
|
||||
// session's Stop clears the teardown-refusal flag so its own routed calls are not
|
||||
// refused. (Stop already puts the monolith adapters back and clears the flag; this is
|
||||
@@ -778,6 +806,9 @@ namespace MobileGL::MG_Remote::Client {
|
||||
// is complete, by ReinstallMonolithAfterTeardown, for the at-exit deletes that reach a
|
||||
// process with no session at all. Idempotent: safe to call when nothing was installed.
|
||||
g_clientTablesUninstalled.store(true, std::memory_order_release);
|
||||
if (MG_State::GLState::GetStateObjectDeathOps() == &kClientStateObjectDeathOps) {
|
||||
MG_State::GLState::SetStateObjectDeathOps(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ReinstallMonolithAfterTeardown() {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
// P6.5 handshake policy, shared by both roles. Rejections are returned, never aborted.
|
||||
#pragma once
|
||||
#include "CapsCodec.h"
|
||||
#include "Protocol/generated/protocol_generated.h"
|
||||
#include "Transport/ITransport.h"
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace MobileGL::MG_Remote {
|
||||
inline MobileGLResult RefuseHandshake(Transport::ITransport& transport,
|
||||
::MobileGL::Wire::RefuseCode code,
|
||||
const char* detail, Uint64 expected = 0,
|
||||
Uint64 actual = 0, const char* peerValue = nullptr) {
|
||||
MGLOG_E("MGPipe: Refuse{%s} %s expected=%llu actual=%llu peer=%s",
|
||||
::MobileGL::Wire::EnumNameRefuseCode(code), detail,
|
||||
static_cast<unsigned long long>(expected), static_cast<unsigned long long>(actual),
|
||||
peerValue == nullptr ? "" : peerValue);
|
||||
::flatbuffers::FlatBufferBuilder builder(256);
|
||||
auto refusal = ::MobileGL::Wire::CreateRefuseDirect(builder, code, detail, expected, actual, peerValue);
|
||||
auto envelope = ::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::Refuse,
|
||||
refusal.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
transport.SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
|
||||
inline bool LogPeerRefusal(const ::MobileGL::Wire::CtrlEnvelope* envelope) {
|
||||
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::Refuse) return false;
|
||||
const auto* refusal = envelope->msg_as_Refuse();
|
||||
if (refusal == nullptr) return false;
|
||||
MGLOG_E("MGPipe: peer Refuse{%s} %s expected=%llu actual=%llu",
|
||||
::MobileGL::Wire::EnumNameRefuseCode(refusal->code()),
|
||||
refusal->detail() == nullptr ? "" : refusal->detail()->c_str(),
|
||||
static_cast<unsigned long long>(refusal->expected()),
|
||||
static_cast<unsigned long long>(refusal->actual()));
|
||||
return true;
|
||||
}
|
||||
|
||||
inline MobileGLResult ValidatePeerHandshake(Transport::ITransport& transport,
|
||||
Uint32 major, Uint32 minor, Uint64 fingerprint,
|
||||
const char* stamp, ::MobileGL::Wire::DialMode dial) {
|
||||
using ::MobileGL::Wire::RefuseCode;
|
||||
if (major != MOBILEGL_PROTOCOL_ABI_MAJOR || minor != MOBILEGL_PROTOCOL_ABI_MINOR)
|
||||
return RefuseHandshake(transport, RefuseCode::ProtocolVersion, "protocol version",
|
||||
MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR),
|
||||
MOBILEGL_ABI_VERSION(major, minor));
|
||||
if (fingerprint != WireFingerprint())
|
||||
return RefuseHandshake(transport, RefuseCode::WireFingerprint, "wire layout",
|
||||
WireFingerprint(), fingerprint);
|
||||
const bool sameBuild = BuildFingerprintPresent() && stamp != nullptr && stamp[0] != '\0' &&
|
||||
std::strcmp(stamp, BuildFingerprint()) == 0;
|
||||
const char* required = std::getenv("MOBILEGL_IPC_REQUIRE_SAME_BUILD");
|
||||
const bool requireSame = dial == ::MobileGL::Wire::DialMode::Fork ||
|
||||
(required != nullptr && std::strcmp(required, "1") == 0);
|
||||
if (!sameBuild && requireSame)
|
||||
return RefuseHandshake(transport, RefuseCode::BuildFingerprint, "build identity", 0, 0,
|
||||
stamp == nullptr ? "<missing>" : stamp);
|
||||
if (!sameBuild && dial == ::MobileGL::Wire::DialMode::Connect)
|
||||
MGLOG_W("MGPipe: compatible wire with different build: local=%s peer=%s",
|
||||
BuildFingerprint(), stamp == nullptr ? "<missing>" : stamp);
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
} // namespace MobileGL::MG_Remote
|
||||
@@ -190,7 +190,7 @@ namespace MobileGL::MG_Remote {
|
||||
void EncodeSurfaceReplyFrame(const SurfaceControlFrame& frame,
|
||||
flatbuffers::FlatBufferBuilder* builder) {
|
||||
const auto reply = ::MobileGL::Wire::CreateSurfaceReply(*builder, frame.seq, frame.ok, frame.eglMajor,
|
||||
frame.eglMinor, /*defaultFb=*/0);
|
||||
frame.eglMinor, /*defaultFb=*/0, frame.eventHead);
|
||||
const auto envelope =
|
||||
::MobileGL::Wire::CreateCtrlEnvelope(*builder, ::MobileGL::Wire::CtrlMsg::SurfaceReply, reply.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(*builder, envelope);
|
||||
@@ -201,6 +201,7 @@ namespace MobileGL::MG_Remote {
|
||||
frame->ok = reply.ok();
|
||||
frame->eglMajor = reply.eglMajor();
|
||||
frame->eglMinor = reply.eglMinor();
|
||||
frame->eventHead = reply.eventHead();
|
||||
}
|
||||
|
||||
MobileGLResult ServerApplyWireSurfaceOp(const ::MobileGL::Wire::SurfaceOp& op, SurfaceControlFrame* replyOut) {
|
||||
|
||||
@@ -32,6 +32,15 @@ namespace Wire {
|
||||
struct SegmentRef;
|
||||
struct SegmentRefBuilder;
|
||||
|
||||
struct LinkTerms;
|
||||
struct LinkTermsBuilder;
|
||||
|
||||
struct Refuse;
|
||||
struct RefuseBuilder;
|
||||
|
||||
struct LogFlush;
|
||||
struct LogFlushBuilder;
|
||||
|
||||
struct Hello;
|
||||
struct HelloBuilder;
|
||||
|
||||
@@ -113,6 +122,147 @@ inline const char *EnumNameSegmentKind(SegmentKind e) {
|
||||
return EnumNamesSegmentKind()[index];
|
||||
}
|
||||
|
||||
enum class DataPlane : uint8_t {
|
||||
SharedSegments = 0,
|
||||
Stream = 1,
|
||||
MIN = SharedSegments,
|
||||
MAX = Stream
|
||||
};
|
||||
|
||||
inline const DataPlane (&EnumValuesDataPlane())[2] {
|
||||
static const DataPlane values[] = {
|
||||
DataPlane::SharedSegments,
|
||||
DataPlane::Stream
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesDataPlane() {
|
||||
static const char * const names[3] = {
|
||||
"SharedSegments",
|
||||
"Stream",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameDataPlane(DataPlane e) {
|
||||
if (::flatbuffers::IsOutRange(e, DataPlane::SharedSegments, DataPlane::Stream)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesDataPlane()[index];
|
||||
}
|
||||
|
||||
enum class WireForm : uint8_t {
|
||||
StructImage = 0,
|
||||
MIN = StructImage,
|
||||
MAX = StructImage
|
||||
};
|
||||
|
||||
inline const WireForm (&EnumValuesWireForm())[1] {
|
||||
static const WireForm values[] = {
|
||||
WireForm::StructImage
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesWireForm() {
|
||||
static const char * const names[2] = {
|
||||
"StructImage",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameWireForm(WireForm e) {
|
||||
if (::flatbuffers::IsOutRange(e, WireForm::StructImage, WireForm::StructImage)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesWireForm()[index];
|
||||
}
|
||||
|
||||
enum class DialMode : uint8_t {
|
||||
No = 0,
|
||||
Fork = 1,
|
||||
Connect = 2,
|
||||
MIN = No,
|
||||
MAX = Connect
|
||||
};
|
||||
|
||||
inline const DialMode (&EnumValuesDialMode())[3] {
|
||||
static const DialMode values[] = {
|
||||
DialMode::No,
|
||||
DialMode::Fork,
|
||||
DialMode::Connect
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesDialMode() {
|
||||
static const char * const names[4] = {
|
||||
"No",
|
||||
"Fork",
|
||||
"Connect",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameDialMode(DialMode e) {
|
||||
if (::flatbuffers::IsOutRange(e, DialMode::No, DialMode::Connect)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesDialMode()[index];
|
||||
}
|
||||
|
||||
enum class RefuseCode : uint32_t {
|
||||
None = 0,
|
||||
ProtocolVersion = 1,
|
||||
WireFingerprint = 2,
|
||||
BuildFingerprint = 3,
|
||||
Authentication = 4,
|
||||
LinkTerms = 5,
|
||||
Backend = 6,
|
||||
Busy = 7,
|
||||
MalformedHello = 8,
|
||||
MIN = None,
|
||||
MAX = MalformedHello
|
||||
};
|
||||
|
||||
inline const RefuseCode (&EnumValuesRefuseCode())[9] {
|
||||
static const RefuseCode values[] = {
|
||||
RefuseCode::None,
|
||||
RefuseCode::ProtocolVersion,
|
||||
RefuseCode::WireFingerprint,
|
||||
RefuseCode::BuildFingerprint,
|
||||
RefuseCode::Authentication,
|
||||
RefuseCode::LinkTerms,
|
||||
RefuseCode::Backend,
|
||||
RefuseCode::Busy,
|
||||
RefuseCode::MalformedHello
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesRefuseCode() {
|
||||
static const char * const names[10] = {
|
||||
"None",
|
||||
"ProtocolVersion",
|
||||
"WireFingerprint",
|
||||
"BuildFingerprint",
|
||||
"Authentication",
|
||||
"LinkTerms",
|
||||
"Backend",
|
||||
"Busy",
|
||||
"MalformedHello",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameRefuseCode(RefuseCode e) {
|
||||
if (::flatbuffers::IsOutRange(e, RefuseCode::None, RefuseCode::MalformedHello)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesRefuseCode()[index];
|
||||
}
|
||||
|
||||
enum class SurfaceOpKind : uint8_t {
|
||||
None = 0,
|
||||
InitializeDisplay = 1,
|
||||
@@ -350,11 +500,13 @@ enum class CtrlMsg : uint8_t {
|
||||
AuxRequest = 8,
|
||||
Fatal = 9,
|
||||
LogLine = 10,
|
||||
Refuse = 11,
|
||||
LogFlush = 12,
|
||||
MIN = NONE,
|
||||
MAX = LogLine
|
||||
MAX = LogFlush
|
||||
};
|
||||
|
||||
inline const CtrlMsg (&EnumValuesCtrlMsg())[11] {
|
||||
inline const CtrlMsg (&EnumValuesCtrlMsg())[13] {
|
||||
static const CtrlMsg values[] = {
|
||||
CtrlMsg::NONE,
|
||||
CtrlMsg::Hello,
|
||||
@@ -366,13 +518,15 @@ inline const CtrlMsg (&EnumValuesCtrlMsg())[11] {
|
||||
CtrlMsg::ResyncDone,
|
||||
CtrlMsg::AuxRequest,
|
||||
CtrlMsg::Fatal,
|
||||
CtrlMsg::LogLine
|
||||
CtrlMsg::LogLine,
|
||||
CtrlMsg::Refuse,
|
||||
CtrlMsg::LogFlush
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
inline const char * const *EnumNamesCtrlMsg() {
|
||||
static const char * const names[12] = {
|
||||
static const char * const names[14] = {
|
||||
"NONE",
|
||||
"Hello",
|
||||
"Welcome",
|
||||
@@ -384,13 +538,15 @@ inline const char * const *EnumNamesCtrlMsg() {
|
||||
"AuxRequest",
|
||||
"Fatal",
|
||||
"LogLine",
|
||||
"Refuse",
|
||||
"LogFlush",
|
||||
nullptr
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
inline const char *EnumNameCtrlMsg(CtrlMsg e) {
|
||||
if (::flatbuffers::IsOutRange(e, CtrlMsg::NONE, CtrlMsg::LogLine)) return "";
|
||||
if (::flatbuffers::IsOutRange(e, CtrlMsg::NONE, CtrlMsg::LogFlush)) return "";
|
||||
const size_t index = static_cast<size_t>(e);
|
||||
return EnumNamesCtrlMsg()[index];
|
||||
}
|
||||
@@ -439,6 +595,14 @@ template<> struct CtrlMsgTraits<MobileGL::Wire::LogLine> {
|
||||
static const CtrlMsg enum_value = CtrlMsg::LogLine;
|
||||
};
|
||||
|
||||
template<> struct CtrlMsgTraits<MobileGL::Wire::Refuse> {
|
||||
static const CtrlMsg enum_value = CtrlMsg::Refuse;
|
||||
};
|
||||
|
||||
template<> struct CtrlMsgTraits<MobileGL::Wire::LogFlush> {
|
||||
static const CtrlMsg enum_value = CtrlMsg::LogFlush;
|
||||
};
|
||||
|
||||
template <bool B = false>
|
||||
bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const void *obj, CtrlMsg type);
|
||||
template <bool B = false>
|
||||
@@ -538,6 +702,270 @@ inline ::flatbuffers::Offset<SegmentRef> CreateSegmentRefDirect(
|
||||
name__);
|
||||
}
|
||||
|
||||
struct LinkTerms FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef LinkTermsBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_DATAPLANE = 4,
|
||||
VT_WIREFORM = 6,
|
||||
VT_MAXREPLYBYTES = 8,
|
||||
VT_CMDWINDOWBYTES = 10,
|
||||
VT_STAGEWINDOWBYTES = 12,
|
||||
VT_EVENTWINDOWBYTES = 14
|
||||
};
|
||||
MobileGL::Wire::DataPlane dataPlane() const {
|
||||
return static_cast<MobileGL::Wire::DataPlane>(GetField<uint8_t>(VT_DATAPLANE, 0));
|
||||
}
|
||||
MobileGL::Wire::WireForm wireForm() const {
|
||||
return static_cast<MobileGL::Wire::WireForm>(GetField<uint8_t>(VT_WIREFORM, 0));
|
||||
}
|
||||
uint64_t maxReplyBytes() const {
|
||||
return GetField<uint64_t>(VT_MAXREPLYBYTES, 0);
|
||||
}
|
||||
uint64_t cmdWindowBytes() const {
|
||||
return GetField<uint64_t>(VT_CMDWINDOWBYTES, 0);
|
||||
}
|
||||
uint64_t stageWindowBytes() const {
|
||||
return GetField<uint64_t>(VT_STAGEWINDOWBYTES, 0);
|
||||
}
|
||||
uint64_t eventWindowBytes() const {
|
||||
return GetField<uint64_t>(VT_EVENTWINDOWBYTES, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DATAPLANE, 1) &&
|
||||
VerifyField<uint8_t>(verifier, VT_WIREFORM, 1) &&
|
||||
VerifyField<uint64_t>(verifier, VT_MAXREPLYBYTES, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_CMDWINDOWBYTES, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_STAGEWINDOWBYTES, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_EVENTWINDOWBYTES, 8) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct LinkTermsBuilder {
|
||||
typedef LinkTerms Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_dataPlane(MobileGL::Wire::DataPlane dataPlane) {
|
||||
fbb_.AddElement<uint8_t>(LinkTerms::VT_DATAPLANE, static_cast<uint8_t>(dataPlane), 0);
|
||||
}
|
||||
void add_wireForm(MobileGL::Wire::WireForm wireForm) {
|
||||
fbb_.AddElement<uint8_t>(LinkTerms::VT_WIREFORM, static_cast<uint8_t>(wireForm), 0);
|
||||
}
|
||||
void add_maxReplyBytes(uint64_t maxReplyBytes) {
|
||||
fbb_.AddElement<uint64_t>(LinkTerms::VT_MAXREPLYBYTES, maxReplyBytes, 0);
|
||||
}
|
||||
void add_cmdWindowBytes(uint64_t cmdWindowBytes) {
|
||||
fbb_.AddElement<uint64_t>(LinkTerms::VT_CMDWINDOWBYTES, cmdWindowBytes, 0);
|
||||
}
|
||||
void add_stageWindowBytes(uint64_t stageWindowBytes) {
|
||||
fbb_.AddElement<uint64_t>(LinkTerms::VT_STAGEWINDOWBYTES, stageWindowBytes, 0);
|
||||
}
|
||||
void add_eventWindowBytes(uint64_t eventWindowBytes) {
|
||||
fbb_.AddElement<uint64_t>(LinkTerms::VT_EVENTWINDOWBYTES, eventWindowBytes, 0);
|
||||
}
|
||||
explicit LinkTermsBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<LinkTerms> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<LinkTerms>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<LinkTerms> CreateLinkTerms(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
MobileGL::Wire::DataPlane dataPlane = MobileGL::Wire::DataPlane::SharedSegments,
|
||||
MobileGL::Wire::WireForm wireForm = MobileGL::Wire::WireForm::StructImage,
|
||||
uint64_t maxReplyBytes = 0,
|
||||
uint64_t cmdWindowBytes = 0,
|
||||
uint64_t stageWindowBytes = 0,
|
||||
uint64_t eventWindowBytes = 0) {
|
||||
LinkTermsBuilder builder_(_fbb);
|
||||
builder_.add_eventWindowBytes(eventWindowBytes);
|
||||
builder_.add_stageWindowBytes(stageWindowBytes);
|
||||
builder_.add_cmdWindowBytes(cmdWindowBytes);
|
||||
builder_.add_maxReplyBytes(maxReplyBytes);
|
||||
builder_.add_wireForm(wireForm);
|
||||
builder_.add_dataPlane(dataPlane);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct LinkTerms::Traits {
|
||||
using type = LinkTerms;
|
||||
static auto constexpr Create = CreateLinkTerms;
|
||||
};
|
||||
|
||||
struct Refuse FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef RefuseBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_CODE = 4,
|
||||
VT_DETAIL = 6,
|
||||
VT_EXPECTED = 8,
|
||||
VT_ACTUAL = 10,
|
||||
VT_PEERVALUE = 12
|
||||
};
|
||||
MobileGL::Wire::RefuseCode code() const {
|
||||
return static_cast<MobileGL::Wire::RefuseCode>(GetField<uint32_t>(VT_CODE, 0));
|
||||
}
|
||||
const ::flatbuffers::String *detail() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_DETAIL);
|
||||
}
|
||||
uint64_t expected() const {
|
||||
return GetField<uint64_t>(VT_EXPECTED, 0);
|
||||
}
|
||||
uint64_t actual() const {
|
||||
return GetField<uint64_t>(VT_ACTUAL, 0);
|
||||
}
|
||||
const ::flatbuffers::String *peerValue() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_PEERVALUE);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint32_t>(verifier, VT_CODE, 4) &&
|
||||
VerifyOffset(verifier, VT_DETAIL) &&
|
||||
verifier.VerifyString(detail()) &&
|
||||
VerifyField<uint64_t>(verifier, VT_EXPECTED, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_ACTUAL, 8) &&
|
||||
VerifyOffset(verifier, VT_PEERVALUE) &&
|
||||
verifier.VerifyString(peerValue()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct RefuseBuilder {
|
||||
typedef Refuse Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_code(MobileGL::Wire::RefuseCode code) {
|
||||
fbb_.AddElement<uint32_t>(Refuse::VT_CODE, static_cast<uint32_t>(code), 0);
|
||||
}
|
||||
void add_detail(::flatbuffers::Offset<::flatbuffers::String> detail) {
|
||||
fbb_.AddOffset(Refuse::VT_DETAIL, detail);
|
||||
}
|
||||
void add_expected(uint64_t expected) {
|
||||
fbb_.AddElement<uint64_t>(Refuse::VT_EXPECTED, expected, 0);
|
||||
}
|
||||
void add_actual(uint64_t actual) {
|
||||
fbb_.AddElement<uint64_t>(Refuse::VT_ACTUAL, actual, 0);
|
||||
}
|
||||
void add_peerValue(::flatbuffers::Offset<::flatbuffers::String> peerValue) {
|
||||
fbb_.AddOffset(Refuse::VT_PEERVALUE, peerValue);
|
||||
}
|
||||
explicit RefuseBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<Refuse> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<Refuse>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Refuse> CreateRefuse(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
MobileGL::Wire::RefuseCode code = MobileGL::Wire::RefuseCode::None,
|
||||
::flatbuffers::Offset<::flatbuffers::String> detail = 0,
|
||||
uint64_t expected = 0,
|
||||
uint64_t actual = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> peerValue = 0) {
|
||||
RefuseBuilder builder_(_fbb);
|
||||
builder_.add_actual(actual);
|
||||
builder_.add_expected(expected);
|
||||
builder_.add_peerValue(peerValue);
|
||||
builder_.add_detail(detail);
|
||||
builder_.add_code(code);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct Refuse::Traits {
|
||||
using type = Refuse;
|
||||
static auto constexpr Create = CreateRefuse;
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<Refuse> CreateRefuseDirect(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
MobileGL::Wire::RefuseCode code = MobileGL::Wire::RefuseCode::None,
|
||||
const char *detail = nullptr,
|
||||
uint64_t expected = 0,
|
||||
uint64_t actual = 0,
|
||||
const char *peerValue = nullptr) {
|
||||
auto detail__ = detail ? _fbb.CreateString(detail) : 0;
|
||||
auto peerValue__ = peerValue ? _fbb.CreateString(peerValue) : 0;
|
||||
return MobileGL::Wire::CreateRefuse(
|
||||
_fbb,
|
||||
code,
|
||||
detail__,
|
||||
expected,
|
||||
actual,
|
||||
peerValue__);
|
||||
}
|
||||
|
||||
struct LogFlush FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef LogFlushBuilder Builder;
|
||||
struct Traits;
|
||||
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
|
||||
VT_SEQ = 4,
|
||||
VT_ACK = 6
|
||||
};
|
||||
uint64_t seq() const {
|
||||
return GetField<uint64_t>(VT_SEQ, 0);
|
||||
}
|
||||
bool ack() const {
|
||||
return GetField<uint8_t>(VT_ACK, 0) != 0;
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint64_t>(verifier, VT_SEQ, 8) &&
|
||||
VerifyField<uint8_t>(verifier, VT_ACK, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct LogFlushBuilder {
|
||||
typedef LogFlush Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
::flatbuffers::uoffset_t start_;
|
||||
void add_seq(uint64_t seq) {
|
||||
fbb_.AddElement<uint64_t>(LogFlush::VT_SEQ, seq, 0);
|
||||
}
|
||||
void add_ack(bool ack) {
|
||||
fbb_.AddElement<uint8_t>(LogFlush::VT_ACK, static_cast<uint8_t>(ack), 0);
|
||||
}
|
||||
explicit LogFlushBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
}
|
||||
::flatbuffers::Offset<LogFlush> Finish() {
|
||||
const auto end = fbb_.EndTable(start_);
|
||||
auto o = ::flatbuffers::Offset<LogFlush>(end);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline ::flatbuffers::Offset<LogFlush> CreateLogFlush(
|
||||
::flatbuffers::FlatBufferBuilder &_fbb,
|
||||
uint64_t seq = 0,
|
||||
bool ack = false) {
|
||||
LogFlushBuilder builder_(_fbb);
|
||||
builder_.add_seq(seq);
|
||||
builder_.add_ack(ack);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct LogFlush::Traits {
|
||||
using type = LogFlush;
|
||||
static auto constexpr Create = CreateLogFlush;
|
||||
};
|
||||
|
||||
struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
typedef HelloBuilder Builder;
|
||||
struct Traits;
|
||||
@@ -548,7 +976,11 @@ struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VT_BACKENDTYPE = 10,
|
||||
VT_PID = 12,
|
||||
VT_CONFIGBLOB = 14,
|
||||
VT_ABIFINGERPRINT = 16
|
||||
VT_ABIFINGERPRINT = 16,
|
||||
VT_WIREFINGERPRINT = 18,
|
||||
VT_LINKTERMS = 20,
|
||||
VT_TOKEN = 22,
|
||||
VT_DIALMODE = 24
|
||||
};
|
||||
uint32_t abiMajor() const {
|
||||
return GetField<uint32_t>(VT_ABIMAJOR, 0);
|
||||
@@ -571,6 +1003,18 @@ struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
uint64_t abiFingerprint() const {
|
||||
return GetField<uint64_t>(VT_ABIFINGERPRINT, 0);
|
||||
}
|
||||
uint64_t wireFingerprint() const {
|
||||
return GetField<uint64_t>(VT_WIREFINGERPRINT, 0);
|
||||
}
|
||||
const MobileGL::Wire::LinkTerms *linkTerms() const {
|
||||
return GetPointer<const MobileGL::Wire::LinkTerms *>(VT_LINKTERMS);
|
||||
}
|
||||
const ::flatbuffers::String *token() const {
|
||||
return GetPointer<const ::flatbuffers::String *>(VT_TOKEN);
|
||||
}
|
||||
MobileGL::Wire::DialMode dialMode() const {
|
||||
return static_cast<MobileGL::Wire::DialMode>(GetField<uint8_t>(VT_DIALMODE, 0));
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -583,6 +1027,12 @@ struct Hello FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VerifyOffset(verifier, VT_CONFIGBLOB) &&
|
||||
verifier.VerifyVector(configBlob()) &&
|
||||
VerifyField<uint64_t>(verifier, VT_ABIFINGERPRINT, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_WIREFINGERPRINT, 8) &&
|
||||
VerifyOffset(verifier, VT_LINKTERMS) &&
|
||||
verifier.VerifyTable(linkTerms()) &&
|
||||
VerifyOffset(verifier, VT_TOKEN) &&
|
||||
verifier.VerifyString(token()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_DIALMODE, 1) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -612,6 +1062,18 @@ struct HelloBuilder {
|
||||
void add_abiFingerprint(uint64_t abiFingerprint) {
|
||||
fbb_.AddElement<uint64_t>(Hello::VT_ABIFINGERPRINT, abiFingerprint, 0);
|
||||
}
|
||||
void add_wireFingerprint(uint64_t wireFingerprint) {
|
||||
fbb_.AddElement<uint64_t>(Hello::VT_WIREFINGERPRINT, wireFingerprint, 0);
|
||||
}
|
||||
void add_linkTerms(::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms) {
|
||||
fbb_.AddOffset(Hello::VT_LINKTERMS, linkTerms);
|
||||
}
|
||||
void add_token(::flatbuffers::Offset<::flatbuffers::String> token) {
|
||||
fbb_.AddOffset(Hello::VT_TOKEN, token);
|
||||
}
|
||||
void add_dialMode(MobileGL::Wire::DialMode dialMode) {
|
||||
fbb_.AddElement<uint8_t>(Hello::VT_DIALMODE, static_cast<uint8_t>(dialMode), 0);
|
||||
}
|
||||
explicit HelloBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
@@ -631,15 +1093,23 @@ inline ::flatbuffers::Offset<Hello> CreateHello(
|
||||
uint32_t backendType = 0,
|
||||
uint32_t pid = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> configBlob = 0,
|
||||
uint64_t abiFingerprint = 0) {
|
||||
uint64_t abiFingerprint = 0,
|
||||
uint64_t wireFingerprint = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> token = 0,
|
||||
MobileGL::Wire::DialMode dialMode = MobileGL::Wire::DialMode::No) {
|
||||
HelloBuilder builder_(_fbb);
|
||||
builder_.add_wireFingerprint(wireFingerprint);
|
||||
builder_.add_abiFingerprint(abiFingerprint);
|
||||
builder_.add_token(token);
|
||||
builder_.add_linkTerms(linkTerms);
|
||||
builder_.add_configBlob(configBlob);
|
||||
builder_.add_pid(pid);
|
||||
builder_.add_backendType(backendType);
|
||||
builder_.add_buildFingerprint(buildFingerprint);
|
||||
builder_.add_abiMinor(abiMinor);
|
||||
builder_.add_abiMajor(abiMajor);
|
||||
builder_.add_dialMode(dialMode);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
@@ -656,9 +1126,14 @@ inline ::flatbuffers::Offset<Hello> CreateHelloDirect(
|
||||
uint32_t backendType = 0,
|
||||
uint32_t pid = 0,
|
||||
const std::vector<uint8_t> *configBlob = nullptr,
|
||||
uint64_t abiFingerprint = 0) {
|
||||
uint64_t abiFingerprint = 0,
|
||||
uint64_t wireFingerprint = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||
const char *token = nullptr,
|
||||
MobileGL::Wire::DialMode dialMode = MobileGL::Wire::DialMode::No) {
|
||||
auto buildFingerprint__ = buildFingerprint ? _fbb.CreateString(buildFingerprint) : 0;
|
||||
auto configBlob__ = configBlob ? _fbb.CreateVector<uint8_t>(*configBlob) : 0;
|
||||
auto token__ = token ? _fbb.CreateString(token) : 0;
|
||||
return MobileGL::Wire::CreateHello(
|
||||
_fbb,
|
||||
abiMajor,
|
||||
@@ -667,7 +1142,11 @@ inline ::flatbuffers::Offset<Hello> CreateHelloDirect(
|
||||
backendType,
|
||||
pid,
|
||||
configBlob__,
|
||||
abiFingerprint);
|
||||
abiFingerprint,
|
||||
wireFingerprint,
|
||||
linkTerms,
|
||||
token__,
|
||||
dialMode);
|
||||
}
|
||||
|
||||
struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
@@ -682,7 +1161,10 @@ struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VT_REPLYPOOL = 14,
|
||||
VT_EVENTRING = 16,
|
||||
VT_BUILDFINGERPRINT = 18,
|
||||
VT_ABIFINGERPRINT = 20
|
||||
VT_ABIFINGERPRINT = 20,
|
||||
VT_WIREFINGERPRINT = 22,
|
||||
VT_LINKTERMS = 24,
|
||||
VT_BACKENDTYPE = 26
|
||||
};
|
||||
uint32_t abiMajor() const {
|
||||
return GetField<uint32_t>(VT_ABIMAJOR, 0);
|
||||
@@ -711,6 +1193,15 @@ struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
uint64_t abiFingerprint() const {
|
||||
return GetField<uint64_t>(VT_ABIFINGERPRINT, 0);
|
||||
}
|
||||
uint64_t wireFingerprint() const {
|
||||
return GetField<uint64_t>(VT_WIREFINGERPRINT, 0);
|
||||
}
|
||||
const MobileGL::Wire::LinkTerms *linkTerms() const {
|
||||
return GetPointer<const MobileGL::Wire::LinkTerms *>(VT_LINKTERMS);
|
||||
}
|
||||
uint32_t backendType() const {
|
||||
return GetField<uint32_t>(VT_BACKENDTYPE, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -728,6 +1219,10 @@ struct Welcome FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VerifyOffset(verifier, VT_BUILDFINGERPRINT) &&
|
||||
verifier.VerifyString(buildFingerprint()) &&
|
||||
VerifyField<uint64_t>(verifier, VT_ABIFINGERPRINT, 8) &&
|
||||
VerifyField<uint64_t>(verifier, VT_WIREFINGERPRINT, 8) &&
|
||||
VerifyOffset(verifier, VT_LINKTERMS) &&
|
||||
verifier.VerifyTable(linkTerms()) &&
|
||||
VerifyField<uint32_t>(verifier, VT_BACKENDTYPE, 4) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -763,6 +1258,15 @@ struct WelcomeBuilder {
|
||||
void add_abiFingerprint(uint64_t abiFingerprint) {
|
||||
fbb_.AddElement<uint64_t>(Welcome::VT_ABIFINGERPRINT, abiFingerprint, 0);
|
||||
}
|
||||
void add_wireFingerprint(uint64_t wireFingerprint) {
|
||||
fbb_.AddElement<uint64_t>(Welcome::VT_WIREFINGERPRINT, wireFingerprint, 0);
|
||||
}
|
||||
void add_linkTerms(::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms) {
|
||||
fbb_.AddOffset(Welcome::VT_LINKTERMS, linkTerms);
|
||||
}
|
||||
void add_backendType(uint32_t backendType) {
|
||||
fbb_.AddElement<uint32_t>(Welcome::VT_BACKENDTYPE, backendType, 0);
|
||||
}
|
||||
explicit WelcomeBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
@@ -784,9 +1288,15 @@ inline ::flatbuffers::Offset<Welcome> CreateWelcome(
|
||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> replyPool = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> eventRing = 0,
|
||||
::flatbuffers::Offset<::flatbuffers::String> buildFingerprint = 0,
|
||||
uint64_t abiFingerprint = 0) {
|
||||
uint64_t abiFingerprint = 0,
|
||||
uint64_t wireFingerprint = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||
uint32_t backendType = 0) {
|
||||
WelcomeBuilder builder_(_fbb);
|
||||
builder_.add_wireFingerprint(wireFingerprint);
|
||||
builder_.add_abiFingerprint(abiFingerprint);
|
||||
builder_.add_backendType(backendType);
|
||||
builder_.add_linkTerms(linkTerms);
|
||||
builder_.add_buildFingerprint(buildFingerprint);
|
||||
builder_.add_eventRing(eventRing);
|
||||
builder_.add_replyPool(replyPool);
|
||||
@@ -813,7 +1323,10 @@ inline ::flatbuffers::Offset<Welcome> CreateWelcomeDirect(
|
||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> replyPool = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::SegmentRef> eventRing = 0,
|
||||
const char *buildFingerprint = nullptr,
|
||||
uint64_t abiFingerprint = 0) {
|
||||
uint64_t abiFingerprint = 0,
|
||||
uint64_t wireFingerprint = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::LinkTerms> linkTerms = 0,
|
||||
uint32_t backendType = 0) {
|
||||
auto buildFingerprint__ = buildFingerprint ? _fbb.CreateString(buildFingerprint) : 0;
|
||||
return MobileGL::Wire::CreateWelcome(
|
||||
_fbb,
|
||||
@@ -825,7 +1338,10 @@ inline ::flatbuffers::Offset<Welcome> CreateWelcomeDirect(
|
||||
replyPool,
|
||||
eventRing,
|
||||
buildFingerprint__,
|
||||
abiFingerprint);
|
||||
abiFingerprint,
|
||||
wireFingerprint,
|
||||
linkTerms,
|
||||
backendType);
|
||||
}
|
||||
|
||||
struct CapsSnapshot FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
@@ -1211,7 +1727,8 @@ struct SurfaceReply FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VT_OK = 6,
|
||||
VT_EGLMAJOR = 8,
|
||||
VT_EGLMINOR = 10,
|
||||
VT_DEFAULTFB = 12
|
||||
VT_DEFAULTFB = 12,
|
||||
VT_EVENTHEAD = 14
|
||||
};
|
||||
uint64_t seq() const {
|
||||
return GetField<uint64_t>(VT_SEQ, 0);
|
||||
@@ -1228,6 +1745,9 @@ struct SurfaceReply FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
const MobileGL::Wire::DefaultFramebufferInfo *defaultFb() const {
|
||||
return GetPointer<const MobileGL::Wire::DefaultFramebufferInfo *>(VT_DEFAULTFB);
|
||||
}
|
||||
uint64_t eventHead() const {
|
||||
return GetField<uint64_t>(VT_EVENTHEAD, 0);
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -1237,6 +1757,7 @@ struct SurfaceReply FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
VerifyField<int32_t>(verifier, VT_EGLMINOR, 4) &&
|
||||
VerifyOffset(verifier, VT_DEFAULTFB) &&
|
||||
verifier.VerifyTable(defaultFb()) &&
|
||||
VerifyField<uint64_t>(verifier, VT_EVENTHEAD, 8) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
@@ -1260,6 +1781,9 @@ struct SurfaceReplyBuilder {
|
||||
void add_defaultFb(::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb) {
|
||||
fbb_.AddOffset(SurfaceReply::VT_DEFAULTFB, defaultFb);
|
||||
}
|
||||
void add_eventHead(uint64_t eventHead) {
|
||||
fbb_.AddElement<uint64_t>(SurfaceReply::VT_EVENTHEAD, eventHead, 0);
|
||||
}
|
||||
explicit SurfaceReplyBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
|
||||
: fbb_(_fbb) {
|
||||
start_ = fbb_.StartTable();
|
||||
@@ -1277,8 +1801,10 @@ inline ::flatbuffers::Offset<SurfaceReply> CreateSurfaceReply(
|
||||
bool ok = false,
|
||||
int32_t eglMajor = 0,
|
||||
int32_t eglMinor = 0,
|
||||
::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb = 0) {
|
||||
::flatbuffers::Offset<MobileGL::Wire::DefaultFramebufferInfo> defaultFb = 0,
|
||||
uint64_t eventHead = 0) {
|
||||
SurfaceReplyBuilder builder_(_fbb);
|
||||
builder_.add_eventHead(eventHead);
|
||||
builder_.add_seq(seq);
|
||||
builder_.add_defaultFb(defaultFb);
|
||||
builder_.add_eglMinor(eglMinor);
|
||||
@@ -1656,6 +2182,12 @@ struct CtrlEnvelope FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
|
||||
const MobileGL::Wire::LogLine *msg_as_LogLine() const {
|
||||
return msg_type() == MobileGL::Wire::CtrlMsg::LogLine ? static_cast<const MobileGL::Wire::LogLine *>(msg()) : nullptr;
|
||||
}
|
||||
const MobileGL::Wire::Refuse *msg_as_Refuse() const {
|
||||
return msg_type() == MobileGL::Wire::CtrlMsg::Refuse ? static_cast<const MobileGL::Wire::Refuse *>(msg()) : nullptr;
|
||||
}
|
||||
const MobileGL::Wire::LogFlush *msg_as_LogFlush() const {
|
||||
return msg_type() == MobileGL::Wire::CtrlMsg::LogFlush ? static_cast<const MobileGL::Wire::LogFlush *>(msg()) : nullptr;
|
||||
}
|
||||
template <bool B = false>
|
||||
bool Verify(::flatbuffers::VerifierTemplate<B> &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
@@ -1706,6 +2238,14 @@ template<> inline const MobileGL::Wire::LogLine *CtrlEnvelope::msg_as<MobileGL::
|
||||
return msg_as_LogLine();
|
||||
}
|
||||
|
||||
template<> inline const MobileGL::Wire::Refuse *CtrlEnvelope::msg_as<MobileGL::Wire::Refuse>() const {
|
||||
return msg_as_Refuse();
|
||||
}
|
||||
|
||||
template<> inline const MobileGL::Wire::LogFlush *CtrlEnvelope::msg_as<MobileGL::Wire::LogFlush>() const {
|
||||
return msg_as_LogFlush();
|
||||
}
|
||||
|
||||
struct CtrlEnvelopeBuilder {
|
||||
typedef CtrlEnvelope Table;
|
||||
::flatbuffers::FlatBufferBuilder &fbb_;
|
||||
@@ -1788,6 +2328,14 @@ inline bool VerifyCtrlMsg(::flatbuffers::VerifierTemplate<B> &verifier, const vo
|
||||
auto ptr = reinterpret_cast<const MobileGL::Wire::LogLine *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case CtrlMsg::Refuse: {
|
||||
auto ptr = reinterpret_cast<const MobileGL::Wire::Refuse *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
case CtrlMsg::LogFlush: {
|
||||
auto ptr = reinterpret_cast<const MobileGL::Wire::LogFlush *>(obj);
|
||||
return verifier.VerifyTable(ptr);
|
||||
}
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,47 @@ table SegmentRef {
|
||||
// Handshake
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// P6.5: independent control and data-plane choices. Values are append-only.
|
||||
enum DataPlane : ubyte { SharedSegments = 0, Stream = 1 }
|
||||
enum WireForm : ubyte { StructImage = 0 }
|
||||
enum DialMode : ubyte { No = 0, Fork = 1, Connect = 2 }
|
||||
|
||||
// Window sizes are stated by the server; the client's values are proposals only.
|
||||
table LinkTerms {
|
||||
dataPlane: DataPlane;
|
||||
wireForm: WireForm;
|
||||
maxReplyBytes: ulong;
|
||||
cmdWindowBytes: ulong;
|
||||
stageWindowBytes: ulong;
|
||||
eventWindowBytes: ulong;
|
||||
}
|
||||
|
||||
enum RefuseCode : uint {
|
||||
None = 0,
|
||||
ProtocolVersion = 1,
|
||||
WireFingerprint = 2,
|
||||
BuildFingerprint = 3,
|
||||
Authentication = 4,
|
||||
LinkTerms = 5,
|
||||
Backend = 6,
|
||||
Busy = 7,
|
||||
MalformedHello = 8,
|
||||
}
|
||||
|
||||
// A handshake rejection is a normal session outcome, never a process abort.
|
||||
table Refuse {
|
||||
code: RefuseCode;
|
||||
detail: string;
|
||||
expected: ulong;
|
||||
actual: ulong;
|
||||
peerValue: string;
|
||||
}
|
||||
|
||||
table LogFlush {
|
||||
seq: ulong;
|
||||
ack: bool;
|
||||
}
|
||||
|
||||
table Hello {
|
||||
abiMajor: uint;
|
||||
abiMinor: uint;
|
||||
@@ -63,15 +104,12 @@ table Hello {
|
||||
backendType: uint;
|
||||
pid: uint;
|
||||
configBlob: [ubyte];
|
||||
// CONTRACT-P5 table 0, "ABI agreement": MGPCaps has only a COMPOSITIONAL size
|
||||
// assertion, because DynamicBackendParameters still carries SizeT and GLenum.
|
||||
// So the two peers assert they were built from the same struct shapes instead
|
||||
// of rewriting them fixed-width (that is P7's account). This is
|
||||
// MG_Remote::CapsAbiFingerprint(): sizeof(DynamicBackendParameters),
|
||||
// sizeof(MGPCaps), sizeof(GLFunctionsTable), the protocol ABI version and the
|
||||
// build's git stamp, mixed. A mismatch is Fatal{AbiMismatch} and NEVER a
|
||||
// downgrade - every alternative silently reads one struct as another.
|
||||
// Retained legacy slot. P6.5 peers compare wireFingerprint instead.
|
||||
abiFingerprint: ulong;
|
||||
wireFingerprint: ulong;
|
||||
linkTerms: LinkTerms;
|
||||
token: string;
|
||||
dialMode: DialMode;
|
||||
}
|
||||
|
||||
table Welcome {
|
||||
@@ -82,12 +120,12 @@ table Welcome {
|
||||
stageRing: SegmentRef;
|
||||
replyPool: SegmentRef;
|
||||
eventRing: SegmentRef;
|
||||
// The server's half of the assertion above. The string is carried beside the
|
||||
// mixed value only so a mismatch can name both builds in the Fatal line; the
|
||||
// COMPARISON is on abiFingerprint, which also covers the three sizeofs the
|
||||
// string cannot.
|
||||
buildFingerprint: string;
|
||||
// Retained legacy slot; do not reuse or renumber it.
|
||||
abiFingerprint: ulong;
|
||||
wireFingerprint: ulong;
|
||||
linkTerms: LinkTerms;
|
||||
backendType: uint;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -221,6 +259,8 @@ table SurfaceReply {
|
||||
eglMajor: int;
|
||||
eglMinor: int;
|
||||
defaultFb: DefaultFramebufferInfo;
|
||||
// P6.5: all preceding data-plane events must arrive before this reply is observed.
|
||||
eventHead: ulong;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -306,6 +346,8 @@ union CtrlMsg {
|
||||
AuxRequest,
|
||||
Fatal,
|
||||
LogLine,
|
||||
Refuse,
|
||||
LogFlush,
|
||||
}
|
||||
|
||||
table CtrlEnvelope {
|
||||
|
||||
@@ -62,6 +62,12 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// The view is rebuilt per call rather than stored, so that this body does not change
|
||||
// ReplyPool's four members and therefore does not touch v1's header at all.
|
||||
void ReplyPool::PostReply(Uint64 seq, Int32 status, const void* bytes, Uint64 size) {
|
||||
if (m_link) {
|
||||
const auto result = m_link->PostReply(seq, status, bytes, size);
|
||||
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL)
|
||||
SessionFail(MGFatalFamily::ReplyTooLarge, "MGPipe: Fatal{ReplyTooLarge, stream reply}");
|
||||
return;
|
||||
}
|
||||
Transport::ReplySlotPool pool(m_base, m_size, m_slots);
|
||||
// Fatal inside Post when the answer does not fit a slot: P5 does not chunk replies,
|
||||
// and the client knows an answer's size before it emits the record.
|
||||
@@ -1192,6 +1198,15 @@ namespace MobileGL::MG_Remote::Server {
|
||||
PipeApplier::PipeApplier(Wire::SegmentTable* segments, ReplyPool* replies)
|
||||
: m_segments(segments), m_replies(replies) {}
|
||||
|
||||
void PipeApplier::Attach(Transport::ILink* link, MG_Backend::BackendObject* backend) {
|
||||
if (!link || !link->Attached() || !m_segments)
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, PipeApplier::Attach missing link}");
|
||||
m_verbs.SetBackend(backend);
|
||||
m_decoder = Wire::PipeWireDecoder(link, m_segments, m_replies);
|
||||
m_decoder.SetVerbSink(&m_verbs);
|
||||
MG_Pipe::MGPipeServerBlockNoteIdentity(); m_attached = true;
|
||||
}
|
||||
|
||||
void PipeApplier::Attach(Transport::RingControl* control, MG_Backend::BackendObject* backend) {
|
||||
if (control == nullptr || m_segments == nullptr) {
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"PipeApplier::Attach\"} - no control "
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
ReplyPool() = default;
|
||||
ReplyPool(void* base, Uint64 sizeBytes, Uint32 slotCount, Uint32 slotBytes);
|
||||
|
||||
void SetLink(Transport::ILink* link) { m_link = link; }
|
||||
void PostReply(Uint64 seq, Int32 status, const void* bytes, Uint64 size) override;
|
||||
|
||||
// A reply larger than one slot is Fatal rather than chunked: P5's only large answer is
|
||||
@@ -97,6 +98,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
Uint32 SlotBytes() const;
|
||||
|
||||
private:
|
||||
Transport::ILink* m_link = nullptr;
|
||||
Uint8* m_base = nullptr;
|
||||
Uint64 m_size = 0;
|
||||
Uint32 m_slots = 0;
|
||||
@@ -350,6 +352,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// CALLED ON THE APPLY THREAD, ONCE, BEFORE THE FIRST RECORD. PipeWireDecoder is "not
|
||||
// thread safe: one decoder on the apply thread, by construction", and its constructor
|
||||
// installs the process-wide apply hook.
|
||||
void Attach(Transport::ILink* link, MG_Backend::BackendObject* backend);
|
||||
void Attach(Transport::RingControl* control, MG_Backend::BackendObject* backend);
|
||||
void Detach();
|
||||
Bool Attached() const;
|
||||
|
||||
@@ -372,10 +372,10 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// The decoder is built HERE, on this thread, because PipeWireDecoder is "not thread
|
||||
// safe: one decoder on the apply thread, by construction" and its constructor installs
|
||||
// the process-wide apply hook.
|
||||
session.Applier().Attach(&session.Control(), m_backend.get());
|
||||
session.Applier().Attach(session.DataLink(), m_backend.get());
|
||||
|
||||
Transport::RingControl& control = session.Control();
|
||||
Transport::Doorbell& bell = session.ConsumerDoorbell();
|
||||
const auto signals = session.DataLink()->Signals();
|
||||
Transport::Doorbell& bell = session.DataLink()->ConsumerBell();
|
||||
Transport::RingConsumer& ring = session.CommandRing();
|
||||
const Uint32 spinUs = SpinUsFromConfig();
|
||||
|
||||
@@ -400,16 +400,16 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// this bell (that pairing is the whole of the flow-control protocol; a cleared flag
|
||||
// with no bell is the lost wakeup the forward direction's publish-then-ring order
|
||||
// exists to prevent).
|
||||
const auto ready = [this, &control, &ring] {
|
||||
const auto ready = [this, signals, &ring] {
|
||||
if (m_stopRequested.load(std::memory_order_acquire) || ControlIsPending()) return true;
|
||||
if (control.eventRingFull.load(std::memory_order_acquire) != 0) return false;
|
||||
return control.cmdHead.load(std::memory_order_acquire) != ring.LocalTail();
|
||||
if (signals.EventRingFull->load(std::memory_order_acquire) != 0) return false;
|
||||
return signals.CmdHead->load(std::memory_order_acquire) != ring.LocalTail();
|
||||
};
|
||||
|
||||
for (;;) {
|
||||
PumpControlRequest();
|
||||
if (m_stopRequested.load(std::memory_order_acquire)) break;
|
||||
if (control.eventRingFull.load(std::memory_order_acquire) == 0) DrainRing();
|
||||
if (signals.EventRingFull->load(std::memory_order_acquire) == 0) DrainRing();
|
||||
if (m_stopRequested.load(std::memory_order_acquire)) break;
|
||||
if (ready()) continue;
|
||||
|
||||
@@ -436,7 +436,9 @@ namespace MobileGL::MG_Remote::Server {
|
||||
MG_Util::PipeStats::PublishGauge(Gauge::ServerWaits, waits);
|
||||
MG_Util::PipeStats::PublishGauge(Gauge::ServerParks, ParkBlockCount());
|
||||
}
|
||||
const bool woke = bell.Wait(control.consumerParked, ready, spinUs,
|
||||
// Flush-on-idle publishes the last reply record even below the batch threshold.
|
||||
session.FlushDataProgress();
|
||||
const bool woke = bell.Wait(*signals.ConsumerParked, ready, spinUs,
|
||||
Transport::kWaitForever, &m_parkBlocks);
|
||||
if (!woke) {
|
||||
// Wait returns false only on a dead bell or an expired deadline, and this park
|
||||
@@ -735,7 +737,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// it atomically, so the apply thread cannot observe the request until this side is
|
||||
// waiting, and the doorbell remembers the notify regardless.
|
||||
if (m_session != nullptr) {
|
||||
m_session->ConsumerDoorbell().Notify();
|
||||
m_session->DataLink()->ConsumerBell().Notify();
|
||||
}
|
||||
m_controlDone.wait(lock, [this] { return m_controlFinished; });
|
||||
frame = m_controlFrame; // the reply half, written by the dispatch
|
||||
@@ -786,7 +788,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// The bell may already be dead - ClientSession::Stop calls transport->Shutdown()
|
||||
// first, which is what table 3's step 2 requires - and Notify on a dead bell is
|
||||
// harmless. Ringing anyway covers the paths that Stop without a Kill.
|
||||
m_session->ConsumerDoorbell().Notify();
|
||||
m_session->DataLink()->ConsumerBell().Notify();
|
||||
}
|
||||
|
||||
// THE JOIN IS BOUNDED. std::thread::join has no deadline, so a lost wakeup would wedge
|
||||
|
||||
@@ -1,316 +1,134 @@
|
||||
// MobileGL - MobileGL/MG_Remote/Server/ServerMain.cpp
|
||||
// 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
|
||||
// MobileGL - separate-process server and TCP session supervisor.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
// The server process's entry point. Package `sm` (CONTRACT-P6.md §3).
|
||||
//
|
||||
// ARCHITECTURE.md:488-496 has described this symbol for three phases and a6
|
||||
// found it existed nowhere in the tree. This is the real one.
|
||||
//
|
||||
// THE TWO PROCESSES ARE INDEPENDENT. This process is started by whoever starts
|
||||
// it - a shell, a test, an Android Service - and it LISTENS. The client is
|
||||
// started separately and CONNECTS. Nothing is inherited: no fds, no memory, no
|
||||
// parent.
|
||||
//
|
||||
// That is a deliberate change from this package's first shape, which forked the
|
||||
// server and handed it fds 3..6. Inheritance works and is less code, but it can
|
||||
// only ever produce a server that is a CHILD OF ITS CLIENT - the one arrangement
|
||||
// the end state cannot use, because there the server is a standing application
|
||||
// and the client is somewhere else entirely, possibly on another kernel.
|
||||
// CONTRACT-P6 §3.1 calls this Dial == Connect and had it as a later shape. It is
|
||||
// the primary one.
|
||||
//
|
||||
// WHAT THIS PACKAGE OWNS: the process, the rendezvous, the backend, the session,
|
||||
// the descriptor hand-off and the exit discipline. NOT what a control frame
|
||||
// means - that is `cp` - and not the data-plane seam, which is `lk`.
|
||||
//
|
||||
// _exit, NOT exit (CONTRACT-P6 §12.4). It decides whether g_processTeardown is
|
||||
// ever set, and therefore whether seven twin destructors take their early-out or
|
||||
// call into a driver whose context is already gone. The log is flushed first,
|
||||
// because _exit runs no atexit handler and a server that died without saying why
|
||||
// is the diagnostic this project refuses.
|
||||
|
||||
#include "../Transport/Doorbell.h" // kWaitForever, SocketDoorbell
|
||||
#include "../Transport/FdPassing.h"
|
||||
#include "../Transport/Doorbell.h"
|
||||
#include "../Transport/SocketTransport.h"
|
||||
#include "../Transport/WireLog.h"
|
||||
#include "../Protocol/SurfaceOpCodec.h"
|
||||
#include "../Handshake.h"
|
||||
#include "ServerLoop.h"
|
||||
#include "ServerSession.h"
|
||||
#include "SurfaceControlFrame.h"
|
||||
|
||||
#include <Config.h> // MG_Config::Transport - D1 pins it to Spawn in this process
|
||||
#include <MG_Backend/MGPipe/PipeInputs.h> // D1c: MGPipeSetServerProcessRole
|
||||
#include <Config.h>
|
||||
#include <Init.h>
|
||||
#include <MG_Backend/MGPipe/PipeInputs.h>
|
||||
#include <MG_Backend/ServerRole.h>
|
||||
#include <MG_Util/Metrics/PipeStats.h> // step 1.6: the counters' latch, server-process half
|
||||
#include <Init.h> // MG_ConfigLoader::Init - the child loads its own config (step 1.5)
|
||||
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
#include <MG_Util/Metrics/PipeStats.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__)
|
||||
# include <sys/socket.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <chrono>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace {
|
||||
using namespace MobileGL::MG_Remote;
|
||||
using namespace MobileGL::MG_Remote::Transport;
|
||||
namespace Protocol = ::MobileGL::Wire;
|
||||
|
||||
// The server must not be able to become a client. CONTRACT-P6 §3.1: this is
|
||||
// catch (a), STRUCTURAL and separate from role selection, because forcing
|
||||
// MG_Config::Transport to Monolith - what ARCHITECTURE.md:488 says - would
|
||||
// flip 148 MG_Backend lines to the frontend arm in the one process with no
|
||||
// frontend. Catch (b) is the launcher's envp scrub, and the two report
|
||||
// through DIFFERENT exit codes so they are distinguishable: two safeties
|
||||
// that cannot be told apart are one safety.
|
||||
bool DialingIsForbidden() {
|
||||
const char* dial = std::getenv("MOBILEGL_IPC_DIAL");
|
||||
return dial != nullptr && std::strcmp(dial, "no") == 0;
|
||||
void Refuse(SocketTransport& transport, Protocol::RefuseCode code, const char* detail) {
|
||||
flatbuffers::FlatBufferBuilder builder(256);
|
||||
auto refusal = Protocol::CreateRefuseDirect(builder, code, detail);
|
||||
auto envelope = Protocol::CreateCtrlEnvelope(builder, Protocol::CtrlMsg::Refuse, refusal.Union());
|
||||
Protocol::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
transport.SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||
WireLogError("MG_Remote server: Refuse{%s} %s", Protocol::EnumNameRefuseCode(code), detail);
|
||||
}
|
||||
|
||||
void ForwardLog(void* user, const char* text) {
|
||||
auto& transport = *static_cast<ITransport*>(user);
|
||||
flatbuffers::FlatBufferBuilder builder(512);
|
||||
auto log = Protocol::CreateLogLine(builder, Protocol::LogLevel::Info, builder.CreateString(text));
|
||||
auto envelope = Protocol::CreateCtrlEnvelope(builder, Protocol::CtrlMsg::LogLine, log.Union());
|
||||
Protocol::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
(void)transport.SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||
}
|
||||
|
||||
void RefuseBusy(SocketTransport& transport, const char* detail) {
|
||||
// Unread Hello bytes can make close send RST and discard our Refuse.
|
||||
std::uint64_t bytes = 0;
|
||||
if (transport.ReceiveFrame({nullptr, 0}, &bytes, 2000) == MOBILEGL_ERR_BUFFER_TOO_SMALL &&
|
||||
bytes <= 1024 * 1024) {
|
||||
std::vector<std::uint8_t> hello(static_cast<std::size_t>(bytes));
|
||||
(void)transport.ReceiveFrame({hello.data(), hello.size()}, &bytes, 0);
|
||||
}
|
||||
Refuse(transport, Protocol::RefuseCode::Busy, detail);
|
||||
}
|
||||
|
||||
bool LooksLikeAClientEnvironment() {
|
||||
static constexpr const char* kNames[] = {"MOBILEGL_TRANSPORT", "MOBILEGL_IPC_SERVER_PATH",
|
||||
"MOBILEGL_IPC_RING_MB", "MOBILEGL_IPC_STAGE_MB"};
|
||||
for (const char* name : kNames) {
|
||||
if (std::getenv(name) != nullptr) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// The rendezvous. A NAME, because independent processes have no other way to
|
||||
// find each other. No default: a default rendezvous is one that two unrelated
|
||||
// runs can collide on.
|
||||
std::string Endpoint(int argc, char** argv) {
|
||||
if (argc > 1 && argv[1] != nullptr && argv[1][0] != '\0') {
|
||||
return argv[1];
|
||||
}
|
||||
if (const char* fromEnv = std::getenv("MOBILEGL_IPC_ENDPOINT")) {
|
||||
return fromEnv;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
extern "C" __attribute__((visibility("default"))) int mobilegl_server_main(int argc, char** argv) {
|
||||
using namespace MobileGL::MG_Remote;
|
||||
using namespace MobileGL::MG_Remote::Transport;
|
||||
struct FlushAck { ITransport* transport; std::uint64_t seq; };
|
||||
void SendLogAck(void* pointer) {
|
||||
auto& ack = *static_cast<FlushAck*>(pointer);
|
||||
flatbuffers::FlatBufferBuilder builder(64);
|
||||
auto flush = Protocol::CreateLogFlush(builder, ack.seq, true);
|
||||
auto envelope = Protocol::CreateCtrlEnvelope(builder, Protocol::CtrlMsg::LogFlush, flush.Union());
|
||||
Protocol::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
(void)ack.transport->SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||
}
|
||||
|
||||
// Called only after fork: the supervisor never creates a backend or EGL context.
|
||||
[[noreturn]] void RunSession(std::unique_ptr<SocketTransport> control) {
|
||||
const int selfPid = static_cast<int>(::getpid());
|
||||
|
||||
// The arm-proof line (CONTRACT-P6 §9.5). ID-124 proved a lane can run
|
||||
// monolith and pass every other gate, so each entry leaves its own evidence.
|
||||
WireLogError("MG_Remote server: pid=%d transport=spawn role=server", selfPid);
|
||||
|
||||
if (!DialingIsForbidden()) {
|
||||
std::fprintf(stderr,
|
||||
"MG_Remote server: pid=%d refusing to start - MOBILEGL_IPC_DIAL=no was not "
|
||||
"set; anti-recursion catch (a) is missing\n",
|
||||
selfPid);
|
||||
std::fflush(nullptr);
|
||||
::_exit(64);
|
||||
const bool tcp = control->IsTcp();
|
||||
std::vector<std::uint8_t> helloFrame;
|
||||
std::uint64_t bytes = 0;
|
||||
auto received = control->ReceiveFrame({nullptr, 0}, &bytes, 10000);
|
||||
if (received != MOBILEGL_ERR_BUFFER_TOO_SMALL || bytes > 1024 * 1024) ::_exit(67);
|
||||
helloFrame.resize(static_cast<std::size_t>(bytes));
|
||||
if (control->ReceiveFrame({helloFrame.data(), helloFrame.size()}, &bytes, 0) != MOBILEGL_OK) ::_exit(67);
|
||||
flatbuffers::Verifier verifier(helloFrame.data(), helloFrame.size());
|
||||
if (!Protocol::VerifyCtrlEnvelopeBuffer(verifier)) ::_exit(67);
|
||||
const auto* hello = Protocol::GetCtrlEnvelope(helloFrame.data())->msg_as_Hello();
|
||||
if (!hello) ::_exit(67);
|
||||
// Reject incompatible wire before backend bring-up can obscure the cause.
|
||||
if (ValidatePeerHandshake(*control, hello->abiMajor(), hello->abiMinor(),
|
||||
hello->wireFingerprint(), hello->buildFingerprint() ? hello->buildFingerprint()->c_str() : nullptr,
|
||||
hello->dialMode()) != MOBILEGL_OK) ::_exit(0);
|
||||
if (tcp) {
|
||||
const char* expected = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||
const std::string token = hello->token() ? hello->token()->str() : std::string();
|
||||
if (token != (expected ? expected : "")) {
|
||||
Refuse(*control, Protocol::RefuseCode::Authentication, "TCP token mismatch");
|
||||
::_exit(0);
|
||||
}
|
||||
}
|
||||
if (LooksLikeAClientEnvironment()) {
|
||||
std::fprintf(stderr,
|
||||
"MG_Remote server: pid=%d the envp scrub FAILED - a client knob survived "
|
||||
"into this process; catch (a) held, catch (b) did not\n",
|
||||
selfPid);
|
||||
std::fflush(nullptr);
|
||||
::_exit(65);
|
||||
}
|
||||
|
||||
const std::string endpoint = Endpoint(argc, argv);
|
||||
if (endpoint.empty()) {
|
||||
std::fprintf(stderr,
|
||||
"MG_Remote server: pid=%d no endpoint - pass one as argv[1] or set "
|
||||
"MOBILEGL_IPC_ENDPOINT\n",
|
||||
selfPid);
|
||||
std::fflush(nullptr);
|
||||
::_exit(71);
|
||||
}
|
||||
|
||||
// ---- 1. listen, BEFORE the backend. The client's bounded connect retry is
|
||||
// what tolerates the backend taking a while; a client that connected and then
|
||||
// waited for a Welcome a failed bring-up will never send would have to learn
|
||||
// about death from a timeout, which §5.4 forbids.
|
||||
int listenFd = -1;
|
||||
if (SocketTransport::Listen(endpoint, &listenFd) != MOBILEGL_OK) {
|
||||
std::fprintf(stderr, "MG_Remote server: pid=%d could not listen on \"%s\"\n", selfPid,
|
||||
endpoint.c_str());
|
||||
std::fflush(nullptr);
|
||||
::_exit(72);
|
||||
}
|
||||
WireLogError("MG_Remote server: pid=%d listening on \"%s\"", selfPid, endpoint.c_str());
|
||||
|
||||
// ---- 1.5. CONFIG, AND THEN D1.
|
||||
//
|
||||
// TWO SEPARATE DEFECTS LIVED HERE, and both were silent.
|
||||
//
|
||||
// (a) NOTHING LOADED THE CONFIG AT ALL. mobilegl_server_main calls
|
||||
// InitServerRoleForSpawn directly rather than MobileGL::Initialize, and
|
||||
// MG_ConfigLoader::Init is a step of the latter - so every MG_Config
|
||||
// value in this process was its STATIC DEFAULT. MOBILEGL_BACKEND_TYPE
|
||||
// survives the launcher's scrub on purpose, and it was being read by
|
||||
// nobody: a DirectVulkan session would have brought up a DirectGLES
|
||||
// server and then disagreed with its client about which backend the
|
||||
// capability mask describes.
|
||||
//
|
||||
// (b) THE CHILD RESOLVED Transport == Monolith. CONTRACT-P6 §3.1 (D1) says
|
||||
// it must read as Spawn, and a6 measured the cost of getting it wrong:
|
||||
// 226 live lines test `Transport != Monolith` to select the SERVER arm,
|
||||
// 148 of them in MG_Backend. Monolith flips all of them to frontend glue
|
||||
// in the one process that has no frontend. Observed, exactly as
|
||||
// predicted: TextureImpl::UnitTexturesByHandle() answered false, Clear
|
||||
// took the legacy arm that dereferences borrowed FRONTEND slot pointers,
|
||||
// and the apply thread took a SIGSEGV inside SyncNeccessaryTextures on
|
||||
// the first Clear record of the OpenRA retrace.
|
||||
//
|
||||
// IT IS SET HERE AND NOT THROUGH THE ENVIRONMENT because the environment is
|
||||
// where it must NOT appear: LooksLikeAClientEnvironment above exits 65 if
|
||||
// MOBILEGL_TRANSPORT survived into this process, and that check is
|
||||
// anti-recursion catch (b). D1's own answer is that Dial - not Transport -
|
||||
// is the anti-recursion axis, so Transport is free to say what is true.
|
||||
MobileGL::MG_ConfigLoader::Init();
|
||||
MobileGL::MG_Config::Transport = MobileGL::MG_Config::TransportMode::Spawn;
|
||||
// D1c/D10: THIS PROCESS IS THE SERVER, stated once and before any GL work.
|
||||
//
|
||||
// Four guards used to ask "am I on the apply thread" or "is a ClientSession active" - both
|
||||
// questions a server PROCESS answers wrongly: it has no ClientSession at all, and every one
|
||||
// of its threads is a server thread, not just the applier's. Saying it here is what arms
|
||||
// them; without it they are compiled in and permanently false, which is worse than absent
|
||||
// because it reads as coverage.
|
||||
MobileGL::MG_Pipe::MGPipeSetServerProcessRole(true);
|
||||
// ---- 1.6. THE MGPIPE COUNTERS, and this is the ONLY call site outside
|
||||
// MobileGL::Initialize().
|
||||
//
|
||||
// GATE 8'S SERVER HALF WAS STRUCTURALLY ZERO WITHOUT THIS, and the shape of the
|
||||
// defect is worth stating: the child never runs MobileGL::Initialize, so
|
||||
// PipeStats::Init() - a step of it - never ran here, and g_pipeStatsEnabled
|
||||
// stayed false. Every one of the ~80 `if (Enabled())` sites in the backends and
|
||||
// in MG_Remote (ServerLoop's own ServerWaits/ServerParks publish included)
|
||||
// compiled in and was permanently false in this process. The contract's
|
||||
// mandatory "socket doorbell vs inproc condvar" number therefore had no server
|
||||
// half under `spawn` at all, and its absence read exactly like a real zero:
|
||||
// `wait[srv=0 srvpark=0]` is what "the server never waited" looks like too.
|
||||
//
|
||||
// IT GOES AFTER THE CONFIG LOAD AND AFTER THE ROLE IS STATED, and both halves
|
||||
// of that order are load-bearing:
|
||||
//
|
||||
// * AFTER MG_ConfigLoader::Init, because Init() LATCHES the flag out of
|
||||
// MG_Config::Features.PipeStats, and the parser does not exist until the
|
||||
// line above has run. Calling it earlier would latch the static default
|
||||
// (false) and the MOBILEGL_PIPE_STATS the launcher passed would be read by
|
||||
// nobody - the same class of defect the config load itself used to have.
|
||||
// * AFTER MGPipeSetServerProcessRole, because that is what makes the LOG SINK
|
||||
// know this process is the server, and PipeStats' summary line is emitted
|
||||
// through MGLOG_I. The sink resolves its role from MOBILEGL_IPC_ROLE (which
|
||||
// the launcher sets and its envp scrub preserves) and would in fact be
|
||||
// right either way, but ordering it this way means the line cannot be filed
|
||||
// under the client by a future change to that resolution. What the contract
|
||||
// requires - that the summary lands in `<base>.server.log` - is asserted by
|
||||
// the lane, not assumed from this comment.
|
||||
//
|
||||
// MOBILEGL_PIPE_STATS / _PERIOD / _FILE MEAN EXACTLY WHAT THEY MEAN IN THE
|
||||
// CLIENT PROCESS, and that is the whole point of routing through Init(): all
|
||||
// three are read from the child's own environment by the same parser and
|
||||
// latched by the same function. Nothing about the stats channel is spawn-shaped.
|
||||
// One asymmetry is real and intended: this process has no backend Present of
|
||||
// its own, so its line cadence rides the present RECORDS it applies
|
||||
// (PipeApplier -> DirectGLES/DirectVulkan Present -> OnPresent) rather than a
|
||||
// swap the server does not perform. A spawn session that presents N times
|
||||
// produces N windows here, which is the same N the client's own line counts.
|
||||
// The child bypasses MobileGL::Initialize: arm its own role counters.
|
||||
MobileGL::MG_Util::PipeStats::Init();
|
||||
WireLogError("MG_Remote server: pid=%d config loaded, backend=%d, Transport pinned to Spawn "
|
||||
"(D1: this process IS the server arm)",
|
||||
selfPid, static_cast<int>(MobileGL::MG_Config::ActiveBackendType));
|
||||
|
||||
// ---- 2. the backend, through the SAME entry point the inproc server role
|
||||
// uses (MG_Backend/ServerRole.h). No EGL yet: the context is created on the
|
||||
// apply thread when the client's first eglMakeCurrent crosses.
|
||||
if (!MobileGL::MG_Backend::InitServerRoleForSpawn()) {
|
||||
std::fprintf(stderr,
|
||||
"MG_Remote server: pid=%d could not create a backend; refusing to accept a "
|
||||
"session it could never apply\n",
|
||||
selfPid);
|
||||
::close(listenFd);
|
||||
::unlink(endpoint.c_str());
|
||||
std::fflush(nullptr);
|
||||
::_exit(66);
|
||||
const auto backend = static_cast<MobileGL::BackendType>(hello->backendType());
|
||||
if (backend != MobileGL::BackendType::DirectGLES && backend != MobileGL::BackendType::DirectVulkan) {
|
||||
Refuse(*control, Protocol::RefuseCode::Backend, "unsupported Hello.backendType");
|
||||
::_exit(0);
|
||||
}
|
||||
|
||||
// ---- 3. accept the client's TWO connections: control, then aux.
|
||||
std::unique_ptr<SocketTransport> control;
|
||||
if (SocketTransport::AcceptPair(listenFd, 30000, control) != MOBILEGL_OK) {
|
||||
std::fprintf(stderr, "MG_Remote server: pid=%d no client within 30 s\n", selfPid);
|
||||
::close(listenFd);
|
||||
::unlink(endpoint.c_str());
|
||||
std::fflush(nullptr);
|
||||
::_exit(73);
|
||||
const char* pinned = std::getenv("MOBILEGL_BACKEND_TYPE");
|
||||
if (pinned && *pinned && backend != MobileGL::MG_Config::ActiveBackendType) {
|
||||
Refuse(*control, Protocol::RefuseCode::Backend, "Hello.backendType disagrees with pinned backend");
|
||||
::_exit(0);
|
||||
}
|
||||
// One session per process (CONTRACT-P6 §12.3), so the door closes behind the
|
||||
// one client that came through it. A second would collide on four process
|
||||
// globals and on DirectGLES's single per-process EGL tuple.
|
||||
::close(listenFd);
|
||||
::unlink(endpoint.c_str());
|
||||
|
||||
// ---- 4. the two bells, created HERE and handed over. NOT inherited: there
|
||||
// is no parent to inherit from. One socketpair per DIRECTION, because
|
||||
// SocketDoorbell is "write a byte to wake the peer, poll to be woken" and a
|
||||
// single pair would have each side reading the byte it wrote to the other.
|
||||
int serverBell[2] = {-1, -1};
|
||||
int clientBell[2] = {-1, -1};
|
||||
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, serverBell) != 0 ||
|
||||
::socketpair(AF_UNIX, SOCK_STREAM, 0, clientBell) != 0) {
|
||||
std::fprintf(stderr, "MG_Remote server: pid=%d bell socketpair failed\n", selfPid);
|
||||
std::fflush(nullptr);
|
||||
::_exit(74);
|
||||
MobileGL::MG_Config::ActiveBackendType = backend;
|
||||
if (!MobileGL::MG_Backend::InitServerRoleForSpawn()) ::_exit(66);
|
||||
auto& session = Server::ServerSessionInstance();
|
||||
int serverBell[2] = {-1, -1}, clientBell[2] = {-1, -1};
|
||||
std::unique_ptr<SocketDoorbell> selfBell, peerBell;
|
||||
if (!tcp) {
|
||||
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, serverBell) != 0 ||
|
||||
::socketpair(AF_UNIX, SOCK_STREAM, 0, clientBell) != 0) ::_exit(74);
|
||||
selfBell = std::make_unique<SocketDoorbell>(serverBell[0], serverBell[1], 1, true);
|
||||
peerBell = std::make_unique<SocketDoorbell>(-1, clientBell[1], 1, true);
|
||||
session.SetExternalDoorbells(selfBell.get(), peerBell.get());
|
||||
}
|
||||
// PARK AND NOTIFY ON DIFFERENT DESCRIPTORS, and this is not a refinement -
|
||||
// the single-fd form CANNOT WAKE ITSELF. send() on one end of a socketpair
|
||||
// is delivered to the OTHER end, so a one-fd bell built on serverBell[0]
|
||||
// writes to serverBell[1] and polls serverBell[0]: correct for waking a
|
||||
// PEER, useless for waking a thread in this process. The server needs
|
||||
// exactly that, because the control pump posts into the apply thread's
|
||||
// mailbox and then has to ring the bell that thread is parked on. Measured
|
||||
// symptom when it was wrong: every eglInitialize crossed, landed in the
|
||||
// mailbox, and timed out at 5 s because nothing ever woke mgl-srv-apply.
|
||||
SocketDoorbell selfBell(/*parkFd=*/serverBell[0], /*notifyFd=*/serverBell[1], /*code=*/1,
|
||||
/*ownsFds=*/true);
|
||||
// RINGS ONLY. The client parks on clientBell[0]; writing clientBell[1] is
|
||||
// what reaches it. parkFd = -1 says in the type that this side never waits.
|
||||
SocketDoorbell peerBell(/*parkFd=*/-1, /*notifyFd=*/clientBell[1], /*code=*/1,
|
||||
/*ownsFds=*/true);
|
||||
|
||||
Server::ServerSession& session = Server::ServerSessionInstance();
|
||||
session.SetExternalDoorbells(&selfBell, &peerBell);
|
||||
|
||||
// ---- 5. Accept: the ABI assertion, the four segments, and Welcome.
|
||||
const MobileGLResult accepted = session.Accept(*control);
|
||||
const auto accepted = session.Accept(*control, &helloFrame);
|
||||
if (accepted != MOBILEGL_OK) {
|
||||
std::fprintf(stderr, "MG_Remote server: pid=%d Accept failed (rc=%d)\n", selfPid,
|
||||
static_cast<int>(accepted));
|
||||
WireLogError("MG_Remote server: pid=%d Accept failed (rc=%d)", selfPid, static_cast<int>(accepted));
|
||||
std::fflush(nullptr);
|
||||
::_exit(67);
|
||||
::_exit(accepted == MOBILEGL_ERR_PROTOCOL_MISMATCH ? 0 : 67);
|
||||
}
|
||||
|
||||
// ---- 6. hand SIX descriptors over. THIS IS WHY SCM_RIGHTS IS IN THIS
|
||||
// DESIGN: the segments are anonymous - ASharedMemory_create has no filesystem
|
||||
// name at all, and memfd / shm_open+unlink are not openable either
|
||||
// (ShmSegmentPosix.cpp says so) - so the descriptor IS the only key, and this
|
||||
// process is the side that created them.
|
||||
//
|
||||
// The slot travels in the sideband rather than being inferred from arrival
|
||||
// order, so a reordered or dropped offer is a NAMED mismatch on arrival
|
||||
// instead of two segments quietly swapped.
|
||||
if (!tcp)
|
||||
{
|
||||
struct Sideband {
|
||||
std::uint32_t slot;
|
||||
@@ -359,87 +177,135 @@ extern "C" __attribute__((visibility("default"))) int mobilegl_server_main(int a
|
||||
::close(clientBell[0]);
|
||||
}
|
||||
|
||||
// ---- 7. the apply thread. It holds the native context for its whole life,
|
||||
// which is what turns MakeCurrent's cache-invalidation storm into a one-off.
|
||||
Server::ServerLoop& loop = Server::ServerLoopInstance();
|
||||
if (loop.Start(session) != MOBILEGL_OK) {
|
||||
std::fprintf(stderr, "MG_Remote server: pid=%d the apply thread did not start\n", selfPid);
|
||||
std::fflush(nullptr);
|
||||
::_exit(70);
|
||||
}
|
||||
|
||||
WireLogError("MG_Remote server: pid=%d transport=spawn role=server ready "
|
||||
"(backend up, seven descriptors handed over, apply thread running)",
|
||||
selfPid);
|
||||
|
||||
// ---- 8. the control pump. EOF is the whole exit condition: no timeout may
|
||||
// ever stand in for the death fact (§5.4), because a server one frame behind
|
||||
// is the intended steady state and a server that is gone is a different thing.
|
||||
const char* forwarding = std::getenv("MOBILEGL_IPC_LOG_FORWARD");
|
||||
if (tcp && (!forwarding || std::strcmp(forwarding, "0") != 0))
|
||||
MobileGL::MG_Util::Debug::SetLogForwarder(&ForwardLog, control.get());
|
||||
auto& loop = Server::ServerLoopInstance();
|
||||
if (loop.Start(session) != MOBILEGL_OK) ::_exit(70);
|
||||
WireLogError("MG_Remote server: pid=%d transport=spawn role=server ready control=%s data=%s",
|
||||
selfPid, tcp ? "tcp" : "unix", tcp ? "stream" : "shm");
|
||||
std::vector<std::uint8_t> buffer(64 * 1024);
|
||||
for (;;) {
|
||||
std::uint64_t size = 0;
|
||||
MobileGLMutableByteSpan span{buffer.data(), buffer.size()};
|
||||
const MobileGLResult result = control->ReceiveFrame(span, &size, kWaitForever);
|
||||
if (result == MOBILEGL_ERR_TRANSPORT_CLOSED) {
|
||||
WireLogError("MG_Remote server: pid=%d peer closed the control stream; exiting",
|
||||
selfPid);
|
||||
break;
|
||||
}
|
||||
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL) {
|
||||
buffer.resize(static_cast<std::size_t>(size));
|
||||
continue; // still queued: ITransport's contract
|
||||
}
|
||||
if (result != MOBILEGL_OK) {
|
||||
WireLogError("MG_Remote server: pid=%d control stream failed (rc=%d); exiting", selfPid,
|
||||
static_cast<int>(result));
|
||||
break;
|
||||
}
|
||||
// `cp`: decode, apply, reply. THIS THREAD IS NOT THE APPLY THREAD, which
|
||||
// is what CONTRACT-P6 §6.2 requires - a control arrival must not wake the
|
||||
// applier, and frame decode must not happen on the thread holding the
|
||||
// native context. ServerApplyWireSurfaceOp posts through ServerLoop's
|
||||
// existing one-slot mailbox, unchanged.
|
||||
const ::MobileGL::Wire::CtrlEnvelope* envelope = nullptr;
|
||||
{
|
||||
::flatbuffers::Verifier verifier(buffer.data(), static_cast<std::size_t>(size));
|
||||
if (::MobileGL::Wire::VerifyCtrlEnvelopeBuffer(verifier)) {
|
||||
envelope = ::MobileGL::Wire::GetCtrlEnvelope(buffer.data());
|
||||
const auto result = control->ReceiveFrame({buffer.data(), buffer.size()}, &size, kWaitForever);
|
||||
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL) { buffer.resize(static_cast<std::size_t>(size)); continue; }
|
||||
if (result != MOBILEGL_OK) break;
|
||||
flatbuffers::Verifier check(buffer.data(), static_cast<std::size_t>(size));
|
||||
if (!Protocol::VerifyCtrlEnvelopeBuffer(check)) break;
|
||||
const auto* envelope = Protocol::GetCtrlEnvelope(buffer.data());
|
||||
if (const auto* flush = envelope->msg_as_LogFlush()) {
|
||||
if (flush->ack()) break;
|
||||
if (const char* inspect = std::getenv("MOBILEGL_TEST_SERVER_COUNTERS");
|
||||
inspect && std::strcmp(inspect, "1") == 0) {
|
||||
// SyncPeerLog has fenced the client's complete command prefix.
|
||||
// Acquire the applier's publication before reading its counters;
|
||||
// this serial client sends no more records until this ack.
|
||||
const auto applied = session.DataLink()->Progress()->appliedSeq.load(std::memory_order_acquire);
|
||||
const auto& verbs = session.Applier().Verbs();
|
||||
MGLOG_I("MGPipe server counters: applied=%llu resets=%llu reset-serial=%llu deaths=%llu",
|
||||
static_cast<unsigned long long>(applied),
|
||||
static_cast<unsigned long long>(verbs.ApplierResets()),
|
||||
static_cast<unsigned long long>(verbs.ExpectedApplierResetSerial()),
|
||||
static_cast<unsigned long long>(verbs.ObjectDeaths()));
|
||||
}
|
||||
FlushAck ack{control.get(), flush->seq()};
|
||||
MobileGL::MG_Util::Debug::WithLogBarrier(&SendLogAck, &ack);
|
||||
continue;
|
||||
}
|
||||
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::SurfaceOp ||
|
||||
envelope->msg_as_SurfaceOp() == nullptr) {
|
||||
WireLogError("MG_Remote server: pid=%d a control frame that is not a verifiable "
|
||||
"SurfaceOp arrived; ignoring it would be the silent drop this project "
|
||||
"refuses, so the session ends here",
|
||||
selfPid);
|
||||
break;
|
||||
}
|
||||
|
||||
const auto* operation = envelope->msg_as_SurfaceOp();
|
||||
if (!operation) break;
|
||||
Server::SurfaceControlFrame reply{};
|
||||
const MobileGLResult applied =
|
||||
ServerApplyWireSurfaceOp(*envelope->msg_as_SurfaceOp(), &reply);
|
||||
(void)applied; // carried in the reply's ok/result, not thrown away here
|
||||
|
||||
::flatbuffers::FlatBufferBuilder builder(256);
|
||||
(void)ServerApplyWireSurfaceOp(*operation, &reply);
|
||||
session.FlushDataProgress();
|
||||
if (session.DataLink()) reply.eventHead = session.DataLink()->EventPublishedHead();
|
||||
flatbuffers::FlatBufferBuilder builder(256);
|
||||
EncodeSurfaceReplyFrame(reply, &builder);
|
||||
if (control->SendFrame(
|
||||
MobileGLByteSpan{builder.GetBufferPointer(), builder.GetSize()}) != MOBILEGL_OK) {
|
||||
break;
|
||||
}
|
||||
if (control->SendFrame({builder.GetBufferPointer(), builder.GetSize()}) != MOBILEGL_OK) break;
|
||||
}
|
||||
|
||||
loop.Stop();
|
||||
session.Close();
|
||||
control->Shutdown();
|
||||
// Step 1.6's other half, and its position is the same argument MobileGL::Destroy
|
||||
// makes: AFTER loop.Stop(), because the apply thread is what publishes
|
||||
// ServerWaits / ServerParks and a dump taken while it still runs is a race; and
|
||||
// BEFORE _exit, because _exit runs no atexit handler and this is the only place
|
||||
// the server's run totals and its JSON dump can be written at all. Without it
|
||||
// the server printed whatever windows its last period boundary happened to
|
||||
// reach and lost the final one - the same "the last frame's numbers can be
|
||||
// lost" case Init.cpp's Shutdown call exists to avoid on the client side.
|
||||
// Publish the final server window while log forwarding is still attached.
|
||||
MobileGL::MG_Util::PipeStats::Shutdown();
|
||||
session.Close();
|
||||
MobileGL::MG_Util::Debug::SetLogForwarder(nullptr, nullptr);
|
||||
// _exit closes control after cleanup/flush; peer EOF is the client's fence.
|
||||
std::fflush(nullptr);
|
||||
::_exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default"))) int mobilegl_server_main(int argc, char** argv) {
|
||||
// The supervisor and every forked session child log under the server role.
|
||||
// Set it here rather than trusting the launcher to have done so: log role is
|
||||
// resolved from this env at first use, and a launcher that omits it would
|
||||
// silently misfile this process's main-thread server lines as the client
|
||||
// role and never forward them. Done before any logging so the value is cached
|
||||
// as server and inherited by the fork children. DIAL/scrub stay hard checks.
|
||||
if (const char* role = std::getenv("MOBILEGL_IPC_ROLE");
|
||||
!role || std::strcmp(role, "server") != 0) {
|
||||
::setenv("MOBILEGL_IPC_ROLE", "server", 1);
|
||||
}
|
||||
const char* dial = std::getenv("MOBILEGL_IPC_DIAL");
|
||||
if (!dial || std::strcmp(dial, "no") != 0) {
|
||||
std::fprintf(stderr, "MG_Remote server: MOBILEGL_IPC_DIAL=no anti-recursion catch (a) missing\n");
|
||||
return 64;
|
||||
}
|
||||
for (const char* name : {"MOBILEGL_TRANSPORT", "MOBILEGL_IPC_SERVER_PATH", "MOBILEGL_IPC_RING_MB", "MOBILEGL_IPC_STAGE_MB"}) {
|
||||
if (std::getenv(name)) {
|
||||
std::fprintf(stderr, "MG_Remote server: envp scrub FAILED, catch (b): %s\n", name);
|
||||
return 65;
|
||||
}
|
||||
}
|
||||
std::string endpoint;
|
||||
bool serve = false;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
const std::string arg(argv[i]);
|
||||
if (arg == "--serve") serve = true;
|
||||
else if (arg == "--max-sessions" && i + 1 < argc) {
|
||||
char* end = nullptr;
|
||||
const auto count = std::strtoul(argv[++i], &end, 10);
|
||||
// This is a concurrency limit, not a cumulative session budget.
|
||||
// P6.5 deliberately supports one active rendering session.
|
||||
if (*end || count != 1) return 71;
|
||||
} else if (endpoint.empty() && arg.compare(0, 2, "--") != 0) endpoint = arg;
|
||||
else return 71;
|
||||
}
|
||||
if (endpoint.empty()) if (const char* value = std::getenv("MOBILEGL_IPC_ENDPOINT")) endpoint = value;
|
||||
if (endpoint.empty()) return 71;
|
||||
int listener = -1;
|
||||
if (SocketTransport::Listen(endpoint, &listener) != MOBILEGL_OK) return 72;
|
||||
WireLogError("MG_Remote server: pid=%d listening on %s", static_cast<int>(::getpid()), endpoint.c_str());
|
||||
pid_t active = -1;
|
||||
for (;;) {
|
||||
if (active > 0 && ::waitpid(active, nullptr, WNOHANG) == active) active = -1;
|
||||
std::unique_ptr<SocketTransport> control;
|
||||
const auto accepted = SocketTransport::AcceptPair(listener, serve ? 250 : 30000, control);
|
||||
if (accepted == MOBILEGL_ERR_TIMEOUT && serve) continue;
|
||||
if (accepted != MOBILEGL_OK) { ::close(listener); return 73; }
|
||||
if (!serve) {
|
||||
::close(listener);
|
||||
if (endpoint[0] != '@' && endpoint.compare(0, 6, "tcp://") != 0) ::unlink(endpoint.c_str());
|
||||
RunSession(std::move(control));
|
||||
}
|
||||
if (active > 0 && ::waitpid(active, nullptr, WNOHANG) == active) active = -1;
|
||||
// exit_group closes files just before waitpid can observe the exit.
|
||||
// Allow that small scheduling window; a live peer remains Busy.
|
||||
const auto reapDeadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(50);
|
||||
while (active > 0 && std::chrono::steady_clock::now() < reapDeadline) {
|
||||
if (::waitpid(active, nullptr, WNOHANG) == active) { active = -1; break; }
|
||||
::usleep(1000);
|
||||
}
|
||||
if (active > 0) {
|
||||
RefuseBusy(*control, "one session is already active");
|
||||
continue;
|
||||
}
|
||||
std::fflush(nullptr);
|
||||
const pid_t child = ::fork();
|
||||
if (child == 0) { ::close(listener); RunSession(std::move(control)); }
|
||||
if (child < 0) { RefuseBusy(*control, "could not create session child"); continue; }
|
||||
active = child;
|
||||
control->CloseLocalCopy();
|
||||
}
|
||||
::close(listener);
|
||||
if (endpoint[0] != '@' && endpoint.compare(0, 6, "tcp://") != 0) ::unlink(endpoint.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
|
||||
// P5 package s1: the server half of a session.
|
||||
|
||||
#include "../Transport/SocketTransport.h"
|
||||
#include "ServerSession.h"
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
|
||||
#include "../CapsCodec.h"
|
||||
#include "../Handshake.h"
|
||||
#include "../Transport/LinkMetrics.h"
|
||||
#include "../Protocol/generated/protocol_generated.h"
|
||||
#include "../Transport/InProcessTransport.h"
|
||||
|
||||
@@ -109,23 +112,6 @@ namespace MobileGL::MG_Remote::Server {
|
||||
return ::MobileGL::Wire::GetCtrlEnvelope(bytes.data());
|
||||
}
|
||||
|
||||
[[noreturn]] void FatalAbiMismatch(const char* what, Uint64 ours, Uint64 theirs,
|
||||
const char* ourStamp, const char* theirStamp) {
|
||||
// NEVER a downgrade. Every alternative to aborting here reads one struct as
|
||||
// another - MGPCaps has only a compositional size assertion because
|
||||
// DynamicBackendParameters still carries SizeT, so a peer built from a different
|
||||
// tree hands over a caps block whose members are at different offsets and whose
|
||||
// bytes are all individually plausible.
|
||||
SessionFail(MGFatalFamily::AbiMismatch, "MGPipe: Fatal{AbiMismatch, \"%s\"} ours=%llu theirs=%llu ourBuild=%s "
|
||||
"theirBuild=%s - the two peers were not built from the same struct shapes, "
|
||||
"and there is no downgrade path: the caps block's size is ABI-dependent "
|
||||
"(MGPipeTypes.h:145-146) and every field past the first difference would be "
|
||||
"read at the wrong offset",
|
||||
what, static_cast<unsigned long long>(ours),
|
||||
static_cast<unsigned long long>(theirs),
|
||||
ourStamp == nullptr ? "?" : ourStamp, theirStamp == nullptr ? "?" : theirStamp);
|
||||
}
|
||||
|
||||
// MOBILEGL_IPC_RING_MB / MOBILEGL_IPC_STAGE_MB, actually applied.
|
||||
//
|
||||
// The first version of this file called this only `if (m_sizes.CmdBytes == 0)`, and
|
||||
@@ -246,17 +232,17 @@ namespace MobileGL::MG_Remote::Server {
|
||||
static_cast<unsigned long long>(cap));
|
||||
}
|
||||
|
||||
Transport::RingControl& control = session.Control();
|
||||
Transport::Doorbell& bell = session.ConsumerDoorbell();
|
||||
const auto drained = [&control] {
|
||||
return control.eventRingFull.load(std::memory_order_acquire) == 0;
|
||||
const auto signals = session.DataLink()->Signals();
|
||||
Transport::Doorbell& bell = session.DataLink()->ConsumerBell();
|
||||
const auto drained = [signals] {
|
||||
return signals.EventRingFull->load(std::memory_order_acquire) == 0;
|
||||
};
|
||||
for (Uint32 round = 0; round < 2; ++round) {
|
||||
// PUBLISH AND RING FIRST. The client cannot drain a ring whose head it has not
|
||||
// been shown, and the latch Reserve just set is only useful to a client that
|
||||
// gets a bell with it.
|
||||
session.PublishEvents();
|
||||
if (!drained() && !bell.Wait(control.consumerParked, drained, /*spinUs=*/0,
|
||||
if (!drained() && !bell.Wait(*signals.ConsumerParked, drained, /*spinUs=*/0,
|
||||
kEventBacklogWaitMs)) {
|
||||
SessionFail(MGFatalFamily::EventRingOverflow, "MGPipe: Fatal{EventRingOverflow} - %s waited %u ms for the client "
|
||||
"to drain SEG_EVENT and it never did. Under run-ahead the apply "
|
||||
@@ -394,6 +380,11 @@ namespace MobileGL::MG_Remote::Server {
|
||||
|
||||
ServerSession* ServerSession::Active() { return g_active.load(std::memory_order_acquire); }
|
||||
|
||||
ServerSession::ServerSession() {
|
||||
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ServerConsumer);
|
||||
m_commands = &m_link->CommandsIn(); m_events = &m_link->EventsOut();
|
||||
}
|
||||
|
||||
ServerSession::~ServerSession() { Close(); }
|
||||
|
||||
void ServerSession::SetSegmentSizes(const Transport::SessionSegmentSizes& sizes) {
|
||||
@@ -429,7 +420,8 @@ namespace MobileGL::MG_Remote::Server {
|
||||
|
||||
Bool ServerSession::Accepted() const { return m_accepted; }
|
||||
|
||||
MobileGLResult ServerSession::Accept(Transport::ITransport& transport) {
|
||||
MobileGLResult ServerSession::Accept(Transport::ITransport& transport,
|
||||
const std::vector<Uint8>* firstFrame) {
|
||||
ServerSession* expectedOwner = nullptr;
|
||||
if (!g_sessionOwner.compare_exchange_strong(expectedOwner, this,
|
||||
std::memory_order_acq_rel, std::memory_order_acquire)) {
|
||||
@@ -457,7 +449,9 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// ---- 1/2. the ABI assertion, BEFORE a single record is decoded and before a byte of
|
||||
// shared memory exists. Its whole purpose is to refuse to interpret the peer's bytes.
|
||||
std::vector<Uint8> frame;
|
||||
const MobileGLResult received = ReceiveEnvelope(transport, frame, kHandshakeTimeoutMs);
|
||||
if (firstFrame != nullptr) frame = *firstFrame;
|
||||
const MobileGLResult received = firstFrame != nullptr ? MOBILEGL_OK
|
||||
: ReceiveEnvelope(transport, frame, kHandshakeTimeoutMs);
|
||||
if (received != MOBILEGL_OK) {
|
||||
MGLOG_E("MG_Remote server: no Hello within %u ms (rc=%d)", kHandshakeTimeoutMs,
|
||||
static_cast<int>(received));
|
||||
@@ -472,57 +466,69 @@ namespace MobileGL::MG_Remote::Server {
|
||||
if (envelope == nullptr || envelope->msg_type() != ::MobileGL::Wire::CtrlMsg::Hello ||
|
||||
envelope->msg_as_Hello() == nullptr) {
|
||||
MGLOG_E("MG_Remote server: the first control frame is not a verifiable Hello");
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::MalformedHello,
|
||||
"first control frame is not a verifiable Hello");
|
||||
}
|
||||
const ::MobileGL::Wire::Hello* hello = envelope->msg_as_Hello();
|
||||
const char* theirStamp =
|
||||
hello->buildFingerprint() == nullptr ? nullptr : hello->buildFingerprint()->c_str();
|
||||
|
||||
if (hello->abiMajor() != static_cast<Uint32>(MOBILEGL_PROTOCOL_ABI_MAJOR) ||
|
||||
hello->abiMinor() != static_cast<Uint32>(MOBILEGL_PROTOCOL_ABI_MINOR)) {
|
||||
FatalAbiMismatch("protocol version",
|
||||
MOBILEGL_ABI_VERSION(MOBILEGL_PROTOCOL_ABI_MAJOR,
|
||||
MOBILEGL_PROTOCOL_ABI_MINOR),
|
||||
MOBILEGL_ABI_VERSION(hello->abiMajor(), hello->abiMinor()),
|
||||
GIT_COMMIT_HASH_SHORT, theirStamp);
|
||||
}
|
||||
const Uint64 ourFingerprint = CapsAbiFingerprint();
|
||||
if (hello->abiFingerprint() != ourFingerprint) {
|
||||
FatalAbiMismatch("struct shapes", ourFingerprint, hello->abiFingerprint(),
|
||||
GIT_COMMIT_HASH_SHORT, theirStamp);
|
||||
}
|
||||
if (hello->dialMode() != ::MobileGL::Wire::DialMode::No &&
|
||||
hello->dialMode() != ::MobileGL::Wire::DialMode::Fork &&
|
||||
hello->dialMode() != ::MobileGL::Wire::DialMode::Connect)
|
||||
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::MalformedHello,
|
||||
"unknown dial mode");
|
||||
const MobileGLResult compatible = ValidatePeerHandshake(transport, hello->abiMajor(),
|
||||
hello->abiMinor(), hello->wireFingerprint(), theirStamp, hello->dialMode());
|
||||
if (compatible != MOBILEGL_OK) return compatible;
|
||||
const Uint64 ourFingerprint = WireFingerprint();
|
||||
const auto* terms = hello->linkTerms();
|
||||
if (terms == nullptr || terms->wireForm() != ::MobileGL::Wire::WireForm::StructImage ||
|
||||
(terms->dataPlane() != ::MobileGL::Wire::DataPlane::SharedSegments &&
|
||||
terms->dataPlane() != ::MobileGL::Wire::DataPlane::Stream))
|
||||
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::LinkTerms,
|
||||
"unsupported or missing link terms");
|
||||
const bool stream = terms->dataPlane() == ::MobileGL::Wire::DataPlane::Stream;
|
||||
if (stream && transport.Role() == Transport::TransportRole::InProcess)
|
||||
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::LinkTerms,
|
||||
"stream requires a data connection");
|
||||
const char* expectedToken = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||
if (transport.Role() != Transport::TransportRole::InProcess && expectedToken != nullptr &&
|
||||
expectedToken[0] != '\0' && (hello->token() == nullptr ||
|
||||
std::strcmp(hello->token()->c_str(), expectedToken) != 0))
|
||||
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::Authentication,
|
||||
"token mismatch");
|
||||
if (hello->backendType() >= static_cast<Uint32>(BackendType::BackendTypeCount) ||
|
||||
(m_backend != nullptr && hello->backendType() != static_cast<Uint32>(m_backend->GetBackendType())))
|
||||
return RefuseHandshake(transport, ::MobileGL::Wire::RefuseCode::Backend,
|
||||
"backend request differs from server", m_backend == nullptr ? 0 :
|
||||
static_cast<Uint32>(m_backend->GetBackendType()), hello->backendType());
|
||||
|
||||
// ---- 3. the four segments, both control pages, the rings.
|
||||
const MobileGLResult created = m_shm.Create(m_sizes, Transport::MemoryRole::Server);
|
||||
MobileGLResult created = MOBILEGL_ERR_UNSUPPORTED;
|
||||
if (stream) {
|
||||
auto* socket = dynamic_cast<Transport::SocketTransport*>(&transport);
|
||||
if (socket && socket->IsTcp()) created = AttachStreamLink(socket->TakeDataFd(), m_sizes);
|
||||
} else {
|
||||
created = m_link->Memory().Create(m_sizes, Transport::MemoryRole::Server);
|
||||
}
|
||||
if (created != MOBILEGL_OK) {
|
||||
return created;
|
||||
}
|
||||
|
||||
Transport::RingControl* control = m_shm.CmdControl();
|
||||
m_commands = Transport::RingConsumer(control, m_shm.CmdRingBase(), m_shm.CmdRingCapacity(),
|
||||
Transport::RingCursorSet::Cmd);
|
||||
if (!m_commands.Valid()) {
|
||||
m_link->InitializeEndpoints();
|
||||
if (!m_commands->Valid()) {
|
||||
Close();
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
m_consumer.Attach(control, &m_commands, &ProducerDoorbell(), &ConsumerDoorbell(),
|
||||
SpinUsFromConfig());
|
||||
m_link->BindDoorbells(&ConsumerDoorbell(), &ProducerDoorbell());
|
||||
m_consumer.Attach(*m_link, SpinUsFromConfig());
|
||||
m_replies = ReplyPool();
|
||||
m_replies.SetLink(m_link.get());
|
||||
|
||||
{
|
||||
Transport::ReplySlotPool pool(m_shm.ReplyBase(), m_shm.ReplyBytes(),
|
||||
m_shm.ReplySlotCount());
|
||||
if (!pool.Valid()) {
|
||||
Close();
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
// A stale stamp from a previous session must never read as this session's answer.
|
||||
pool.Clear();
|
||||
m_replies = ReplyPool(m_shm.ReplyBase(), m_shm.ReplyBytes(), m_shm.ReplySlotCount(),
|
||||
pool.SlotBytes());
|
||||
}
|
||||
|
||||
m_events = Transport::EventRingProducer(m_shm.EventControl(), control, m_shm.EventRingBase(),
|
||||
m_shm.EventRingCapacity());
|
||||
m_consumer.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
m_replies.SetLink(m_link.get());
|
||||
m_applier = PipeApplier(&m_segments, &m_replies);
|
||||
|
||||
// ---- 4. Welcome: the four SegmentRefs, plus this side's half of the ABI statement.
|
||||
@@ -531,14 +537,18 @@ namespace MobileGL::MG_Remote::Server {
|
||||
using Slot = Transport::SessionSegmentSlot;
|
||||
const auto segmentRef = [&](Uint32 id, ::MobileGL::Wire::SegmentKind kind, Slot slot) {
|
||||
return ::MobileGL::Wire::CreateSegmentRefDirect(builder, id, kind,
|
||||
m_shm.AnnouncedSize(slot),
|
||||
m_shm.AnnouncedName(slot));
|
||||
m_link->Memory().AnnouncedSize(slot),
|
||||
m_link->Memory().AnnouncedName(slot));
|
||||
};
|
||||
auto cmd = segmentRef(1, ::MobileGL::Wire::SegmentKind::Cmd, Slot::Cmd);
|
||||
auto stage = segmentRef(2, ::MobileGL::Wire::SegmentKind::Stage, Slot::Stage);
|
||||
auto reply = segmentRef(3, ::MobileGL::Wire::SegmentKind::Reply, Slot::Reply);
|
||||
auto event = segmentRef(4, ::MobileGL::Wire::SegmentKind::Event, Slot::Event);
|
||||
auto stamp = builder.CreateString(GIT_COMMIT_HASH_SHORT);
|
||||
auto stamp = builder.CreateString(BuildFingerprint());
|
||||
const Uint64 maxReply = m_sizes.ReplyBytes / m_sizes.ReplySlotCount - sizeof(Transport::ReplySlotHeader);
|
||||
auto negotiated = ::MobileGL::Wire::CreateLinkTerms(builder, terms->dataPlane(),
|
||||
::MobileGL::Wire::WireForm::StructImage, maxReply, m_link->Memory().CmdRingCapacity(),
|
||||
m_link->Memory().StageBytes(), m_link->Memory().EventRingCapacity());
|
||||
auto welcome = ::MobileGL::Wire::CreateWelcome(
|
||||
builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR,
|
||||
// CONTRACT-P6 4.3: THE SERVER'S OWN PID, not an echo of the client's.
|
||||
@@ -549,7 +559,8 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// that a same-process session cannot produce, because there the two pids are
|
||||
// equal by construction.
|
||||
static_cast<Uint32>(SelfProcessId()),
|
||||
cmd, stage, reply, event, stamp, ourFingerprint);
|
||||
cmd, stage, reply, event, stamp, ourFingerprint, ourFingerprint, negotiated,
|
||||
m_backend == nullptr ? hello->backendType() : static_cast<Uint32>(m_backend->GetBackendType()));
|
||||
auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
||||
builder, ::MobileGL::Wire::CtrlMsg::Welcome, welcome.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
||||
@@ -571,15 +582,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// w1 lands. That is deliberate and is where the bring-up currently stops: a session
|
||||
// that skipped them and carried on would be a decoder with no segments, which is the
|
||||
// "split lane ran monolith and went green" shape.
|
||||
m_segments.Install(Wire::kSegCmd,
|
||||
Wire::SegmentView{m_shm.CmdRingBase(), m_shm.CmdRingCapacity()});
|
||||
m_segments.Install(Wire::kSegStage,
|
||||
Wire::SegmentView{m_shm.StageBase(), m_shm.StageBytes()});
|
||||
m_segments.Install(Wire::kSegReply,
|
||||
Wire::SegmentView{m_shm.ReplyBase(), m_shm.ReplyBytes()});
|
||||
m_segments.Install(Wire::kSegEvent, Wire::SegmentView{m_shm.EventSegmentBase(),
|
||||
m_shm.AnnouncedSize(
|
||||
Transport::SessionSegmentSlot::Event)});
|
||||
m_segments.AttachLink(m_link.get());
|
||||
m_segments.InstallProcessResolver();
|
||||
|
||||
m_accepted = true;
|
||||
@@ -671,6 +674,26 @@ namespace MobileGL::MG_Remote::Server {
|
||||
return SendEnvelope(*m_transport, builder);
|
||||
}
|
||||
|
||||
MobileGLResult ServerSession::AttachStreamLink(int fd, const Transport::SessionSegmentSizes& sizes) {
|
||||
std::unique_ptr<Transport::ILink> link;
|
||||
const auto attached = Transport::CreateStreamLink(fd, sizes, Transport::TransportRoleTag::ServerConsumer, link);
|
||||
if (attached != MOBILEGL_OK) return attached;
|
||||
AttachDataLink(std::move(link));
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
|
||||
void ServerSession::AttachDataLink(std::unique_ptr<Transport::ILink> link) {
|
||||
m_link = std::move(link);
|
||||
m_commands = &m_link->CommandsIn(); m_events = &m_link->EventsOut();
|
||||
m_consumer.SetLink(m_link->Capabilities().PublishIsDelivery ? nullptr : m_link.get());
|
||||
m_replies.SetLink(m_link.get());
|
||||
if (m_link) SetExternalDoorbells(&m_link->ConsumerBell(), &m_link->ProducerBell());
|
||||
}
|
||||
|
||||
void ServerSession::FlushDataProgress() {
|
||||
if (m_link) m_link->FlushProgress();
|
||||
}
|
||||
|
||||
void ServerSession::Close() {
|
||||
ServerSession* expectedActive = this;
|
||||
g_active.compare_exchange_strong(expectedActive, nullptr,
|
||||
@@ -695,10 +718,13 @@ namespace MobileGL::MG_Remote::Server {
|
||||
}
|
||||
}
|
||||
m_consumer.Detach();
|
||||
m_commands = Transport::RingConsumer();
|
||||
m_events = Transport::EventRingProducer();
|
||||
*m_commands = Transport::RingConsumer();
|
||||
*m_events = Transport::EventRingProducer();
|
||||
m_replies = ReplyPool();
|
||||
m_shm.Close();
|
||||
m_link = Transport::CreateSharedLink(Transport::TransportRoleTag::ServerConsumer);
|
||||
m_commands = &m_link->CommandsIn(); m_events = &m_link->EventsOut();
|
||||
m_externalConsumerBell = nullptr; m_externalProducerBell = nullptr;
|
||||
m_link->Memory().Close();
|
||||
m_transport = nullptr;
|
||||
m_accepted = false;
|
||||
ServerSession* expectedOwner = this;
|
||||
@@ -706,10 +732,10 @@ namespace MobileGL::MG_Remote::Server {
|
||||
std::memory_order_release, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
Transport::RingConsumer& ServerSession::CommandRing() { return m_commands; }
|
||||
Transport::RingConsumer& ServerSession::CommandRing() { return *m_commands; }
|
||||
|
||||
Transport::RingControl& ServerSession::Control() {
|
||||
Transport::RingControl* control = m_shm.CmdControl();
|
||||
Transport::RingControl* control = m_link->Memory().CmdControl();
|
||||
if (control == nullptr) {
|
||||
SessionFail(MGFatalFamily::ProtocolCorruption, "MGPipe: Fatal{ProtocolCorruption, \"ServerSession::Control\"} - the control "
|
||||
"page does not exist until Accept() has mapped SEG_CMD");
|
||||
@@ -766,9 +792,9 @@ namespace MobileGL::MG_Remote::Server {
|
||||
static_cast<unsigned>(m_transport->Role()));
|
||||
}
|
||||
|
||||
Transport::SessionSegments& ServerSession::Shm() { return m_shm; }
|
||||
Transport::SessionSegments& ServerSession::Shm() { return m_link->Memory(); }
|
||||
Transport::SessionConsumer& ServerSession::Consumer() { return m_consumer; }
|
||||
Transport::EventRingProducer& ServerSession::Events() { return m_events; }
|
||||
Transport::EventRingProducer& ServerSession::Events() { return *m_events; }
|
||||
Transport::ITransport* ServerSession::Control_Plane() { return m_transport; }
|
||||
|
||||
void ServerSession::PublishEvents() {
|
||||
@@ -777,8 +803,9 @@ namespace MobileGL::MG_Remote::Server {
|
||||
}
|
||||
// Publish, THEN ring - the same order as the forward direction, and the session picks
|
||||
// the bell so that no caller can pair the right ring with the wrong flag.
|
||||
m_events.Ring().Publish();
|
||||
m_events->Ring().Publish();
|
||||
m_consumer.NotifyClient();
|
||||
FlushDataProgress();
|
||||
}
|
||||
|
||||
void ServerSession::PostGlError(Uint32 code, const char* message) {
|
||||
@@ -820,13 +847,16 @@ namespace MobileGL::MG_Remote::Server {
|
||||
return;
|
||||
}
|
||||
m_consumer.CompleteFrame(serial);
|
||||
FlushDataProgress();
|
||||
}
|
||||
|
||||
void ServerSession::ReturnPresentCredit(Uint64 serial) {
|
||||
if (!m_accepted) {
|
||||
return;
|
||||
}
|
||||
Transport::LinkMetricsServerPresent(serial);
|
||||
m_consumer.ReturnPresentCredit(serial);
|
||||
FlushDataProgress();
|
||||
}
|
||||
|
||||
Transport::RoleMemorySample ServerSession::SampleMemory() const {
|
||||
|
||||
@@ -40,7 +40,9 @@
|
||||
// refused to exist until both landed would block every other package's bring-up.
|
||||
|
||||
#pragma once
|
||||
#include "../Transport/ILink.h"
|
||||
#include <Includes.h>
|
||||
#include <vector>
|
||||
|
||||
#include <MG_Pipe/MGPipe.h>
|
||||
|
||||
@@ -60,13 +62,19 @@ namespace MobileGL::MG_Remote::Server {
|
||||
public:
|
||||
static ServerSession* Active();
|
||||
|
||||
ServerSession();
|
||||
~ServerSession();
|
||||
MobileGLResult AttachStreamLink(int dataFd, const Transport::SessionSegmentSizes& sizes);
|
||||
void AttachDataLink(std::unique_ptr<Transport::ILink> link);
|
||||
Transport::ILink* DataLink() const { return m_link.get(); }
|
||||
void FlushDataProgress();
|
||||
|
||||
// Maps the four segments, answers Hello with Welcome, and publishes the first
|
||||
// CapsSnapshot. The ABI assertion (CapsCodec.h) happens HERE, before a single record is
|
||||
// decoded: sizeof(DynamicBackendParameters), sizeof(MGPCaps), sizeof(GLFunctionsTable)
|
||||
// and the build fingerprint must match, and a mismatch is Fatal{AbiMismatch}.
|
||||
MobileGLResult Accept(Transport::ITransport& transport);
|
||||
MobileGLResult Accept(Transport::ITransport& transport,
|
||||
const std::vector<Uint8>* firstFrame = nullptr);
|
||||
|
||||
// Re-publishes the whole snapshot. R-12: a SECOND arrival IS the invalidation signal,
|
||||
// which is how DirectGLES - which has no OnCapsInvalidated producer - tells the client
|
||||
@@ -199,17 +207,17 @@ namespace MobileGL::MG_Remote::Server {
|
||||
void LogMemory(const char* phase) const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Transport::ILink> m_link;
|
||||
// sm: non-owning; the spawn entry point owns the SocketDoorbells.
|
||||
Transport::Doorbell* m_externalConsumerBell = nullptr;
|
||||
Transport::Doorbell* m_externalProducerBell = nullptr;
|
||||
Transport::RingConsumer m_commands;
|
||||
Transport::RingConsumer* m_commands = nullptr;
|
||||
Wire::SegmentTable m_segments;
|
||||
PipeApplier m_applier;
|
||||
ReplyPool m_replies;
|
||||
|
||||
Transport::SessionSegments m_shm;
|
||||
Transport::SessionConsumer m_consumer;
|
||||
Transport::EventRingProducer m_events;
|
||||
Transport::EventRingProducer* m_events = nullptr;
|
||||
Transport::ITransport* m_transport = nullptr;
|
||||
MG_Backend::BackendObject* m_backend = nullptr;
|
||||
Transport::SessionSegmentSizes m_sizes;
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace MobileGL::MG_Remote::Server {
|
||||
Bool ok = false;
|
||||
Int eglMajor = 0;
|
||||
Int eglMinor = 0;
|
||||
Uint64 eventHead = 0; // data-plane delivery fence carried by SurfaceReply
|
||||
};
|
||||
|
||||
namespace Detail {
|
||||
@@ -110,14 +111,15 @@ namespace MobileGL::MG_Remote::Server {
|
||||
// Exhaustive by the language's aggregate decomposition rule: adding ANY member
|
||||
// without extending this binding is a compile error, so new fields cannot evade it.
|
||||
const auto& [kind, seq, display, surface, readSurface, context, windowBackend,
|
||||
nativeToken, width, height, swapInterval, ok, eglMajor, eglMinor] = frame;
|
||||
nativeToken, width, height, swapInterval, ok, eglMajor, eglMinor, eventHead] = frame;
|
||||
return IsSurfaceControlValue<decltype(kind)> && IsSurfaceControlValue<decltype(seq)> &&
|
||||
IsSurfaceControlValue<decltype(display)> && IsSurfaceControlValue<decltype(surface)> &&
|
||||
IsSurfaceControlValue<decltype(readSurface)> && IsSurfaceControlValue<decltype(context)> &&
|
||||
IsSurfaceControlValue<decltype(windowBackend)> && IsSurfaceControlValue<decltype(nativeToken)> &&
|
||||
IsSurfaceControlValue<decltype(width)> && IsSurfaceControlValue<decltype(height)> &&
|
||||
IsSurfaceControlValue<decltype(swapInterval)> && IsSurfaceControlValue<decltype(ok)> &&
|
||||
IsSurfaceControlValue<decltype(eglMajor)> && IsSurfaceControlValue<decltype(eglMinor)>;
|
||||
IsSurfaceControlValue<decltype(eglMajor)> && IsSurfaceControlValue<decltype(eglMinor)> &&
|
||||
IsSurfaceControlValue<decltype(eventHead)>;
|
||||
}
|
||||
} // namespace Detail
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "ControlInbox.h"
|
||||
#include "Doorbell.h"
|
||||
#include "../Protocol/SurfaceOpCodec.h"
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
#include <chrono>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
ControlInbox::ControlInbox(ITransport& transport) : m_transport(transport), m_reader([this] { Read(); }) {}
|
||||
ControlInbox::~ControlInbox() { Stop(); }
|
||||
|
||||
void ControlInbox::Stop() {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
m_stop = true;
|
||||
m_cv.notify_all();
|
||||
}
|
||||
// Receive uses a short bounded wait, so no shutdown of the data plane is needed.
|
||||
if (m_reader.joinable()) m_reader.join();
|
||||
}
|
||||
|
||||
void ControlInbox::Read() {
|
||||
for (;;) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_stop) return;
|
||||
}
|
||||
std::uint64_t size = 0;
|
||||
auto result = m_transport.ReceiveFrame({nullptr, 0}, &size, 100);
|
||||
if (result == MOBILEGL_ERR_TIMEOUT) continue;
|
||||
std::vector<std::uint8_t> frame;
|
||||
if (result == MOBILEGL_ERR_BUFFER_TOO_SMALL && size <= 64ull * 1024 * 1024) {
|
||||
frame.resize(static_cast<std::size_t>(size));
|
||||
result = m_transport.ReceiveFrame({frame.data(), frame.size()}, &size, 0);
|
||||
}
|
||||
if (result == MOBILEGL_OK) {
|
||||
flatbuffers::Verifier verifier(frame.data(), frame.size());
|
||||
if (!::MobileGL::Wire::VerifyCtrlEnvelopeBuffer(verifier)) result = MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
else {
|
||||
const auto* envelope = ::MobileGL::Wire::GetCtrlEnvelope(frame.data());
|
||||
if (const auto* log = envelope->msg_as_LogLine()) {
|
||||
if (log->text()) MG_Util::Debug::WritePeerLog(log->text()->c_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
if (result != MOBILEGL_OK) {
|
||||
m_result = result;
|
||||
m_cv.notify_all();
|
||||
return;
|
||||
}
|
||||
m_cv.wait(lock, [&] { return m_stop || (m_frames.size() < 256 && m_bytes < 64ull * 1024 * 1024); });
|
||||
if (m_stop) return;
|
||||
m_bytes += frame.size();
|
||||
m_frames.push_back(std::move(frame));
|
||||
m_cv.notify_all();
|
||||
}
|
||||
}
|
||||
|
||||
MobileGLResult ControlInbox::Receive(std::vector<std::uint8_t>& frame, std::uint32_t timeoutMs) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
const auto ready = [&] { return m_stop || !m_frames.empty() || m_result != MOBILEGL_OK; };
|
||||
if (timeoutMs == kWaitForever) m_cv.wait(lock, ready);
|
||||
else if (!m_cv.wait_for(lock, std::chrono::milliseconds(timeoutMs), ready)) return MOBILEGL_ERR_TIMEOUT;
|
||||
if (m_frames.empty()) return m_result == MOBILEGL_OK ? MOBILEGL_ERR_TRANSPORT_CLOSED : m_result;
|
||||
frame = std::move(m_frames.front());
|
||||
m_frames.pop_front();
|
||||
m_bytes -= frame.size();
|
||||
m_cv.notify_all();
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
|
||||
std::uint64_t ControlInbox::Peek() {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
return m_frames.empty() ? 0 : m_frames.front().size();
|
||||
}
|
||||
bool ControlInbox::WaitClosed(std::uint32_t timeoutMs) {
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
// Teardown has no outstanding control caller; discard queued snapshots
|
||||
// so the reader can always reach EOF through its bounded inbox.
|
||||
const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
||||
for (;;) {
|
||||
m_frames.clear();
|
||||
m_bytes = 0;
|
||||
m_cv.notify_all();
|
||||
if (m_result != MOBILEGL_OK || m_stop) return true;
|
||||
if (m_cv.wait_until(lock, deadline) == std::cv_status::timeout) return m_result != MOBILEGL_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "ITransport.h"
|
||||
#include <condition_variable>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
// The control reader remains runnable while the GL thread waits on data.
|
||||
// Log forwarding can therefore never fill a socket and block the applier.
|
||||
class ControlInbox {
|
||||
public:
|
||||
explicit ControlInbox(ITransport& transport);
|
||||
~ControlInbox();
|
||||
void Stop();
|
||||
MobileGLResult Receive(std::vector<std::uint8_t>& frame, std::uint32_t timeoutMs);
|
||||
std::uint64_t Peek();
|
||||
bool WaitClosed(std::uint32_t timeoutMs);
|
||||
private:
|
||||
void Read();
|
||||
ITransport& m_transport;
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_cv;
|
||||
std::deque<std::vector<std::uint8_t>> m_frames;
|
||||
std::uint64_t m_bytes = 0;
|
||||
bool m_stop = false;
|
||||
MobileGLResult m_result = MOBILEGL_OK;
|
||||
std::thread m_reader;
|
||||
};
|
||||
}
|
||||
@@ -186,6 +186,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// finished with every payload pointer it popped: a writeback's bytes live
|
||||
// in the ring itself, so retiring early is the R-11 violation one level
|
||||
// down.
|
||||
void SetLink(ILink* link) { m_link = link; }
|
||||
void Drained() {
|
||||
m_consumer.PublishRetired();
|
||||
if (m_cmdControl != nullptr) {
|
||||
@@ -202,6 +203,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
NotifyIfParked(*m_serverBell, m_cmdControl->consumerParked);
|
||||
}
|
||||
}
|
||||
if (m_link) m_link->Flush();
|
||||
}
|
||||
|
||||
// The bell the SERVER parks on, lent by the session so that Drained() can ring it.
|
||||
@@ -231,6 +233,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
private:
|
||||
RingControl* m_cmdControl = nullptr;
|
||||
ILink* m_link = nullptr;
|
||||
RingConsumer m_consumer;
|
||||
const std::uint8_t* m_segmentBase = nullptr;
|
||||
// P5e (ra): the server's bell, rung by Drained() when it cleared a full latch.
|
||||
|
||||
@@ -79,6 +79,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// Incremental frame extractor over a raw byte stream.
|
||||
class FrameReader {
|
||||
public:
|
||||
explicit FrameReader(std::uint32_t expectedMagic = kFrameMagic) : m_expectedMagic(expectedMagic) {}
|
||||
|
||||
// Feeds raw stream bytes. Validates the frame header the moment enough
|
||||
// bytes for one exist - a bad magic or an oversized length is reported
|
||||
// here, not swallowed.
|
||||
@@ -163,11 +165,11 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
std::uint32_t length = 0;
|
||||
std::memcpy(&magic, m_buffer.data() + m_readPos, sizeof(magic));
|
||||
std::memcpy(&length, m_buffer.data() + m_readPos + 4, sizeof(length));
|
||||
if (magic != kFrameMagic) {
|
||||
if (magic != m_expectedMagic) {
|
||||
m_failed = true;
|
||||
WireLogError("MG_Remote framing: bad frame magic 0x%08X (expected 0x%08X); the "
|
||||
"control stream is desynchronized and this transport is now dead",
|
||||
magic, kFrameMagic);
|
||||
magic, m_expectedMagic);
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
if (length > kMaxFramePayloadSize) {
|
||||
@@ -203,6 +205,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
std::uint64_t m_pendingSize = 0;
|
||||
bool m_haveHeader = false;
|
||||
bool m_failed = false;
|
||||
std::uint32_t m_expectedMagic = kFrameMagic;
|
||||
};
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
|
||||
@@ -72,10 +72,17 @@
|
||||
#include <atomic>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
class Doorbell;
|
||||
class SessionSegments;
|
||||
struct SessionSegmentSizes;
|
||||
class RingProducer;
|
||||
class RingConsumer;
|
||||
class EventRingProducer;
|
||||
class EventRingConsumer;
|
||||
|
||||
// Which end of the link this instance is. Deliberately NOT ITransport's
|
||||
// TransportRole: that enum's InProcess value names a control-plane
|
||||
@@ -194,6 +201,16 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
std::uint64_t MaxReplyBytes = 0;
|
||||
};
|
||||
|
||||
// Non-owning synchronization addresses, acquired once at attachment. They
|
||||
// denote process-local atomics on a stream and shared atomics on a mapping.
|
||||
struct LinkSignals {
|
||||
std::atomic<std::uint64_t>* CmdHead = nullptr;
|
||||
std::atomic<std::uint64_t>* SubmittedSeq = nullptr;
|
||||
std::atomic<std::uint32_t>* ConsumerParked = nullptr;
|
||||
std::atomic<std::uint32_t>* ProducerParked = nullptr;
|
||||
std::atomic<std::uint32_t>* EventRingFull = nullptr;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The seam itself.
|
||||
//
|
||||
@@ -211,6 +228,19 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
virtual LinkCapabilities Capabilities() const = 0;
|
||||
|
||||
// Setup views. Ownership remains in the link; callers cache the ring
|
||||
// endpoint once so reserve/pop and spin predicates remain non-virtual.
|
||||
virtual SessionSegments& Memory() = 0;
|
||||
virtual void InitializeEndpoints() = 0;
|
||||
LinkSignals Signals();
|
||||
std::uint64_t SegmentSize(LinkSegment segment);
|
||||
virtual RingProducer& CommandsOut() = 0;
|
||||
virtual RingConsumer& CommandsIn() = 0;
|
||||
virtual EventRingProducer& EventsOut() = 0;
|
||||
virtual EventRingConsumer& EventsIn() = 0;
|
||||
virtual void BindDoorbells(Doorbell*, Doorbell*) {}
|
||||
|
||||
|
||||
// The watermark block. Taken once; every wait predicate reads through
|
||||
// the returned pointer with no further virtual dispatch. Never null on
|
||||
// an attached link.
|
||||
@@ -259,6 +289,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
virtual LinkArena* EventArena() = 0;
|
||||
virtual LinkCursor* EventCursor() = 0;
|
||||
virtual std::uint64_t EventPublishedHead() const = 0;
|
||||
virtual MobileGLResult WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) = 0;
|
||||
|
||||
// ---- wakeups --------------------------------------------------------
|
||||
//
|
||||
@@ -289,6 +321,14 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// waiting on. The second method writing StreamLink revealed.
|
||||
virtual MobileGLResult FlushProgress() = 0;
|
||||
|
||||
// The encoder keeps its established stage allocator; the link tracks only the
|
||||
// newly written spans that must precede command delivery.
|
||||
virtual void NoteStage(LinkSpan) {}
|
||||
// Called after local progress advances. Stream links coalesce transmission;
|
||||
// the explicit FlushProgress at every park remains mandatory.
|
||||
virtual void ProgressChanged() {}
|
||||
virtual bool PeerHungUp() const { return false; }
|
||||
|
||||
// ---- lifecycle -------------------------------------------------------
|
||||
|
||||
virtual bool Attached() const = 0;
|
||||
@@ -299,4 +339,9 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
ILink() = default;
|
||||
};
|
||||
|
||||
// Setup factories keep concrete link selection out of codec/session code.
|
||||
std::unique_ptr<ILink> CreateSharedLink(TransportRoleTag role);
|
||||
MobileGLResult CreateStreamLink(int fd, const SessionSegmentSizes& sizes,
|
||||
TransportRoleTag role, std::unique_ptr<ILink>& out);
|
||||
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
#include "LinkMetrics.h"
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#if !defined(_WIN32)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
namespace {
|
||||
struct Window {
|
||||
std::uint64_t waitReplies = 0, samples = 0, replyNs = 0, stageBytes = 0;
|
||||
std::array<std::uint64_t, 32> histogram{};
|
||||
};
|
||||
// The client already has exactly one record producer. The server never writes these.
|
||||
struct Metrics {
|
||||
bool active = false;
|
||||
std::uint64_t frame = 0, started = 0, lastFrame = 0, cpuStarted = 0, cpuLast = 0;
|
||||
Window total{}, current{};
|
||||
} metrics;
|
||||
std::uint64_t ClockNs() {
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||
}
|
||||
std::uint64_t ThreadCpuNs() {
|
||||
#if defined(CLOCK_THREAD_CPUTIME_ID)
|
||||
timespec value{};
|
||||
if (::clock_gettime(CLOCK_THREAD_CPUTIME_ID, &value) == 0)
|
||||
return std::uint64_t(value.tv_sec) * 1000000000ull + value.tv_nsec;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
std::uint64_t QuantileUpperUs(const Window& w, unsigned percentile) {
|
||||
if (w.samples == 0) return 0;
|
||||
const auto target = (w.samples * percentile + 99) / 100;
|
||||
std::uint64_t count = 0;
|
||||
for (unsigned i = 0; i < w.histogram.size(); ++i) {
|
||||
count += w.histogram[i];
|
||||
if (count >= target) return 1ull << i;
|
||||
}
|
||||
return 1ull << 31;
|
||||
}
|
||||
void Emit(const char* kind, const Window& w, std::uint64_t wallNs, std::uint64_t cpuNs) {
|
||||
char histogram[768]{};
|
||||
std::size_t at = 0;
|
||||
for (unsigned i = 0; i < w.histogram.size(); ++i) {
|
||||
const int n = std::snprintf(histogram + at, sizeof(histogram) - at, "%s%llu",
|
||||
i == 0 ? "" : ",", static_cast<unsigned long long>(w.histogram[i]));
|
||||
if (n < 0 || static_cast<std::size_t>(n) >= sizeof(histogram) - at) break;
|
||||
at += static_cast<std::size_t>(n);
|
||||
}
|
||||
MGLOG_I("P65LinkMetrics kind=%s frame=%llu wait_replies=%llu rtt_samples=%llu "
|
||||
"rtt_mean_us=%.3f rtt_p50_upper_us=%llu rtt_p99_upper_us=%llu "
|
||||
"stage_bytes=%llu wall_ns=%llu client_thread_cpu_ns=%llu rtt_hist_us_pow2=%s",
|
||||
kind, static_cast<unsigned long long>(metrics.frame),
|
||||
static_cast<unsigned long long>(w.waitReplies), static_cast<unsigned long long>(w.samples),
|
||||
w.samples == 0 ? 0.0 : double(w.replyNs) / double(w.samples) / 1000.0,
|
||||
static_cast<unsigned long long>(QuantileUpperUs(w, 50)),
|
||||
static_cast<unsigned long long>(QuantileUpperUs(w, 99)),
|
||||
static_cast<unsigned long long>(w.stageBytes), static_cast<unsigned long long>(wallNs),
|
||||
static_cast<unsigned long long>(cpuNs), histogram);
|
||||
}
|
||||
}
|
||||
void LinkMetricsBegin() {
|
||||
metrics = {};
|
||||
const char* enabled = std::getenv("MOBILEGL_PIPE_STATS");
|
||||
metrics.active = enabled != nullptr && std::strcmp(enabled, "1") == 0;
|
||||
if (!metrics.active) return;
|
||||
metrics.started = metrics.lastFrame = ClockNs();
|
||||
metrics.cpuStarted = metrics.cpuLast = ThreadCpuNs();
|
||||
}
|
||||
std::uint64_t LinkMetricsBeginReply(bool wantsReply) {
|
||||
if (!metrics.active || !wantsReply) return 0;
|
||||
++metrics.current.waitReplies; ++metrics.total.waitReplies;
|
||||
return ClockNs();
|
||||
}
|
||||
void LinkMetricsReplyApplied(std::uint64_t startedNs) {
|
||||
if (!metrics.active || startedNs == 0) return;
|
||||
const auto ns = ClockNs() - startedNs;
|
||||
const auto us = (ns + 999) / 1000;
|
||||
unsigned bucket = 0;
|
||||
while (bucket < 31 && us > (1ull << bucket)) ++bucket;
|
||||
for (Window* w : {&metrics.current, &metrics.total}) {
|
||||
++w->samples; w->replyNs += ns; ++w->histogram[bucket];
|
||||
}
|
||||
}
|
||||
void LinkMetricsStageBytes(std::uint64_t bytes) {
|
||||
if (!metrics.active) return;
|
||||
metrics.current.stageBytes += bytes; metrics.total.stageBytes += bytes;
|
||||
}
|
||||
void LinkMetricsPresent() {
|
||||
if (!metrics.active) return;
|
||||
++metrics.frame;
|
||||
const auto now = ClockNs(), cpu = ThreadCpuNs();
|
||||
Emit("frame", metrics.current, now - metrics.lastFrame, cpu - metrics.cpuLast);
|
||||
metrics.current = {}; metrics.lastFrame = now; metrics.cpuLast = cpu;
|
||||
}
|
||||
void LinkMetricsEnd() {
|
||||
if (!metrics.active) return;
|
||||
Emit("summary", metrics.total, ClockNs() - metrics.started, ThreadCpuNs() - metrics.cpuStarted);
|
||||
metrics.active = false;
|
||||
}
|
||||
void LinkMetricsServerPresent(std::uint64_t serial) {
|
||||
// Independent of the client latch: spawn servers never call LinkMetricsBegin.
|
||||
// The baseline belongs to the apply thread, and is discarded if that thread is replaced.
|
||||
static thread_local const bool enabled = [] {
|
||||
const char* value = std::getenv("MOBILEGL_PIPE_STATS");
|
||||
return value != nullptr && std::strcmp(value, "1") == 0;
|
||||
}();
|
||||
if (!enabled) return;
|
||||
static thread_local std::uint64_t previousSerial = 0, previousWall = 0, previousCpu = 0;
|
||||
const auto wall = ClockNs(), cpu = ThreadCpuNs();
|
||||
const bool valid = previousWall != 0 && serial > previousSerial && cpu >= previousCpu;
|
||||
MGLOG_I("P65ServerMetrics frame=%llu valid=%u wall_ns=%llu apply_thread_cpu_ns=%llu",
|
||||
static_cast<unsigned long long>(serial), valid ? 1u : 0u,
|
||||
static_cast<unsigned long long>(valid ? wall - previousWall : 0),
|
||||
static_cast<unsigned long long>(valid ? cpu - previousCpu : 0));
|
||||
previousSerial = serial; previousWall = wall; previousCpu = cpu;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// P6.5 transport measurements. Called only by the single client producer.
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
// Disabled sessions never read a clock. Samples are a fixed 32-bucket histogram.
|
||||
void LinkMetricsBegin();
|
||||
void LinkMetricsEnd();
|
||||
std::uint64_t LinkMetricsBeginReply(bool wantsReply);
|
||||
void LinkMetricsReplyApplied(std::uint64_t startedNs);
|
||||
void LinkMetricsStageBytes(std::uint64_t bytes);
|
||||
void LinkMetricsPresent();
|
||||
void LinkMetricsServerPresent(std::uint64_t serial);
|
||||
}
|
||||
@@ -257,6 +257,19 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
std::memcpy(slot, &header, sizeof(header));
|
||||
}
|
||||
|
||||
// The link can lend the immutable payload after appliedSeq without a
|
||||
// second copy. The same seq and size honesty checks guard both readers.
|
||||
bool ReadView(std::uint64_t seq, std::int32_t* status, const void** payload,
|
||||
std::uint64_t* size) const {
|
||||
if (!m_base || !seq || !status || !payload || !size) return false;
|
||||
const auto* slot = SlotAt(seq);
|
||||
ReplySlotHeader header{}; std::memcpy(&header, slot, sizeof header);
|
||||
std::atomic_thread_fence(std::memory_order_acquire);
|
||||
if (header.Seq != seq || header.Size > MaxReplyBytes()) return false;
|
||||
*status = header.Status; *size = header.Size;
|
||||
*payload = slot + sizeof header; return true;
|
||||
}
|
||||
|
||||
// Client side. Returns false when the slot does not carry THIS seq - the
|
||||
// self-check the stamp exists for. `outBytes` may be null for an answer
|
||||
// with no payload (every DECLINE, and the four Bool acceptances).
|
||||
|
||||
@@ -417,6 +417,11 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// SessionProducer
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void SessionProducer::Attach(ILink& link, std::uint32_t spinUs) {
|
||||
Attach(link.Memory().CmdControl(), &link.CommandsOut(), &link.ConsumerBell(), &link.ProducerBell(), spinUs);
|
||||
SetLink(link.Capabilities().PublishIsDelivery ? nullptr : &link);
|
||||
}
|
||||
|
||||
void SessionProducer::Attach(RingControl* control, RingProducer* cmd, Doorbell* peerBell,
|
||||
Doorbell* selfBell, std::uint32_t spinUs) {
|
||||
m_control = control;
|
||||
@@ -432,6 +437,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
m_peerBell = nullptr;
|
||||
m_selfBell = nullptr;
|
||||
m_lastPublishedSeq = 0;
|
||||
m_link = nullptr;
|
||||
}
|
||||
|
||||
void SessionProducer::PublishAndNotify(std::uint64_t submittedSeq) {
|
||||
@@ -469,6 +475,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// COUNTED BEFORE THE WAIT AND ONLY WHEN ONE REALLY HAPPENS - after the two refusals
|
||||
// above, which answer TimedOut without ever reaching the bell. See Waits()/Parks() in
|
||||
// the header for why the pair is the reading and either number alone is not.
|
||||
if (m_link && m_link->Flush() != MOBILEGL_OK) return SessionWait::ShutDown;
|
||||
m_waits.fetch_add(1, std::memory_order_relaxed);
|
||||
// &m_parks is the OTHER half of the pair, and it is passed rather than read off the
|
||||
// bell: the bell is this endpoint's and the encoder waits on it too, so its own
|
||||
@@ -547,6 +554,11 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// SessionConsumer
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
void SessionConsumer::Attach(ILink& link, std::uint32_t spinUs) {
|
||||
Attach(link.Memory().CmdControl(), &link.CommandsIn(), &link.ProducerBell(), &link.ConsumerBell(), spinUs);
|
||||
SetLink(link.Capabilities().PublishIsDelivery ? nullptr : &link);
|
||||
}
|
||||
|
||||
void SessionConsumer::Attach(RingControl* control, RingConsumer* cmd, Doorbell* peerBell,
|
||||
Doorbell* selfBell, std::uint32_t spinUs) {
|
||||
m_control = control;
|
||||
@@ -566,6 +578,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
m_selfBell = nullptr;
|
||||
m_retirableCursor = 0;
|
||||
m_borrowHeld = false;
|
||||
m_link = nullptr;
|
||||
}
|
||||
|
||||
SessionWait SessionConsumer::WaitForWork(std::uint32_t timeoutMs) {
|
||||
@@ -574,6 +587,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
RingControl* control = m_control;
|
||||
RingConsumer* cmd = m_cmd;
|
||||
if (m_link && m_link->FlushProgress() != MOBILEGL_OK) return SessionWait::ShutDown;
|
||||
const bool woke = m_selfBell->Wait(
|
||||
control->consumerParked,
|
||||
[control, cmd] {
|
||||
@@ -647,6 +661,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
|
||||
void SessionConsumer::NotifyClient() {
|
||||
if (m_link) m_link->ProgressChanged();
|
||||
if (m_control != nullptr && m_peerBell != nullptr) {
|
||||
NotifyIfParked(*m_peerBell, m_control->producerParked);
|
||||
}
|
||||
@@ -671,29 +686,19 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
};
|
||||
mix(inputs.DynamicParamsSize);
|
||||
mix(inputs.CapsSize);
|
||||
mix(inputs.FunctionTableSize);
|
||||
mix(inputs.MemberLayout);
|
||||
mix(inputs.CatalogueLayout);
|
||||
mix(inputs.RenderStateLayout);
|
||||
mix(inputs.FormatCapabilityTargets);
|
||||
mix(inputs.FormatCapabilityFormats);
|
||||
mix(inputs.FormatCapabilitiesCodecVersion);
|
||||
mix(inputs.RendererInfoCodecVersion);
|
||||
mix(inputs.ProgramArtifactsCodecVersion);
|
||||
mix(inputs.ProgramArtifactsSchema);
|
||||
mix(inputs.OpCount);
|
||||
mix(inputs.AbiVersion);
|
||||
// CONTRACT-P6 4.2: THE BUILD SYSTEM'S OWN ANSWER, mixed before the bytes and separately
|
||||
// from them. `BuildStampPresent == 0` means the build could not determine a commit at
|
||||
// all; that is a different claim from "the commit is the empty string", and before this
|
||||
// field existed the two collapsed - so every stampless build agreed with every other,
|
||||
// which is the exact agreement the stamp is there to refuse.
|
||||
mix(inputs.BuildStampPresent);
|
||||
// A presence marker before the bytes, so that "no stamp" (nullptr) and
|
||||
// "an empty stamp" ("") are different inputs rather than the same
|
||||
// absence of bytes.
|
||||
mix(inputs.BuildStamp != nullptr ? 1u : 0u);
|
||||
if (inputs.BuildStamp != nullptr) {
|
||||
for (const char* c = inputs.BuildStamp; *c != '\0'; ++c) {
|
||||
hash ^= static_cast<std::uint64_t>(static_cast<unsigned char>(*c));
|
||||
hash *= 1099511628211ull;
|
||||
}
|
||||
}
|
||||
mix(inputs.PointerBits);
|
||||
mix(inputs.LittleEndian);
|
||||
// 0 is reserved for "not stated": a peer that forgot to fill the field
|
||||
// must not accidentally agree with one that did.
|
||||
return hash == 0 ? 1ull : hash;
|
||||
|
||||
@@ -138,6 +138,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// Creates and maps all four, initialises BOTH control pages (SEG_CMD's
|
||||
// and SEG_EVENT's), and books the mapping in `role`'s ledger.
|
||||
MobileGLResult Create(const SessionSegmentSizes& sizes, MemoryRole role);
|
||||
// Private, identically addressed mirrors for the stream data plane.
|
||||
MobileGLResult CreatePrivate(const SessionSegmentSizes& sizes, MemoryRole role);
|
||||
|
||||
// The inproc peer's view of the owner's four segments, booked under the
|
||||
// OTHER role. It does NOT re-init the control pages - there is one shared
|
||||
@@ -210,6 +212,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
private:
|
||||
void DeriveViews();
|
||||
|
||||
void* m_private[4] = {};
|
||||
std::uint64_t m_privateSizes[4] = {};
|
||||
ShmSegment m_owned[4]; // empty on an attached (peer) view
|
||||
ShmSegment* m_segments[4] = {nullptr, nullptr, nullptr, nullptr};
|
||||
|
||||
@@ -314,9 +318,11 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// stageHead with nothing advancing the two tails, so FreeBytes() would
|
||||
// fall to zero the first time the head lapped the capacity and never
|
||||
// recover: a guaranteed hang, not a slow path.
|
||||
void Attach(ILink& link, std::uint32_t spinUs);
|
||||
void Attach(RingControl* control, RingProducer* cmd, Doorbell* peerBell, Doorbell* selfBell,
|
||||
std::uint32_t spinUs);
|
||||
void Detach();
|
||||
void SetLink(ILink* link) { m_link = link; }
|
||||
bool Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
||||
|
||||
// Publish the command ring's head, record submittedSeq, THEN ring - in
|
||||
@@ -365,6 +371,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// stalls forever.
|
||||
SessionWait WaitForCmdSpace(std::uint64_t bytes, std::uint32_t timeoutMs);
|
||||
|
||||
LinkProgress* Progress() const { return m_control ? &m_control->Progress : nullptr; }
|
||||
RingControl* Control() const { return m_control; }
|
||||
RingProducer* Cmd() const { return m_cmd; }
|
||||
Doorbell* PeerDoorbell() const { return m_peerBell; }
|
||||
@@ -398,6 +405,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
template <class Ready>
|
||||
SessionWait Park(Ready&& ready, std::uint32_t timeoutMs);
|
||||
|
||||
ILink* m_link = nullptr;
|
||||
RingControl* m_control = nullptr;
|
||||
RingProducer* m_cmd = nullptr;
|
||||
Doorbell* m_peerBell = nullptr;
|
||||
@@ -420,9 +428,11 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
public:
|
||||
SessionConsumer() = default;
|
||||
|
||||
void Attach(ILink& link, std::uint32_t spinUs);
|
||||
void Attach(RingControl* control, RingConsumer* cmd, Doorbell* peerBell, Doorbell* selfBell,
|
||||
std::uint32_t spinUs);
|
||||
void Detach();
|
||||
void SetLink(ILink* link) { m_link = link; }
|
||||
bool Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
||||
|
||||
// Park until a record is waiting, the session is shut down, or the
|
||||
@@ -520,6 +530,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// How many kRecBorrowSlot records this consumer has seen. Non-zero in P5
|
||||
// is a finding, not a statistic.
|
||||
std::uint64_t BorrowedRecordsSeen() const { return m_borrowedSeen; }
|
||||
LinkProgress* Progress() const { return m_control ? &m_control->Progress : nullptr; }
|
||||
RingControl* Control() const { return m_control; }
|
||||
RingConsumer* Cmd() const { return m_cmd; }
|
||||
Doorbell* PeerDoorbell() const { return m_peerBell; }
|
||||
@@ -527,6 +538,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
std::uint32_t SpinUs() const { return m_spinUs; }
|
||||
|
||||
private:
|
||||
ILink* m_link = nullptr;
|
||||
RingControl* m_control = nullptr;
|
||||
RingConsumer* m_cmd = nullptr;
|
||||
Doorbell* m_peerBell = nullptr;
|
||||
@@ -543,58 +555,27 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// The ABI fingerprint's mixer - THE ONE IMPLEMENTATION.
|
||||
//
|
||||
// CapsCodec.cpp's CapsAbiFingerprint(), the value both handshakes compare,
|
||||
// is exactly MixAbiFingerprint(CapsAbiFingerprintInputs()). It lives under
|
||||
// Transport/ so that it can be tested without the GL frontend's umbrella
|
||||
// header, and it takes its inputs as a struct so that the SAME function the
|
||||
// handshake calls can be driven with one field perturbed at a time.
|
||||
//
|
||||
// The wave-1 review (ID-46 finding 6) found the previous shape - a
|
||||
// five-argument mixer here and a SEPARATE hand-rolled FNV loop in
|
||||
// CapsCodec.cpp - had exactly one caller of this function: the sensitivity
|
||||
// test. Production never called it, so replacing CapsAbiFingerprint() with
|
||||
// `return 1;` left every fingerprint test green and both peers agreeing on
|
||||
// nothing. Now there is one mixer, the sensitivity case starts from the
|
||||
// production entry point, and that perturbation turns it red.
|
||||
// P6.5 wire fingerprint: one mixer, driven by compiler-derived layout facts.
|
||||
// CapsCodec supplies generated member/catalogue digests; build identity and
|
||||
// negotiated window sizes do not participate in wire compatibility.
|
||||
// -----------------------------------------------------------------------
|
||||
// Wire facts only. Segment geometry and build identity are negotiated separately.
|
||||
struct AbiFingerprintInputs {
|
||||
// The three struct shapes table 0's ABI-agreement row names.
|
||||
std::uint64_t DynamicParamsSize = 0;
|
||||
std::uint64_t CapsSize = 0;
|
||||
std::uint64_t FunctionTableSize = 0;
|
||||
// The caps blob's own geometry and the two blob codecs' versions: the
|
||||
// format-capability table's extents and the codec version stamps.
|
||||
std::uint64_t MemberLayout = 0;
|
||||
std::uint64_t CatalogueLayout = 0;
|
||||
std::uint64_t RenderStateLayout = 0;
|
||||
std::uint64_t FormatCapabilityTargets = 0;
|
||||
std::uint64_t FormatCapabilityFormats = 0;
|
||||
std::uint64_t FormatCapabilitiesCodecVersion = 0;
|
||||
std::uint64_t RendererInfoCodecVersion = 0;
|
||||
// The catalogue's length (ID-33): a peer with one more opcode is a
|
||||
// different wire even if every struct kept its size.
|
||||
std::uint64_t ProgramArtifactsCodecVersion = 0;
|
||||
std::uint64_t ProgramArtifactsSchema = 0;
|
||||
std::uint64_t OpCount = 0;
|
||||
// MOBILEGL_ABI_VERSION(major, minor): a protocol change that left every
|
||||
// struct the same size, which nothing above can see.
|
||||
std::uint32_t AbiVersion = 0;
|
||||
// MOBILEGL_BUILD_STAMP_VALUE: two builds of the same sizes can still
|
||||
// disagree about a FIELD ORDER, which no sizeof can see. nullptr and ""
|
||||
// are distinct inputs and neither equals a real stamp.
|
||||
const char* BuildStamp = nullptr;
|
||||
// CONTRACT-P6 4.2. WHETHER THE BUILD COULD NAME ITS COMMIT AT ALL, which
|
||||
// is not the same question as whether BuildStamp is empty - and telling
|
||||
// them apart is the entire fix.
|
||||
//
|
||||
// The old mix took GIT_COMMIT_HASH_SHORT, and a `git rev-parse` that
|
||||
// FAILED yielded "" with nothing reporting it (no RESULT_VARIABLE).
|
||||
// Every stampless build in the world then mixed the same "" and agreed
|
||||
// with every other, which is precisely the agreement the stamp exists to
|
||||
// refuse. Measured in this worktree: WSL cannot resolve the Windows path
|
||||
// in its `.git` file, so every WSL build was stampless and silent.
|
||||
//
|
||||
// Mixed as its own field so that 0-with-"" and 1-with-"" are different
|
||||
// fingerprints: a build that says "I have no stamp" must not collide
|
||||
// with one whose stamp genuinely is the empty string.
|
||||
std::uint32_t BuildStampPresent = 0;
|
||||
std::uint32_t PointerBits = 0;
|
||||
std::uint32_t LittleEndian = 0;
|
||||
};
|
||||
|
||||
// FNV-1a over every field above, in declaration order. Never 0: that value is
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
#include "ShmLink.h"
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
LinkSignals ILink::Signals() {
|
||||
auto* c = Memory().CmdControl();
|
||||
return {&c->cmdHead, &c->submittedSeq, &c->consumerParked, &c->producerParked, &c->eventRingFull};
|
||||
}
|
||||
std::uint64_t ILink::SegmentSize(LinkSegment segment) {
|
||||
auto& m = Memory();
|
||||
switch (segment) {
|
||||
case LinkSegment::Cmd:
|
||||
return m.CmdRingCapacity();
|
||||
case LinkSegment::Stage:
|
||||
return m.StageBytes();
|
||||
case LinkSegment::Reply:
|
||||
return m.ReplyBytes();
|
||||
case LinkSegment::Event:
|
||||
return m.AnnouncedSize(SessionSegmentSlot::Event);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
std::unique_ptr<ILink> CreateSharedLink(TransportRoleTag role) {
|
||||
auto link = std::make_unique<ShmLink>();
|
||||
link->SetRole(role);
|
||||
return link;
|
||||
}
|
||||
void ShmLink::InitializeEndpoints() {
|
||||
auto* c = m_memory.CmdControl();
|
||||
m_commandsOut = RingProducer(c, m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), RingCursorSet::Cmd);
|
||||
m_commandsIn = RingConsumer(c, m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), RingCursorSet::Cmd);
|
||||
m_eventsOut =
|
||||
EventRingProducer(m_memory.EventControl(), c, m_memory.EventRingBase(), m_memory.EventRingCapacity());
|
||||
m_eventsIn = EventRingConsumer(m_memory.EventControl(), c, m_memory.EventRingBase(),
|
||||
m_memory.EventRingCapacity(), m_memory.EventSegmentBase());
|
||||
if (m_role == TransportRoleTag::ServerConsumer) {
|
||||
ReplySlotPool pool(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||
pool.Clear();
|
||||
}
|
||||
}
|
||||
void ShmLink::BindDoorbells(Doorbell* c, Doorbell* p) {
|
||||
m_consumer = c;
|
||||
m_producer = p;
|
||||
}
|
||||
LinkCapabilities ShmLink::Capabilities() const {
|
||||
const ReplySlotPool replies(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||
return {true, true, true, m_memory.CmdRingCapacity() / 2, replies.MaxReplyBytes()};
|
||||
}
|
||||
LinkProgress* ShmLink::Progress() {
|
||||
return m_memory.Valid() ? &m_memory.CmdControl()->Progress : nullptr;
|
||||
}
|
||||
LinkEventFlags* ShmLink::EventFlags() {
|
||||
return m_memory.Valid() ? reinterpret_cast<LinkEventFlags*>(&m_memory.CmdControl()->eventRingFull) : nullptr;
|
||||
}
|
||||
LinkArena* ShmLink::RecordArena() {
|
||||
m_recordArena = {m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), m_memory.CmdRingCapacity() - 1,
|
||||
m_commandsOut.LocalHead()};
|
||||
return &m_recordArena;
|
||||
}
|
||||
LinkCursor* ShmLink::RecordCursor() {
|
||||
m_recordCursor = {m_memory.CmdRingBase(), m_memory.CmdRingCapacity(), m_memory.CmdRingCapacity() - 1,
|
||||
m_commandsIn.LocalTail()};
|
||||
return &m_recordCursor;
|
||||
}
|
||||
LinkArena* ShmLink::EventArena() {
|
||||
m_eventArena = {m_memory.EventRingBase(), m_memory.EventRingCapacity(), m_memory.EventRingCapacity() - 1,
|
||||
m_eventsOut.Ring().LocalHead()};
|
||||
return &m_eventArena;
|
||||
}
|
||||
LinkCursor* ShmLink::EventCursor() {
|
||||
m_eventCursor = {m_memory.EventRingBase(), m_memory.EventRingCapacity(), m_memory.EventRingCapacity() - 1,
|
||||
m_eventsIn.Ring().LocalTail()};
|
||||
return &m_eventCursor;
|
||||
}
|
||||
MobileGLResult ShmLink::StageBytes(std::uint64_t, LinkSpan*, void**) {
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
MobileGLResult ShmLink::ResolveSpan(LinkSegment segment, LinkSpan span, const void** out) {
|
||||
if (!out || !Attached()) return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
const void* base = nullptr;
|
||||
std::uint64_t size = 0;
|
||||
switch (segment) {
|
||||
case LinkSegment::Cmd:
|
||||
base = m_memory.CmdRingBase();
|
||||
size = m_memory.CmdRingCapacity();
|
||||
break;
|
||||
case LinkSegment::Stage:
|
||||
base = m_memory.StageBase();
|
||||
size = m_memory.StageBytes();
|
||||
break;
|
||||
case LinkSegment::Reply:
|
||||
base = m_memory.ReplyBase();
|
||||
size = m_memory.ReplyBytes();
|
||||
break;
|
||||
case LinkSegment::Event:
|
||||
base = m_memory.EventSegmentBase();
|
||||
size = m_memory.AnnouncedSize(SessionSegmentSlot::Event);
|
||||
break;
|
||||
default:
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
if (span.Offset > size || span.Size > size - span.Offset) return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
*out = static_cast<const std::uint8_t*>(base) + span.Offset;
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
MobileGLResult ShmLink::PostReply(std::uint64_t seq, std::int32_t status, const void* payload, std::uint64_t size) {
|
||||
ReplySlotPool replies(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||
replies.Post(seq, status, payload, size);
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
MobileGLResult ShmLink::ReadReply(std::uint64_t seq, std::int32_t* status, const void** payload,
|
||||
std::uint64_t* size) {
|
||||
if (!status || !payload || !size) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
ReplySlotPool replies(m_memory.ReplyBase(), m_memory.ReplyBytes(), m_memory.ReplySlotCount());
|
||||
return replies.ReadView(seq, status, payload, size) ? MOBILEGL_OK : MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
std::uint64_t ShmLink::EventPublishedHead() const {
|
||||
return m_memory.Valid() ? m_memory.EventControl()->cmdHead.load(std::memory_order_acquire) : 0;
|
||||
}
|
||||
MobileGLResult ShmLink::WaitForEventDelivery(std::uint64_t head, std::uint32_t) {
|
||||
return EventPublishedHead() >= head ? MOBILEGL_OK : MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
}
|
||||
Doorbell& ShmLink::ConsumerBell() {
|
||||
return *m_consumer;
|
||||
}
|
||||
Doorbell& ShmLink::ProducerBell() {
|
||||
return *m_producer;
|
||||
}
|
||||
void ShmLink::Detach() {
|
||||
m_commandsOut = {};
|
||||
m_commandsIn = {};
|
||||
m_eventsOut = {};
|
||||
m_eventsIn = {};
|
||||
m_memory.Close();
|
||||
}
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
@@ -0,0 +1,55 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
#pragma once
|
||||
#include "ILink.h"
|
||||
#include "SessionRings.h"
|
||||
#include <vector>
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
// Owns the mappings and every physical endpoint. Shared and private mirrored
|
||||
// storage use identical ring algorithms; only delivery belongs to the link.
|
||||
class ShmLink final : public ILink {
|
||||
public:
|
||||
ShmLink() = default;
|
||||
~ShmLink() override = default;
|
||||
SessionSegments& Memory() override { return m_memory; }
|
||||
RingProducer& CommandsOut() override { return m_commandsOut; }
|
||||
RingConsumer& CommandsIn() override { return m_commandsIn; }
|
||||
EventRingProducer& EventsOut() override { return m_eventsOut; }
|
||||
EventRingConsumer& EventsIn() override { return m_eventsIn; }
|
||||
void InitializeEndpoints() override;
|
||||
void BindDoorbells(Doorbell* consumer, Doorbell* producer) override;
|
||||
void SetRole(TransportRoleTag role) { m_role = role; }
|
||||
LinkCapabilities Capabilities() const override;
|
||||
LinkProgress* Progress() override;
|
||||
LinkEventFlags* EventFlags() override;
|
||||
LinkArena* RecordArena() override;
|
||||
LinkCursor* RecordCursor() override;
|
||||
MobileGLResult StageBytes(std::uint64_t, LinkSpan*, void**) override;
|
||||
MobileGLResult ResolveSpan(LinkSegment, LinkSpan, const void**) override;
|
||||
MobileGLResult PostReply(std::uint64_t, std::int32_t, const void*, std::uint64_t) override;
|
||||
MobileGLResult ReadReply(std::uint64_t, std::int32_t*, const void**, std::uint64_t*) override;
|
||||
LinkArena* EventArena() override;
|
||||
LinkCursor* EventCursor() override;
|
||||
std::uint64_t EventPublishedHead() const override;
|
||||
MobileGLResult WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) override;
|
||||
Doorbell& ConsumerBell() override;
|
||||
Doorbell& ProducerBell() override;
|
||||
MobileGLResult Flush() override { return MOBILEGL_OK; }
|
||||
MobileGLResult FlushProgress() override { return MOBILEGL_OK; }
|
||||
bool Attached() const override { return m_memory.Valid(); }
|
||||
void Detach() override;
|
||||
TransportRoleTag Role() const override { return m_role; }
|
||||
|
||||
private:
|
||||
SessionSegments m_memory;
|
||||
RingProducer m_commandsOut;
|
||||
RingConsumer m_commandsIn;
|
||||
EventRingProducer m_eventsOut;
|
||||
EventRingConsumer m_eventsIn;
|
||||
Doorbell* m_consumer = nullptr;
|
||||
Doorbell* m_producer = nullptr;
|
||||
TransportRoleTag m_role = TransportRoleTag::ClientProducer;
|
||||
LinkArena m_recordArena{}, m_eventArena{};
|
||||
LinkCursor m_recordCursor{}, m_eventCursor{};
|
||||
std::vector<std::uint8_t> m_reply;
|
||||
};
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "RoleMemory.h"
|
||||
#include "SessionRings.h"
|
||||
#include <new>
|
||||
|
||||
#include <MG_Util/Debug/Log.h>
|
||||
|
||||
@@ -308,6 +309,36 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
|
||||
MobileGLResult SessionSegments::CreatePrivate(const SessionSegmentSizes& sizes, MemoryRole role) {
|
||||
Close();
|
||||
const std::uint64_t bytes[4] = {SegmentBytesForRing(sizes.CmdRingBytes), sizes.StageBytes,
|
||||
sizes.ReplyBytes, SegmentBytesForRing(sizes.EventRingBytes)};
|
||||
for (unsigned i = 0; i != 4; ++i) {
|
||||
if (!bytes[i] || bytes[i] > static_cast<std::uint64_t>(SIZE_MAX)) {
|
||||
Close(); return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
m_private[i] = ::operator new(static_cast<std::size_t>(bytes[i]),
|
||||
std::align_val_t{alignof(RingControl)}, std::nothrow);
|
||||
if (!m_private[i]) { Close(); return MOBILEGL_ERR_OUT_OF_MEMORY; }
|
||||
m_privateSizes[i] = bytes[i];
|
||||
std::memset(m_private[i], 0, static_cast<std::size_t>(bytes[i]));
|
||||
m_mappedBytes += bytes[i];
|
||||
}
|
||||
m_cmdControl = static_cast<RingControl*>(m_private[0]);
|
||||
m_cmdRingBase = static_cast<std::uint8_t*>(m_private[0]) + sizeof(RingControl);
|
||||
m_cmdRingCapacity = RingCapacityForSegment(bytes[0]);
|
||||
m_stageBase = m_private[1]; m_stageBytes = bytes[1];
|
||||
m_replyBase = m_private[2]; m_replyBytes = bytes[2]; m_replySlotCount = sizes.ReplySlotCount;
|
||||
m_eventControl = static_cast<RingControl*>(m_private[3]);
|
||||
m_eventSegmentBase = m_private[3];
|
||||
m_eventRingBase = static_cast<std::uint8_t*>(m_private[3]) + sizeof(RingControl);
|
||||
m_eventRingCapacity = RingCapacityForSegment(bytes[3]);
|
||||
InitRingControl(*m_cmdControl); InitRingControl(*m_eventControl);
|
||||
m_role = role; m_valid = true;
|
||||
LedgerAddSegment(role, m_mappedBytes); m_booked = true;
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
|
||||
MobileGLResult SessionSegments::AttachInProcess(SessionSegments& owner, MemoryRole role) {
|
||||
Close();
|
||||
if (!owner.Valid()) {
|
||||
@@ -497,6 +528,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
for (std::size_t index = 0; index < kSlotCount; ++index) {
|
||||
m_segments[index] = nullptr;
|
||||
if (m_private[index]) ::operator delete(m_private[index], std::align_val_t{alignof(RingControl)});
|
||||
m_private[index] = nullptr; m_privateSizes[index] = 0;
|
||||
}
|
||||
m_cmdControl = nullptr;
|
||||
m_cmdRingBase = nullptr;
|
||||
@@ -516,7 +549,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
std::uint64_t SessionSegments::AnnouncedSize(SessionSegmentSlot slot) const {
|
||||
const ShmSegment* segment = m_segments[SlotIndex(slot)];
|
||||
return segment == nullptr ? 0 : segment->Size();
|
||||
return segment == nullptr ? m_privateSizes[SlotIndex(slot)] : segment->Size();
|
||||
}
|
||||
|
||||
const char* SessionSegments::AnnouncedName(SessionSegmentSlot slot) const {
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <chrono>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(__unix__) || defined(__APPLE__) || defined(__ANDROID__)
|
||||
# define MOBILEGL_SOCKET_TRANSPORT_POSIX 1
|
||||
@@ -25,6 +29,10 @@
|
||||
# include <sys/socket.h>
|
||||
# include <sys/types.h>
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netinet/tcp.h>
|
||||
#else
|
||||
# define MOBILEGL_SOCKET_TRANSPORT_POSIX 0
|
||||
#endif
|
||||
@@ -36,6 +44,140 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
namespace {
|
||||
constexpr std::uint64_t kPumpChunkBytes = 64ull * 1024;
|
||||
|
||||
bool TcpName(const std::string& name) { return name.compare(0, 6, "tcp://") == 0; }
|
||||
|
||||
bool TcpAddress(const std::string& name, addrinfo** result) {
|
||||
*result = nullptr;
|
||||
const std::string address = name.substr(6);
|
||||
std::string host, port;
|
||||
if (!address.empty() && address[0] == '[') {
|
||||
const auto end = address.find(']');
|
||||
if (end == std::string::npos || end + 1 >= address.size() || address[end + 1] != ':')
|
||||
return false;
|
||||
host = address.substr(1, end - 1);
|
||||
port = address.substr(end + 2);
|
||||
} else {
|
||||
const auto colon = address.find(':');
|
||||
if (colon == std::string::npos || address.find(':', colon + 1) != std::string::npos)
|
||||
return false;
|
||||
host = address.substr(0, colon);
|
||||
port = address.substr(colon + 1);
|
||||
}
|
||||
if (host.empty() || port.empty() || port.find_first_not_of("0123456789") != std::string::npos)
|
||||
return false;
|
||||
char* end = nullptr;
|
||||
const auto number = std::strtoul(port.c_str(), &end, 10);
|
||||
if (*end || number == 0 || number > 65535) return false;
|
||||
addrinfo hints{};
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
hints.ai_flags = AI_NUMERICSERV;
|
||||
return ::getaddrinfo(host.c_str(), port.c_str(), &hints, result) == 0;
|
||||
}
|
||||
|
||||
bool Loopback(const sockaddr* address) {
|
||||
if (address->sa_family == AF_INET)
|
||||
return (ntohl(reinterpret_cast<const sockaddr_in*>(address)->sin_addr.s_addr) >> 24) == 127;
|
||||
if (address->sa_family == AF_INET6)
|
||||
return IN6_IS_ADDR_LOOPBACK(&reinterpret_cast<const sockaddr_in6*>(address)->sin6_addr);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TcpSocket(int fd) {
|
||||
sockaddr_storage address{};
|
||||
socklen_t size = sizeof(address);
|
||||
return ::getsockname(fd, reinterpret_cast<sockaddr*>(&address), &size) == 0 &&
|
||||
(address.ss_family == AF_INET || address.ss_family == AF_INET6);
|
||||
}
|
||||
|
||||
bool ConfigureTcp(int fd) {
|
||||
const int one = 1, idle = 2, interval = 1, count = 3, timeout = 5000;
|
||||
if (::setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)) != 0 ||
|
||||
::setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one)) != 0) return false;
|
||||
#if defined(TCP_KEEPIDLE)
|
||||
if (::setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle, sizeof(idle)) != 0) return false;
|
||||
#endif
|
||||
#if defined(TCP_KEEPINTVL)
|
||||
if (::setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval, sizeof(interval)) != 0) return false;
|
||||
#endif
|
||||
#if defined(TCP_KEEPCNT)
|
||||
if (::setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &count, sizeof(count)) != 0) return false;
|
||||
#endif
|
||||
#if defined(TCP_USER_TIMEOUT)
|
||||
if (::setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout, sizeof(timeout)) != 0) return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
MobileGLResult ConnectTcp(const std::string& name, std::uint32_t timeoutMs, int* outFd) {
|
||||
addrinfo* addresses = nullptr;
|
||||
if (!TcpAddress(name, &addresses)) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
const auto deadline = std::chrono::steady_clock::now() +
|
||||
std::chrono::milliseconds(std::max(1u, timeoutMs));
|
||||
do {
|
||||
for (auto* address = addresses; address; address = address->ai_next) {
|
||||
const int fd = ::socket(address->ai_family, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (fd < 0) continue;
|
||||
const int flags = ::fcntl(fd, F_GETFL, 0);
|
||||
::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
|
||||
bool connected = ::connect(fd, address->ai_addr, address->ai_addrlen) == 0;
|
||||
if (!connected && errno == EINPROGRESS) {
|
||||
const auto remaining = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
deadline - std::chrono::steady_clock::now()).count();
|
||||
pollfd pfd{fd, POLLOUT, 0};
|
||||
int rc;
|
||||
do { rc = ::poll(&pfd, 1, static_cast<int>(std::max<std::int64_t>(0, remaining))); }
|
||||
while (rc < 0 && errno == EINTR && std::chrono::steady_clock::now() < deadline);
|
||||
int error = 0;
|
||||
socklen_t length = sizeof(error);
|
||||
connected = rc > 0 && ::getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &length) == 0 && error == 0;
|
||||
}
|
||||
if (connected && ConfigureTcp(fd)) {
|
||||
::fcntl(fd, F_SETFL, flags);
|
||||
::fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
*outFd = fd;
|
||||
::freeaddrinfo(addresses);
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
::close(fd);
|
||||
if (std::chrono::steady_clock::now() >= deadline) break;
|
||||
}
|
||||
::usleep(5000);
|
||||
} while (std::chrono::steady_clock::now() < deadline);
|
||||
::freeaddrinfo(addresses);
|
||||
WireLogError("MG_Remote SocketTransport: TCP connect to %s exhausted %u ms", name.c_str(), timeoutMs);
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
|
||||
MobileGLResult ListenTcp(const std::string& name, int* outFd) {
|
||||
addrinfo* addresses = nullptr;
|
||||
if (!TcpAddress(name, &addresses)) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
const char* token = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||
const bool authenticated = token != nullptr && token[0] != '\0';
|
||||
MobileGLResult result = MOBILEGL_ERR_UNSUPPORTED;
|
||||
for (auto* address = addresses; address; address = address->ai_next) {
|
||||
if (!authenticated && !Loopback(address->ai_addr)) {
|
||||
WireLogError("MG_Remote: Refuse{AuthenticationRequired} non-loopback TCP listen needs MOBILEGL_IPC_TOKEN");
|
||||
result = MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
continue;
|
||||
}
|
||||
const int fd = ::socket(address->ai_family, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (fd < 0) continue;
|
||||
const int one = 1;
|
||||
::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
::fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
if (::bind(fd, address->ai_addr, address->ai_addrlen) == 0 && ::listen(fd, 8) == 0) {
|
||||
*outFd = fd;
|
||||
result = MOBILEGL_OK;
|
||||
break;
|
||||
}
|
||||
::close(fd);
|
||||
}
|
||||
::freeaddrinfo(addresses);
|
||||
return result;
|
||||
}
|
||||
|
||||
void CloseIfOpen(int& fd) {
|
||||
if (fd >= 0) {
|
||||
::close(fd);
|
||||
@@ -116,6 +258,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
|
||||
MobileGLResult ConnectOne(const std::string& path, std::uint32_t timeoutMs, int* outFd) {
|
||||
if (TcpName(path)) return ConnectTcp(path, timeoutMs, outFd);
|
||||
sockaddr_un address{};
|
||||
socklen_t length = 0;
|
||||
if (!FillAddress(path, &address, &length)) {
|
||||
@@ -155,6 +298,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
*outListenFd = -1;
|
||||
if (TcpName(path)) return ListenTcp(path, outListenFd);
|
||||
sockaddr_un address{};
|
||||
socklen_t length = 0;
|
||||
if (!FillAddress(path, &address, &length)) {
|
||||
@@ -210,26 +354,39 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
int accepted[2] = {-1, -1};
|
||||
for (int index = 0; index < 2; ++index) {
|
||||
const int ready = WaitReadable(listenFd, timeoutMs);
|
||||
if (ready <= 0) {
|
||||
for (int fd : accepted) {
|
||||
if (fd >= 0) ::close(fd);
|
||||
const std::uint32_t budget = index == 0 ? timeoutMs : 2000;
|
||||
for (;;) {
|
||||
const int ready = WaitReadable(listenFd, budget);
|
||||
if (ready <= 0) {
|
||||
for (int fd : accepted) {
|
||||
if (fd >= 0) ::close(fd);
|
||||
}
|
||||
// Half a client is not a client. Both connections or neither, so
|
||||
// a peer that died between the two cannot leave a session that
|
||||
// looks up but has no way to receive a descriptor.
|
||||
if (index != 0 || ready < 0) WireLogError("MG_Remote SocketTransport: only %d of 2 connections arrived within "
|
||||
"%u ms", index, timeoutMs);
|
||||
return ready == 0 ? MOBILEGL_ERR_TIMEOUT : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
// Half a client is not a client. Both connections or neither, so
|
||||
// a peer that died between the two cannot leave a session that
|
||||
// looks up but has no way to receive a descriptor.
|
||||
WireLogError("MG_Remote SocketTransport: only %d of 2 connections arrived within "
|
||||
"%u ms", index, timeoutMs);
|
||||
return ready == 0 ? MOBILEGL_ERR_TIMEOUT : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
accepted[index] = ::accept(listenFd, nullptr, nullptr);
|
||||
if (accepted[index] < 0) {
|
||||
accepted[index] = ::accept(listenFd, nullptr, nullptr);
|
||||
if (accepted[index] >= 0) break;
|
||||
// EINTR (this process reaps SIGCHLD by construction) and ECONNABORTED
|
||||
// (the peer reset between poll() and accept()) are not transport
|
||||
// failures: the listener is still good. Re-poll within the budget
|
||||
// rather than returning TRANSPORT_CLOSED, which the --serve
|
||||
// supervisor turns into a full server exit (return 73).
|
||||
if (errno == EINTR || errno == ECONNABORTED) continue;
|
||||
for (int fd : accepted) {
|
||||
if (fd >= 0) ::close(fd);
|
||||
}
|
||||
WireLogError("MG_Remote SocketTransport: accept failed: %s", std::strerror(errno));
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
::fcntl(accepted[index], F_SETFD, FD_CLOEXEC);
|
||||
if (TcpSocket(accepted[index]) && !ConfigureTcp(accepted[index])) {
|
||||
for (int fd : accepted) if (fd >= 0) ::close(fd);
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
// First connection is control, second is aux. The order IS the protocol;
|
||||
// it is stated here and in ConnectTo and nowhere else.
|
||||
@@ -292,7 +449,26 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
|
||||
SocketTransport::SocketTransport(int streamFd, int auxFd, TransportRole role)
|
||||
: m_streamFd(streamFd), m_auxFd(auxFd), m_role(role) {}
|
||||
: m_streamFd(streamFd), m_auxFd(auxFd), m_tcp(TcpSocket(streamFd)), m_role(role) {}
|
||||
|
||||
int SocketTransport::TakeDataFd() {
|
||||
if (!m_tcp) return -1;
|
||||
const int fd = m_auxFd;
|
||||
m_auxFd = -1;
|
||||
return fd;
|
||||
}
|
||||
|
||||
void SocketTransport::CloseLocalCopy() {
|
||||
CloseIfOpen(m_streamFd);
|
||||
CloseIfOpen(m_auxFd);
|
||||
m_closed = true;
|
||||
}
|
||||
|
||||
MobileGLResult SocketTransport::ShutdownSend() {
|
||||
std::lock_guard<std::mutex> lock(m_sendMutex);
|
||||
if (m_streamFd < 0 || m_closed) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
return ::shutdown(m_streamFd, SHUT_WR) == 0 ? MOBILEGL_OK : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
|
||||
SocketTransport::~SocketTransport() { Shutdown(); }
|
||||
|
||||
@@ -340,7 +516,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
m_closed = true;
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
WireLogError("MG_Remote SocketTransport: send failed after %llu of %llu bytes: %s",
|
||||
// SendFrame is also the log sink: do not recurse into the logger.
|
||||
std::fprintf(stderr, "MG_Remote SocketTransport: send failed after %llu of %llu bytes: %s\n",
|
||||
static_cast<unsigned long long>(written),
|
||||
static_cast<unsigned long long>(framed.size()), std::strerror(errno));
|
||||
m_closed = true;
|
||||
@@ -385,9 +562,9 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
if (n == 0) {
|
||||
// Clean EOF. The peer is gone - but anything already reassembled
|
||||
// stays readable, which ITransport promises in as many words.
|
||||
m_closed = true;
|
||||
// Request EOF can be a half-close: drain queued frames and keep
|
||||
// the reverse direction usable for teardown diagnostics.
|
||||
m_readClosed = true;
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
if (errno == EINTR) {
|
||||
@@ -426,7 +603,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
if (m_reader.HasMessage()) {
|
||||
return m_reader.TakeMessage(buffer, outSize);
|
||||
}
|
||||
if (m_closed) {
|
||||
if (m_closed || m_readClosed) {
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
|
||||
@@ -446,7 +623,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
if (m_failed) {
|
||||
return 0;
|
||||
}
|
||||
if (!m_reader.HasMessage() && !m_closed) {
|
||||
if (!m_reader.HasMessage() && !m_closed && !m_readClosed) {
|
||||
// A non-blocking pump, so a caller that has not received yet can
|
||||
// still size its buffer. Errors are not reported here: PeekFrameSize
|
||||
// answers "how big is the next message", and 0 means "none buffered",
|
||||
@@ -457,7 +634,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
}
|
||||
|
||||
MobileGLResult SocketTransport::ShareFd(int fd, MobileGLByteSpan sideband) {
|
||||
if (m_auxFd < 0) {
|
||||
if (m_tcp || m_auxFd < 0) {
|
||||
// A link that declared no descriptor passing. Rule G: it does not
|
||||
// invent a third answer, and the caller transfers the bytes instead.
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
@@ -472,13 +649,15 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
MobileGLResult SocketTransport::ReceiveFd(int* outFd, MobileGLMutableByteSpan sideband,
|
||||
std::uint64_t* outSidebandSize,
|
||||
std::uint32_t timeoutMs) {
|
||||
if (m_auxFd < 0) {
|
||||
if (m_tcp || m_auxFd < 0) {
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
return FdPassing::ReceiveFd(m_auxFd, outFd, sideband, outSidebandSize, timeoutMs);
|
||||
}
|
||||
|
||||
void SocketTransport::Shutdown() {
|
||||
// Wake a blocking ReceiveFrame before taking its lock.
|
||||
if (m_streamFd >= 0) ::shutdown(m_streamFd, SHUT_RDWR);
|
||||
// Idempotent, and tears down BOTH directions - which on a socket is what
|
||||
// closing does anyway. Taking both locks in a fixed order (send, then
|
||||
// recv) so a concurrent sender and the dedicated reader cannot deadlock
|
||||
@@ -510,6 +689,9 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
SocketTransport::SocketTransport(int, int, TransportRole role) : m_role(role) {}
|
||||
SocketTransport::~SocketTransport() = default;
|
||||
int SocketTransport::TakeDataFd() { return -1; }
|
||||
void SocketTransport::CloseLocalCopy() {}
|
||||
MobileGLResult SocketTransport::ShutdownSend() { return MOBILEGL_ERR_UNSUPPORTED; }
|
||||
|
||||
MobileGLResult SocketTransport::SendFrame(MobileGLByteSpan) { return MOBILEGL_ERR_UNSUPPORTED; }
|
||||
MobileGLResult SocketTransport::ReceiveFrame(MobileGLMutableByteSpan, std::uint64_t*,
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
// calls it, the peer's reads return 0 and its sends fail.
|
||||
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
|
||||
#include "Framing.h"
|
||||
#include "ITransport.h"
|
||||
@@ -124,6 +125,15 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
// transport owns, so a test can assert the child inherited exactly these.
|
||||
int StreamFd() const { return m_streamFd; }
|
||||
int AuxFd() const { return m_auxFd; }
|
||||
bool IsTcp() const { return m_tcp; }
|
||||
// TCP's second connection belongs exclusively to the data plane.
|
||||
// Taking it disables all descriptor passing on this transport.
|
||||
int TakeDataFd();
|
||||
// Parent of a session child closes its duplicate without shutdown(2),
|
||||
// which would also disconnect the child's inherited socket.
|
||||
void CloseLocalCopy();
|
||||
// End requests while retaining the receive side for final diagnostics/EOF.
|
||||
MobileGLResult ShutdownSend();
|
||||
|
||||
private:
|
||||
// Pulls whatever the socket has into the reassembler. Returns
|
||||
@@ -132,6 +142,7 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
int m_streamFd = -1;
|
||||
int m_auxFd = -1;
|
||||
bool m_tcp = false;
|
||||
TransportRole m_role = TransportRole::Client;
|
||||
|
||||
// ITransport's threading rule: callers serialise sends, and receives may
|
||||
@@ -143,7 +154,8 @@ namespace MobileGL::MG_Remote::Transport {
|
||||
std::mutex m_recvMutex;
|
||||
|
||||
FrameReader m_reader;
|
||||
bool m_closed = false;
|
||||
std::atomic<bool> m_closed{false};
|
||||
std::atomic<bool> m_readClosed{false};
|
||||
bool m_failed = false; // framing violated: latched, never recovers
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,555 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
#include "StreamLink.h"
|
||||
#include "SessionRings.h"
|
||||
#include "ShmLink.h"
|
||||
#include "Doorbell.h"
|
||||
#include "ReplySlot.h"
|
||||
#include "Framing.h"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#if !defined(_WIN32)
|
||||
#include <cerrno>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__linux__)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
namespace {
|
||||
constexpr std::uint64_t kDataEnvelopeBytes = 20;
|
||||
constexpr std::uint64_t kMaxDataPayload = kMaxFramePayloadSize - kDataEnvelopeBytes;
|
||||
constexpr std::uint32_t kDataMagic = 0x444c474d; // MGLD, little endian
|
||||
enum Kind : unsigned {
|
||||
Cmd = 1,
|
||||
Stage,
|
||||
ClientProgress,
|
||||
ProgressFrame,
|
||||
Reply,
|
||||
Event
|
||||
};
|
||||
void Put32(std::uint8_t* p, std::uint32_t v) {
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
p[i] = v >> (i * 8);
|
||||
}
|
||||
void Put64(std::uint8_t* p, std::uint64_t v) {
|
||||
for (unsigned i = 0; i < 8; ++i)
|
||||
p[i] = v >> (i * 8);
|
||||
}
|
||||
std::uint32_t Get32(const std::uint8_t* p) {
|
||||
std::uint32_t v = 0;
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
v |= std::uint32_t(p[i]) << (i * 8);
|
||||
return v;
|
||||
}
|
||||
std::uint64_t Get64(const std::uint8_t* p) {
|
||||
std::uint64_t v = 0;
|
||||
for (unsigned i = 0; i < 8; ++i)
|
||||
v |= std::uint64_t(p[i]) << (i * 8);
|
||||
return v;
|
||||
}
|
||||
[[noreturn]] void Corrupt(const char* detail) {
|
||||
WireLogFatal("MGPipe: Fatal{ProtocolCorruption, \"StreamLink\"} %s", detail);
|
||||
}
|
||||
void Advance(std::atomic<std::uint64_t>& value, std::uint64_t next) {
|
||||
if (next < value.load(std::memory_order_acquire)) Corrupt("watermark moved backwards");
|
||||
value.store(next, std::memory_order_release);
|
||||
}
|
||||
class StreamBell final : public Doorbell {
|
||||
public:
|
||||
void Notify() override { m_bell.Notify(); }
|
||||
bool Park(std::uint32_t timeout) override { return m_bell.Park(timeout); }
|
||||
void Reset() override { m_bell.Reset(); }
|
||||
bool Dead() const override { return m_bell.Dead(); }
|
||||
bool PeerHungUp() const override { return m_peer.load(std::memory_order_acquire); }
|
||||
void Kill(bool peer) {
|
||||
if (peer) m_peer.store(true, std::memory_order_release);
|
||||
m_bell.Kill();
|
||||
}
|
||||
|
||||
private:
|
||||
CondVarDoorbell m_bell;
|
||||
std::atomic<bool> m_peer{false};
|
||||
};
|
||||
} // namespace
|
||||
|
||||
struct StreamLink::Impl {
|
||||
std::unique_ptr<ShmLink> owned = std::make_unique<ShmLink>();
|
||||
SessionSegments* memory = nullptr;
|
||||
TransportRoleTag role = TransportRoleTag::ClientProducer;
|
||||
int fd = -1;
|
||||
std::atomic<bool> closed{false}, stopping{false};
|
||||
StreamBell consumer, producer;
|
||||
std::thread reader;
|
||||
std::mutex writeMutex, replyMutex;
|
||||
std::condition_variable replyReady;
|
||||
std::vector<LinkSpan> stage;
|
||||
std::vector<std::uint8_t> reply, readReply;
|
||||
std::uint64_t replySeq = 0, sentCmd = 0, receivedCmd = 0, sentEvent = 0, receivedEvent = 0;
|
||||
std::int32_t replyStatus = 0;
|
||||
std::uint64_t lastProgressSeq = 0;
|
||||
std::chrono::steady_clock::time_point lastProgress = std::chrono::steady_clock::now();
|
||||
LinkArena records{}, events{};
|
||||
LinkCursor recordCursor{}, eventCursor{};
|
||||
bool Client() const { return role == TransportRoleTag::ClientProducer; }
|
||||
RingControl& C() const { return *memory->CmdControl(); }
|
||||
RingControl& E() const { return *memory->EventControl(); }
|
||||
std::uint64_t MaxReply() const {
|
||||
return memory->ReplyBytes() / memory->ReplySlotCount() - sizeof(ReplySlotHeader);
|
||||
}
|
||||
void Die(bool peer) {
|
||||
{
|
||||
// Pair every reply-wait predicate transition with its mutex:
|
||||
// an EOF between the predicate and cv.wait must not lose a wake.
|
||||
std::lock_guard<std::mutex> lock(replyMutex);
|
||||
closed.store(true, std::memory_order_release);
|
||||
}
|
||||
consumer.Kill(peer);
|
||||
producer.Kill(peer);
|
||||
replyReady.notify_all();
|
||||
#if !defined(_WIN32)
|
||||
if (fd >= 0) ::shutdown(fd, SHUT_RDWR);
|
||||
#endif
|
||||
}
|
||||
bool Read(void* data, std::size_t size) {
|
||||
#if !defined(_WIN32)
|
||||
auto* p = static_cast<std::uint8_t*>(data);
|
||||
while (size) {
|
||||
const auto n = ::recv(fd, p, size, 0);
|
||||
if (n < 0 && errno == EINTR) continue;
|
||||
if (n <= 0) {
|
||||
Die(!stopping.load(std::memory_order_acquire));
|
||||
return false;
|
||||
}
|
||||
p += n;
|
||||
size -= static_cast<std::size_t>(n);
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
(void)data;
|
||||
(void)size;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
bool Send(unsigned kind, std::uint64_t a, std::uint64_t b, const void* payload, std::uint64_t size) {
|
||||
if (size > kMaxDataPayload) Corrupt("outgoing frame exceeds limit");
|
||||
std::uint8_t h[28]{};
|
||||
Put32(h, kDataMagic);
|
||||
Put32(h + 4, static_cast<std::uint32_t>(kDataEnvelopeBytes + size));
|
||||
h[8] = static_cast<std::uint8_t>(kind);
|
||||
Put64(h + 12, a);
|
||||
Put64(h + 20, b);
|
||||
#if !defined(_WIN32)
|
||||
// One gather write keeps a small command and its envelope in one
|
||||
// TCP send (TCP_NODELAY is enabled). Partial writes retain the same
|
||||
// frame lock and advance through both vectors without copying.
|
||||
iovec vectors[2] = {{h, sizeof h}, {const_cast<void*>(payload), static_cast<std::size_t>(size)}};
|
||||
msghdr message{};
|
||||
message.msg_iov = vectors;
|
||||
message.msg_iovlen = size ? 2 : 1;
|
||||
while (message.msg_iovlen) {
|
||||
const auto sent = ::sendmsg(fd, &message, MSG_NOSIGNAL);
|
||||
if (sent < 0 && errno == EINTR) continue;
|
||||
if (sent <= 0) {
|
||||
Die(!stopping.load(std::memory_order_acquire));
|
||||
return false;
|
||||
}
|
||||
auto consumed = static_cast<std::size_t>(sent);
|
||||
while (message.msg_iovlen && consumed >= message.msg_iov->iov_len) {
|
||||
consumed -= message.msg_iov->iov_len;
|
||||
++message.msg_iov;
|
||||
--message.msg_iovlen;
|
||||
}
|
||||
if (message.msg_iovlen && consumed) {
|
||||
message.msg_iov->iov_base = static_cast<std::uint8_t*>(message.msg_iov->iov_base) + consumed;
|
||||
message.msg_iov->iov_len -= consumed;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
(void)payload;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
bool SendRing(unsigned kind, void* base, std::uint64_t capacity, std::uint64_t head, std::uint64_t& sent) {
|
||||
if (head < sent || head - sent > capacity) Corrupt("outgoing ring window invalid");
|
||||
while (sent < head) {
|
||||
const auto at = sent % capacity;
|
||||
const auto count = std::min({head - sent, capacity - at, kMaxDataPayload});
|
||||
if (!Send(kind, sent, 0, static_cast<std::uint8_t*>(base) + at, count)) return false;
|
||||
sent += count;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool SendEvents() {
|
||||
return SendRing(Event, memory->EventRingBase(), memory->EventRingCapacity(),
|
||||
E().cmdHead.load(std::memory_order_acquire), sentEvent);
|
||||
}
|
||||
bool SendProgress() {
|
||||
// Events and replies always precede the applied watermark that publishes them.
|
||||
if (!SendEvents()) return false;
|
||||
std::uint8_t p[64]{};
|
||||
Put64(p, C().Progress.appliedSeq.load(std::memory_order_acquire));
|
||||
Put64(p + 8, C().Progress.retiredSeq.load(std::memory_order_acquire));
|
||||
Put64(p + 16, C().Progress.completedFrameSerial.load(std::memory_order_acquire));
|
||||
Put64(p + 24, C().Progress.presentAckSerial.load(std::memory_order_acquire));
|
||||
Put64(p + 32, C().cmdAppliedTail.load(std::memory_order_acquire));
|
||||
// FreeBytes uses RETIRED tail. Sending only applied tail silently permits
|
||||
// reuse of borrowed command slots, and omitting this tail wedges on wrap.
|
||||
Put64(p + 40, C().cmdRetiredTail.load(std::memory_order_acquire));
|
||||
Put64(p + 48, C().eventRingFull.load(std::memory_order_acquire));
|
||||
Put64(p + 56, C().eventDropped.load(std::memory_order_acquire));
|
||||
lastProgressSeq = Get64(p);
|
||||
lastProgress = std::chrono::steady_clock::now();
|
||||
return Send(ProgressFrame, 0, 0, p, sizeof p);
|
||||
}
|
||||
void ReceiveRing(void* base, std::uint64_t capacity, std::uint64_t tail, std::uint64_t a,
|
||||
const std::uint8_t* payload, std::uint64_t size, std::uint64_t& received) {
|
||||
if (a != received || a < tail || a - tail > capacity || size > capacity - (a - tail) ||
|
||||
size > capacity - a % capacity || size == 0)
|
||||
Corrupt("ring frame outside receive window");
|
||||
std::memcpy(static_cast<std::uint8_t*>(base) + a % capacity, payload, static_cast<std::size_t>(size));
|
||||
received += size;
|
||||
}
|
||||
void Loop() {
|
||||
#if defined(__linux__)
|
||||
pthread_setname_np(pthread_self(), Client() ? "mgl-cli-io" : "mgl-srv-io");
|
||||
#endif
|
||||
FrameReader frames(kDataMagic);
|
||||
for (;;) {
|
||||
std::uint8_t h[28];
|
||||
if (!Read(h, kFrameHeaderSize)) return;
|
||||
if (frames.Feed(h, kFrameHeaderSize) != MOBILEGL_OK) Corrupt("invalid data frame header");
|
||||
const auto framedSize = Get32(h + 4);
|
||||
if (framedSize < kDataEnvelopeBytes) Corrupt("truncated data envelope");
|
||||
if (!Read(h + kFrameHeaderSize, kDataEnvelopeBytes)) return;
|
||||
if (frames.Feed(h + kFrameHeaderSize, kDataEnvelopeBytes) != MOBILEGL_OK)
|
||||
Corrupt("invalid data frame envelope");
|
||||
const auto size = framedSize - static_cast<std::uint32_t>(kDataEnvelopeBytes);
|
||||
const auto kind = unsigned(h[8]);
|
||||
const auto a = Get64(h + 12), b = Get64(h + 20);
|
||||
if (Get32(h) != kDataMagic || h[9] || h[10] || h[11] || size > kMaxDataPayload)
|
||||
Corrupt("invalid data frame header");
|
||||
// Reject the size/window before allocating or reading a hostile payload.
|
||||
if ((kind == Stage && (Client() || a > memory->StageBytes() || size > memory->StageBytes() - a)) ||
|
||||
(kind == Cmd && (Client() || size > memory->CmdRingCapacity())) ||
|
||||
(kind == Event && (!Client() || size > memory->EventRingCapacity())) ||
|
||||
(kind == Reply && (!Client() || size > MaxReply())) ||
|
||||
(kind == ProgressFrame && (!Client() || size != 64)) ||
|
||||
(kind == ClientProgress && (Client() || size != 8)) || kind < Cmd || kind > Event)
|
||||
Corrupt("frame kind or size outside negotiated window");
|
||||
if (((kind == Cmd || kind == Stage || kind == Event) && b != 0) ||
|
||||
(kind == ProgressFrame && (a != 0 || b != 0)) || (kind == Reply && b > UINT32_MAX))
|
||||
Corrupt("nonzero reserved data envelope field");
|
||||
std::uint8_t chunk[64 * 1024];
|
||||
std::uint64_t remaining = size;
|
||||
while (remaining) {
|
||||
const auto count = std::min<std::uint64_t>(remaining, sizeof chunk);
|
||||
if (!Read(chunk, static_cast<std::size_t>(count))) return;
|
||||
if (frames.Feed(chunk, count) != MOBILEGL_OK) Corrupt("invalid data frame payload");
|
||||
remaining -= count;
|
||||
}
|
||||
std::vector<std::uint8_t> p;
|
||||
if (frames.TakeMessage(p) != MOBILEGL_OK) Corrupt("incomplete data frame");
|
||||
const auto* payload = p.data() + kDataEnvelopeBytes;
|
||||
if (kind == Stage) {
|
||||
std::memcpy(static_cast<std::uint8_t*>(memory->StageBase()) + a, payload, size);
|
||||
} else if (kind == Cmd) {
|
||||
ReceiveRing(memory->CmdRingBase(), memory->CmdRingCapacity(),
|
||||
C().cmdRetiredTail.load(std::memory_order_acquire), a, payload, size, receivedCmd);
|
||||
} else if (kind == ClientProgress) {
|
||||
if (a != receivedCmd) Corrupt("cmdHead does not match delivered bytes");
|
||||
const auto tail = Get64(payload);
|
||||
if (tail > E().cmdHead.load(std::memory_order_acquire)) Corrupt("event tail ahead of head");
|
||||
const auto oldTail = E().cmdRetiredTail.load(std::memory_order_acquire);
|
||||
Advance(E().cmdAppliedTail, tail);
|
||||
Advance(E().cmdRetiredTail, tail);
|
||||
// Only a real drain can clear a latched backlog. A command-only
|
||||
// publication carrying the old tail must not undo a new full latch.
|
||||
if (tail > oldTail) C().eventRingFull.store(0, std::memory_order_release);
|
||||
Watermark::AdvanceSubmitted(C(), b);
|
||||
Advance(C().cmdHead, a);
|
||||
consumer.Notify();
|
||||
} else if (kind == Event) {
|
||||
ReceiveRing(memory->EventRingBase(), memory->EventRingCapacity(),
|
||||
E().cmdRetiredTail.load(std::memory_order_acquire), a, payload, size, receivedEvent);
|
||||
Advance(E().cmdHead, receivedEvent);
|
||||
producer.Notify();
|
||||
} else if (kind == ProgressFrame) {
|
||||
const auto* v = payload;
|
||||
if (Get64(v + 8) > Get64(v) || Get64(v) > C().submittedSeq.load(std::memory_order_acquire) ||
|
||||
Get64(v + 40) > Get64(v + 32) || Get64(v + 32) > C().cmdHead.load(std::memory_order_acquire) ||
|
||||
Get64(v + 48) > 1)
|
||||
Corrupt("progress ahead of delivered work");
|
||||
Advance(C().cmdAppliedTail, Get64(v + 32));
|
||||
Advance(C().cmdRetiredTail, Get64(v + 40));
|
||||
C().eventRingFull.store(static_cast<std::uint32_t>(Get64(v + 48)), std::memory_order_release);
|
||||
C().eventDropped.store(static_cast<std::uint32_t>(Get64(v + 56)), std::memory_order_release);
|
||||
Watermark::AdvanceCompletedFrame(C(), Get64(v + 16));
|
||||
Watermark::AdvancePresentAck(C(), Get64(v + 24));
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(replyMutex);
|
||||
Watermark::AdvanceApplied(C(), Get64(v));
|
||||
// AdvanceRetired clamps to local appliedSeq. Apply this
|
||||
// received snapshot in dependency order or the final
|
||||
// retirement is silently clamped to the previous batch.
|
||||
Watermark::AdvanceRetired(C(), Get64(v + 8));
|
||||
}
|
||||
replyReady.notify_all();
|
||||
producer.Notify();
|
||||
} else if (kind == Reply) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(replyMutex);
|
||||
if (a <= replySeq) Corrupt("reply sequence moved backwards");
|
||||
replySeq = a;
|
||||
replyStatus = static_cast<std::int32_t>(static_cast<std::uint32_t>(b));
|
||||
reply.assign(payload, payload + size);
|
||||
}
|
||||
replyReady.notify_all();
|
||||
producer.Notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
StreamLink::StreamLink() : m_impl(new Impl) {}
|
||||
StreamLink::~StreamLink() {
|
||||
Detach();
|
||||
}
|
||||
MobileGLResult StreamLink::Attach(int fd, SessionSegments& mirrors, TransportRoleTag role) {
|
||||
#if defined(_WIN32)
|
||||
(void)fd;
|
||||
(void)mirrors;
|
||||
(void)role;
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
#else
|
||||
if (fd < 0 || !mirrors.Valid() || !mirrors.ReplySlotCount() ||
|
||||
mirrors.ReplyBytes() / mirrors.ReplySlotCount() <= sizeof(ReplySlotHeader))
|
||||
return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
Detach();
|
||||
m_impl.reset(new Impl);
|
||||
auto& x = *m_impl;
|
||||
x.fd = fd;
|
||||
x.memory = &mirrors;
|
||||
x.role = role;
|
||||
x.records = {mirrors.CmdRingBase(), mirrors.CmdRingCapacity(), mirrors.CmdRingCapacity() - 1, 0};
|
||||
x.recordCursor = {mirrors.CmdRingBase(), mirrors.CmdRingCapacity(), mirrors.CmdRingCapacity() - 1, 0};
|
||||
x.events = {mirrors.EventRingBase(), mirrors.EventRingCapacity(), mirrors.EventRingCapacity() - 1, 0};
|
||||
x.eventCursor = {mirrors.EventRingBase(), mirrors.EventRingCapacity(), mirrors.EventRingCapacity() - 1, 0};
|
||||
x.reader = std::thread([&x] { x.Loop(); });
|
||||
return MOBILEGL_OK;
|
||||
#endif
|
||||
}
|
||||
MobileGLResult StreamLink::AttachOwned(int fd, const SessionSegmentSizes& sizes, TransportRoleTag role) {
|
||||
auto owned = std::make_unique<ShmLink>();
|
||||
const auto result = owned->Memory().CreatePrivate(
|
||||
sizes, role == TransportRoleTag::ClientProducer ? MemoryRole::Client : MemoryRole::Server);
|
||||
if (result != MOBILEGL_OK) return result;
|
||||
const auto attached = Attach(fd, owned->Memory(), role);
|
||||
if (attached == MOBILEGL_OK) m_impl->owned = std::move(owned);
|
||||
return attached;
|
||||
}
|
||||
MobileGLResult CreateStreamLink(int fd, const SessionSegmentSizes& sizes, TransportRoleTag role,
|
||||
std::unique_ptr<ILink>& out) {
|
||||
auto link = std::make_unique<StreamLink>();
|
||||
const auto result = link->AttachOwned(fd, sizes, role);
|
||||
if (result == MOBILEGL_OK) out = std::move(link);
|
||||
#if !defined(_WIN32)
|
||||
else if (fd >= 0)
|
||||
::close(fd);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
void StreamLink::InitializeEndpoints() {
|
||||
m_impl->owned->SetRole(m_impl->role);
|
||||
m_impl->owned->InitializeEndpoints();
|
||||
}
|
||||
SessionSegments& StreamLink::Memory() {
|
||||
return m_impl->memory ? *m_impl->memory : m_impl->owned->Memory();
|
||||
}
|
||||
RingProducer& StreamLink::CommandsOut() {
|
||||
return m_impl->owned->CommandsOut();
|
||||
}
|
||||
RingConsumer& StreamLink::CommandsIn() {
|
||||
return m_impl->owned->CommandsIn();
|
||||
}
|
||||
EventRingProducer& StreamLink::EventsOut() {
|
||||
return m_impl->owned->EventsOut();
|
||||
}
|
||||
EventRingConsumer& StreamLink::EventsIn() {
|
||||
return m_impl->owned->EventsIn();
|
||||
}
|
||||
LinkCapabilities StreamLink::Capabilities() const {
|
||||
if (!m_impl->memory) return {};
|
||||
return {false, false, false, m_impl->memory->CmdRingCapacity() / 2, m_impl->MaxReply()};
|
||||
}
|
||||
LinkProgress* StreamLink::Progress() {
|
||||
return m_impl->memory ? &m_impl->C().Progress : nullptr;
|
||||
}
|
||||
LinkEventFlags* StreamLink::EventFlags() {
|
||||
return m_impl->memory ? reinterpret_cast<LinkEventFlags*>(&m_impl->C().eventRingFull) : nullptr;
|
||||
}
|
||||
LinkArena* StreamLink::RecordArena() {
|
||||
return m_impl->Client() ? &m_impl->records : nullptr;
|
||||
}
|
||||
LinkCursor* StreamLink::RecordCursor() {
|
||||
return m_impl->Client() ? nullptr : &m_impl->recordCursor;
|
||||
}
|
||||
LinkArena* StreamLink::EventArena() {
|
||||
return m_impl->Client() ? nullptr : &m_impl->events;
|
||||
}
|
||||
LinkCursor* StreamLink::EventCursor() {
|
||||
return m_impl->Client() ? &m_impl->eventCursor : nullptr;
|
||||
}
|
||||
Doorbell& StreamLink::ConsumerBell() {
|
||||
return m_impl->consumer;
|
||||
}
|
||||
Doorbell& StreamLink::ProducerBell() {
|
||||
return m_impl->producer;
|
||||
}
|
||||
MobileGLResult StreamLink::StageBytes(std::uint64_t, LinkSpan*, void**) {
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
MobileGLResult StreamLink::ResolveSpan(LinkSegment segment, LinkSpan span, const void** out) {
|
||||
if (!out || !m_impl->memory) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
auto& m = *m_impl->memory;
|
||||
const void* base = nullptr;
|
||||
std::uint64_t cap = 0;
|
||||
switch (segment) {
|
||||
case LinkSegment::Cmd:
|
||||
base = m.CmdRingBase();
|
||||
cap = m.CmdRingCapacity();
|
||||
break;
|
||||
case LinkSegment::Stage:
|
||||
base = m.StageBase();
|
||||
cap = m.StageBytes();
|
||||
break;
|
||||
case LinkSegment::Reply:
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
case LinkSegment::Event:
|
||||
base = m.EventSegmentBase();
|
||||
cap = m.AnnouncedSize(SessionSegmentSlot::Event);
|
||||
break;
|
||||
default:
|
||||
return MOBILEGL_ERR_UNSUPPORTED;
|
||||
}
|
||||
if (span.Offset > cap || span.Size > cap - span.Offset) return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
*out = static_cast<const std::uint8_t*>(base) + span.Offset;
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
void StreamLink::NoteStage(LinkSpan span) {
|
||||
auto& x = *m_impl;
|
||||
if (!x.Client() || span.Offset > x.memory->StageBytes() || span.Size > x.memory->StageBytes() - span.Offset)
|
||||
Corrupt("staged span outside window");
|
||||
if (!x.stage.empty() && x.stage.back().Offset + x.stage.back().Size == span.Offset)
|
||||
x.stage.back().Size += span.Size;
|
||||
else
|
||||
x.stage.push_back(span);
|
||||
}
|
||||
MobileGLResult StreamLink::Flush() {
|
||||
auto& x = *m_impl;
|
||||
if (!Attached()) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
std::lock_guard<std::mutex> lock(x.writeMutex);
|
||||
if (!x.Client()) return x.SendEvents() ? MOBILEGL_OK : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
for (const auto span : x.stage) {
|
||||
std::uint64_t sent = 0;
|
||||
while (sent < span.Size) {
|
||||
const auto count = std::min(span.Size - sent, kMaxDataPayload);
|
||||
if (!x.Send(Stage, span.Offset + sent, 0,
|
||||
static_cast<std::uint8_t*>(x.memory->StageBase()) + span.Offset + sent, count))
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
sent += count;
|
||||
}
|
||||
}
|
||||
x.stage.clear();
|
||||
const auto head = x.C().cmdHead.load(std::memory_order_acquire);
|
||||
if (!x.SendRing(Cmd, x.memory->CmdRingBase(), x.memory->CmdRingCapacity(), head, x.sentCmd))
|
||||
return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
std::uint8_t tail[8];
|
||||
Put64(tail, x.E().cmdRetiredTail.load(std::memory_order_acquire));
|
||||
return x.Send(ClientProgress, head, x.C().submittedSeq.load(std::memory_order_acquire), tail, sizeof tail)
|
||||
? MOBILEGL_OK
|
||||
: MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
MobileGLResult StreamLink::FlushProgress() {
|
||||
auto& x = *m_impl;
|
||||
if (!Attached()) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
if (x.Client()) return Flush();
|
||||
std::lock_guard<std::mutex> lock(x.writeMutex);
|
||||
return x.SendProgress() ? MOBILEGL_OK : MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
void StreamLink::ProgressChanged() {
|
||||
auto& x = *m_impl;
|
||||
if (x.Client() || !Attached()) return;
|
||||
const auto seq = x.C().Progress.appliedSeq.load(std::memory_order_acquire);
|
||||
if (seq - x.lastProgressSeq >= 64 ||
|
||||
std::chrono::steady_clock::now() - x.lastProgress >= std::chrono::milliseconds(1))
|
||||
FlushProgress();
|
||||
}
|
||||
MobileGLResult StreamLink::PostReply(std::uint64_t seq, std::int32_t status, const void* p, std::uint64_t size) {
|
||||
auto& x = *m_impl;
|
||||
if (x.Client() || !Attached()) return MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
if (size > x.MaxReply() || (size && !p)) return MOBILEGL_ERR_BUFFER_TOO_SMALL;
|
||||
std::lock_guard<std::mutex> lock(x.writeMutex);
|
||||
return x.Send(Reply, seq, static_cast<std::uint32_t>(status), p, size) && x.SendProgress()
|
||||
? MOBILEGL_OK
|
||||
: MOBILEGL_ERR_TRANSPORT_CLOSED;
|
||||
}
|
||||
MobileGLResult StreamLink::ReadReply(std::uint64_t seq, std::int32_t* status, const void** p, std::uint64_t* size) {
|
||||
auto& x = *m_impl;
|
||||
if (!status || !p || !size || !seq || !x.Client()) return MOBILEGL_ERR_INVALID_ARGUMENT;
|
||||
if (!x.memory) return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
std::unique_lock<std::mutex> lock(x.replyMutex);
|
||||
// The applied watermark is sent after the reply, so normal callers never
|
||||
// wait here. A standalone reply reader may wait without polling.
|
||||
x.replyReady.wait(lock, [&] {
|
||||
return x.closed.load(std::memory_order_acquire) || x.replySeq >= seq ||
|
||||
x.C().Progress.appliedSeq.load(std::memory_order_acquire) >= seq;
|
||||
});
|
||||
if (x.replySeq != seq) return x.closed.load() ? MOBILEGL_ERR_TRANSPORT_CLOSED : MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
x.readReply = x.reply;
|
||||
*status = x.replyStatus;
|
||||
*size = x.readReply.size();
|
||||
*p = x.readReply.data();
|
||||
return MOBILEGL_OK;
|
||||
}
|
||||
std::uint64_t StreamLink::EventPublishedHead() const {
|
||||
return m_impl->memory ? m_impl->E().cmdHead.load(std::memory_order_acquire) : 0;
|
||||
}
|
||||
MobileGLResult StreamLink::WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) {
|
||||
auto& x = *m_impl;
|
||||
if (!x.memory) return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
const auto ready = [&] { return x.E().cmdHead.load(std::memory_order_acquire) >= head; };
|
||||
if (ready()) return MOBILEGL_OK;
|
||||
const bool delivered = x.producer.Wait(x.C().producerParked, ready, 0, timeoutMs);
|
||||
return delivered ? MOBILEGL_OK : x.producer.Dead() ? MOBILEGL_ERR_TRANSPORT_CLOSED : MOBILEGL_ERR_TIMEOUT;
|
||||
}
|
||||
bool StreamLink::Attached() const {
|
||||
return m_impl->memory && !m_impl->closed.load(std::memory_order_acquire);
|
||||
}
|
||||
bool StreamLink::PeerHungUp() const {
|
||||
return m_impl->producer.PeerHungUp();
|
||||
}
|
||||
TransportRoleTag StreamLink::Role() const {
|
||||
return m_impl->role;
|
||||
}
|
||||
void StreamLink::Detach() {
|
||||
auto& x = *m_impl;
|
||||
if (!x.memory) return;
|
||||
x.stopping.store(true, std::memory_order_release);
|
||||
x.Die(false);
|
||||
if (x.reader.joinable()) x.reader.join();
|
||||
#if !defined(_WIN32)
|
||||
if (x.fd >= 0) ::close(x.fd);
|
||||
#endif
|
||||
x.fd = -1;
|
||||
x.memory = nullptr;
|
||||
}
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
@@ -1,108 +1,50 @@
|
||||
// MobileGL - MobileGL/MG_Remote/Transport/StreamLink.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
|
||||
|
||||
// ILink's second implementation, DECLARED BY c6 AND IMPLEMENTED BY NOBODY.
|
||||
// Authority: CONTRACT-P6.md §8.4. Its phase is P6.5.
|
||||
//
|
||||
// The link it exists for is TCP across machines (end state re-ruled 2026-09-22,
|
||||
// CONTRACT-P6.md §10.3, ARCHITECTURE.md §11.9), and it is one axis of two: the
|
||||
// control plane (ITransport) is chosen independently, so tcp control + shm data
|
||||
// on one machine is a legal pair and nothing above Transport/ may tell which.
|
||||
//
|
||||
// WHY A HEADER FOR SOMETHING THAT DOES NOT EXIST. ILink's adequacy - "can this
|
||||
// seam name what a byte stream needs?" - is the one claim c6 makes that an
|
||||
// argument cannot settle and a compile can. If ILink cannot express progress
|
||||
// transmission, a send window, a flush, span resolution without a mapping, and
|
||||
// replies that are messages rather than slots, then StreamLink cannot be
|
||||
// declared against it, and the build says so. That is c6's red-once: delete
|
||||
// one ILink method this class declares and the build goes red.
|
||||
//
|
||||
// It has already earned its keep. Writing it forced THREE methods that the
|
||||
// original brief's list - progress transmission, send window, flush - did not
|
||||
// name:
|
||||
//
|
||||
// ResolveSpan - a stream has no mapping to do pointer arithmetic over, so
|
||||
// the eleven ResolveOrFatal sites in the decoder need the
|
||||
// link to answer, not a segment table. Without it the seam
|
||||
// was unimplementable for the case it exists for.
|
||||
// FlushProgress - separate from Flush because the triggers differ: Flush is
|
||||
// about records the peer has not seen, FlushProgress is
|
||||
// about watermarks the peer is WAITING on. On a shared page
|
||||
// a release-store is both; on a stream, conflating them
|
||||
// either sends too much or hangs a waiter.
|
||||
// PostReply / - SEG_REPLY carries no message today: the server memcpys
|
||||
// ReadReply into a slot addressed `seq % slotCount` and the client
|
||||
// reads it after observing appliedSeq. A stream turns that
|
||||
// into a real message carrying its own seq, which DELETES
|
||||
// the slot pool, the modulus addressing and the stamp
|
||||
// self-check - so the seam has to own the operation rather
|
||||
// than hand out the pool.
|
||||
//
|
||||
// WHAT P6.5 STILL HAS TO SETTLE, recorded here so it is not rediscovered:
|
||||
// - SEG_STAGE's three ring cursors are DELIBERATELY DEAD (Ring.h's "DEAD IN P5, DELIBERATELY",
|
||||
// pinned by a test). Staging is an encoder-local linear allocator that
|
||||
// reclaims on retiredSeq. A send window either revives them COMPLETELY or
|
||||
// does not use them; the header names the middle state as a guaranteed
|
||||
// hang rather than a slow path.
|
||||
// - appliedSeq is excluded BY NAME from lazy publication (Ring.h's "BATCHING MAY ONLY MAKE A WATERMARK LATE").
|
||||
// P6.5 AMENDS that rule with a flush-on-idle discipline; it does not infer
|
||||
// around it.
|
||||
// - one dedicated reader thread per direction per process, or the event-ring
|
||||
// flow-control deadlock returns as write() blocked against write().
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ILink.h"
|
||||
#include <memory>
|
||||
|
||||
namespace MobileGL::MG_Remote::Transport {
|
||||
|
||||
// Every entry point is a named refusal. There is no partial implementation
|
||||
// and there may not be one: a half-wired stream link is the shape Ring.h
|
||||
// warns about, where FreeBytes() falls to zero on the first lap and never
|
||||
// recovers.
|
||||
//
|
||||
// The refusals live in StreamLink.cpp (package P6.5) rather than inline,
|
||||
// for the reason ILink.h gives: no header under Transport/ pulls the logger
|
||||
// in, and this one does not start.
|
||||
class SessionSegments;
|
||||
// One reader owns receive/reassembly. Writers serialize complete frames and use
|
||||
// the caller thread, so both directions can always drain a blocked peer writer.
|
||||
class StreamLink final : public ILink {
|
||||
public:
|
||||
StreamLink();
|
||||
~StreamLink() override;
|
||||
|
||||
MobileGLResult Attach(int dataFd, SessionSegments& mirrors, TransportRoleTag role);
|
||||
MobileGLResult AttachOwned(int dataFd, const struct SessionSegmentSizes& sizes, TransportRoleTag role);
|
||||
SessionSegments& Memory() override;
|
||||
void InitializeEndpoints() override;
|
||||
RingProducer& CommandsOut() override;
|
||||
RingConsumer& CommandsIn() override;
|
||||
EventRingProducer& EventsOut() override;
|
||||
EventRingConsumer& EventsIn() override;
|
||||
LinkCapabilities Capabilities() const override;
|
||||
|
||||
LinkProgress* Progress() override;
|
||||
LinkEventFlags* EventFlags() override;
|
||||
LinkArena* RecordArena() override;
|
||||
LinkCursor* RecordCursor() override;
|
||||
|
||||
MobileGLResult StageBytes(std::uint64_t bytes, LinkSpan* outSpan,
|
||||
void** outWritePtr) override;
|
||||
MobileGLResult ResolveSpan(LinkSegment segment, LinkSpan span,
|
||||
const void** outPtr) override;
|
||||
|
||||
MobileGLResult PostReply(std::uint64_t seq, std::int32_t status,
|
||||
const void* payload, std::uint64_t size) override;
|
||||
MobileGLResult ReadReply(std::uint64_t seq, std::int32_t* outStatus,
|
||||
const void** outPayload, std::uint64_t* outSize) override;
|
||||
|
||||
MobileGLResult StageBytes(std::uint64_t, LinkSpan*, void**) override;
|
||||
MobileGLResult ResolveSpan(LinkSegment, LinkSpan, const void**) override;
|
||||
MobileGLResult PostReply(std::uint64_t, std::int32_t, const void*, std::uint64_t) override;
|
||||
MobileGLResult ReadReply(std::uint64_t, std::int32_t*, const void**, std::uint64_t*) override;
|
||||
LinkArena* EventArena() override;
|
||||
LinkCursor* EventCursor() override;
|
||||
|
||||
std::uint64_t EventPublishedHead() const override;
|
||||
MobileGLResult WaitForEventDelivery(std::uint64_t head, std::uint32_t timeoutMs) override;
|
||||
Doorbell& ConsumerBell() override;
|
||||
Doorbell& ProducerBell() override;
|
||||
|
||||
MobileGLResult Flush() override;
|
||||
MobileGLResult FlushProgress() override;
|
||||
|
||||
void NoteStage(LinkSpan span) override;
|
||||
void ProgressChanged() override;
|
||||
bool PeerHungUp() const override;
|
||||
bool Attached() const override;
|
||||
void Detach() override;
|
||||
TransportRoleTag Role() const override;
|
||||
};
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
};
|
||||
} // namespace MobileGL::MG_Remote::Transport
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// first place. The static_asserts below pin the collision so it cannot be re-introduced by
|
||||
// someone who reads the comment and not this file.
|
||||
|
||||
#include <MG_Remote/Transport/LinkMetrics.h>
|
||||
#include "PipeWireCodec.h"
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
|
||||
@@ -392,6 +393,17 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// SegmentTable
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
void SegmentTable::AttachLink(Transport::ILink* link) {
|
||||
m_link = link;
|
||||
for (Uint32 id = kSegCmd; id <= kSegEvent; ++id) {
|
||||
const auto segment = static_cast<Transport::LinkSegment>(id);
|
||||
const Uint64 size = link ? link->SegmentSize(segment) : 0;
|
||||
const void* base = nullptr;
|
||||
if (link && link->ResolveSpan(segment, {0, size}, &base) != MOBILEGL_OK) base = nullptr;
|
||||
Install(static_cast<SegmentId>(id), {const_cast<void*>(base), size});
|
||||
}
|
||||
}
|
||||
|
||||
void SegmentTable::Install(SegmentId seg, SegmentView view) {
|
||||
if (seg == kSegNone || static_cast<Uint32>(seg) > static_cast<Uint32>(kSegAdopt)) {
|
||||
WireProtocolFatalAt("SegmentTable::Install", static_cast<Uint64>(seg),
|
||||
@@ -418,6 +430,11 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
if (size == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
if (m_link) {
|
||||
const void* bytes = nullptr;
|
||||
return m_link->ResolveSpan(static_cast<Transport::LinkSegment>(seg), {offset, size}, &bytes)
|
||||
== MOBILEGL_OK ? bytes : nullptr;
|
||||
}
|
||||
const SegmentView& view = m_views[static_cast<SizeT>(seg)];
|
||||
if (view.Base == nullptr) {
|
||||
return nullptr;
|
||||
@@ -822,13 +839,35 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// Encoder
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
PipeWireEncoder::PipeWireEncoder(Transport::ILink* link, SegmentTable* segments)
|
||||
: m_segments(segments) {
|
||||
if (!link) return;
|
||||
m_progress = link->Progress(); m_signals = link->Signals(); m_cmd = &link->CommandsOut();
|
||||
m_link = link->Capabilities().PublishIsDelivery ? nullptr : link;
|
||||
}
|
||||
|
||||
PipeWireEncoder::PipeWireEncoder(Transport::RingControl* control, Transport::RingProducer* cmd,
|
||||
Transport::RingProducer* stage, SegmentTable* segments)
|
||||
: m_control(control), m_cmd(cmd), m_stage(stage), m_segments(segments) {}
|
||||
: m_cmd(cmd), m_stage(stage), m_segments(segments) {
|
||||
if (control) {
|
||||
m_progress = &control->Progress;
|
||||
m_signals = {&control->cmdHead, &control->submittedSeq, &control->consumerParked,
|
||||
&control->producerParked, &control->eventRingFull};
|
||||
}
|
||||
}
|
||||
|
||||
Bool PipeWireEncoder::Valid() const { return m_control != nullptr && m_cmd != nullptr; }
|
||||
Bool PipeWireEncoder::Valid() const { return m_progress != nullptr && m_cmd != nullptr; }
|
||||
|
||||
Bool PipeWireEncoder::CheckCancellation() {
|
||||
if (Cancelled() || (m_cancellationHook && m_cancellationHook(m_cancellationSelf)) ||
|
||||
(m_stageRetirementBell && m_stageRetirementBell->Dead())) {
|
||||
m_cancelled = true;
|
||||
}
|
||||
return m_cancelled;
|
||||
}
|
||||
|
||||
Uint8* PipeWireEncoder::StageAllocate(Uint64 size) {
|
||||
if (CheckCancellation()) return nullptr;
|
||||
if (m_stageBase == nullptr) {
|
||||
const SegmentView view = m_segments != nullptr ? m_segments->Get(kSegStage)
|
||||
: SegmentView{};
|
||||
@@ -882,6 +921,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
bool reclaimed = false;
|
||||
bool waited = false;
|
||||
for (;;) {
|
||||
if (CheckCancellation()) return nullptr;
|
||||
// THE WRAP SKIP MAY ONLY BE CHARGED AGAINST BYTES THAT ARE STILL IN FLIGHT. When
|
||||
// there are none the allocator starts over at offset zero, so a blob the segment
|
||||
// can hold whole is never refused (see RebaseEmptyStage). On retry this runs
|
||||
@@ -896,6 +936,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
if ((m_stageHead + skip + need) - m_stageTail <= m_stageCapacity) {
|
||||
const Uint64 at = (m_stageHead + skip) % m_stageCapacity;
|
||||
m_stageHead += skip + need;
|
||||
Transport::LinkMetricsStageBytes(size);
|
||||
return m_stageBase + at;
|
||||
}
|
||||
if (!reclaimed) {
|
||||
@@ -907,7 +948,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
if (m_stageRetirementBell == nullptr || m_stageMarkFront == m_stageMarks.size()) break;
|
||||
const Uint64 pending = m_stageMarks[m_stageMarkFront].Seq;
|
||||
const auto ready = [&] {
|
||||
return m_control->Progress.retiredSeq.load(std::memory_order_acquire) >= pending;
|
||||
return m_progress->retiredSeq.load(std::memory_order_acquire) >= pending;
|
||||
};
|
||||
if (!ready()) {
|
||||
// The allocation still cannot progress after reclamation. Count this
|
||||
@@ -920,9 +961,14 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// again. The hook is null in every standalone codec, which has no session and
|
||||
// therefore no reverse channel to drain.
|
||||
if (m_stageWaitHook != nullptr) m_stageWaitHook(m_stageWaitSelf);
|
||||
if (!ready() && !m_stageRetirementBell->Wait(m_control->producerParked, ready, 0, 5000)) {
|
||||
SessionFail(MGFatalFamily::RetirementWaitFailed, "MGPipe: Fatal{RetirementWaitFailed, \"SEG_STAGE\"} producer wait "
|
||||
"ended before the pending allocation retired (shutdown or timeout)");
|
||||
if (m_link) m_link->Flush();
|
||||
if (CheckCancellation()) return nullptr;
|
||||
if (!ready() && !m_stageRetirementBell->Wait(*m_signals.ProducerParked, ready, 0,
|
||||
m_stageWaitTimeoutMs)) {
|
||||
if (CheckCancellation()) return nullptr;
|
||||
SessionFail(MGFatalFamily::RetirementWaitFailed,
|
||||
"MGPipe: Fatal{RetirementWaitFailed, \"SEG_STAGE\"} live peer did not retire "
|
||||
"the pending allocation within %u ms", m_stageWaitTimeoutMs);
|
||||
}
|
||||
if (m_stageWaitHook != nullptr) m_stageWaitHook(m_stageWaitSelf);
|
||||
}
|
||||
@@ -936,10 +982,11 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
static_cast<unsigned long long>(m_stageCapacity),
|
||||
static_cast<unsigned long long>(m_stageHead - m_stageTail),
|
||||
static_cast<unsigned long long>(
|
||||
m_control != nullptr ? m_control->Progress.retiredSeq.load(std::memory_order_acquire) : 0));
|
||||
m_progress != nullptr ? m_progress->retiredSeq.load(std::memory_order_acquire) : 0));
|
||||
}
|
||||
|
||||
MGPBlobRef PipeWireEncoder::StageBytes(const void* bytes, Uint64 size) {
|
||||
if (CheckCancellation()) return {};
|
||||
if (!Valid() || m_segments == nullptr) {
|
||||
WireProtocolFatal("PipeWireEncoder::StageBytes",
|
||||
"no command producer or segment table installed");
|
||||
@@ -956,8 +1003,10 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
}
|
||||
|
||||
Uint8* slot = StageAllocate(size);
|
||||
if (slot == nullptr || CheckCancellation()) return {};
|
||||
std::memcpy(slot, bytes, static_cast<SizeT>(size));
|
||||
const Uint64 offset = static_cast<Uint64>(slot - m_stageBase);
|
||||
if (m_link) m_link->NoteStage({offset, size});
|
||||
|
||||
MGPBlobRef ref{};
|
||||
ref.Seg = kSegStage;
|
||||
@@ -984,6 +1033,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
|
||||
Uint64 PipeWireEncoder::EncodeRecord(MGPWireOp op, const void* payload, Uint64 payloadBytes,
|
||||
const WireTail* tails, Uint32 tailCount) {
|
||||
if (Cancelled()) return kInvalidSeq;
|
||||
if (!Valid()) {
|
||||
WireProtocolFatal("PipeWireEncoder::EncodeRecord", "no SEG_CMD producer installed");
|
||||
}
|
||||
@@ -1222,10 +1272,10 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
}
|
||||
|
||||
void PipeWireEncoder::ReclaimStagedBytes() {
|
||||
if (m_control == nullptr) {
|
||||
if (m_progress == nullptr) {
|
||||
return;
|
||||
}
|
||||
const Uint64 retired = m_control->Progress.retiredSeq.load(std::memory_order_acquire);
|
||||
const Uint64 retired = m_progress->retiredSeq.load(std::memory_order_acquire);
|
||||
Uint64 upTo = m_stageTail;
|
||||
while (m_stageMarkFront < m_stageMarks.size() &&
|
||||
m_stageMarks[m_stageMarkFront].Seq <= retired) {
|
||||
@@ -1281,11 +1331,11 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// popping a ring, and the release store on SEG_CMD's head below is what orders the
|
||||
// staged writes before the record that names them.
|
||||
m_cmd->Publish();
|
||||
if (m_control != nullptr) {
|
||||
if (m_progress != nullptr) {
|
||||
// submittedSeq is the one watermark the PRODUCER owns (Ring.h's five-watermark
|
||||
// block). Nobody waits on it; it answers "how far ahead of the server is the
|
||||
// client right now".
|
||||
m_control->submittedSeq.store(m_emitSeq, std::memory_order_release);
|
||||
m_signals.SubmittedSeq->store(m_emitSeq, std::memory_order_release);
|
||||
}
|
||||
// The reclaim has a trigger in this package, rather than depending on a c1 barrier
|
||||
// that does not exist yet: every publish is a chance to notice what the server has
|
||||
@@ -1324,9 +1374,15 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// Decoder
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
PipeWireDecoder::PipeWireDecoder(Transport::ILink* link, SegmentTable* segments, ReplySink* replies)
|
||||
: m_valid(link && link->Attached()), m_segments(segments), m_replies(replies) {
|
||||
m_auditPoison = MG_Config::Ipc.Audit;
|
||||
InstallApplyHook();
|
||||
}
|
||||
|
||||
PipeWireDecoder::PipeWireDecoder(Transport::RingControl* control, SegmentTable* segments,
|
||||
ReplySink* replies)
|
||||
: m_control(control), m_segments(segments), m_replies(replies) {
|
||||
: m_valid(control != nullptr), m_segments(segments), m_replies(replies) {
|
||||
m_auditPoison = MG_Config::Ipc.Audit;
|
||||
// Once, at construction, beside the resolver it is modelled on - not per record from
|
||||
// the apply thread. The thunk is inert without a decoder on the calling thread, so an
|
||||
@@ -1340,7 +1396,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
|
||||
void PipeWireDecoder::UninstallApplyHook() { MG_Pipe::gMGPipeWireRecordApply = nullptr; }
|
||||
|
||||
Bool PipeWireDecoder::Valid() const { return m_control != nullptr && m_segments != nullptr; }
|
||||
Bool PipeWireDecoder::Valid() const { return m_valid && m_segments != nullptr; }
|
||||
|
||||
Uint64 PipeWireDecoder::AppliedSeq() const { return m_applySeq; }
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// span at all (it only ever writes Ptr = nullptr). Install() therefore takes the role.
|
||||
class SegmentTable {
|
||||
public:
|
||||
void AttachLink(Transport::ILink* link);
|
||||
void Install(SegmentId seg, SegmentView view);
|
||||
SegmentView Get(SegmentId seg) const;
|
||||
|
||||
@@ -100,6 +101,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
static void UninstallProcessResolver();
|
||||
|
||||
private:
|
||||
Transport::ILink* m_link = nullptr;
|
||||
SegmentView m_views[kSegAdopt + 1];
|
||||
};
|
||||
|
||||
@@ -218,6 +220,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
class PipeWireEncoder {
|
||||
public:
|
||||
PipeWireEncoder() = default;
|
||||
PipeWireEncoder(Transport::ILink* link, SegmentTable* segments);
|
||||
PipeWireEncoder(Transport::RingControl* control, Transport::RingProducer* cmd,
|
||||
Transport::RingProducer* stage, SegmentTable* segments);
|
||||
|
||||
@@ -338,7 +341,20 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
Uint64 StageReclaimWaits() const;
|
||||
// The live session supplies its shutdown-aware producer doorbell. Standalone codecs
|
||||
// without a consumer cannot wait for retirement and retain the named refusal.
|
||||
void SetLink(Transport::ILink* link) { m_link = link; }
|
||||
void SetStageRetirementDoorbell(Transport::Doorbell* bell) { m_stageRetirementBell = bell; }
|
||||
using CancellationHook = Bool (*)(void* self);
|
||||
void SetCancellationState(const std::atomic<bool>* lost, CancellationHook hook, void* self) {
|
||||
m_sessionLost = lost; m_cancellationHook = hook; m_cancellationSelf = self;
|
||||
}
|
||||
// The fast check is used on encode; the doorbell probe only runs while
|
||||
// staging or at an unsuccessful wait boundary.
|
||||
Bool Cancelled() const {
|
||||
return m_cancelled || (m_sessionLost && m_sessionLost->load(std::memory_order_acquire));
|
||||
}
|
||||
Bool CheckCancellation();
|
||||
void SetStageWaitTimeoutMs(Uint32 timeoutMs) { m_stageWaitTimeoutMs = timeoutMs; }
|
||||
|
||||
|
||||
// P5e (ra, CONTRACT-P5E §2.6): THE STAGE BELL IS A CLIENT WAIT, so it has to drain the
|
||||
// reverse channel like every other one. The encoder cannot drain it itself - SEG_EVENT
|
||||
@@ -373,6 +389,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// over the segment; the in-segment offset is `cursor % capacity` and a run that would
|
||||
// straddle the end skips to the boundary, exactly as a ring does, but WITHOUT touching
|
||||
// RingControl - see ReclaimStagedBytes above.
|
||||
Transport::ILink* m_link = nullptr;
|
||||
Uint8* StageAllocate(Uint64 size);
|
||||
|
||||
// AN EMPTY STAGE STARTS OVER AT ZERO, so that the wrap skip is only ever charged
|
||||
@@ -386,7 +403,8 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// the head and underflow StagedBytesInFlight().
|
||||
void RebaseEmptyStage();
|
||||
|
||||
Transport::RingControl* m_control = nullptr;
|
||||
Transport::LinkProgress* m_progress = nullptr;
|
||||
Transport::LinkSignals m_signals{};
|
||||
Transport::RingProducer* m_cmd = nullptr;
|
||||
Transport::RingProducer* m_stage = nullptr;
|
||||
SegmentTable* m_segments = nullptr;
|
||||
@@ -397,6 +415,12 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
Uint64 m_cmdWrapPads = 0;
|
||||
Uint64 m_stageReclaimWaits = 0;
|
||||
Transport::Doorbell* m_stageRetirementBell = nullptr;
|
||||
const std::atomic<bool>* m_sessionLost = nullptr;
|
||||
CancellationHook m_cancellationHook = nullptr;
|
||||
void* m_cancellationSelf = nullptr;
|
||||
Bool m_cancelled = false;
|
||||
Uint32 m_stageWaitTimeoutMs = 120000;
|
||||
|
||||
// P5e (ra): the session's event drain, called around the stage-bell park (§2.6).
|
||||
StageWaitHook m_stageWaitHook = nullptr;
|
||||
void* m_stageWaitSelf = nullptr;
|
||||
@@ -606,6 +630,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
class PipeWireDecoder {
|
||||
public:
|
||||
PipeWireDecoder() = default;
|
||||
PipeWireDecoder(Transport::ILink* link, SegmentTable* segments, ReplySink* replies);
|
||||
PipeWireDecoder(Transport::RingControl* control, SegmentTable* segments,
|
||||
ReplySink* replies);
|
||||
|
||||
@@ -707,7 +732,7 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
|
||||
friend Bool MGPipeWireRecordApplyThunk(MG_Pipe::MGPWireOp, const void*, Uint64, Uint64);
|
||||
|
||||
Transport::RingControl* m_control = nullptr;
|
||||
Bool m_valid = false;
|
||||
SegmentTable* m_segments = nullptr;
|
||||
ReplySink* m_replies = nullptr;
|
||||
WireVerbSink* m_verbs = nullptr;
|
||||
|
||||
@@ -413,9 +413,9 @@ namespace MobileGL::MG_State::GLState {
|
||||
// {h,cpp}, beside this header rather than inside it so the check_include_closure.py
|
||||
// "artifacts-header" probe stays untouched. It is two visitors over the tables below - a
|
||||
// writer that appends to a Vector<Uint8> and a reader that consumes one - length-prefixed,
|
||||
// little-endian, with a format-version word first and a MGL_LINKARTIFACTS_SIZE echo
|
||||
// second, so a struct that gained a field and a codec that did not is a mismatch at READ
|
||||
// time rather than a silent truncation. Adding a member to any struct above therefore
|
||||
// little-endian, with a format-version word and (for disaggregated v2) a recursive
|
||||
// wire-schema digest of these tables. Native container sizes are local maintenance
|
||||
// assertions below, never cross-standard-library wire facts. Adding a member to any struct above therefore
|
||||
// means: add its VisitFields row here, update the sizeof number below, and bump
|
||||
// kProgramArtifactsCodecVersion. `LinkArtifacts::program` stays the one deliberate
|
||||
// omission, and the codec has no arm for it.
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
@@ -70,6 +71,88 @@ namespace MobileGL::MG_State::GLState {
|
||||
template <class T>
|
||||
concept ArchiveUniformInitializer = std::same_as<T, UniformInitializer>;
|
||||
|
||||
// glslang supplies no VisitFields table for this aggregate. Keep its one explicit
|
||||
// table shared by the payload writer, reader and wire-schema walk.
|
||||
template <class Self, class Visitor>
|
||||
void VisitUniformInitializer(Self& value, Visitor&& visit) {
|
||||
visit("name", value.name);
|
||||
visit("basicType", value.basicType);
|
||||
visit("vectorSize", value.vectorSize);
|
||||
visit("matrixCols", value.matrixCols);
|
||||
visit("matrixRows", value.matrixRows);
|
||||
visit("arraySize", value.arraySize);
|
||||
visit("intValues", value.intValues);
|
||||
visit("floatValues", value.floatValues);
|
||||
}
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
void SchemaWord(Uint64& hash, Uint64 word) {
|
||||
for (unsigned i = 0; i < 8; ++i) {
|
||||
hash ^= (word >> (i * 8)) & 255u;
|
||||
hash *= 1099511628211ull;
|
||||
}
|
||||
}
|
||||
void SchemaName(Uint64& hash, const char* text) {
|
||||
do {
|
||||
hash ^= static_cast<unsigned char>(*text);
|
||||
hash *= 1099511628211ull;
|
||||
} while (*text++ != '\0');
|
||||
}
|
||||
template <class Value>
|
||||
void DescribeWireType(Uint64& hash) {
|
||||
using T = std::remove_cv_t<Value>;
|
||||
if constexpr (ArchiveScalar<T>) {
|
||||
// These are the bytes PutRaw/TakeRaw actually carry, not the surrounding
|
||||
// C++ object's layout. Equal-width signed/unsigned or float/int differ.
|
||||
if constexpr (std::is_enum_v<T>) {
|
||||
SchemaName(hash, "enum");
|
||||
DescribeWireType<std::underlying_type_t<T>>(hash);
|
||||
} else {
|
||||
SchemaName(hash, std::is_same_v<T, bool> ? "bool" :
|
||||
std::is_floating_point_v<T> ? "ieee-float" :
|
||||
std::is_signed_v<T> ? "signed" : "unsigned");
|
||||
SchemaWord(hash, sizeof(T));
|
||||
if constexpr (std::is_floating_point_v<T>) {
|
||||
static_assert(std::numeric_limits<T>::is_iec559);
|
||||
SchemaWord(hash, std::numeric_limits<T>::digits);
|
||||
SchemaWord(hash, std::numeric_limits<T>::max_exponent);
|
||||
}
|
||||
}
|
||||
} else if constexpr (ArchiveString<T>) {
|
||||
SchemaName(hash, "string-u64-count-byte-content");
|
||||
} else if constexpr (ArchiveMap<T>) {
|
||||
SchemaName(hash, "map-u64-count");
|
||||
DescribeWireType<typename T::key_type>(hash);
|
||||
DescribeWireType<typename T::mapped_type>(hash);
|
||||
} else if constexpr (ArchiveSet<T>) {
|
||||
SchemaName(hash, "set-u64-count");
|
||||
DescribeWireType<typename T::value_type>(hash);
|
||||
} else if constexpr (ArchiveFixedArray<T>) {
|
||||
SchemaName(hash, "fixed-array");
|
||||
SchemaWord(hash, std::tuple_size<T>::value);
|
||||
DescribeWireType<typename T::value_type>(hash);
|
||||
} else if constexpr (ArchiveVector<T>) {
|
||||
SchemaName(hash, "vector-u64-count");
|
||||
DescribeWireType<typename T::value_type>(hash);
|
||||
} else {
|
||||
SchemaName(hash, ArchiveUniformInitializer<T> ? "uniform-initializer" : "record");
|
||||
// Visit only types/names from default records. Container contents are never
|
||||
// traversed, and no sizeof(string/vector/map), offset or allocator enters it.
|
||||
T value{};
|
||||
Uint64 fields = 0;
|
||||
const auto field = [&](const char* name, const auto& member) {
|
||||
++fields;
|
||||
SchemaName(hash, name);
|
||||
DescribeWireType<std::remove_cvref_t<decltype(member)>>(hash);
|
||||
};
|
||||
if constexpr (ArchiveUniformInitializer<T>) VisitUniformInitializer(value, field);
|
||||
else VisitFields(value, field);
|
||||
SchemaWord(hash, fields);
|
||||
SchemaName(hash, "end-record");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// ---- the writer ----
|
||||
|
||||
template <class T>
|
||||
@@ -117,6 +200,11 @@ namespace MobileGL::MG_State::GLState {
|
||||
} else if constexpr (ArchiveVector<T>) {
|
||||
WriteSequence(out, value);
|
||||
} else if constexpr (ArchiveUniformInitializer<T>) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
VisitUniformInitializer(value, [&out](const char*, const auto& member) {
|
||||
WriteValue(out, member);
|
||||
});
|
||||
#else
|
||||
WriteValue(out, value.name);
|
||||
WriteValue(out, value.basicType);
|
||||
WriteValue(out, value.vectorSize);
|
||||
@@ -125,6 +213,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
WriteValue(out, value.arraySize);
|
||||
WriteValue(out, value.intValues);
|
||||
WriteValue(out, value.floatValues);
|
||||
#endif
|
||||
} else {
|
||||
// The archive's own structs: TypeFacts, ResourceReflection, XfbVarying. ONE
|
||||
// table serves both directions, so a member added to any of them is carried by
|
||||
@@ -223,6 +312,11 @@ namespace MobileGL::MG_State::GLState {
|
||||
if (!in.Ok) return;
|
||||
}
|
||||
} else if constexpr (ArchiveUniformInitializer<T>) {
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
VisitUniformInitializer(value, [&in](const char*, auto& member) {
|
||||
if (in.Ok) ReadValue(in, member);
|
||||
});
|
||||
#else
|
||||
ReadValue(in, value.name);
|
||||
ReadValue(in, value.basicType);
|
||||
ReadValue(in, value.vectorSize);
|
||||
@@ -231,6 +325,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
ReadValue(in, value.arraySize);
|
||||
ReadValue(in, value.intValues);
|
||||
ReadValue(in, value.floatValues);
|
||||
#endif
|
||||
} else {
|
||||
VisitFields(value, [&in](const char*, auto& field) {
|
||||
if (in.Ok) ReadValue(in, field);
|
||||
@@ -238,29 +333,41 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
}
|
||||
|
||||
// The struct-size echo. Under a toolchain whose sizes are not pinned yet
|
||||
// (ProgramArtifacts.h's libc++ branch until the integrator fills it in) this is 0,
|
||||
// which still round-trips within one build - the echo compares what THIS build wrote
|
||||
// against what THIS build expects - and stops mattering the moment the pin lands.
|
||||
//
|
||||
// P5e (pg) READ THIS LINE AS THE CONTRACT ASKED (CONTRACT-P5E §5.5) and its verdict is
|
||||
// in ProgramArtifactsCodec.h's header comment: the caveat is about the ECHO WORD, not
|
||||
// about a member the codec skips - the one member VisitFields omits is
|
||||
// `LinkArtifacts::program`, and no backend twin reads it. A 0 echo is exact for an
|
||||
// in-process split, where the writer and the reader are one build, and becomes a real
|
||||
// cross-toolchain check when P6 puts a client and a server in different processes
|
||||
// built by different compilers.
|
||||
// v1 is retained for local monolith verification. Its native size echo is not a
|
||||
// wire compatibility fact: libstdc++ writes 1056 while unpinned libc++ writes zero.
|
||||
#if !MOBILEGL_BUILD_DISAGGREGATED
|
||||
#ifdef MGL_LINKARTIFACTS_SIZE
|
||||
inline constexpr Uint64 kLinkArtifactsSizeEcho = MGL_LINKARTIFACTS_SIZE;
|
||||
#else
|
||||
inline constexpr Uint64 kLinkArtifactsSizeEcho = 0;
|
||||
#endif
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
Uint64 ProgramArtifactsSchemaFingerprint() {
|
||||
static const Uint64 fingerprint = [] {
|
||||
Uint64 hash = 1469598103934665603ull;
|
||||
SchemaName(hash, "MobileGL.ProgramArchive.v2.little-endian");
|
||||
// The outer stage framing is part of the same wire contract.
|
||||
SchemaName(hash, "stage-list-u32-count-u32-elements");
|
||||
SchemaWord(hash, kProgramArchiveMaxStages);
|
||||
DescribeWireType<LinkArtifacts>(hash);
|
||||
DescribeWireType<SpirvArtifacts>(hash);
|
||||
return hash == 0 ? Uint64{1} : hash;
|
||||
}();
|
||||
return fingerprint;
|
||||
}
|
||||
#endif
|
||||
|
||||
void EncodeProgramArtifacts(const LinkArtifacts& link, const SpirvArtifacts& spirv,
|
||||
Vector<Uint8>& out) {
|
||||
PutRaw(out, kProgramArtifactsCodecVersion);
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
PutRaw(out, ProgramArtifactsSchemaFingerprint());
|
||||
#else
|
||||
PutRaw(out, kLinkArtifactsSizeEcho);
|
||||
#endif
|
||||
// `link` is walked through its own VisitFields table, which omits the live
|
||||
// SharedPtr<glslang::TProgram>: 57 of the 58 members. There is no arm here for it and
|
||||
// there must not be one - it points into a glslang arena that no archived instance
|
||||
@@ -280,14 +387,16 @@ namespace MobileGL::MG_State::GLState {
|
||||
|
||||
ReadCursor in{bytes, size, 0, true};
|
||||
Uint32 version = 0;
|
||||
Uint64 sizeEcho = 0;
|
||||
if (!TakeRaw(in, version) || !TakeRaw(in, sizeEcho)) return false;
|
||||
// REFUSED, NOT GUESSED. A different version word or a struct that changed width means
|
||||
// the bytes describe a layout this build does not have; deserialising them anyway
|
||||
// writes garbage into the tail of a reflection table, which is exactly the failure the
|
||||
// two words exist to turn into a clean false.
|
||||
Uint64 schema = 0;
|
||||
if (!TakeRaw(in, version) || !TakeRaw(in, schema)) return false;
|
||||
// Refuse the declared wire shape before reading any field. In v2 the second word
|
||||
// follows serialization types/order; C++ container object sizes are irrelevant.
|
||||
if (version != kProgramArtifactsCodecVersion) return false;
|
||||
if (sizeEcho != kLinkArtifactsSizeEcho) return false;
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (schema != ProgramArtifactsSchemaFingerprint()) return false;
|
||||
#else
|
||||
if (schema != kLinkArtifactsSizeEcho) return false;
|
||||
#endif
|
||||
|
||||
ReadValue(in, link);
|
||||
ReadValue(in, spirv);
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
// path.
|
||||
//
|
||||
// THE FORMAT, and every part of it is a refusal rather than a guess:
|
||||
// * a VERSION word first, and a MGL_LINKARTIFACTS_SIZE echo second, so a struct that gained
|
||||
// a field and a codec that did not is a MISMATCH AT READ TIME rather than a silent
|
||||
// truncation that deserialises garbage into the tail of a reflection table;
|
||||
// * a VERSION word first, and a wire-schema fingerprint second (v2), so member order,
|
||||
// type or count-layout drift is a MISMATCH before decoding. The local-only v1 form
|
||||
// retains its legacy native-size echo;
|
||||
// * length-prefixed everything - strings, vectors, maps, sets - with the count checked
|
||||
// against the bytes that remain before a single element is allocated, so a corrupt count
|
||||
// cannot turn into a four-billion-element resize;
|
||||
@@ -54,19 +54,20 @@
|
||||
// member it does not carry is one no twin has ever asked for. It could not be carried in any
|
||||
// case: it points into a glslang arena that no archived instance owns.
|
||||
//
|
||||
// AND THE OTHER HALF OF THAT CONTRACT LINE - `ProgramArtifactsCodec.cpp`'s libc++ caveat - is
|
||||
// about the STRUCT-SIZE ECHO, not about a member: under a toolchain whose `MGL_LINKARTIFACTS_SIZE`
|
||||
// is not pinned yet (the NDK's libc++ branch of `ProgramArtifacts.h`, inert until the integrator
|
||||
// fills it in) the echo word is 0. That is SAFE FOR P5e AND NOT A GAP: the echo compares what
|
||||
// this build wrote against what this build expects, so a round trip within one build is exact,
|
||||
// and P5e is an in-process split where the writer and the reader ARE one build. It becomes a
|
||||
// real check the day a client and a server built by different toolchains share a wire, which is
|
||||
// P6's boundary and P6's problem - stated here so it cannot be discovered instead.
|
||||
// P6.5: native STL object sizes never describe this field-wise byte stream. Disaggregated
|
||||
// peers use v2's recursive wire-schema fingerprint; monolith verification retains v1.
|
||||
namespace MobileGL::MG_State::GLState {
|
||||
|
||||
// Bumped whenever the byte format changes in a way a previous reader would misread. A
|
||||
// reader that sees a different word REFUSES; it never tries to guess a layout.
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
inline constexpr Uint32 kProgramArtifactsCodecVersion = 2;
|
||||
// Derived from the actual VisitFields order/names, container element schemas and scalar
|
||||
// representations. No native container size/offset is included. Also checked in Hello.
|
||||
Uint64 ProgramArtifactsSchemaFingerprint();
|
||||
#else
|
||||
inline constexpr Uint32 kProgramArtifactsCodecVersion = 1;
|
||||
#endif
|
||||
|
||||
// Appends the archive to `out` (which is not cleared, so a caller may frame it). Never
|
||||
// fails: everything it walks is owned plain data.
|
||||
@@ -75,7 +76,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
|
||||
// Replaces `link` and `spirv` with what `bytes` describes. Returns false - with both
|
||||
// outputs left in a defined, default state - for a truncated stream, a version mismatch, a
|
||||
// struct-size mismatch, or trailing bytes the format does not account for. `link.program`
|
||||
// wire-schema mismatch (native-size echo for local v1), or trailing bytes. `link.program`
|
||||
// is always null on return.
|
||||
Bool DecodeProgramArtifacts(const Uint8* bytes, SizeT size, LinkArtifacts& link,
|
||||
SpirvArtifacts& spirv);
|
||||
|
||||
@@ -213,6 +213,17 @@ endif()
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(PipeCatalogueTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
# This source scanner must inspect the configured checkout, including in out-of-tree builds.
|
||||
# Apply the override after GoogleTest's deferred discovery, and only to this one test.
|
||||
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/PipeCatalogueSourceRoot.cmake" CONTENT
|
||||
"if(\"PipeCatalogue.FrontendNeverTakesAnApplierAddress\" IN_LIST PipeCatalogueTest_TESTS)
|
||||
set_tests_properties(PipeCatalogue.FrontendNeverTakesAnApplierAddress PROPERTIES
|
||||
WORKING_DIRECTORY [==[${MGL_ROOT}]==])
|
||||
endif()
|
||||
")
|
||||
set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/PipeCatalogueSourceRoot.cmake")
|
||||
|
||||
gtest_discover_tests(FieldOwnershipTest DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
foreach(pipeTest ResourceEmitTest VertexInputEmitTest
|
||||
FramebufferEmitTest TextureEmitTest SamplerEmitTest ImageEmitTest
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
// and every one of TypeFacts' twenty members - a codec that dropped one would be invisible
|
||||
// until a backend read a reflection answer that had quietly become zero;
|
||||
// * a TRUNCATED stream is refused rather than guessed at;
|
||||
// * a VERSION or struct-size mismatch is refused rather than deserialised into a layout this
|
||||
// build does not have.
|
||||
// * a VERSION or wire-schema mismatch is refused before decoding; native STL object
|
||||
// sizes do not describe a cross-platform serialized archive.
|
||||
//
|
||||
// AND ONE PROPERTY THAT IS NOT ABOUT BYTES AT ALL: LinkArtifacts has 58 members and its
|
||||
// VisitFields table visits 57. The 58th is the live SharedPtr<glslang::TProgram>, which is
|
||||
@@ -32,6 +32,7 @@
|
||||
// stays name-for-name identical between the pull and the push trees.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "Includes.h"
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
@@ -325,9 +326,8 @@ TEST(ProgramArtifactsCodec, ATruncatedStreamIsRefusedNotGuessed) {
|
||||
#endif
|
||||
}
|
||||
|
||||
// Negative control 2. The version word and the struct-size echo are the two things a compiler
|
||||
// cannot check: a struct that gained a field and a codec that did not would otherwise
|
||||
// deserialise garbage into the tail of a reflection table. Both have to REFUSE.
|
||||
// Negative control 2: both the version and schema word must refuse mismatches.
|
||||
// Monolith v1 retains the old native-size echo in that second word.
|
||||
TEST(ProgramArtifactsCodec, AVersionMismatchIsRefused) {
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
Vector<Uint8> bytes;
|
||||
@@ -344,9 +344,7 @@ TEST(ProgramArtifactsCodec, AVersionMismatchIsRefused) {
|
||||
++wrongVersion[0];
|
||||
EXPECT_FALSE(DecodeProgramArtifacts(wrongVersion.data(), wrongVersion.size(), link, spirv));
|
||||
|
||||
// Then the MGL_LINKARTIFACTS_SIZE echo, which is the half that catches a struct that grew
|
||||
// under a codec that did not - the failure the four sizeof trip wires in
|
||||
// ProgramArtifacts.h send an author here to fix.
|
||||
// Then the wire schema (v2) or local native-size echo (v1). Neither may be ignored.
|
||||
Vector<Uint8> wrongSize = bytes;
|
||||
++wrongSize[4];
|
||||
EXPECT_FALSE(DecodeProgramArtifacts(wrongSize.data(), wrongSize.size(), link, spirv));
|
||||
@@ -373,3 +371,39 @@ TEST(ProgramArtifactsCodec, TheTablesVisitEveryMemberExceptTheLiveProgram) {
|
||||
GTEST_SKIP() << "MOBILEGL_PIPE_PUSH is off: the archive codec is push-only";
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(ProgramArtifactsCodec, PortableHeaderUsesWireSchemaRatherThanNativeContainerSize) {
|
||||
#if MOBILEGL_PIPE_PUSH && MOBILEGL_BUILD_DISAGGREGATED
|
||||
Vector<Uint8> bytes;
|
||||
EncodeProgramArtifacts(MakeLinkArtifacts(), MakeSpirvArtifacts(), bytes);
|
||||
ASSERT_GT(bytes.size(), 12u);
|
||||
Uint32 version = 0;
|
||||
Uint64 schema = 0;
|
||||
std::memcpy(&version, bytes.data(), sizeof(version));
|
||||
std::memcpy(&schema, bytes.data() + sizeof(version), sizeof(schema));
|
||||
EXPECT_EQ(version, 2u);
|
||||
EXPECT_EQ(schema, ProgramArtifactsSchemaFingerprint());
|
||||
EXPECT_NE(schema, 0u);
|
||||
EXPECT_NE(schema, sizeof(LinkArtifacts));
|
||||
RecordProperty("program_archive_wire_schema", std::to_string(schema));
|
||||
|
||||
// The old Linux/native echo (1056) and unpinned libc++ echo (0) both fail.
|
||||
// This control distinguishes a portable schema from simply deleting the check.
|
||||
for (const Uint64 legacyEcho : {Uint64{1056}, Uint64{0}}) {
|
||||
auto legacy = bytes;
|
||||
std::memcpy(legacy.data() + sizeof(version), &legacyEcho, sizeof(legacyEcho));
|
||||
LinkArtifacts link;
|
||||
SpirvArtifacts spirv;
|
||||
EXPECT_FALSE(DecodeProgramArtifacts(legacy.data(), legacy.size(), link, spirv));
|
||||
EXPECT_TRUE(link.uniformReflection.empty());
|
||||
EXPECT_TRUE(spirv.generatedSpirv.empty());
|
||||
}
|
||||
auto v1 = bytes;
|
||||
v1[0] = 1;
|
||||
LinkArtifacts link;
|
||||
SpirvArtifacts spirv;
|
||||
EXPECT_FALSE(DecodeProgramArtifacts(v1.data(), v1.size(), link, spirv));
|
||||
#else
|
||||
GTEST_SKIP() << "portable archive headers apply to the disaggregated wire";
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -134,13 +134,19 @@ namespace {
|
||||
PS::Init();
|
||||
|
||||
for (Uint32 i = 0; i < 5; ++i) {
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
PS::PublishGauge(PS::Gauge::ServerWaits, static_cast<Uint64>(100 * (i + 1)));
|
||||
#endif
|
||||
PS::OnPresent();
|
||||
}
|
||||
EXPECT_EQ(PS::FrameCount(), 5u);
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
// The gauge is a RUN TOTAL: publishing five increasing values leaves the last one,
|
||||
// never their sum. This is the mistake the report's first aggregation script made.
|
||||
// Gauges are push-only (gate G1, see PipeStats.h); the pull flavour keeps the case
|
||||
// registered for name parity and asserts only the window arithmetic above.
|
||||
EXPECT_EQ(PS::GaugeValue(PS::Gauge::ServerWaits), 500u);
|
||||
#endif
|
||||
|
||||
MobileGL::MG_Config::Features.PipeStatsPeriod = saved;
|
||||
PS::Init();
|
||||
|
||||
@@ -22,7 +22,7 @@ if (NOT WIN32)
|
||||
# P6 so: the SAME nine ITransport-contract cases InProcessTransportTest runs, over a real
|
||||
# socketpair with real threads, plus the three a stream has and a message queue does not.
|
||||
# POSIX for the same reason as FdPassingTest - and because CONTRACT-P6 §2.6 lands POSIX only.
|
||||
list(APPEND MOBILEGL_WIRE_TESTS SocketTransportTest)
|
||||
list(APPEND MOBILEGL_WIRE_TESTS SocketTransportTest StreamLinkTest StreamClientPublicationTest InitialCapsStartupTest)
|
||||
# P6 sm: two MobileGL processes. Needs the real server image beside it, so
|
||||
# the dependency is declared after the loop rather than assumed.
|
||||
list(APPEND MOBILEGL_WIRE_TESTS ServerSpawnTest)
|
||||
@@ -141,3 +141,15 @@ foreach (wiretest IN ITEMS RemoteClientTest ServerLoopTest SessionHandshakeTest
|
||||
|
||||
gtest_discover_tests(${wiretest} DISCOVERY_TIMEOUT 30 PROPERTIES LABELS unit)
|
||||
endforeach ()
|
||||
|
||||
# P6.5 manual fault-injection probe: requires an explicit live peer and is never
|
||||
# registered with ctest, so a device-less unit run cannot silently skip this gate.
|
||||
if (NOT WIN32)
|
||||
add_executable(MobileGLPeerLossProbe PeerLossProbe.cpp)
|
||||
target_include_directories(MobileGLPeerLossProbe PRIVATE
|
||||
${MGL_ROOT}/include
|
||||
${MGL_ROOT}/MobileGL
|
||||
${MGL_ROOT}/3rdparty/flatbuffers/include
|
||||
)
|
||||
target_link_libraries(MobileGLPeerLossProbe PRIVATE ${LINK_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
@@ -195,3 +195,21 @@ TEST(FramingTest, ManyMessagesCompactTheBufferInsteadOfGrowing) {
|
||||
}
|
||||
EXPECT_EQ(reader.BufferedBytes(), 0u);
|
||||
}
|
||||
|
||||
TEST(Framing, ADataMagicReaderKeepsTheSameLengthAndReassemblyRules) {
|
||||
using namespace MobileGL::MG_Remote::Transport;
|
||||
constexpr std::uint32_t dataMagic = 0x444c474d;
|
||||
std::vector<std::uint8_t> payload(20 + 9, 0x5a), framed;
|
||||
ASSERT_EQ(AppendFrame(framed, payload.data(), payload.size()), MOBILEGL_OK);
|
||||
std::memcpy(framed.data(), &dataMagic, sizeof dataMagic);
|
||||
FrameReader reader(dataMagic);
|
||||
ASSERT_EQ(reader.Feed(framed.data(), 7), MOBILEGL_OK);
|
||||
EXPECT_FALSE(reader.HasMessage());
|
||||
ASSERT_EQ(reader.Feed(framed.data() + 7, framed.size() - 7), MOBILEGL_OK);
|
||||
EXPECT_EQ(reader.PendingMessageSize(), payload.size());
|
||||
std::vector<std::uint8_t> received;
|
||||
ASSERT_EQ(reader.TakeMessage(received), MOBILEGL_OK);
|
||||
EXPECT_EQ(received, payload);
|
||||
FrameReader controlReader;
|
||||
EXPECT_EQ(controlReader.Feed(framed.data(), framed.size()), MOBILEGL_ERR_PROTOCOL_MISMATCH);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// Starts at the post-Welcome boundary with real TCP endpoints and ControlInbox.
|
||||
// The peer publishes real CapsSnapshot bytes; no private run-ahead flag is set.
|
||||
#include <MG_Remote/Client/ClientSession.h>
|
||||
#include <MG_Remote/CapsCodec.h>
|
||||
#include <MG_Remote/Transport/ControlInbox.h>
|
||||
#include <MG_Remote/Transport/SocketTransport.h>
|
||||
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace MobileGL;
|
||||
using namespace MobileGL::MG_Remote;
|
||||
namespace {
|
||||
template <class Tag, typename Tag::Type member>
|
||||
struct StartupPeerAccess {
|
||||
friend typename Tag::Type StartupPeerMember(Tag) { return member; }
|
||||
};
|
||||
struct StartupControlTag {
|
||||
using Type = Transport::ITransport* Client::ClientSession::*;
|
||||
friend Type StartupPeerMember(StartupControlTag);
|
||||
};
|
||||
template struct StartupPeerAccess<StartupControlTag, &Client::ClientSession::m_transport>;
|
||||
struct StartupInboxTag {
|
||||
using Type = std::unique_ptr<Transport::ControlInbox> Client::ClientSession::*;
|
||||
friend Type StartupPeerMember(StartupInboxTag);
|
||||
};
|
||||
template struct StartupPeerAccess<StartupInboxTag, &Client::ClientSession::m_controlInbox>;
|
||||
|
||||
class InitialCapsStartup : public testing::Test {
|
||||
protected:
|
||||
Client::ClientSession client;
|
||||
std::unique_ptr<Transport::SocketTransport> controlClient, controlPeer;
|
||||
std::unique_ptr<Transport::ILink> dataPeer;
|
||||
const decltype(MG_Config::Ipc) savedIpc = MG_Config::Ipc;
|
||||
const MG_Config::TransportMode savedTransport = MG_Config::Transport;
|
||||
|
||||
void SetUp() override {
|
||||
::alarm(10);
|
||||
MG_Config::Transport = MG_Config::TransportMode::Spawn;
|
||||
MG_Config::Ipc.RunAhead = 1;
|
||||
MG_Config::Ipc.VerbBarrier = 1;
|
||||
int reserve = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
ASSERT_GE(reserve, 0);
|
||||
sockaddr_in address{};
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
ASSERT_EQ(::bind(reserve, reinterpret_cast<sockaddr*>(&address), sizeof address), 0);
|
||||
socklen_t length = sizeof address;
|
||||
ASSERT_EQ(::getsockname(reserve, reinterpret_cast<sockaddr*>(&address), &length), 0);
|
||||
const std::string endpoint = "tcp://127.0.0.1:" + std::to_string(ntohs(address.sin_port));
|
||||
::close(reserve);
|
||||
int listener = -1;
|
||||
ASSERT_EQ(Transport::SocketTransport::Listen(endpoint, &listener), MOBILEGL_OK);
|
||||
MobileGLResult accepted = MOBILEGL_ERR_TIMEOUT;
|
||||
std::thread accepting(
|
||||
[&] { accepted = Transport::SocketTransport::AcceptPair(listener, 2000, controlPeer); });
|
||||
const auto connected = Transport::SocketTransport::ConnectTo(endpoint, 2000, controlClient);
|
||||
accepting.join();
|
||||
::close(listener);
|
||||
ASSERT_EQ(connected, MOBILEGL_OK);
|
||||
ASSERT_EQ(accepted, MOBILEGL_OK);
|
||||
ASSERT_TRUE(controlClient->IsTcp());
|
||||
ASSERT_TRUE(controlPeer->IsTcp());
|
||||
|
||||
Transport::SessionSegmentSizes sizes;
|
||||
sizes.CmdRingBytes = 4096;
|
||||
sizes.StageBytes = 4096;
|
||||
sizes.EventRingBytes = 4096;
|
||||
sizes.ReplyBytes = 4096;
|
||||
ASSERT_EQ(client.AttachStreamLink(controlClient->TakeDataFd(), sizes), MOBILEGL_OK);
|
||||
ASSERT_EQ(Transport::CreateStreamLink(controlPeer->TakeDataFd(), sizes,
|
||||
Transport::TransportRoleTag::ServerConsumer, dataPeer),
|
||||
MOBILEGL_OK);
|
||||
dataPeer->InitializeEndpoints();
|
||||
client.*StartupPeerMember(StartupControlTag{}) = controlClient.get();
|
||||
client.*StartupPeerMember(StartupInboxTag{}) = std::make_unique<Transport::ControlInbox>(*controlClient);
|
||||
}
|
||||
void TearDown() override {
|
||||
if (client.DataLink()) client.DataLink()->Detach();
|
||||
if (dataPeer) dataPeer->Detach();
|
||||
client.Stop();
|
||||
MG_Config::Ipc = savedIpc;
|
||||
MG_Config::Transport = savedTransport;
|
||||
::alarm(0);
|
||||
}
|
||||
MobileGLResult Start() {
|
||||
return client.FinishStartup(&client.DataLink()->ConsumerBell(), &client.DataLink()->ProducerBell(), false);
|
||||
}
|
||||
MobileGLResult SendCaps(Uint64 bits) {
|
||||
MG_Backend::DynamicBackendParameters dynamic{};
|
||||
MG_Backend::FormatCapabilityCache formats{};
|
||||
RendererInfo renderer{};
|
||||
Vector<Uint8> encodedFormats, encodedRenderer;
|
||||
if (!EncodeFormatCapabilities(formats, encodedFormats) || !EncodeRendererInfo(renderer, encodedRenderer))
|
||||
return MOBILEGL_ERR_PROTOCOL_MISMATCH;
|
||||
flatbuffers::FlatBufferBuilder builder;
|
||||
const auto parameters = builder.CreateVector(reinterpret_cast<const Uint8*>(&dynamic), sizeof dynamic);
|
||||
const auto rendererBytes = builder.CreateVector(encodedRenderer.data(), encodedRenderer.size());
|
||||
const auto formatBytes = builder.CreateVector(encodedFormats.data(), encodedFormats.size());
|
||||
const auto version = builder.CreateString("4.6");
|
||||
const auto caps =
|
||||
::MobileGL::Wire::CreateCapsSnapshot(builder, parameters, rendererBytes, formatBytes, 0, version, bits,
|
||||
static_cast<Uint32>(BackendType::DirectGLES));
|
||||
const auto envelope =
|
||||
::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::CapsSnapshot, caps.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
return controlPeer->SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||
}
|
||||
MobileGLResult SendLog() {
|
||||
flatbuffers::FlatBufferBuilder builder;
|
||||
const auto line = ::MobileGL::Wire::CreateLogLine(
|
||||
builder, ::MobileGL::Wire::LogLevel::Info,
|
||||
builder.CreateString("initial caps intentionally delayed by test peer"));
|
||||
const auto envelope =
|
||||
::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::LogLine, line.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
return controlPeer->SendFrame({builder.GetBufferPointer(), builder.GetSize()});
|
||||
}
|
||||
bool PumpSnapshot() {
|
||||
const auto end = std::chrono::steady_clock::now() + std::chrono::seconds(1);
|
||||
do {
|
||||
if (client.PumpControlPlane()) return true;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
} while (std::chrono::steady_clock::now() < end);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(InitialCapsStartup, DelayedTcpSnapshotArmsRunAheadAndLaterSnapshotsCanOnlyDemote) {
|
||||
std::atomic<bool> startupReturned{false};
|
||||
bool returnedBeforeCaps = false;
|
||||
MobileGLResult logResult = MOBILEGL_ERR_TIMEOUT, capsResult = MOBILEGL_ERR_TIMEOUT;
|
||||
std::thread sender([&] {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
returnedBeforeCaps = startupReturned.load(std::memory_order_acquire);
|
||||
logResult = SendLog();
|
||||
capsResult = SendCaps(MG_Pipe::kCapRunAheadApply);
|
||||
});
|
||||
const auto result = Start();
|
||||
startupReturned.store(true, std::memory_order_release);
|
||||
sender.join();
|
||||
ASSERT_EQ(logResult, MOBILEGL_OK);
|
||||
ASSERT_EQ(capsResult, MOBILEGL_OK);
|
||||
EXPECT_FALSE(returnedBeforeCaps) << "startup returned without a real initial snapshot";
|
||||
ASSERT_EQ(result, MOBILEGL_OK);
|
||||
EXPECT_TRUE(client.Started());
|
||||
EXPECT_TRUE(client.RunAheadArmed());
|
||||
ASSERT_EQ(SendCaps(0), MOBILEGL_OK);
|
||||
ASSERT_TRUE(PumpSnapshot());
|
||||
EXPECT_FALSE(client.RunAheadArmed());
|
||||
ASSERT_EQ(SendCaps(MG_Pipe::kCapRunAheadApply), MOBILEGL_OK);
|
||||
ASSERT_TRUE(PumpSnapshot());
|
||||
EXPECT_FALSE(client.RunAheadArmed()) << "a later cap must not re-promote this session";
|
||||
}
|
||||
|
||||
TEST_F(InitialCapsStartup, AHealthyPeerWithoutInitialCapsFailsStartupWithoutDeviceLoss) {
|
||||
const auto before = std::chrono::steady_clock::now();
|
||||
EXPECT_EQ(Start(), MOBILEGL_ERR_TIMEOUT);
|
||||
const auto elapsed = std::chrono::steady_clock::now() - before;
|
||||
EXPECT_GE(elapsed, std::chrono::seconds(4));
|
||||
EXPECT_LT(elapsed, std::chrono::seconds(8));
|
||||
EXPECT_FALSE(client.Started());
|
||||
EXPECT_FALSE(client.RunAheadArmed());
|
||||
EXPECT_FALSE(Client::ClientSession::DeviceLost());
|
||||
}
|
||||
|
||||
TEST_F(InitialCapsStartup, ANullInitialSnapshotFailsInsteadOfStartingWithAPlaceholder) {
|
||||
flatbuffers::FlatBufferBuilder builder;
|
||||
const auto envelope = ::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::CapsSnapshot,
|
||||
flatbuffers::Offset<void>{});
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
ASSERT_EQ(controlPeer->SendFrame({builder.GetBufferPointer(), builder.GetSize()}), MOBILEGL_OK);
|
||||
EXPECT_EQ(Start(), MOBILEGL_ERR_PROTOCOL_MISMATCH);
|
||||
EXPECT_FALSE(client.Started());
|
||||
EXPECT_FALSE(Client::ClientSession::DeviceLost());
|
||||
}
|
||||
} // namespace
|
||||
@@ -0,0 +1,270 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// Manual P6.5 S2/half-open probe. Never registered as a device-less unit test.
|
||||
#include <Init.h>
|
||||
#include <MG_Impl/GLImpl/Getter/GL_Getter.h>
|
||||
#include <MG_Impl/Pipe/SlotAllocator.h>
|
||||
#include <MG_Remote/Client/ClientSession.h>
|
||||
#include <MG_Remote/Transport/Doorbell.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <csignal>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace MobileGL;
|
||||
using namespace MobileGL::MG_Remote;
|
||||
namespace {
|
||||
struct Options {
|
||||
bool kill = false;
|
||||
bool external = false;
|
||||
unsigned deadlineMs = 10000;
|
||||
unsigned armTimeoutMs = 120000;
|
||||
std::string readyFile;
|
||||
std::string startFile;
|
||||
};
|
||||
void Usage() {
|
||||
std::fprintf(stderr, "MobileGLPeerLossProbe (--kill | --external) [--deadline-ms 10000]\n"
|
||||
" [--ready-file PATH] [--start-file PATH] [--arm-timeout-ms 120000]\n"
|
||||
"MOBILEGL_IPC_CONTROL=tcp://host:port is required; token/build policy use normal env.\n"
|
||||
"--kill executes MGITEST_PEER_KILL_CMD with {pid} replaced by Welcome.serverPid.\n"
|
||||
"--external sends no fault command. After READY, create --start-file immediately\n"
|
||||
"before the parent's Wi-Fi cut; without a start file, type GO on stdin to arm.\n"
|
||||
"Only descriptor hangup passes. A deadline never sets the device-lost latch.\n");
|
||||
}
|
||||
bool Number(const char* text, unsigned& result) {
|
||||
char* end = nullptr;
|
||||
const auto value = std::strtoul(text, &end, 10);
|
||||
if (!text[0] || !end || *end || !value || value > 600000) return false;
|
||||
result = static_cast<unsigned>(value);
|
||||
return true;
|
||||
}
|
||||
bool Parse(int argc, char** argv, Options& options) {
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
const std::string argument = argv[i];
|
||||
if (argument == "--kill")
|
||||
options.kill = true;
|
||||
else if (argument == "--external")
|
||||
options.external = true;
|
||||
else if (i + 1 < argc && argument == "--deadline-ms") {
|
||||
if (!Number(argv[++i], options.deadlineMs)) return false;
|
||||
} else if (i + 1 < argc && argument == "--arm-timeout-ms") {
|
||||
if (!Number(argv[++i], options.armTimeoutMs)) return false;
|
||||
} else if (i + 1 < argc && argument == "--ready-file")
|
||||
options.readyFile = argv[++i];
|
||||
else if (i + 1 < argc && argument == "--start-file")
|
||||
options.startFile = argv[++i];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return options.kill != options.external && (!options.kill || options.startFile.empty());
|
||||
}
|
||||
bool Exists(const std::string& path) {
|
||||
std::error_code error;
|
||||
return std::filesystem::exists(path, error);
|
||||
}
|
||||
struct SessionCleanup {
|
||||
Client::ClientSession& session;
|
||||
~SessionCleanup() { session.Stop(); }
|
||||
};
|
||||
// The fault helper gets its own process group. It only execs the caller's
|
||||
// explicit template; killing/reaping this helper never touches a supervisor.
|
||||
class FaultCommand {
|
||||
public:
|
||||
bool Start(const std::string& command) {
|
||||
m_pid = ::fork();
|
||||
if (m_pid == 0) {
|
||||
if (::setpgid(0, 0) != 0) ::_exit(126);
|
||||
::execl("/bin/sh", "sh", "-c", command.c_str(), static_cast<char*>(nullptr));
|
||||
::_exit(127);
|
||||
}
|
||||
if (m_pid < 0) return false;
|
||||
(void)::setpgid(m_pid, m_pid);
|
||||
return true;
|
||||
}
|
||||
bool Finished() {
|
||||
if (m_pid <= 0) return true;
|
||||
const auto result = ::waitpid(m_pid, &m_status, WNOHANG);
|
||||
if (result == m_pid) {
|
||||
m_pid = -1;
|
||||
m_finished = true;
|
||||
}
|
||||
return m_finished;
|
||||
}
|
||||
bool Succeeded() const { return m_finished && WIFEXITED(m_status) && WEXITSTATUS(m_status) == 0; }
|
||||
~FaultCommand() {
|
||||
if (m_pid <= 0 || Finished()) return;
|
||||
(void)::kill(-m_pid, SIGTERM);
|
||||
for (int i = 0; i != 20 && !Finished(); ++i)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
if (m_pid > 0) {
|
||||
(void)::kill(-m_pid, SIGKILL);
|
||||
(void)::waitpid(m_pid, &m_status, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
pid_t m_pid = -1;
|
||||
int m_status = -1;
|
||||
bool m_finished = false;
|
||||
};
|
||||
bool ArmExternal(const Options& options) {
|
||||
if (options.startFile.empty()) {
|
||||
std::string line;
|
||||
return std::getline(std::cin, line) && line == "GO";
|
||||
}
|
||||
const auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(options.armTimeoutMs);
|
||||
while (!Exists(options.startFile)) {
|
||||
if (std::chrono::steady_clock::now() >= deadline) return false;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc == 2 && std::strcmp(argv[1], "--help") == 0) {
|
||||
Usage();
|
||||
return 0;
|
||||
}
|
||||
Options options;
|
||||
if (!Parse(argc, argv, options)) {
|
||||
Usage();
|
||||
return 64;
|
||||
}
|
||||
const char* endpoint = std::getenv("MOBILEGL_IPC_CONTROL");
|
||||
if (!endpoint || std::strncmp(endpoint, "tcp://", 6) != 0) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: MOBILEGL_IPC_CONTROL must name an existing TCP server\n");
|
||||
return 64;
|
||||
}
|
||||
if ((!options.readyFile.empty() && Exists(options.readyFile)) ||
|
||||
(!options.startFile.empty() && Exists(options.startFile))) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: readiness/start files must be fresh for this run\n");
|
||||
return 64;
|
||||
}
|
||||
const char* killTemplate = std::getenv("MGITEST_PEER_KILL_CMD");
|
||||
if (options.kill && (!killTemplate || !std::strstr(killTemplate, "{pid}"))) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: --kill requires MGITEST_PEER_KILL_CMD containing {pid}\n");
|
||||
return 64;
|
||||
}
|
||||
// No server is forked by the client. StartSpawned resolves Connect from the
|
||||
// ordinary configuration, exactly as the integration TCP lane does.
|
||||
::setenv("MOBILEGL_TRANSPORT", "spawn", 1);
|
||||
::setenv("MOBILEGL_IPC_DATA", "stream", 1);
|
||||
::setenv("MOBILEGL_IPC_ROLE", "client", 1);
|
||||
::setenv("MOBILEGL_BACKEND_TYPE", "DirectGLES", 0);
|
||||
MG_ConfigLoader::Init();
|
||||
auto& session = Client::ClientSessionInstance();
|
||||
SessionCleanup cleanup{session};
|
||||
const auto started = session.StartSpawned();
|
||||
if (started != MOBILEGL_OK || !session.ConnectDial() || !session.DataLink() ||
|
||||
session.DataLink()->Capabilities().SharedMapping) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: TCP+stream bringup rc=%d\n", started);
|
||||
return 2;
|
||||
}
|
||||
const auto peerPid = session.PeerServerPid();
|
||||
auto* bell = session.SelfDoorbellForTest();
|
||||
if (peerPid <= 1 || !bell || bell->PeerHungUp() || Client::ClientSession::DeviceLost() ||
|
||||
MG_Impl::GLImpl::GetGraphicsResetStatus() != GL_NO_ERROR) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: no healthy Welcome peer before arming\n");
|
||||
return 2;
|
||||
}
|
||||
// A real control round-trip finishes before the idle measurement. No GL
|
||||
// command or application heartbeat is sent during the detection interval.
|
||||
session.SyncPeerLog();
|
||||
if (bell->PeerHungUp() || Client::ClientSession::DeviceLost()) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: peer disappeared before readiness\n");
|
||||
return 2;
|
||||
}
|
||||
if (!options.readyFile.empty()) {
|
||||
std::ofstream ready(options.readyFile, std::ios::out | std::ios::trunc);
|
||||
ready << peerPid << '\n';
|
||||
ready.flush();
|
||||
if (!ready) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: cannot publish ready file\n");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
std::printf("P65_PEER_LOSS_READY pid=%u mode=%s control=%s data=stream deadline_ms=%u\n", peerPid,
|
||||
options.kill ? "kill" : "external", endpoint, options.deadlineMs);
|
||||
std::fflush(stdout);
|
||||
if (options.external && !ArmExternal(options)) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: external trigger was not armed\n");
|
||||
return 3;
|
||||
}
|
||||
if (bell->PeerHungUp()) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: peer disappeared before timer arm; timing is invalid\n");
|
||||
return 3;
|
||||
}
|
||||
std::string command;
|
||||
if (options.kill) {
|
||||
command = killTemplate;
|
||||
const auto pidText = std::to_string(peerPid);
|
||||
for (std::size_t at = 0; (at = command.find("{pid}", at)) != std::string::npos; at += pidText.size())
|
||||
command.replace(at, 5, pidText);
|
||||
}
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
const auto deadline = start + std::chrono::milliseconds(options.deadlineMs);
|
||||
FaultCommand fault;
|
||||
if (options.kill && !fault.Start(command)) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: could not start the caller's kill command\n");
|
||||
return 4;
|
||||
}
|
||||
std::printf("P65_PEER_LOSS_ARMED pid=%u mode=%s\n", peerPid, options.kill ? "kill" : "external");
|
||||
std::fflush(stdout);
|
||||
while (!bell->PeerHungUp() && std::chrono::steady_clock::now() < deadline) {
|
||||
if (options.kill && fault.Finished() && !fault.Succeeded()) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: caller's kill command failed\n");
|
||||
return 4;
|
||||
}
|
||||
(void)bell->Park(10);
|
||||
}
|
||||
const auto hangupAt = std::chrono::steady_clock::now();
|
||||
const auto hangupMs = std::chrono::duration_cast<std::chrono::milliseconds>(hangupAt - start).count();
|
||||
if (!bell->PeerHungUp() || !bell->Dead() || hangupAt >= deadline) {
|
||||
std::fprintf(stderr,
|
||||
"P65_PEER_LOSS_FAIL: deadline_ms=%u elapsed_ms=%lld peer_hung_up=%d dead=%d device_lost=%d\n",
|
||||
options.deadlineMs, static_cast<long long>(hangupMs), bell->PeerHungUp(), bell->Dead(),
|
||||
Client::ClientSession::DeviceLost());
|
||||
return 3;
|
||||
}
|
||||
if (options.kill) {
|
||||
while (!fault.Finished() && std::chrono::steady_clock::now() < deadline)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
if (!fault.Succeeded()) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: kill command did not complete successfully within budget\n");
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
// Exercise the production barrier's ShutDown branch, not a test-written
|
||||
// latch. The peer is already proven gone, so this valid reply-owning record
|
||||
// cannot reach a server or inspect an invented fence handle there.
|
||||
const MG_Pipe::MGPHandleOnly fence{{1, 1}, static_cast<Uint32>(MG_Pipe::MGPipeKind::Fence), 0};
|
||||
Uint32 reply = 0;
|
||||
Int32 status = Wire::ReplySink::kStatusError;
|
||||
session.EmitAndWait(MG_Pipe::MGPWireOp::FenceStatus, &fence, sizeof fence, nullptr, 0, &reply, sizeof reply,
|
||||
&status);
|
||||
const auto lostMs =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
|
||||
const bool lost = Client::ClientSession::DeviceLost();
|
||||
const auto reset = MG_Impl::GLImpl::GetGraphicsResetStatus();
|
||||
if (!lost || reset != GL_UNKNOWN_CONTEXT_RESET || status != Wire::ReplySink::kStatusDeclined ||
|
||||
lostMs >= options.deadlineMs) {
|
||||
std::fprintf(stderr, "P65_PEER_LOSS_FAIL: production latch=%d gl_reset=0x%x reply_status=%d elapsed_ms=%lld\n",
|
||||
lost, reset, status, static_cast<long long>(lostMs));
|
||||
return 5;
|
||||
}
|
||||
std::printf("P65_PEER_LOSS_PASS pid=%u mode=%s peer_hung_up_ms=%lld device_lost_ms=%lld "
|
||||
"deadline_ms=%u device_lost=1 gl_reset=0x%x source=production-barrier\n",
|
||||
peerPid, options.kill ? "kill" : "external", static_cast<long long>(hangupMs),
|
||||
static_cast<long long>(lostMs), options.deadlineMs, reset);
|
||||
std::fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
@@ -118,6 +118,8 @@ TEST(ProtocolSmokeTest, UnionTagsAreFrozenWireValues) {
|
||||
EXPECT_EQ(static_cast<int>(CtrlMsg::AuxRequest), 8);
|
||||
EXPECT_EQ(static_cast<int>(CtrlMsg::Fatal), 9);
|
||||
EXPECT_EQ(static_cast<int>(CtrlMsg::LogLine), 10);
|
||||
EXPECT_EQ(static_cast<int>(CtrlMsg::Refuse), 11);
|
||||
EXPECT_EQ(static_cast<int>(CtrlMsg::LogFlush), 12);
|
||||
|
||||
EXPECT_EQ(static_cast<int>(SegmentKind::Cmd), 1);
|
||||
EXPECT_EQ(static_cast<int>(SegmentKind::Adopt), 6);
|
||||
@@ -156,3 +158,27 @@ TEST(ProtocolSmokeTest, TravelsAcrossTheTransportUnchanged) {
|
||||
ASSERT_NE(hello, nullptr);
|
||||
EXPECT_EQ(hello->pid(), 4242u);
|
||||
}
|
||||
|
||||
TEST(ProtocolSmokeTest, StreamHandshakeCarriesIndependentWireBuildAndServerWindows) {
|
||||
::flatbuffers::FlatBufferBuilder builder(512);
|
||||
auto terms = CreateLinkTerms(builder, DataPlane::Stream, WireForm::StructImage,
|
||||
1048560, 8388608, 33554432, 262144);
|
||||
auto hello = CreateHelloDirect(builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR,
|
||||
"commit-123", 1, 42, nullptr, 0, 0x12345678, terms, "pairing-token", DialMode::Connect);
|
||||
auto envelope = CreateCtrlEnvelope(builder, CtrlMsg::Hello, hello.Union());
|
||||
FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
::flatbuffers::Verifier verifier(builder.GetBufferPointer(), builder.GetSize());
|
||||
ASSERT_TRUE(VerifyCtrlEnvelopeBuffer(verifier));
|
||||
const auto* parsed = GetCtrlEnvelope(builder.GetBufferPointer())->msg_as_Hello();
|
||||
ASSERT_NE(parsed, nullptr);
|
||||
EXPECT_EQ(parsed->wireFingerprint(), 0x12345678u);
|
||||
EXPECT_EQ(parsed->buildFingerprint()->str(), "commit-123");
|
||||
EXPECT_EQ(parsed->token()->str(), "pairing-token");
|
||||
EXPECT_EQ(parsed->dialMode(), DialMode::Connect);
|
||||
ASSERT_NE(parsed->linkTerms(), nullptr);
|
||||
EXPECT_EQ(parsed->linkTerms()->dataPlane(), DataPlane::Stream);
|
||||
EXPECT_EQ(parsed->linkTerms()->maxReplyBytes(), 1048560u);
|
||||
EXPECT_EQ(parsed->linkTerms()->cmdWindowBytes(), 8388608u);
|
||||
EXPECT_EQ(parsed->linkTerms()->stageWindowBytes(), 33554432u);
|
||||
EXPECT_EQ(parsed->linkTerms()->eventWindowBytes(), 262144u);
|
||||
}
|
||||
|
||||
@@ -74,9 +74,12 @@ struct BackendTag {
|
||||
};
|
||||
template struct PeerAccess<BackendTag, &Srv::ServerLoop::m_backend>;
|
||||
|
||||
void StartControlSession() {
|
||||
MG_Backend::BackendObject* ControlCapsPeer();
|
||||
|
||||
void StartControlSession(MG_Backend::BackendObject* capsSource = nullptr) {
|
||||
::alarm(15);
|
||||
MG_Config::Transport = MG_Config::TransportMode::InProcess;
|
||||
Srv::ServerSessionInstance().SetBackend(capsSource ? capsSource : ControlCapsPeer());
|
||||
Srv::ServerSessionInstance().SetCapabilityBits(0);
|
||||
Srv::ServerSessionInstance().SetConsumedSubsystems(kMGPipeSubsystemsMigratedAtP4a);
|
||||
if (ClientSessionInstance().Start(MG_Config::TransportMode::InProcess, {}) != MOBILEGL_OK)
|
||||
@@ -135,6 +138,13 @@ struct CapsPeer : MG_Backend::BackendObject {
|
||||
BackendType GetBackendType() const override { return BackendType::DirectGLES; }
|
||||
};
|
||||
|
||||
MG_Backend::BackendObject* ControlCapsPeer() {
|
||||
// A real encoded initial snapshot is required even when the apply fixture
|
||||
// substitutes every verb and has no GPU backend of its own.
|
||||
static CapsPeer backend;
|
||||
return &backend;
|
||||
}
|
||||
|
||||
void ExpectNamedAbort(const ChildResult& child, const char* diagnostic) {
|
||||
EXPECT_TRUE(DiedOfAbort(child)) << DescribeStatus(child) << '\n' << child.Log;
|
||||
EXPECT_NE(child.Log.find(diagnostic), std::string::npos) << child.Log;
|
||||
@@ -387,8 +397,7 @@ TEST(RemoteClientControls, BounceReadPixelsShortReplyRefusesBeforeScatter) {
|
||||
TEST(RemoteClientControls, DeleteTexturesAdvancesTheWireOrdinal) {
|
||||
const auto child = RunInChild([] {
|
||||
CapsPeer backend;
|
||||
Srv::ServerSessionInstance().SetBackend(&backend);
|
||||
StartControlSession();
|
||||
StartControlSession(&backend);
|
||||
ErrorPeer replies;
|
||||
replies.status = 0; // The peer accepts the resource; the client must publish and delete it.
|
||||
replies.Install();
|
||||
@@ -442,8 +451,7 @@ TEST(RemoteClientControls, ServerRoleRespecifyDoesNotEmitClientInitialBytes) {
|
||||
// SEG_EVENT producers are what replaces the mechanism this case used to drive.
|
||||
const auto child = RunInChild([] {
|
||||
CapsPeer backend;
|
||||
Srv::ServerSessionInstance().SetBackend(&backend);
|
||||
StartControlSession();
|
||||
StartControlSession(&backend);
|
||||
MG_Config::Features.PipePush |= kMGPipeSubsystemResources;
|
||||
Srv::ServerLoopInstance().RunProbeOnApplyThreadForTesting([](void*) {
|
||||
MG_State::GLState::BufferObject buffer(701);
|
||||
@@ -475,8 +483,7 @@ TEST(RemoteClientControls, ServerRoleFlushDoesNotRunTheClientSubDataFollowup) {
|
||||
// (Fatal{RoleViolation, "MGPipeSlots"}; ev's events replace the mechanism).
|
||||
const auto child = RunInChild([] {
|
||||
CapsPeer backend;
|
||||
Srv::ServerSessionInstance().SetBackend(&backend);
|
||||
StartControlSession();
|
||||
StartControlSession(&backend);
|
||||
MG_Config::Features.PipePush |= kMGPipeSubsystemResources;
|
||||
Srv::ServerLoopInstance().RunProbeOnApplyThreadForTesting([](void*) {
|
||||
MGPipeResourceOps ops{};
|
||||
|
||||
@@ -40,7 +40,7 @@ void CheckE1Boundary(Bool serverCap, MGPWireOp op, Bool expectWait, const char*
|
||||
const Uint64 caps = serverCap ? static_cast<Uint64>(kCapRunAheadApply) : 0;
|
||||
Srv::ServerSessionInstance().SetCapabilityBits(caps);
|
||||
Srv::ServerSessionInstance().SetConsumedSubsystems(kMGPipeSubsystemsMigratedAtP4a);
|
||||
AdoptSnapshot(MakeSnapshot(kMGPipeSubsystemsMigratedAtP4a, caps));
|
||||
Srv::ServerSessionInstance().SetBackend(ControlCapsPeer());
|
||||
auto& session = ClientSessionInstance();
|
||||
if (session.Start(MG_Config::TransportMode::InProcess, {}) != MOBILEGL_OK) ::_exit(81);
|
||||
auto& producer = session.Producer();
|
||||
|
||||
@@ -2338,19 +2338,8 @@ void StartRunAheadSession() {
|
||||
Srv::ServerSessionInstance().SetCapabilityBits(
|
||||
static_cast<Uint64>(MG_Pipe::kCapRunAheadApply));
|
||||
Srv::ServerSessionInstance().SetConsumedSubsystems(kMGPipeSubsystemsMigratedAtP4a);
|
||||
// THE MIRROR IS ADOPTED BEFORE Start, AND THAT IS THE LATCH'S RULE MADE VISIBLE. This
|
||||
// process has no server backend, so PublishCapsSnapshot is deferred and the handshake
|
||||
// carries no snapshot at all - and §1 says a later snapshot may only turn run-ahead OFF,
|
||||
// never on. So the arm has to be true at the FIRST adoption, which for a fixture means
|
||||
// before the session takes its latch. A test that adopted afterwards and found the client
|
||||
// still lockstep would be reading the contract's own rule as a failure.
|
||||
{
|
||||
MG_Pipe::MGPCaps caps{};
|
||||
caps.CallMask = static_cast<Uint64>(MG_Pipe::kCapRunAheadApply) |
|
||||
MG_Remote::MGCapsConsumerBits(kMGPipeSubsystemsMigratedAtP4a);
|
||||
CapsMirrorInstance().Adopt(caps, MG_Backend::FormatCapabilityCache{}, RendererInfo{},
|
||||
String{"4.6"}, BackendType::DirectGLES);
|
||||
}
|
||||
// The test peer publishes the first snapshot through the real handshake.
|
||||
Srv::ServerSessionInstance().SetBackend(ControlCapsPeer());
|
||||
if (ClientSessionInstance().Start(MG_Config::TransportMode::InProcess, {}) != MOBILEGL_OK) {
|
||||
::_exit(81);
|
||||
}
|
||||
@@ -2411,11 +2400,7 @@ TEST(RemoteRunAhead, ClearingTheVerbBarrierDisarmsRunAheadEvenWithTheCapBit) {
|
||||
Srv::ServerSessionInstance().SetCapabilityBits(
|
||||
static_cast<Uint64>(MG_Pipe::kCapRunAheadApply));
|
||||
Srv::ServerSessionInstance().SetConsumedSubsystems(kMGPipeSubsystemsMigratedAtP4a);
|
||||
MG_Pipe::MGPCaps caps{};
|
||||
caps.CallMask = static_cast<Uint64>(MG_Pipe::kCapRunAheadApply) |
|
||||
MG_Remote::MGCapsConsumerBits(kMGPipeSubsystemsMigratedAtP4a);
|
||||
CapsMirrorInstance().Adopt(caps, MG_Backend::FormatCapabilityCache{}, RendererInfo{},
|
||||
String{"4.6"}, BackendType::DirectGLES);
|
||||
Srv::ServerSessionInstance().SetBackend(ControlCapsPeer());
|
||||
if (ClientSessionInstance().Start(MG_Config::TransportMode::InProcess, {}) != MOBILEGL_OK) {
|
||||
::_exit(81);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,8 @@ namespace {
|
||||
auto stamp = builder.CreateString(GIT_COMMIT_HASH_SHORT);
|
||||
auto hello = ::MobileGL::Wire::CreateHello(
|
||||
builder, MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR, stamp,
|
||||
/*backendType=*/0u, /*pid=*/0u, /*configBlob=*/0, CapsAbiFingerprint());
|
||||
/*backendType=*/0u, /*pid=*/0u, /*configBlob=*/0, CapsAbiFingerprint(),
|
||||
CapsAbiFingerprint(), ::MobileGL::Wire::CreateLinkTerms(builder));
|
||||
auto root = ::MobileGL::Wire::CreateCtrlEnvelope(
|
||||
builder, ::MobileGL::Wire::CtrlMsg::Hello, hello.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, root);
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
#include "Includes.h"
|
||||
|
||||
#include <MG_Remote/CapsCodec.h>
|
||||
#include <MG_Remote/Handshake.h>
|
||||
#include <MG_Pipe/PipeWireLayout.h>
|
||||
#include <MG_State/GLState/ProgramState/ProgramArtifactsCodec.h>
|
||||
#include <MG_Remote/Client/ClientSession.h>
|
||||
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||
#include <MG_Remote/Server/ServerSession.h>
|
||||
@@ -114,100 +117,152 @@ namespace {
|
||||
// below. Also red, separately, by deleting any one `mix(...)` line from MixAbiFingerprint: the
|
||||
// matching EXPECT_NE names the input that stopped being mixed. Both perturbations were run.
|
||||
TEST(SessionHandshakeTest, TheAbiFingerprintChangesWhenAnyOfItsInputsDoes) {
|
||||
const Uint64 production = CapsAbiFingerprint();
|
||||
EXPECT_NE(production, 0u) << "0 is reserved for \"not stated\"";
|
||||
EXPECT_EQ(production, CapsAbiFingerprint()) << "not stable within one build";
|
||||
|
||||
const Transport::AbiFingerprintInputs inputs = CapsAbiFingerprintInputs();
|
||||
EXPECT_EQ(production, Transport::MixAbiFingerprint(inputs))
|
||||
<< "CapsAbiFingerprint() is not MixAbiFingerprint over CapsAbiFingerprintInputs(): the "
|
||||
"handshake compares a value this case cannot reach, which is finding 6 again";
|
||||
|
||||
// The inputs are the real ones, so a CapsAbiFingerprintInputs() that hard-coded a size
|
||||
// would be caught here rather than agreed with by a peer built from a different tree.
|
||||
const Uint64 production = WireFingerprint();
|
||||
const auto inputs = CapsAbiFingerprintInputs();
|
||||
EXPECT_NE(production, 0u);
|
||||
EXPECT_EQ(production, CapsAbiFingerprint());
|
||||
EXPECT_EQ(production, Transport::MixAbiFingerprint(inputs));
|
||||
EXPECT_EQ(inputs.DynamicParamsSize, sizeof(MG_Backend::DynamicBackendParameters));
|
||||
EXPECT_EQ(inputs.CapsSize, sizeof(MG_Pipe::MGPCaps));
|
||||
EXPECT_EQ(inputs.FunctionTableSize, sizeof(MG_Backend::GLFunctionsTable));
|
||||
EXPECT_EQ(inputs.FormatCapabilityTargets,
|
||||
static_cast<Uint64>(MG_Backend::kFormatCapabilityTargetCount));
|
||||
EXPECT_EQ(inputs.FormatCapabilityFormats,
|
||||
static_cast<Uint64>(MG_Backend::kFormatCapabilityFormatCount));
|
||||
EXPECT_NE(inputs.FormatCapabilitiesCodecVersion, 0u);
|
||||
EXPECT_NE(inputs.RendererInfoCodecVersion, 0u);
|
||||
EXPECT_EQ(inputs.MemberLayout, MG_Pipe::kMGPipeWireMemberLayoutDigest);
|
||||
EXPECT_EQ(inputs.CatalogueLayout, MG_Pipe::kMGPipeWireCatalogueDigest);
|
||||
EXPECT_EQ(inputs.RenderStateLayout, MG_Pipe::WireRenderStateDigest());
|
||||
EXPECT_EQ(inputs.ProgramArtifactsCodecVersion, MG_State::GLState::kProgramArtifactsCodecVersion);
|
||||
EXPECT_EQ(inputs.ProgramArtifactsSchema, MG_State::GLState::ProgramArtifactsSchemaFingerprint());
|
||||
EXPECT_EQ(inputs.OpCount, static_cast<Uint64>(MG_Pipe::MGPWireOp::kOpCount));
|
||||
EXPECT_EQ(inputs.AbiVersion, static_cast<Uint32>(MOBILEGL_ABI_VERSION(
|
||||
MOBILEGL_PROTOCOL_ABI_MAJOR, MOBILEGL_PROTOCOL_ABI_MINOR)));
|
||||
// CONTRACT-P6 4.2. THE ASSERTION SPLITS WITH THE MACRO PAIR, and it has to: this used to
|
||||
// demand a non-empty stamp unconditionally and was RED in every build whose git could not be
|
||||
// read - a real signal, but one that told the reader nothing about WHICH of the two states
|
||||
// the build was in. Now the build system states it, and both states are asserted.
|
||||
ASSERT_NE(inputs.BuildStamp, nullptr);
|
||||
EXPECT_EQ(inputs.BuildStampPresent, static_cast<Uint32>(MOBILEGL_BUILD_STAMP_PRESENT))
|
||||
<< "the fingerprint disagrees with the build system about whether this build has a stamp";
|
||||
#if MGL_HANDSHAKE_TEST_HAS_GIT_HASH
|
||||
EXPECT_STREQ(inputs.BuildStamp, MOBILEGL_BUILD_STAMP_VALUE);
|
||||
#endif
|
||||
#if MOBILEGL_BUILD_STAMP_PRESENT
|
||||
EXPECT_NE(inputs.BuildStamp[0], '\0')
|
||||
<< "the build claims a stamp and the fingerprint mixed an empty one";
|
||||
#else
|
||||
// A stampless build is a KNOWN, DECLARED state - CMake warns at configure time - but it must
|
||||
// not be a silent one here either. What still has to hold is that the ABSENCE is mixed, which
|
||||
// the BuildStampPresent perturbation below proves.
|
||||
EXPECT_STREQ(inputs.BuildStamp, "")
|
||||
<< "PRESENT is 0 but a value came through; the two halves of the pair disagree";
|
||||
#endif
|
||||
|
||||
// Every input moves the answer. Each lambda changes exactly one field of a copy of the
|
||||
// REAL inputs, so what is proven is that the production value depends on that field.
|
||||
const auto perturbed = [&](auto&& mutate) {
|
||||
Transport::AbiFingerprintInputs copy = inputs;
|
||||
EXPECT_EQ(inputs.PointerBits, sizeof(void*) * 8);
|
||||
const auto perturbed = [&](auto mutate) {
|
||||
auto copy = inputs;
|
||||
mutate(copy);
|
||||
return Transport::MixAbiFingerprint(copy);
|
||||
};
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { ++i.DynamicParamsSize; }))
|
||||
<< "sizeof(DynamicBackendParameters) is not mixed";
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { ++i.CapsSize; }))
|
||||
<< "sizeof(MGPCaps) is not mixed";
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { ++i.FunctionTableSize; }))
|
||||
<< "sizeof(GLFunctionsTable) is not mixed";
|
||||
EXPECT_NE(production,
|
||||
perturbed([](Transport::AbiFingerprintInputs& i) { ++i.FormatCapabilityTargets; }))
|
||||
<< "kFormatCapabilityTargetCount is not mixed";
|
||||
EXPECT_NE(production,
|
||||
perturbed([](Transport::AbiFingerprintInputs& i) { ++i.FormatCapabilityFormats; }))
|
||||
<< "kFormatCapabilityFormatCount is not mixed";
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) {
|
||||
++i.FormatCapabilitiesCodecVersion;
|
||||
}))
|
||||
<< "kFormatCapabilitiesCodecVersion is not mixed";
|
||||
EXPECT_NE(production,
|
||||
perturbed([](Transport::AbiFingerprintInputs& i) { ++i.RendererInfoCodecVersion; }))
|
||||
<< "kRendererInfoCodecVersion is not mixed";
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { ++i.OpCount; }))
|
||||
<< "MGPWireOp::kOpCount is not mixed (ID-33)";
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { ++i.AbiVersion; }))
|
||||
<< "the protocol ABI version is not mixed (ID-33)";
|
||||
EXPECT_NE(production,
|
||||
perturbed([](Transport::AbiFingerprintInputs& i) { i.BuildStamp = "not-this-build"; }))
|
||||
<< "the git stamp is not mixed";
|
||||
// A missing stamp is not the same as an empty one, and neither is the same as a real build.
|
||||
// THE PRESENCE FLAG IS ITSELF AN INPUT (4.2), and this is the assertion that makes a
|
||||
// stampless build safe to reason about: a peer that says "I could not name my commit" must
|
||||
// not produce the same fingerprint as one whose commit genuinely is "". It has to move the
|
||||
// answer in EITHER build state, which is why it sits outside the #if below.
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { ++i.BuildStampPresent; }))
|
||||
<< "BuildStampPresent is not mixed; 'no stamp' and 'empty stamp' are one input again";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.DynamicParamsSize; })) << "DynamicParamsSize";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.CapsSize; })) << "CapsSize";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.MemberLayout; })) << "MemberLayout";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.CatalogueLayout; })) << "CatalogueLayout";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.RenderStateLayout; })) << "RenderStateLayout";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.FormatCapabilityTargets; })) << "FormatCapabilityTargets";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.FormatCapabilityFormats; })) << "FormatCapabilityFormats";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.FormatCapabilitiesCodecVersion; })) << "FormatCapabilitiesCodecVersion";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.RendererInfoCodecVersion; })) << "RendererInfoCodecVersion";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.ProgramArtifactsCodecVersion; })) << "ProgramArtifactsCodecVersion";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.ProgramArtifactsSchema; })) << "ProgramArtifactsSchema";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.OpCount; })) << "OpCount";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.AbiVersion; })) << "AbiVersion";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.PointerBits; })) << "PointerBits";
|
||||
EXPECT_NE(production, perturbed([](auto& i) { ++i.LittleEndian; })) << "LittleEndian";
|
||||
}
|
||||
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { i.BuildStamp = nullptr; }));
|
||||
#if MOBILEGL_BUILD_STAMP_PRESENT
|
||||
// Vacuous without a stamp: production's value already IS "", so this perturbation would be
|
||||
// the identity and the assertion would pass while proving nothing.
|
||||
EXPECT_NE(production, perturbed([](Transport::AbiFingerprintInputs& i) { i.BuildStamp = ""; }));
|
||||
TEST(SessionHandshakeTest, SameWidthFieldReorderingChangesTheWireDigestWithoutABuildStamp) {
|
||||
using namespace MG_Pipe;
|
||||
std::vector<WireLayoutMember> fields(std::begin(kMGPipeWireLayoutMembers),
|
||||
std::end(kMGPipeWireLayoutMembers));
|
||||
// MGPRange.Offset and Size have the same width: sizeof-only checks cannot see this.
|
||||
SizeT offsetIndex = 0, sizeIndex = 0;
|
||||
for (SizeT i = 0; i < fields.size(); ++i) {
|
||||
if (std::strcmp(fields[i].Name, "MGPRange.Offset") == 0) offsetIndex = i;
|
||||
if (std::strcmp(fields[i].Name, "MGPRange.Size") == 0) sizeIndex = i;
|
||||
}
|
||||
ASSERT_NE(offsetIndex, sizeIndex);
|
||||
ASSERT_EQ(fields[offsetIndex].Size, fields[sizeIndex].Size);
|
||||
std::swap(fields[offsetIndex].Offset, fields[sizeIndex].Offset);
|
||||
EXPECT_NE(WireMemberLayoutDigest(fields.data(), fields.size()), kMGPipeWireMemberLayoutDigest);
|
||||
const auto before = WireFingerprint();
|
||||
EXPECT_STREQ(BuildFingerprint(), MOBILEGL_BUILD_STAMP_VALUE);
|
||||
EXPECT_EQ(BuildFingerprintPresent(), MOBILEGL_BUILD_STAMP_PRESENT != 0);
|
||||
EXPECT_EQ(before, WireFingerprint());
|
||||
}
|
||||
|
||||
namespace {
|
||||
class ScopedHandshakeEnvironment {
|
||||
public:
|
||||
ScopedHandshakeEnvironment(const char* name, const char* value) : m_name(name) {
|
||||
const char* previous = std::getenv(name);
|
||||
m_present = previous != nullptr;
|
||||
if (m_present) m_previous = previous;
|
||||
Set(value);
|
||||
}
|
||||
~ScopedHandshakeEnvironment() { Set(m_present ? m_previous.c_str() : nullptr); }
|
||||
private:
|
||||
void Set(const char* value) {
|
||||
#if defined(_WIN32)
|
||||
::_putenv_s(m_name, value == nullptr ? "" : value);
|
||||
#else
|
||||
if (value == nullptr) ::unsetenv(m_name); else ::setenv(m_name, value, 1);
|
||||
#endif
|
||||
EXPECT_NE(perturbed([](Transport::AbiFingerprintInputs& i) { i.BuildStamp = nullptr; }),
|
||||
perturbed([](Transport::AbiFingerprintInputs& i) { i.BuildStamp = ""; }))
|
||||
<< "\"no stamp\" and \"an empty stamp\" collapsed into one input";
|
||||
}
|
||||
const char* m_name;
|
||||
bool m_present = false;
|
||||
std::string m_previous;
|
||||
};
|
||||
|
||||
std::vector<Uint8> ReadHandshakeFrame(Transport::ITransport& transport) {
|
||||
Uint64 bytes = 0;
|
||||
if (transport.ReceiveFrame({nullptr, 0}, &bytes, 1000) != MOBILEGL_ERR_BUFFER_TOO_SMALL) return {};
|
||||
std::vector<Uint8> frame(bytes);
|
||||
if (transport.ReceiveFrame({frame.data(), frame.size()}, &bytes, 1000) != MOBILEGL_OK) return {};
|
||||
return frame;
|
||||
}
|
||||
|
||||
void CheckHandshake(Uint32 major, Uint64 wire, const char* build,
|
||||
::MobileGL::Wire::DialMode dial, ::MobileGL::Wire::RefuseCode expected) {
|
||||
using namespace ::MobileGL::Wire;
|
||||
std::unique_ptr<Transport::InProcessTransport> client, server;
|
||||
Transport::InProcessTransport::CreatePair(client, server);
|
||||
::flatbuffers::FlatBufferBuilder builder(512);
|
||||
auto terms = CreateLinkTerms(builder);
|
||||
auto hello = CreateHelloDirect(builder, major, MOBILEGL_PROTOCOL_ABI_MINOR, build,
|
||||
0, 1, nullptr, wire, wire, terms, nullptr, dial);
|
||||
auto root = CreateCtrlEnvelope(builder, CtrlMsg::Hello, hello.Union());
|
||||
FinishCtrlEnvelopeBuffer(builder, root);
|
||||
std::vector<Uint8> first(builder.GetBufferPointer(), builder.GetBufferPointer() + builder.GetSize());
|
||||
Server::ServerSession session;
|
||||
Transport::SessionSegmentSizes sizes;
|
||||
sizes.CmdRingBytes = 4096; sizes.StageBytes = 4096;
|
||||
sizes.ReplyBytes = 4096; sizes.EventRingBytes = 4096;
|
||||
session.SetSegmentSizes(sizes);
|
||||
const auto result = session.Accept(*server, &first);
|
||||
EXPECT_EQ(result, expected == RefuseCode::None ? MOBILEGL_OK : MOBILEGL_ERR_PROTOCOL_MISMATCH);
|
||||
const auto reply = ReadHandshakeFrame(*client);
|
||||
ASSERT_FALSE(reply.empty());
|
||||
::flatbuffers::Verifier verifier(reply.data(), reply.size());
|
||||
ASSERT_TRUE(VerifyCtrlEnvelopeBuffer(verifier));
|
||||
const auto* envelope = GetCtrlEnvelope(reply.data());
|
||||
if (expected == RefuseCode::None) {
|
||||
ASSERT_NE(envelope->msg_as_Welcome(), nullptr);
|
||||
EXPECT_EQ(envelope->msg_as_Welcome()->wireFingerprint(), WireFingerprint());
|
||||
ASSERT_NE(envelope->msg_as_Welcome()->linkTerms(), nullptr);
|
||||
EXPECT_EQ(envelope->msg_as_Welcome()->linkTerms()->cmdWindowBytes(), 4096u);
|
||||
} else {
|
||||
ASSERT_NE(envelope->msg_as_Refuse(), nullptr);
|
||||
EXPECT_EQ(envelope->msg_as_Refuse()->code(), expected);
|
||||
EXPECT_FALSE(session.Accepted());
|
||||
}
|
||||
session.Close();
|
||||
}
|
||||
}
|
||||
|
||||
TEST(SessionHandshakeTest, WireMajorMismatchReturnsNamedRefuseWithoutAborting) {
|
||||
CheckHandshake(99, WireFingerprint(), BuildFingerprint(), ::MobileGL::Wire::DialMode::No,
|
||||
::MobileGL::Wire::RefuseCode::ProtocolVersion);
|
||||
}
|
||||
TEST(SessionHandshakeTest, WireLayoutMismatchReturnsNamedRefuseWithoutAborting) {
|
||||
CheckHandshake(MOBILEGL_PROTOCOL_ABI_MAJOR, WireFingerprint() ^ 1, BuildFingerprint(),
|
||||
::MobileGL::Wire::DialMode::No, ::MobileGL::Wire::RefuseCode::WireFingerprint);
|
||||
}
|
||||
TEST(SessionHandshakeTest, ConnectAcceptsDifferentBuildWithIdenticalWire) {
|
||||
ScopedHandshakeEnvironment required("MOBILEGL_IPC_REQUIRE_SAME_BUILD", "0");
|
||||
CheckHandshake(MOBILEGL_PROTOCOL_ABI_MAJOR, WireFingerprint(), "different-commit",
|
||||
::MobileGL::Wire::DialMode::Connect, ::MobileGL::Wire::RefuseCode::None);
|
||||
}
|
||||
TEST(SessionHandshakeTest, ForkRefusesDifferentBuildWithIdenticalWire) {
|
||||
CheckHandshake(MOBILEGL_PROTOCOL_ABI_MAJOR, WireFingerprint(), "different-commit",
|
||||
::MobileGL::Wire::DialMode::Fork, ::MobileGL::Wire::RefuseCode::BuildFingerprint);
|
||||
}
|
||||
TEST(SessionHandshakeTest, ConnectCanRequireTheSameBuild) {
|
||||
ScopedHandshakeEnvironment required("MOBILEGL_IPC_REQUIRE_SAME_BUILD", "1");
|
||||
CheckHandshake(MOBILEGL_PROTOCOL_ABI_MAJOR, WireFingerprint(), "different-commit",
|
||||
::MobileGL::Wire::DialMode::Connect, ::MobileGL::Wire::RefuseCode::BuildFingerprint);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
@@ -58,6 +60,68 @@ using namespace MobileGL::MG_Remote::Transport;
|
||||
|
||||
#if !defined(_WIN32)
|
||||
|
||||
TEST(SocketTransportTest, TcpCarriesControlAndIndependentDataWithKeepalive) {
|
||||
// Find an available loopback port; Listen deliberately refuses ambiguous port 0 URIs.
|
||||
int reservation = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
ASSERT_GE(reservation, 0);
|
||||
sockaddr_in address{};
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
ASSERT_EQ(::bind(reservation, reinterpret_cast<sockaddr*>(&address), sizeof(address)), 0);
|
||||
socklen_t addressSize = sizeof(address);
|
||||
ASSERT_EQ(::getsockname(reservation, reinterpret_cast<sockaddr*>(&address), &addressSize), 0);
|
||||
const auto endpoint = std::string("tcp://127.0.0.1:") + std::to_string(ntohs(address.sin_port));
|
||||
::close(reservation);
|
||||
int listener = -1;
|
||||
ASSERT_EQ(SocketTransport::Listen(endpoint, &listener), MOBILEGL_OK);
|
||||
std::unique_ptr<SocketTransport> client, server;
|
||||
ASSERT_EQ(SocketTransport::ConnectTo(endpoint, 1000, client), MOBILEGL_OK);
|
||||
ASSERT_EQ(SocketTransport::AcceptPair(listener, 1000, server), MOBILEGL_OK);
|
||||
::close(listener);
|
||||
ASSERT_TRUE(client->IsTcp());
|
||||
ASSERT_TRUE(server->IsTcp());
|
||||
for (auto* transport : {client.get(), server.get()}) {
|
||||
int option = 0;
|
||||
socklen_t size = sizeof(option);
|
||||
ASSERT_EQ(::getsockopt(transport->StreamFd(), IPPROTO_TCP, TCP_NODELAY, &option, &size), 0);
|
||||
EXPECT_EQ(option, 1);
|
||||
ASSERT_EQ(::getsockopt(transport->StreamFd(), SOL_SOCKET, SO_KEEPALIVE, &option, &size), 0);
|
||||
EXPECT_EQ(option, 1);
|
||||
EXPECT_EQ(transport->ShareFd(0, {nullptr, 0}), MOBILEGL_ERR_UNSUPPORTED);
|
||||
}
|
||||
const int clientData = client->TakeDataFd(), serverData = server->TakeDataFd();
|
||||
ASSERT_GE(clientData, 0);
|
||||
ASSERT_GE(serverData, 0);
|
||||
EXPECT_EQ(client->TakeDataFd(), -1);
|
||||
const char message[] = "independent";
|
||||
ASSERT_EQ(::send(clientData, message, sizeof(message), MSG_NOSIGNAL), sizeof(message));
|
||||
char received[sizeof(message)]{};
|
||||
ASSERT_EQ(::recv(serverData, received, sizeof(received), MSG_WAITALL), sizeof(received));
|
||||
EXPECT_EQ(std::memcmp(message, received, sizeof(message)), 0);
|
||||
ASSERT_EQ(server->SendFrame({message, sizeof(message)}), MOBILEGL_OK);
|
||||
std::uint64_t size = 0;
|
||||
ASSERT_EQ(client->ReceiveFrame({received, sizeof(received)}, &size, 1000), MOBILEGL_OK);
|
||||
EXPECT_EQ(size, sizeof(message));
|
||||
::close(clientData);
|
||||
::close(serverData);
|
||||
}
|
||||
|
||||
TEST(SocketTransportTest, TcpRejectsMalformedNamesAndUnauthenticatedWildcard) {
|
||||
int listener = -1;
|
||||
for (const char* endpoint : {"tcp://", "tcp://localhost", "tcp://localhost:0", "tcp://localhost:65536",
|
||||
"tcp://localhost:-1", "tcp://[::1]broken", "tcp://::1:40000"}) {
|
||||
EXPECT_EQ(SocketTransport::Listen(endpoint, &listener), MOBILEGL_ERR_INVALID_ARGUMENT) << endpoint;
|
||||
EXPECT_EQ(listener, -1);
|
||||
}
|
||||
const char* prior = std::getenv("MOBILEGL_IPC_TOKEN");
|
||||
const std::string saved = prior ? prior : "";
|
||||
const bool wasSet = prior != nullptr;
|
||||
::unsetenv("MOBILEGL_IPC_TOKEN");
|
||||
EXPECT_EQ(SocketTransport::Listen("tcp://0.0.0.0:40613", &listener), MOBILEGL_ERR_PROTOCOL_MISMATCH);
|
||||
EXPECT_EQ(listener, -1);
|
||||
if (wasSet) ::setenv("MOBILEGL_IPC_TOKEN", saved.c_str(), 1);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
MobileGLByteSpan Span(const std::string& text) {
|
||||
@@ -110,6 +174,21 @@ TEST(SocketTransportTest, CarriesFramesInBothDirections) {
|
||||
EXPECT_EQ(Receive(*pair.client), welcome);
|
||||
}
|
||||
|
||||
TEST(SocketTransportTest, RequestHalfCloseStillDeliversTheFinalReply) {
|
||||
std::unique_ptr<SocketTransport> client, server;
|
||||
ASSERT_EQ(SocketTransport::CreatePair(client, server), MOBILEGL_OK);
|
||||
ASSERT_EQ(client->SendFrame(Span("last request")), MOBILEGL_OK);
|
||||
EXPECT_EQ(Receive(*server), "last request");
|
||||
ASSERT_EQ(client->ShutdownSend(), MOBILEGL_OK);
|
||||
std::uint64_t bytes = 0;
|
||||
char buffer[32]{};
|
||||
EXPECT_EQ(server->ReceiveFrame({buffer, sizeof buffer}, &bytes, 1000), MOBILEGL_ERR_TRANSPORT_CLOSED);
|
||||
ASSERT_EQ(server->SendFrame(Span("cleanup complete")), MOBILEGL_OK);
|
||||
EXPECT_EQ(Receive(*client), "cleanup complete");
|
||||
server->Shutdown();
|
||||
EXPECT_EQ(client->ReceiveFrame({buffer, sizeof buffer}, &bytes, 1000), MOBILEGL_ERR_TRANSPORT_CLOSED);
|
||||
}
|
||||
|
||||
TEST(SocketTransportTest, PreservesOrder) {
|
||||
Pair pair = MakePair();
|
||||
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// Production session submission with a real stream reader and a deliberately
|
||||
// non-applying peer. A passing test cannot be supplied by a later client wait.
|
||||
#include <MG_Remote/Client/ClientSession.h>
|
||||
#include <MG_Remote/CapsCodec.h>
|
||||
#include <MG_Remote/Transport/InProcessTransport.h>
|
||||
#include <MG_Remote/Transport/StreamLink.h>
|
||||
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <atomic>
|
||||
#include <MG_Pipe/PipeRoute.h>
|
||||
#include <MG_Impl/GLImpl/Getter/GL_Getter.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <csignal>
|
||||
#include <sys/wait.h>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
||||
using namespace MobileGL;
|
||||
using namespace MobileGL::MG_Remote;
|
||||
namespace {
|
||||
// Only the test's control endpoint is injected. A queued real CapsSnapshot
|
||||
// arms the production latch without a backend, EGL context, or private toggle.
|
||||
template <class Tag, typename Tag::Type member>
|
||||
struct PublicationPeerAccess {
|
||||
friend typename Tag::Type PublicationPeerMember(Tag) { return member; }
|
||||
};
|
||||
struct ControlEndpointTag {
|
||||
using Type = Transport::ITransport* Client::ClientSession::*;
|
||||
friend Type PublicationPeerMember(ControlEndpointTag);
|
||||
};
|
||||
template struct PublicationPeerAccess<ControlEndpointTag, &Client::ClientSession::m_transport>;
|
||||
|
||||
class StreamClientPublication : public testing::Test {
|
||||
protected:
|
||||
Client::ClientSession client;
|
||||
std::unique_ptr<Transport::ILink> peer;
|
||||
std::unique_ptr<Transport::InProcessTransport> controlClient, controlPeer;
|
||||
const decltype(MG_Config::Ipc) savedIpc = MG_Config::Ipc;
|
||||
const MG_Config::TransportMode savedTransport = MG_Config::Transport;
|
||||
|
||||
void SetUp() override {
|
||||
// A regression that turns submission into an applied wait fails
|
||||
// promptly instead of consuming the production 120-second budget.
|
||||
::alarm(5);
|
||||
MG_Config::Transport = MG_Config::TransportMode::Spawn;
|
||||
MG_Config::Ipc.RunAhead = 1;
|
||||
MG_Config::Ipc.VerbBarrier = 1;
|
||||
MG_Config::Ipc.BatchWaits = 1;
|
||||
MG_Config::Ipc.PresentCredit = 3;
|
||||
Transport::SessionSegmentSizes sizes;
|
||||
sizes.CmdRingBytes = 4096;
|
||||
sizes.StageBytes = 4096;
|
||||
sizes.EventRingBytes = 4096;
|
||||
sizes.ReplyBytes = 4096;
|
||||
int sockets[2];
|
||||
ASSERT_EQ(::socketpair(AF_UNIX, SOCK_STREAM, 0, sockets), 0);
|
||||
ASSERT_EQ(AttachData(sockets, sizes), MOBILEGL_OK);
|
||||
Transport::InProcessTransport::CreatePair(controlClient, controlPeer);
|
||||
client.*PublicationPeerMember(ControlEndpointTag{}) = controlClient.get();
|
||||
|
||||
MG_Backend::DynamicBackendParameters dynamic{};
|
||||
MG_Backend::FormatCapabilityCache formats{};
|
||||
RendererInfo renderer{};
|
||||
Vector<Uint8> encodedFormats, encodedRenderer;
|
||||
ASSERT_TRUE(EncodeFormatCapabilities(formats, encodedFormats));
|
||||
ASSERT_TRUE(EncodeRendererInfo(renderer, encodedRenderer));
|
||||
flatbuffers::FlatBufferBuilder builder;
|
||||
const auto dynamicBytes = builder.CreateVector(reinterpret_cast<const Uint8*>(&dynamic), sizeof dynamic);
|
||||
const auto rendererBytes = builder.CreateVector(encodedRenderer.data(), encodedRenderer.size());
|
||||
const auto formatBytes = builder.CreateVector(encodedFormats.data(), encodedFormats.size());
|
||||
const auto version = builder.CreateString("4.6");
|
||||
const auto caps = ::MobileGL::Wire::CreateCapsSnapshot(builder, dynamicBytes, rendererBytes, formatBytes, 0,
|
||||
version, MG_Pipe::kCapRunAheadApply,
|
||||
static_cast<Uint32>(BackendType::DirectGLES));
|
||||
const auto envelope =
|
||||
::MobileGL::Wire::CreateCtrlEnvelope(builder, ::MobileGL::Wire::CtrlMsg::CapsSnapshot, caps.Union());
|
||||
::MobileGL::Wire::FinishCtrlEnvelopeBuffer(builder, envelope);
|
||||
ASSERT_EQ(controlPeer->SendFrame({builder.GetBufferPointer(), builder.GetSize()}), MOBILEGL_OK);
|
||||
ASSERT_EQ(
|
||||
client.FinishStartup(&client.DataLink()->ConsumerBell(), &client.DataLink()->ProducerBell(), false),
|
||||
MOBILEGL_OK);
|
||||
ASSERT_TRUE(client.RunAheadArmed());
|
||||
}
|
||||
void TearDown() override {
|
||||
// The peer intentionally never applies. Closing delivery before
|
||||
// teardown prevents its drain from supplying the assertion.
|
||||
if (client.DataLink()) client.DataLink()->Detach();
|
||||
if (peer) peer->Detach();
|
||||
client.Stop();
|
||||
MG_Config::Ipc = savedIpc;
|
||||
MG_Config::Transport = savedTransport;
|
||||
::alarm(0);
|
||||
}
|
||||
virtual MobileGLResult AttachData(int sockets[2], const Transport::SessionSegmentSizes& sizes) {
|
||||
const auto result = client.AttachStreamLink(sockets[0], sizes);
|
||||
if (result != MOBILEGL_OK) {
|
||||
::close(sockets[1]);
|
||||
return result;
|
||||
}
|
||||
const auto attached =
|
||||
Transport::CreateStreamLink(sockets[1], sizes, Transport::TransportRoleTag::ServerConsumer, peer);
|
||||
if (attached == MOBILEGL_OK) peer->InitializeEndpoints();
|
||||
return attached;
|
||||
}
|
||||
bool Upload(std::size_t count, unsigned char fill) {
|
||||
std::vector<Uint8> bytes(count, fill);
|
||||
MG_Pipe::MGPSubData record{};
|
||||
record.Res = {1, 1};
|
||||
record.Target = MG_Pipe::kMGPipeResourceTargetBuffer;
|
||||
record.UnionBox.W = static_cast<Uint32>(count);
|
||||
record.UnionBox.H = record.UnionBox.D = 1;
|
||||
return MG_Pipe::MGPipeRouteResourceSubData(record, bytes.data(), bytes.size());
|
||||
}
|
||||
bool PeerGone() {
|
||||
auto& bell = client.DataLink()->ProducerBell();
|
||||
const auto end = std::chrono::steady_clock::now() + std::chrono::seconds(1);
|
||||
while (!bell.PeerHungUp() && std::chrono::steady_clock::now() < end)
|
||||
(void)bell.Park(1);
|
||||
return bell.PeerHungUp();
|
||||
}
|
||||
bool StageIs(unsigned char fill) {
|
||||
const auto& memory = client.DataLink()->Memory();
|
||||
const auto* bytes = static_cast<const Uint8*>(memory.StageBase());
|
||||
for (Uint64 i = 0; i < memory.StageBytes(); ++i)
|
||||
if (bytes[i] != fill) return false;
|
||||
return true;
|
||||
}
|
||||
bool ReceivedPublishedPrefix() {
|
||||
const auto head = client.DataLink()->Signals().CmdHead->load(std::memory_order_acquire);
|
||||
const auto signals = peer->Signals();
|
||||
return peer->ConsumerBell().Wait(
|
||||
*signals.ConsumerParked, [&] { return signals.CmdHead->load(std::memory_order_acquire) >= head; }, 0,
|
||||
1000);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(StreamClientPublication, AllThreePresentCreditsReachAnIdlePeerWithoutAnyClientWait) {
|
||||
for (Uint64 serial = 1; serial <= 3; ++serial) {
|
||||
MG_Pipe::MGPPresent present{};
|
||||
present.FrameSerial = client.AcquirePresentCredit();
|
||||
ASSERT_EQ(present.FrameSerial, serial);
|
||||
client.EmitAndWait(MG_Pipe::MGPWireOp::Present, &present, sizeof present, nullptr, 0, nullptr, 0, nullptr);
|
||||
ASSERT_TRUE(ReceivedPublishedPrefix()) << "present " << serial << " remained in the local batch";
|
||||
}
|
||||
EXPECT_EQ(client.Producer().Waits(), 0u);
|
||||
EXPECT_EQ(client.PresentCreditWaits(), 0u);
|
||||
EXPECT_EQ(client.DataLink()->Progress()->appliedSeq.load(), 0u);
|
||||
for (int record = 0; record != 3; ++record) {
|
||||
Transport::RingRecordView view{};
|
||||
ASSERT_TRUE(peer->CommandsIn().Pop(view));
|
||||
EXPECT_EQ(view.kind, static_cast<std::uint16_t>(MG_Pipe::MGPWireOp::Present));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(StreamClientPublication, ExportedGlFlushDeliversPublishedCommandsWithoutWaitingForApplied) {
|
||||
MG_Pipe::MGPMemoryBarrier barrier{};
|
||||
client.EmitAndWait(MG_Pipe::MGPWireOp::MemoryBarrier, &barrier, sizeof barrier, nullptr, 0, nullptr, 0,
|
||||
nullptr);
|
||||
ASSERT_EQ(client.LastPublishedSeq(), 1u);
|
||||
EXPECT_EQ(peer->Signals().CmdHead->load(), 0u);
|
||||
::glFlush();
|
||||
ASSERT_TRUE(ReceivedPublishedPrefix());
|
||||
EXPECT_EQ(client.Producer().Waits(), 0u);
|
||||
EXPECT_EQ(client.DataLink()->Progress()->appliedSeq.load(), 0u);
|
||||
Transport::RingRecordView view{};
|
||||
ASSERT_TRUE(peer->CommandsIn().Pop(view));
|
||||
EXPECT_EQ(view.kind, static_cast<std::uint16_t>(MG_Pipe::MGPWireOp::MemoryBarrier));
|
||||
}
|
||||
|
||||
TEST_F(StreamClientPublication, ADisconnectedPeerDeclinesALargeUploadWithoutCopyOrWireOrdinal) {
|
||||
std::memset(client.DataLink()->Memory().StageBase(), 0x33, 4096);
|
||||
peer->Detach();
|
||||
ASSERT_TRUE(PeerGone());
|
||||
// Larger than the whole window: cancellation must precede allocation,
|
||||
// capacity checks and memcpy. The live path would refuse this request.
|
||||
EXPECT_FALSE(Upload(32768, 0x99));
|
||||
EXPECT_TRUE(Client::ClientSession::DeviceLost());
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetGraphicsResetStatus(), GL_UNKNOWN_CONTEXT_RESET);
|
||||
EXPECT_TRUE(client.Encoder().Cancelled());
|
||||
EXPECT_EQ(client.Encoder().EmitSeq(), 0u);
|
||||
EXPECT_EQ(client.LastPublishedSeq(), 0u);
|
||||
EXPECT_TRUE(StageIs(0x33));
|
||||
// A second local decline still consumes a nonzero MintReplySlot ticket.
|
||||
EXPECT_FALSE(Upload(16, 0x88));
|
||||
EXPECT_EQ(client.Encoder().EmitSeq(), 0u);
|
||||
MG_Pipe::MGPMemoryBarrier record{};
|
||||
EXPECT_EQ(client.Encoder().EncodeRecord(MG_Pipe::MGPWireOp::MemoryBarrier, &record, sizeof record,
|
||||
static_cast<const void*>(nullptr), Uint64{0}),
|
||||
MG_Remote::Wire::kInvalidSeq);
|
||||
EXPECT_TRUE(StageIs(0x33));
|
||||
}
|
||||
|
||||
class StreamClientStagingProcess : public StreamClientPublication {
|
||||
protected:
|
||||
pid_t peerPid = -1;
|
||||
MobileGLResult AttachData(int sockets[2], const Transport::SessionSegmentSizes& sizes) override {
|
||||
int ready[2];
|
||||
if (::pipe(ready) != 0) {
|
||||
::close(sockets[0]);
|
||||
::close(sockets[1]);
|
||||
return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
}
|
||||
// Fork before attaching either stream, so the child starts its own
|
||||
// real reader and inherits no running thread or live link mutex.
|
||||
peerPid = ::fork();
|
||||
if (peerPid == 0) {
|
||||
::close(ready[0]);
|
||||
::close(sockets[0]);
|
||||
std::unique_ptr<Transport::ILink> link;
|
||||
const auto result =
|
||||
Transport::CreateStreamLink(sockets[1], sizes, Transport::TransportRoleTag::ServerConsumer, link);
|
||||
if (result == MOBILEGL_OK) link->InitializeEndpoints();
|
||||
const unsigned char success = result == MOBILEGL_OK;
|
||||
(void)::write(ready[1], &success, 1);
|
||||
::close(ready[1]);
|
||||
if (!success) ::_exit(81);
|
||||
for (;;)
|
||||
::pause(); // Reader receives; the peer deliberately never applies.
|
||||
}
|
||||
::close(ready[1]);
|
||||
::close(sockets[1]);
|
||||
unsigned char success = 0;
|
||||
const auto received = peerPid > 0 ? ::read(ready[0], &success, 1) : -1;
|
||||
::close(ready[0]);
|
||||
if (received != 1 || !success) {
|
||||
::close(sockets[0]);
|
||||
return MOBILEGL_ERR_NOT_INITIALIZED;
|
||||
}
|
||||
return client.AttachStreamLink(sockets[0], sizes);
|
||||
}
|
||||
void TearDown() override {
|
||||
if (peerPid > 0) {
|
||||
(void)::kill(peerPid, SIGKILL);
|
||||
(void)::waitpid(peerPid, nullptr, 0);
|
||||
peerPid = -1;
|
||||
}
|
||||
StreamClientPublication::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(StreamClientStagingProcess, APeerKilledDuringAFullStageWaitDeclinesWithoutCopyingTheNextBlob) {
|
||||
ASSERT_TRUE(Upload(4096, 0x5a));
|
||||
ASSERT_EQ(client.Encoder().EmitSeq(), 1u);
|
||||
client.Flush();
|
||||
auto* parked = client.DataLink()->Signals().ProducerParked;
|
||||
std::atomic<bool> killedWhileParked{false};
|
||||
std::thread killer([&] {
|
||||
const auto end = std::chrono::steady_clock::now() + std::chrono::seconds(2);
|
||||
while (!parked->load(std::memory_order_acquire) && std::chrono::steady_clock::now() < end)
|
||||
std::this_thread::yield();
|
||||
killedWhileParked.store(parked->load(std::memory_order_acquire) != 0, std::memory_order_release);
|
||||
(void)::kill(peerPid, SIGKILL);
|
||||
});
|
||||
const bool accepted = Upload(64, 0xa7);
|
||||
killer.join();
|
||||
EXPECT_TRUE(killedWhileParked.load());
|
||||
EXPECT_FALSE(accepted);
|
||||
EXPECT_TRUE(Client::ClientSession::DeviceLost());
|
||||
EXPECT_EQ(MG_Impl::GLImpl::GetGraphicsResetStatus(), GL_UNKNOWN_CONTEXT_RESET);
|
||||
EXPECT_GT(client.Encoder().StageReclaimWaits(), 0u);
|
||||
EXPECT_EQ(client.Encoder().EmitSeq(), 1u);
|
||||
EXPECT_EQ(client.LastPublishedSeq(), 1u);
|
||||
EXPECT_TRUE(StageIs(0x5a));
|
||||
}
|
||||
|
||||
class HealthyStageTimeoutHarness : public StreamClientPublication {
|
||||
public:
|
||||
void TestBody() override {}
|
||||
void Run() {
|
||||
SetUp();
|
||||
client.Encoder().SetStageWaitTimeoutMs(5);
|
||||
if (!Upload(4096, 0x5a)) ::_exit(82);
|
||||
(void)Upload(64, 0xa7);
|
||||
::_exit(83);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(StreamClientCancellationDeath, AHealthyPeerStageTimeoutDoesNotInventDeviceLoss) {
|
||||
EXPECT_EXIT(
|
||||
{
|
||||
::signal(
|
||||
SIGABRT, +[](int) {
|
||||
const bool lost = Client::ClientSession::DeviceLost();
|
||||
const char* text = lost ? "stage-timeout-device-lost=1\n" : "stage-timeout-device-lost=0\n";
|
||||
(void)::write(STDERR_FILENO, text, sizeof("stage-timeout-device-lost=0\n") - 1);
|
||||
::_exit(lost ? 91 : 72);
|
||||
});
|
||||
HealthyStageTimeoutHarness harness;
|
||||
harness.Run();
|
||||
},
|
||||
testing::ExitedWithCode(72), "RetirementWaitFailed(.|\n)*stage-timeout-device-lost=0");
|
||||
}
|
||||
} // namespace
|
||||
@@ -0,0 +1,323 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
#include <MG_Remote/Transport/StreamLink.h>
|
||||
#include <MG_Remote/Transport/SessionRings.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <array>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace MobileGL::MG_Remote::Transport;
|
||||
namespace {
|
||||
class StreamPair : public testing::Test {
|
||||
protected:
|
||||
SessionSegments clientMemory, serverMemory;
|
||||
StreamLink client, server;
|
||||
RingProducer commands;
|
||||
RingConsumer consumer;
|
||||
SessionProducer publish;
|
||||
SessionConsumer apply;
|
||||
void SetUp() override {
|
||||
SessionSegmentSizes sizes;
|
||||
sizes.CmdRingBytes = 1024;
|
||||
sizes.StageBytes = 4096;
|
||||
sizes.ReplyBytes = 4096;
|
||||
sizes.EventRingBytes = 1024;
|
||||
ASSERT_EQ(clientMemory.CreatePrivate(sizes, MemoryRole::Client), MOBILEGL_OK);
|
||||
ASSERT_EQ(serverMemory.CreatePrivate(sizes, MemoryRole::Server), MOBILEGL_OK);
|
||||
int sockets[2];
|
||||
ASSERT_EQ(::socketpair(AF_UNIX, SOCK_STREAM, 0, sockets), 0);
|
||||
ASSERT_EQ(client.Attach(sockets[0], clientMemory, TransportRoleTag::ClientProducer), MOBILEGL_OK);
|
||||
ASSERT_EQ(server.Attach(sockets[1], serverMemory, TransportRoleTag::ServerConsumer), MOBILEGL_OK);
|
||||
commands = RingProducer(clientMemory.CmdControl(), clientMemory.CmdRingBase(), 1024, RingCursorSet::Cmd);
|
||||
consumer = RingConsumer(serverMemory.CmdControl(), serverMemory.CmdRingBase(), 1024, RingCursorSet::Cmd);
|
||||
publish.Attach(clientMemory.CmdControl(), &commands, &client.ConsumerBell(), &client.ProducerBell(), 0);
|
||||
publish.SetLink(&client);
|
||||
apply.Attach(serverMemory.CmdControl(), &consumer, &server.ProducerBell(), &server.ConsumerBell(), 0);
|
||||
apply.SetLink(&server);
|
||||
}
|
||||
void TearDown() override {
|
||||
client.Detach();
|
||||
server.Detach();
|
||||
}
|
||||
void Queue(std::uint64_t seq, std::uint64_t value) {
|
||||
auto* p = commands.Reserve(1, 0, sizeof value);
|
||||
ASSERT_NE(p, nullptr);
|
||||
std::memcpy(p, &value, sizeof value);
|
||||
publish.PublishAndNotify(seq);
|
||||
}
|
||||
template <class F>
|
||||
bool Eventually(F ready) {
|
||||
const auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(2);
|
||||
while (!ready() && std::chrono::steady_clock::now() < deadline)
|
||||
std::this_thread::yield();
|
||||
return ready();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(StreamPair, StagingArrivesBeforeItsCommandAndLastRecordProgressFlushesOnIdle) {
|
||||
const std::array<unsigned char, 8> bytes{1, 2, 3, 4, 5, 6, 7, 8};
|
||||
std::memcpy(static_cast<unsigned char*>(clientMemory.StageBase()) + 24, bytes.data(), bytes.size());
|
||||
client.NoteStage({24, bytes.size()});
|
||||
Queue(1, 24);
|
||||
ASSERT_EQ(client.Flush(), MOBILEGL_OK);
|
||||
ASSERT_EQ(apply.WaitForWork(2000), SessionWait::Reached);
|
||||
RingRecordView view;
|
||||
ASSERT_TRUE(consumer.Pop(view));
|
||||
[&](const RingRecordView& v) {
|
||||
std::uint64_t offset;
|
||||
std::memcpy(&offset, v.payload, sizeof offset);
|
||||
const void* p = nullptr;
|
||||
ASSERT_EQ(server.ResolveSpan(LinkSegment::Stage, {offset, bytes.size()}, &p), MOBILEGL_OK);
|
||||
EXPECT_EQ(std::memcmp(p, bytes.data(), bytes.size()), 0);
|
||||
}(view);
|
||||
// Advance locally without a periodic-progress callback: this isolates
|
||||
// flush-on-idle so removing it cannot be masked by the one-ms timer.
|
||||
Watermark::AdvanceApplied(*serverMemory.CmdControl(), 1);
|
||||
Watermark::AdvanceRetired(*serverMemory.CmdControl(), 1);
|
||||
consumer.PublishRetired();
|
||||
// This is the production idle discipline, not a polling sender thread.
|
||||
EXPECT_EQ(apply.WaitForWork(1), SessionWait::TimedOut);
|
||||
EXPECT_EQ(publish.WaitForApplied(1, 2000), SessionWait::Reached);
|
||||
// applied and retired are independent watermarks. The reader publishes
|
||||
// them in dependency order, and an applied waiter can run between stores.
|
||||
EXPECT_TRUE(client.ProducerBell().Wait(
|
||||
clientMemory.CmdControl()->producerParked,
|
||||
[&] { return client.Progress()->retiredSeq.load(std::memory_order_acquire) >= 1; }, 0, 2000));
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, RetiredByteCursorCrossesManyWrapsWithoutStageRingCursors) {
|
||||
for (std::uint64_t seq = 1; seq <= 160; ++seq) {
|
||||
Queue(seq, seq);
|
||||
ASSERT_EQ(client.Flush(), MOBILEGL_OK);
|
||||
ASSERT_EQ(apply.WaitForWork(2000), SessionWait::Reached);
|
||||
ASSERT_TRUE(apply.ApplyOne([&](const RingRecordView& v) {
|
||||
std::uint64_t value;
|
||||
std::memcpy(&value, v.payload, sizeof value);
|
||||
EXPECT_EQ(value, seq);
|
||||
}));
|
||||
apply.RetireThrough(seq);
|
||||
ASSERT_EQ(server.FlushProgress(), MOBILEGL_OK);
|
||||
ASSERT_EQ(publish.WaitForApplied(seq, 2000), SessionWait::Reached);
|
||||
}
|
||||
EXPECT_GT(commands.LocalHead(), 1024u);
|
||||
EXPECT_EQ(commands.FreeBytes(), 1024u);
|
||||
EXPECT_EQ(clientMemory.CmdControl()->stageHead.load(), 0u);
|
||||
EXPECT_EQ(clientMemory.CmdControl()->stageRetiredTail.load(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, UnwantedReplyDoesNotBlockLaterReplyAndAppliedPublication) {
|
||||
Queue(1, 1);
|
||||
Queue(2, 2);
|
||||
ASSERT_EQ(client.Flush(), MOBILEGL_OK);
|
||||
ASSERT_EQ(apply.WaitForWork(2000), SessionWait::Reached);
|
||||
ASSERT_TRUE(apply.ApplyOne([&](const RingRecordView&) {
|
||||
const std::uint64_t value = 11;
|
||||
EXPECT_EQ(server.PostReply(1, 0, &value, sizeof value), MOBILEGL_OK);
|
||||
}));
|
||||
ASSERT_TRUE(apply.ApplyOne([&](const RingRecordView&) {
|
||||
const std::uint64_t value = 22;
|
||||
EXPECT_EQ(server.PostReply(2, 0, &value, sizeof value), MOBILEGL_OK);
|
||||
}));
|
||||
apply.RetireThrough(2);
|
||||
ASSERT_EQ(server.FlushProgress(), MOBILEGL_OK);
|
||||
ASSERT_EQ(publish.WaitForApplied(2, 2000), SessionWait::Reached);
|
||||
std::int32_t status;
|
||||
const void* p = nullptr;
|
||||
std::uint64_t size = 0;
|
||||
ASSERT_EQ(client.ReadReply(2, &status, &p, &size), MOBILEGL_OK);
|
||||
ASSERT_EQ(size, sizeof(std::uint64_t));
|
||||
std::uint64_t value;
|
||||
std::memcpy(&value, p, sizeof value);
|
||||
EXPECT_EQ(value, 22u);
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, EventDrainReturnsCreditAndClearsRemoteFullLatch) {
|
||||
EventRingProducer events(serverMemory.EventControl(), serverMemory.CmdControl(), serverMemory.EventRingBase(),
|
||||
1024);
|
||||
EventRingConsumer read(clientMemory.EventControl(), clientMemory.CmdControl(), clientMemory.EventRingBase(),
|
||||
1024, clientMemory.EventSegmentBase());
|
||||
read.SetLink(&client);
|
||||
auto* p = events.Reserve(kEventGlError, 64);
|
||||
ASSERT_NE(p, nullptr);
|
||||
std::memset(p, 0, 64);
|
||||
events.Ring().Publish();
|
||||
serverMemory.CmdControl()->eventRingFull.store(1);
|
||||
ASSERT_EQ(server.FlushProgress(), MOBILEGL_OK);
|
||||
ASSERT_TRUE(Eventually([&] { return clientMemory.CmdControl()->eventRingFull.load() != 0; }));
|
||||
RingRecordView record;
|
||||
ASSERT_TRUE(read.Pop(record));
|
||||
read.Drained();
|
||||
ASSERT_TRUE(Eventually([&] { return serverMemory.CmdControl()->eventRingFull.load() == 0; }));
|
||||
EXPECT_EQ(events.Ring().FreeBytes(), 1024u);
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, PeerEofKillsBothLocalBellsAndWakesAWaiter) {
|
||||
server.Detach();
|
||||
ASSERT_TRUE(Eventually([&] { return client.PeerHungUp(); }));
|
||||
EXPECT_TRUE(client.ProducerBell().Dead());
|
||||
EXPECT_TRUE(client.ConsumerBell().Dead());
|
||||
EXPECT_EQ(publish.WaitForApplied(10, 2000), SessionWait::ShutDown);
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, PeerEofReleasesAnAlreadyWaitingReplyReader) {
|
||||
std::atomic<bool> finished{false};
|
||||
MobileGLResult result = MOBILEGL_OK;
|
||||
std::thread waiting([&] {
|
||||
std::int32_t status;
|
||||
const void* payload;
|
||||
std::uint64_t size;
|
||||
result = client.ReadReply(1, &status, &payload, &size);
|
||||
finished.store(true, std::memory_order_release);
|
||||
});
|
||||
server.Detach();
|
||||
EXPECT_TRUE(Eventually([&] { return finished.load(std::memory_order_acquire); }));
|
||||
waiting.join();
|
||||
EXPECT_EQ(result, MOBILEGL_ERR_TRANSPORT_CLOSED);
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, AppliedWithoutItsReplyIsRefusedWithoutAnUnboundedWait) {
|
||||
Queue(1, 1);
|
||||
ASSERT_EQ(client.Flush(), MOBILEGL_OK);
|
||||
ASSERT_EQ(apply.WaitForWork(2000), SessionWait::Reached);
|
||||
ASSERT_TRUE(apply.ApplyOne([](const RingRecordView&) {}));
|
||||
apply.RetireThrough(1);
|
||||
ASSERT_EQ(server.FlushProgress(), MOBILEGL_OK);
|
||||
ASSERT_EQ(publish.WaitForApplied(1, 2000), SessionWait::Reached);
|
||||
std::int32_t status;
|
||||
const void* p;
|
||||
std::uint64_t size;
|
||||
EXPECT_EQ(client.ReadReply(1, &status, &p, &size), MOBILEGL_ERR_PROTOCOL_MISMATCH);
|
||||
}
|
||||
|
||||
TEST_F(StreamPair, ControlFenceWaitsForEventBytesOnTheIndependentDataConnection) {
|
||||
EventRingProducer events(serverMemory.EventControl(), serverMemory.CmdControl(), serverMemory.EventRingBase(),
|
||||
1024);
|
||||
auto* payload = events.Reserve(kEventGlError, 8);
|
||||
ASSERT_NE(payload, nullptr);
|
||||
std::memset(payload, 0, 8);
|
||||
events.Ring().Publish();
|
||||
const auto fence = server.EventPublishedHead();
|
||||
EXPECT_EQ(client.WaitForEventDelivery(fence, 1), MOBILEGL_ERR_TIMEOUT);
|
||||
ASSERT_EQ(server.Flush(), MOBILEGL_OK);
|
||||
EXPECT_EQ(client.WaitForEventDelivery(fence, 2000), MOBILEGL_OK);
|
||||
EXPECT_GE(client.EventPublishedHead(), fence);
|
||||
}
|
||||
|
||||
TEST(StreamLinkTcp, RecordsSixtyFourMiBStageBurstThroughputOnRealLoopbackTcp) {
|
||||
int listener = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
ASSERT_GE(listener, 0);
|
||||
sockaddr_in address{};
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
ASSERT_EQ(::bind(listener, reinterpret_cast<sockaddr*>(&address), sizeof address), 0);
|
||||
ASSERT_EQ(::listen(listener, 1), 0);
|
||||
socklen_t addressBytes = sizeof address;
|
||||
ASSERT_EQ(::getsockname(listener, reinterpret_cast<sockaddr*>(&address), &addressBytes), 0);
|
||||
int clientFd = ::socket(AF_INET, SOCK_STREAM, 0);
|
||||
ASSERT_GE(clientFd, 0);
|
||||
ASSERT_EQ(::connect(clientFd, reinterpret_cast<sockaddr*>(&address), sizeof address), 0);
|
||||
int serverFd = ::accept(listener, nullptr, nullptr);
|
||||
ASSERT_GE(serverFd, 0);
|
||||
::close(listener);
|
||||
int enabled = 1;
|
||||
ASSERT_EQ(::setsockopt(clientFd, IPPROTO_TCP, TCP_NODELAY, &enabled, sizeof enabled), 0);
|
||||
ASSERT_EQ(::setsockopt(serverFd, IPPROTO_TCP, TCP_NODELAY, &enabled, sizeof enabled), 0);
|
||||
SessionSegmentSizes sizes;
|
||||
sizes.CmdRingBytes = 1024;
|
||||
sizes.EventRingBytes = 1024;
|
||||
sizes.StageBytes = 64ull * 1024 * 1024;
|
||||
sizes.ReplyBytes = 4096;
|
||||
std::unique_ptr<ILink> client, server;
|
||||
ASSERT_EQ(CreateStreamLink(clientFd, sizes, TransportRoleTag::ClientProducer, client), MOBILEGL_OK);
|
||||
ASSERT_EQ(CreateStreamLink(serverFd, sizes, TransportRoleTag::ServerConsumer, server), MOBILEGL_OK);
|
||||
client->InitializeEndpoints();
|
||||
server->InitializeEndpoints();
|
||||
std::memset(client->Memory().StageBase(), 0x5a, static_cast<std::size_t>(sizes.StageBytes));
|
||||
client->NoteStage({0, sizes.StageBytes});
|
||||
SessionProducer producer;
|
||||
producer.Attach(*client, 0);
|
||||
SessionConsumer consumer;
|
||||
consumer.Attach(*server, 0);
|
||||
auto* record = client->CommandsOut().Reserve(1, 0, sizeof(std::uint64_t));
|
||||
ASSERT_NE(record, nullptr);
|
||||
std::memcpy(record, &sizes.StageBytes, sizeof(std::uint64_t));
|
||||
producer.PublishAndNotify(1);
|
||||
const auto start = std::chrono::steady_clock::now();
|
||||
ASSERT_EQ(client->Flush(), MOBILEGL_OK);
|
||||
ASSERT_EQ(consumer.WaitForWork(10000), SessionWait::Reached);
|
||||
ASSERT_TRUE(consumer.ApplyOne([&](const RingRecordView&) {
|
||||
const auto* bytes = static_cast<const unsigned char*>(server->Memory().StageBase());
|
||||
for (std::uint64_t offset = 0; offset < sizes.StageBytes; offset += 4096)
|
||||
EXPECT_EQ(bytes[offset], 0x5a);
|
||||
EXPECT_EQ(bytes[sizes.StageBytes - 1], 0x5a);
|
||||
}));
|
||||
consumer.RetireThrough(1);
|
||||
ASSERT_EQ(server->FlushProgress(), MOBILEGL_OK);
|
||||
ASSERT_EQ(producer.WaitForApplied(1, 10000), SessionWait::Reached);
|
||||
const double elapsed = std::chrono::duration<double>(std::chrono::steady_clock::now() - start).count();
|
||||
const double mibPerSecond = 64.0 / elapsed;
|
||||
RecordProperty("tcp_stage_bytes", std::to_string(sizes.StageBytes));
|
||||
RecordProperty("tcp_stage_mib_per_second", std::to_string(mibPerSecond));
|
||||
std::printf("P6.5 Stage burst control=none data=tcp-loopback bytes=%llu seconds=%.6f MiB/s=%.3f\n",
|
||||
static_cast<unsigned long long>(sizes.StageBytes), elapsed, mibPerSecond);
|
||||
}
|
||||
|
||||
void WriteFrame(int fd, unsigned kind, std::uint64_t a, const void* payload, std::uint32_t size) {
|
||||
unsigned char h[28]{};
|
||||
auto put = [&](unsigned at, std::uint64_t value, unsigned width) {
|
||||
for (unsigned i = 0; i < width; ++i)
|
||||
h[at + i] = value >> (8 * i);
|
||||
};
|
||||
put(0, 0x444c474d, 4);
|
||||
put(4, size + 20, 4);
|
||||
h[8] = kind;
|
||||
put(12, a, 8);
|
||||
ASSERT_EQ(::send(fd, h, sizeof h, MSG_NOSIGNAL), sizeof h);
|
||||
if (size) ASSERT_EQ(::send(fd, payload, size, MSG_NOSIGNAL), size);
|
||||
}
|
||||
|
||||
TEST(StreamLinkDeath, StageOutsideNegotiatedWindowIsNamedProtocolCorruption) {
|
||||
EXPECT_DEATH(
|
||||
{
|
||||
SessionSegments memory;
|
||||
SessionSegmentSizes sizes;
|
||||
sizes.StageBytes = 64;
|
||||
memory.CreatePrivate(sizes, MemoryRole::Server);
|
||||
int sockets[2];
|
||||
socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
|
||||
StreamLink link;
|
||||
link.Attach(sockets[0], memory, TransportRoleTag::ServerConsumer);
|
||||
unsigned char byte = 1;
|
||||
WriteFrame(sockets[1], 2, 64, &byte, 1);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
},
|
||||
"ProtocolCorruption.*window");
|
||||
}
|
||||
|
||||
TEST(StreamLinkDeath, RegressingProgressIsNamedProtocolCorruption) {
|
||||
EXPECT_DEATH(
|
||||
{
|
||||
SessionSegments memory;
|
||||
SessionSegmentSizes sizes;
|
||||
memory.CreatePrivate(sizes, MemoryRole::Client);
|
||||
memory.CmdControl()->submittedSeq.store(3);
|
||||
int sockets[2];
|
||||
socketpair(AF_UNIX, SOCK_STREAM, 0, sockets);
|
||||
StreamLink link;
|
||||
link.Attach(sockets[0], memory, TransportRoleTag::ClientProducer);
|
||||
unsigned char progress[64]{};
|
||||
progress[0] = 2;
|
||||
WriteFrame(sockets[1], 4, 0, progress, 64);
|
||||
progress[0] = 1;
|
||||
WriteFrame(sockets[1], 4, 0, progress, 64);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
},
|
||||
"ProtocolCorruption.*backwards");
|
||||
}
|
||||
} // namespace
|
||||
@@ -279,6 +279,7 @@ TEST(SurfaceControlFrameTest, TheReplyHalfRoundTripsAsASurfaceReply) {
|
||||
frame.ok = true;
|
||||
frame.eglMajor = 1;
|
||||
frame.eglMinor = 5;
|
||||
frame.eventHead = 0x123456789ull;
|
||||
|
||||
flatbuffers::FlatBufferBuilder builder(256);
|
||||
EncodeSurfaceReplyFrame(frame, &builder);
|
||||
@@ -294,6 +295,7 @@ TEST(SurfaceControlFrameTest, TheReplyHalfRoundTripsAsASurfaceReply) {
|
||||
EXPECT_TRUE(back.ok);
|
||||
EXPECT_EQ(back.eglMajor, 1);
|
||||
EXPECT_EQ(back.eglMinor, 5);
|
||||
EXPECT_EQ(back.eventHead, frame.eventHead) << "control replies must fence data events";
|
||||
}
|
||||
|
||||
TEST(SurfaceControlFrameTest, MalformedAndInprocOnlyFramesRefuseToEncode) {
|
||||
|
||||
@@ -12,12 +12,38 @@
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Util::Debug {
|
||||
std::mutex& LogMutex();
|
||||
static FILE* s_logFile = nullptr;
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// The server role's own sink. Opened lazily, on the first line a server-role thread
|
||||
// writes, so a process that never plays the role never creates the file.
|
||||
static FILE* s_serverLogFile = nullptr;
|
||||
static LogForwarder s_forwarder = nullptr;
|
||||
static void* s_forwarderUser = nullptr;
|
||||
|
||||
void SetLogForwarder(LogForwarder forwarder, void* user) {
|
||||
std::lock_guard<std::mutex> lock(LogMutex());
|
||||
s_forwarder = forwarder;
|
||||
s_forwarderUser = user;
|
||||
}
|
||||
|
||||
void WithLogBarrier(void (*action)(void*), void* user) {
|
||||
std::lock_guard<std::mutex> lock(LogMutex());
|
||||
action(user);
|
||||
}
|
||||
|
||||
void WritePeerLog(const char* message) {
|
||||
std::lock_guard<std::mutex> lock(LogMutex());
|
||||
const char* path = std::getenv("MOBILEGL_LOG_FILE_PATH");
|
||||
if (!path || !*path) path = MOBILEGL_LOG_FILE_PATH;
|
||||
if (!path || !*path) return;
|
||||
if (!s_serverLogFile) s_serverLogFile = std::fopen(RoleLogPath(path, LogRole::Server).c_str(), "w");
|
||||
if (s_serverLogFile) {
|
||||
std::fputs(message, s_serverLogFile);
|
||||
std::fflush(s_serverLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
// THE PROCESS DEFAULT, read once. A spawned server image is the server on every thread -
|
||||
// there is no other role in it - and MOBILEGL_IPC_ROLE is set by the launcher before
|
||||
@@ -256,6 +282,9 @@ namespace MobileGL {
|
||||
#endif
|
||||
|
||||
WriteToFile(out.c_str());
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
if (s_forwarder && ThreadIsServerRole()) s_forwarder(s_forwarderUser, out.c_str());
|
||||
#endif
|
||||
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@@ -136,6 +136,10 @@ namespace MobileGL {
|
||||
void Close();
|
||||
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
using LogForwarder = void (*)(void*, const char*);
|
||||
void SetLogForwarder(LogForwarder forwarder, void* user);
|
||||
void WritePeerLog(const char* message);
|
||||
void WithLogBarrier(void (*action)(void*), void* user);
|
||||
// P6: ONE LOG PER ROLE, and the role is a per-THREAD fact because under inproc both
|
||||
// roles live in one process. The client keeps MOBILEGL_LOG_FILE_PATH unchanged so
|
||||
// every existing reader keeps its path; the server's lines go to the same path with
|
||||
|
||||
@@ -2,7 +2,17 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
|
||||
<application>
|
||||
<service
|
||||
android:name=".MobileGLServerService"
|
||||
android:exported="true"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:process=":mglsrv" />
|
||||
<activity
|
||||
android:name=".PluginActivity"
|
||||
tools:node="remove" />
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package top.mobilegl.plugin;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map;
|
||||
|
||||
/** Trace-only entry point for a TCP supervisor; EGL belongs to its session children. */
|
||||
public final class MobileGLServerService extends Service {
|
||||
private static final String TAG = "MobileGLServer";
|
||||
private static final String CHANNEL = "mobilegl-server";
|
||||
private volatile Process supervisor;
|
||||
private PowerManager.WakeLock wakeLock;
|
||||
|
||||
@Override public IBinder onBind(Intent intent) { return null; }
|
||||
|
||||
@Override public void onCreate() {
|
||||
super.onCreate();
|
||||
NotificationManager notifications = getSystemService(NotificationManager.class);
|
||||
notifications.createNotificationChannel(new NotificationChannel(
|
||||
CHANNEL, "MobileGL TCP server", NotificationManager.IMPORTANCE_LOW));
|
||||
startForeground(40613, new Notification.Builder(this, CHANNEL)
|
||||
.setSmallIcon(android.R.drawable.stat_notify_sync)
|
||||
.setContentTitle("MobileGL TCP server")
|
||||
.setContentText("Serving remote rendering sessions")
|
||||
.setOngoing(true).build());
|
||||
wakeLock = getSystemService(PowerManager.class).newWakeLock(
|
||||
PowerManager.PARTIAL_WAKE_LOCK, "MobileGL:TCPServer");
|
||||
wakeLock.acquire();
|
||||
}
|
||||
|
||||
// Keep the replay runner's KEY=VALUE;KEY grammar, including unset and empty values.
|
||||
static void applyEnvironment(Map<String, String> env, String overrides) {
|
||||
if (overrides == null) return;
|
||||
for (String entry : overrides.split(";", -1)) {
|
||||
int separator = entry.indexOf('=');
|
||||
if (entry.isEmpty() || separator == 0) continue;
|
||||
if (separator < 0) env.remove(entry);
|
||||
else env.put(entry.substring(0, separator), entry.substring(separator + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override public synchronized int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (supervisor != null && supervisor.isAlive()) {
|
||||
Log.w(TAG, "supervisor already running; stop the service before reconfiguring");
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
String endpoint = intent == null ? null : intent.getStringExtra("listen");
|
||||
if (endpoint == null) endpoint = "tcp://127.0.0.1:40613";
|
||||
try {
|
||||
File executable = new File(getApplicationInfo().nativeLibraryDir, "libMobileGLServer.so");
|
||||
ProcessBuilder builder = new ProcessBuilder(executable.getAbsolutePath(), endpoint, "--serve");
|
||||
builder.directory(getFilesDir()).redirectErrorStream(true);
|
||||
Map<String, String> env = builder.environment();
|
||||
applyEnvironment(env, intent == null ? null : intent.getStringExtra("env"));
|
||||
env.put("MOBILEGL_IPC_ROLE", "server");
|
||||
env.put("MOBILEGL_IPC_DIAL", "no");
|
||||
env.put("MOBILEGL_IPC_LOG_FORWARD", "1");
|
||||
for (String name : new String[]{"MOBILEGL_TRANSPORT", "MOBILEGL_IPC_CONTROL", "MOBILEGL_IPC_ENDPOINT",
|
||||
"MOBILEGL_IPC_SERVER_PATH", "MOBILEGL_IPC_RING_MB", "MOBILEGL_IPC_STAGE_MB"}) {
|
||||
env.remove(name);
|
||||
}
|
||||
env.put("MOBILEGL_IPC_TOKEN", intent == null || intent.getStringExtra("token") == null
|
||||
? "" : intent.getStringExtra("token"));
|
||||
env.putIfAbsent("MOBILEGL_LOG_FILE_PATH", new File(getFilesDir(), "mgl.log").getAbsolutePath());
|
||||
env.put("LD_LIBRARY_PATH", getApplicationInfo().nativeLibraryDir);
|
||||
supervisor = builder.start();
|
||||
final Process child = supervisor;
|
||||
new Thread(() -> {
|
||||
try (BufferedReader output = new BufferedReader(new InputStreamReader(child.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = output.readLine()) != null) Log.i(TAG, line);
|
||||
Log.i(TAG, "supervisor exited " + child.waitFor());
|
||||
} catch (Exception error) {
|
||||
Log.e(TAG, "supervisor output failed", error);
|
||||
} finally {
|
||||
stopSelf(startId);
|
||||
}
|
||||
}, "mgl-supervisor-log").start();
|
||||
} catch (Exception error) {
|
||||
Log.e(TAG, "cannot start TCP supervisor", error);
|
||||
stopSelf(startId);
|
||||
}
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
|
||||
@Override public void onDestroy() {
|
||||
Process child = supervisor;
|
||||
if (child != null) child.destroy();
|
||||
if (wakeLock != null && wakeLock.isHeld()) wakeLock.release();
|
||||
stopForeground(STOP_FOREGROUND_REMOVE);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,12 @@ is_angle_surface_lost() {
|
||||
is_infrastructure_failure() {
|
||||
diagnostics_dir="$1"
|
||||
adb_state="$(cat "${diagnostics_dir}/adb-state.txt" 2>/dev/null || true)"
|
||||
if [ "${adb_state}" != "device" ]; then
|
||||
# Diagnostics can take several adb calls: a device that was online at their
|
||||
# start may disappear while we collect them. Keep the polling observation and
|
||||
# check the live state as well, rather than trusting that earlier snapshot.
|
||||
live_adb_state="$(adb_device_path get-state 2>/dev/null | tr -d '\r' || true)"
|
||||
if [ -f "${diagnostics_dir}/adb-disconnected.txt" ] ||
|
||||
[ "${adb_state}" != "device" ] || [ "${live_adb_state}" != "device" ]; then
|
||||
echo "trace-replay-ci.sh: Android device is unavailable (state: ${adb_state:-unknown})" >&2
|
||||
record_infrastructure_reason "device-unavailable"
|
||||
return 0
|
||||
@@ -492,25 +497,35 @@ run_retrace() {
|
||||
|
||||
app_exited=0
|
||||
saw_app_process=0
|
||||
poll_started="$(date +%s)"
|
||||
for _ in $(seq 1 "${timeout_seconds}"); do
|
||||
if adb_device_path shell run-as "${package_name}" ls "${app_dir}/output/result.json" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
if adb_device_path shell pidof "${package_name}" >/dev/null 2>&1; then
|
||||
saw_app_process=1
|
||||
elif [ "${saw_app_process}" -eq 1 ]; then
|
||||
app_exited=1
|
||||
break
|
||||
else
|
||||
poll_adb_state="$(adb_device_path get-state 2>/dev/null | tr -d '\r' || true)"
|
||||
if [ "${poll_adb_state}" != "device" ]; then
|
||||
printf '%s\n' "${poll_adb_state:-unknown}" > "${result_dir}/adb-disconnected.txt"
|
||||
break
|
||||
fi
|
||||
if [ "${saw_app_process}" -eq 1 ]; then
|
||||
app_exited=1
|
||||
break
|
||||
fi
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
collect_run_diagnostics "${result_dir}"
|
||||
if ! adb_device_path shell run-as "${package_name}" ls "${app_dir}/output/result.json" >/dev/null 2>&1; then
|
||||
if [ "${app_exited}" -eq 1 ]; then
|
||||
if [ -f "${result_dir}/adb-disconnected.txt" ]; then
|
||||
echo "trace-replay-ci.sh: device disconnected while waiting for result.json" >&2
|
||||
elif [ "${app_exited}" -eq 1 ]; then
|
||||
echo "trace-replay-ci.sh: app process exited before result.json was created" >&2
|
||||
else
|
||||
echo "trace-replay-ci.sh: result.json was not created after ${timeout_seconds}s" >&2
|
||||
echo "trace-replay-ci.sh: result.json was not created after $(($(date +%s) - poll_started))s (budget ${timeout_seconds}s)" >&2
|
||||
fi
|
||||
if [ -s "${result_dir}/retrace.log" ]; then
|
||||
echo "trace-replay-ci.sh: retrace.log:" >&2
|
||||
|
||||
@@ -1,4 +1,41 @@
|
||||
# 当前阶段进度 — P6:backend 跑在第二个进程里
|
||||
# 当前阶段进度 — P6.5:全 TCP 传输
|
||||
|
||||
## P6.5 第一波(2026-09-22)
|
||||
|
||||
实现、代码审查与主要正确性门已完成;**已落地并推送 `feat/disaggregated@fe27380a`(2026-09-22)**(原
|
||||
在 `codex/p65-all-tcp` 的 WIP + 本次审查修复 + 收尾文档一并合入)。完整 39 例 device golden 矩阵与全套
|
||||
链路必测数按用户「本地代表性、CI 兜底」留 CI/后续,**尚未宣布阶段收官**。
|
||||
|
||||
- TCP 控制、ShmLink/StreamLink 数据面、布局指纹、portable program archive v2、令牌/Refuse、
|
||||
设备 supervisor/前台服务、日志前送与有序关闭均已接线。
|
||||
- 初始 caps 到达前误锁为 lockstep 的启动竞态已修复。READY7 主机 TCP **102/102**、
|
||||
Redmi TCP **102/102**,零 skip;两臂逐例确认 **run-ahead ARMED**,无 fallback/demotion。
|
||||
保留车道 spawn **102/102**、inproc **186/186**,零 skip。
|
||||
- **代码审查(四并行切片:数据面 StreamLink / wire 定宽 / 控制面握手)无硬正确性缺陷**;两处修复已落地——
|
||||
`SocketTransport::AcceptPair` 重试 `EINTR`/`ECONNABORTED`(Medium,防常驻 server 因 accept 瞬态 `return 73` 整体退出)、
|
||||
`mobilegl_server_main` 自设 `MOBILEGL_IPC_ROLE=server`(Low,不再盲信 launcher);两处均在 `MG_Remote/`
|
||||
(`MOBILEGL_BUILD_DISAGGREGATED` 门内),G1 monolith `.text` 构造性不受影响。其余为跟进项(`MobileGLServerService.onDestroy`
|
||||
子进程泄漏→P12、`gen_pipe.py` 裸 `char` 符号性普查无实活风险、测试缺口等),见
|
||||
[`code-review-findings.md`](notes/p65/code-review-findings.md)。
|
||||
- **修后固定制品再验收**(WSL client 与设备 APK 同 build stamp `p65-acceptfix-20260922`,`REQUIRE_SAME_BUILD=1` 真实通过):
|
||||
主机 full unit **2399/2399**、P6.5 子集 **147/147**、integration-tcp loopback **102/102**、
|
||||
**device-102 102/102,全 102 条 client 日志 `run-ahead ARMED`**、代表性 device retrace
|
||||
OpenRA SSIM **1.0** / startup **0.999999511** / in-world **0.999995438**,三条全 **ARMED**。
|
||||
- G1 符号 **0/0/0/0**,`.text` 逐字一致;真实远端 kill **133 ms**、真实 Wi-Fi 中断 **5053 ms** 闩住 device loss。
|
||||
- 原有单角色日志读取的 CI 缺陷已与上游修复合并;模拟器掉线分类另有回归验证。
|
||||
- **残余(CI/后续)**:正式 retrace 的完整 **39 项** split 子集 device 矩阵(DirectGLES 现有阈值、OpenRA 1.0;
|
||||
`ci:false` 的 rd12 单列)与链路必测数(逐帧 `kWaitReply`/RTT、`SEG_STAGE` 字节/帧、`PRESENT_CREDIT` 1/2/3、
|
||||
loopback tcp-vs-spawn 逐线程 CPU)。`minecraft-1.21.11-main-menu` 的 Redmi 32B UBO 对齐 golden 伪差为
|
||||
ci-false(设备实图 SSIM 0.998729),不作本波红。跑器 `tools/trace_replay/run_tcp_matrix.py`(支持进度超时、
|
||||
进程组清理、实际 run-ahead 证明与可核验 checkpoint)已入库。
|
||||
|
||||
契约见 [`CONTRACT-P65.md`](../../MobileGL/MG_Remote/CONTRACT-P65.md),
|
||||
制品身份与证据总索引见 [`evidence-index.md`](notes/p65/evidence-index.md);
|
||||
具体结果与未决项见 [`validation-status.md`](notes/p65/validation-status.md)、
|
||||
[`wire-and-validation.md`](notes/p65/wire-and-validation.md)、
|
||||
[`performance.md`](notes/p65/performance.md)。以下保留 P6 收官时的原始进度快照。
|
||||
|
||||
## P6 收官快照
|
||||
|
||||
> **这份文档只记当前阶段(P6)。** 已收官阶段(P0…P5f)的逐门数字与证据在
|
||||
> [`ROADMAP.md`](ROADMAP.md) 的阶段表与各 `P5*` 报告里,不在这里重复。规范契约见
|
||||
|
||||
@@ -281,7 +281,7 @@ red-once:**改成从超时置位闩锁,则配对的正控制"server 落后
|
||||
|
||||
> `MGPipeRunAheadCapBitsFor(...)` 与 `ConsumedSubsystemsFor(ActiveBackendType)` 要挪到 server 侧。
|
||||
> 注意一个被多处写错的细节:**CallMask 的能力位那一半已经读 server 自己的 backend 了**
|
||||
> (`Init.cpp:184-211` 读 `loop.Backend()->GetBackendFunctions()`,代码里带了理由)。只有那两个函数需要搬。
|
||||
> (`MG_Backend/Init.cpp:184-211` 读 `loop.Backend()->GetBackendFunctions()`,代码里带了理由)。只有那两个函数需要搬。
|
||||
|
||||
### 5.5 `t6` 的出口门加三条负控制、两个必测数字
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,48 @@
|
||||
# P6.5 第一波 代码审查(4 切片,2026-09-22)
|
||||
|
||||
审查对象:`codex/p65-all-tcp` HEAD `52ffc6a7` + 未提交工作树(含 archive v2 / Present-glFlush 尾批 / 取消 / half-close 修复)。
|
||||
四个并行 Opus 审查各读设计(ROADMAP §51–116)后逐文件核验。**结论:数据面、wire 布局、握手三块无硬正确性缺陷;实现整体谨慎、扎实。** 下表按严重度排序,两项已修,其余记为跟进。
|
||||
|
||||
| 严重度 | 发现 | 出处 | 处置 |
|
||||
|---|---|---|---|
|
||||
| **Medium** | `AcceptPair` 把可重试的 `accept()` 错误(`EINTR` / `ECONNABORTED`)当致命 → supervisor 映射为 `return 73`,整台常驻 server 退出。LAN 对端在 accept 窗口内 reset、或信号(本进程按构造收 SIGCHLD)打断 `accept()` 都会拆掉 server;与兄弟函数 `WaitReadable` 刻意重试 `EINTR` 自相矛盾。潜伏——设备 102 条顺序会话已过,未触发。 | `SocketTransport.cpp` AcceptPair | **已修**:`EINTR`/`ECONNABORTED` 在 budget 内重新 poll,不返回 `TRANSPORT_CLOSED` |
|
||||
| **Moderate** | `MobileGLServerService.onDestroy()` 只 `destroy()` supervisor PID;在飞的 fork 会话 child(无新 session/group)被 reparent 到 init,泄漏进程 + EGL 上下文。仅 `am force-stop`(按 UID 杀)能清。验收走 force-stop、CI 走 killpg,故门路径干净;属 Android 生命周期 / P12。 | `MobileGLServerService.java:96-102`, `ServerMain.cpp:292` | 跟进(P12 生命周期);本波验收不受影响 |
|
||||
| Low | supervisor 强检 `MOBILEGL_IPC_DIAL=no` 却不设/不检 `MOBILEGL_IPC_ROLE`;launcher 漏设会把 supervisor 主线程 server 日志误记为 client 且不前送。潜伏(四个 launcher 都设了)。 | `ServerMain.cpp` | **已修**:`mobilegl_server_main` 顶部自设 `MOBILEGL_IPC_ROLE=server`(首日志前,fork 继承) |
|
||||
| Low | 设计要求的裸 `char` 符号性普查未在 `gen_pipe.py` 实现;成员摘要抓不到(`sizeof`/`offsetof` 两 ABI 相同)。**当前无实活风险**——所有 wire 子-int 成员都是定符号 `Int8`/`Uint8`。 | `scripts/gen_pipe.py` | 跟进:加 census 守卫 |
|
||||
| Low | `DynamicBackendParameters` / `RenderStateParameters` 只按整体 `sizeof` + 分块边界 offset 入指纹,非逐成员。安全——成员全定宽(无 `long`/`size_t`/指针/位域)。 | `MGPipeRenderStateSpans.h`, `CapsCodec.cpp` | 跟进(可选):逐成员 offset 入摘要 |
|
||||
| Low | client `eventRingFull` 在 drain 后可能被在飞 `ProgressFrame` 短暂重置;自愈(下个 progress 带 `full=0`,1ms timer 兜底),非挂起。 | `StreamLink.cpp:293` | 跟进:加 latch-only 注释/守卫 |
|
||||
| Low | `StreamLink` 的 `RecordArena/RecordCursor/EventArena/EventCursor` attach 时冻结 `LocalHead=0`,与 ILink 性能契约不符;当前无 cpp 消费者,无害。 | `StreamLink.cpp:342-345,399-409` | 跟进:随首个消费者刷新或删访问器 |
|
||||
| 测试缺口 | 无测试断言 keepalive 调优值(KEEPIDLE/INTVL/CNT/USER_TIMEOUT)实际生效;`StreamLinkTest` 不强制跨 recv 边界的帧头拆分,且漏 Cmd 越窗 / reply-seq 倒退 / ProgressFrame 一致性三条 Fatal。 | `SocketTransportTest.cpp`, `StreamLinkTest.cpp` | 跟进:补断言 |
|
||||
|
||||
## 已核验干净(各切片焦点)
|
||||
|
||||
- 数据面:帧重组 / 短读 / iov 回绕 / EOF;水位单调 + late-never-early 接收侧强制(倒退 `Fatal{ProtocolCorruption}`);单邮箱 reply seq 匹配(applied 越过无 reply → `PROTOCOL_MISMATCH`);park 前 `Flush` + flush-on-idle 进度;event 背压(`head − 对端 tail > cap` 阻塞);`ResolveSpan` 指向持久镜像段(非瞬态重组 buffer,无悬垂);单 reader vs apply vs encode 线程安全;EOF→`Die(peer)`→`PeerHungUp`→device-lost 闩(clean detach 不误闩)。
|
||||
- 控制面:`tcp://` 解析(IPv6 `[h]:p`、缺/坏端口、port 0/>65535 全拒);四个 socket 选项全设且查返回值,控制与数据连接都设 keepalive;掉线经 keepalive/USER_TIMEOUT(~5s)→挂断(非 120s barrier);握手零 abort(每条拒绝走具名 `Refuse`,server `_exit(0)`,client 不误回落 monolith);token loopback-only-when-no-token;指纹策略按 Dial(Fork 拒 / Connect 警告 / REQUIRE_SAME_BUILD 拒);fd 泄漏各失败分支已闭。
|
||||
- wire:`gen_pipe.py` 生成与 `PipeFields.def` 同步由 CI `git diff --exit-code` 守;指纹成员齐、删 `GLFunctionsTable`;两端同一 endian-无关计算(非结构体 memcpy 哈希);定宽确认。
|
||||
- server:fork 循环 fd 卫生(child 关 listen、parent 关 accepted、无跨迭代泄漏);僵尸回收 + max-sessions=1 + 第二连接 `Refuse{Busy}` 且干净关闭;child 得 `DIAL=no`;日志前送在 `LogMutex` 下 sink+forward、`LogFlush` 控制线程应答不经 apply 线程(无死锁);exec/argv-env;INTERNET 权限;wake lock 平衡。
|
||||
|
||||
## 已应用修复(本次)
|
||||
|
||||
1. `SocketTransport::AcceptPair`:`EINTR`/`ECONNABORTED` 在 budget 内重新 poll,不再 `TRANSPORT_CLOSED`。防常驻 server 因 accept 瞬态整体退出。
|
||||
2. `mobilegl_server_main`:顶部自设 `MOBILEGL_IPC_ROLE=server`(若未设),不再盲信 launcher。
|
||||
|
||||
两处均在 `MG_Remote/`(`MOBILEGL_BUILD_DISAGGREGATED` 门内),故 G1 monolith `.text` 不受影响(构造性保证)。
|
||||
|
||||
## 修后再验收(固定制品,2026-09-22)
|
||||
|
||||
固定制品:WSL client `libMobileGL.so` SHA16 `e17f82f1`、设备 APK SHA256 `780bb00e…`(`assembleTraceDebug`,`-O0 -g`),**两端 build stamp 同为 `p65-acceptfix-20260922`**(同源同戳,`REQUIRE_SAME_BUILD=1` 真实通过)。
|
||||
|
||||
| 检查 | 结果 | 证据 |
|
||||
|---|---|---|
|
||||
| G1 | monolith `.text` 不变(构造性:改动全在 `MG_Remote/`,非 split 构建不编译) | CMakeLists §497 门 |
|
||||
| 主机 full unit | 2399/2399,0 fail | `/tmp/p65-fullunit2.log` |
|
||||
| P6.5 子集单测 | 147/147(含 wf/ct red-once:同宽字段重排改摘要、wireMajor/layout 不匹配→具名 Refuse 不 abort、Connect 接不同 build、Fork 拒、REQUIRE_SAME_BUILD 拒) | ctest -R 输出 |
|
||||
| integration-tcp **loopback**(Release 固定制品) | 102/102(一条 `ClientVertexArray…GpuWrittenIndices…` 会话槽竞态 flake,单独重跑绿——ci-false 类) | `/tmp/p65-tcp-loopback-fix2.log` |
|
||||
| **device-102** integration(Redmi,固定 APK) | **102/102,0 fail、0 Fatal、0 eglInit 失败;102/102 client 日志 `run-ahead ARMED`** | `/tmp/p65-devlane-fix2.log` |
|
||||
| 代表性 device retrace(Redmi,固定制品,`--require-run-ahead`) | OpenRA ssim=1.0 / startup 0.999999511 / in-world 0.999995438,**三条全 ARMED**(非 lockstep/disarmed) | `/home/swung/p65-repr-device/checkpoint.json` |
|
||||
|
||||
排障留痕(勿重犯):restamp 后只 `ninja libMobileGL.so MobileGLServer` 的**局部构建**会让 `MobileGLIntegrationTest` 与生产库不一致,服务端报 `Fatal{ProtocolCorruption, PipeApplier::Attach missing link}`、客户端 `eglInitialize 0x3001 remote TCP bring-up failed`——**全量 `ninja` 后即消失**,不是 wave 缺陷也不是 debug/release 差异。设备车道无 wake keepalive 会因 Doze 冻结全挂,retrace 用 `--wake-adb-serial` 已规避,device-102 补了 `KEYCODE_WAKEUP` 循环。
|
||||
|
||||
代表性 scope 依用户偏好(本地代表性、CI 兜底全量);此前另有一条完整 39 例 device 矩阵在跑,14 passed / 1 ci-false(`minecraft-1.21.11-main-menu` 的 Redmi 32B UBO 对齐 golden 伪差),因与固定制品身份不一致且 APK 需重装而停,其部分结果 `p65-final-matrix-gles*` 作旁证保留。
|
||||
|
||||
临时环境已恢复:设备 server 停、idle 白名单还原、WSL→手机 host route 删除(adb forward 与本地 fixture 早已清)。设备现装固定 APK `780bb00e`(含本次两修复)。
|
||||
@@ -0,0 +1,57 @@
|
||||
# P6.5 数据面实现记录
|
||||
|
||||
## 已落的边界
|
||||
|
||||
`ILink` 工厂创建共享段或 stream 链路。`ShmLink` 持有段、command/event 环端点;`StreamLink` 持有独立私有镜像及专用 reader。session 只缓存链路借出的 endpoint 指针;Reserve/Pop 与 spin 内的原子读取仍非虚。生产 encoder 保存 `LinkProgress` / `LinkSignals`,decoder 与 writeback 的 span 解析经 `ILink::ResolveSpan`。
|
||||
|
||||
共享车道不装 stream publication hook;共享段 reply 的 `ReadView` 借出已经发布的 payload,由 client 只拷一次。两种 link 均经过 `ILink::PostReply/ReadReply`。旧 raw-ring constructor 与 `Session::Control/Shm` accessor 仍供既有 white-box 测试及共享段 bootstrap 使用;这些兼容点未被冒充成字面 grep 的零命中。
|
||||
|
||||
纯度入口:`python3 scripts/ci/link_seam_purity.py --self-test`。检查物理段/环/slot 池不得回到 session 所有权、上层不得实例化具体 link、apply loop 不得直接读 RingControl、codec 不得持有 RingControl、writeback 不得绕开 link;七个具名负控随脚本执行。cached endpoint 类型与旧测试 constructor 是明确保留的兼容边界。
|
||||
|
||||
## 数据帧
|
||||
|
||||
共用 `Framing.h::FrameReader`;默认 MGLF,data reader 指定 MGLD。长度为 20 字节 data envelope 加 payload,最大 64 MiB;envelope 是 kind:u8、reserved:u8[3]、a:u64、b:u64。所有多字节 data 字段按小端编码。Stage/Cmd/Event 的单帧 payload 上限因而为 64 MiB − 20;64 MiB Stage burst 会拆两帧。
|
||||
|
||||
reader 先验证 framing header 与 data envelope 的角色、长度和窗口,再接收 payload;一条专用 reader 始终排空连接,writer 在调用线程串行发送完整帧。没有无界消息队列。
|
||||
|
||||
Progress 除四个 seq/frame 水位,还携带 **cmdAppliedTail 与 cmdRetiredTail**。原 roadmap 简写只有 applied tail,但现有 `RingProducer::FreeBytes` 只读 retired tail;遗漏会在首次回绕挂死,混成 applied tail 则提前释放 borrowed slot。stage 的三个旧 ring cursor 保持零;原 encoder allocator 保持退休 mark/rebase 规则,链路用 `NoteStage` 记录新字节并先于 Cmd 发送。
|
||||
|
||||
单槽 reply 接受按 seq 前进的最新回复:`wantReply=false` 的 ResourceSubData 仍回复时不会堵住 reader。同步调用只在自身 applied 后读取,Reply 帧严格先于该 applied 进度发送。若 applied 已到而 reply 不存在,立即返回 protocol mismatch;EOF/错误在同一 reply mutex 下唤醒等待者。stream 不读 shared reply slot,不做取模或 stamp 自检。
|
||||
|
||||
## 发布与跨连接顺序
|
||||
|
||||
每次 producer park / stage retirement wait 前 Flush;server apply 的真正 park 点(`ServerLoop`)及 transport 的 `SessionConsumer::WaitForWork` 都 FlushProgress。另在 PostReply、present/completed-frame 变化和每 64 条或 1 ms 发布。水位只晚不早、比较用 >=、倒退具名 Fatal。
|
||||
|
||||
event bytes 先于宣布其完成的 Progress;client drain 返回 event tail,server 只在真实 tail 前进时清除 full latch。控制连接的 SurfaceReply 不能替数据连接保证先后,因此它携 eventHead fence;client 等本地数据 reader 收到该 head 后再排空事件。RPC 前也冲刷并等此前 command 完成,等待过程中继续排空反向事件。
|
||||
|
||||
## 测试与证据边界
|
||||
|
||||
`StreamLinkTest` 覆盖 Stage-before-Cmd、idle 尾水位、160 次记录/多次回绕、无用 reply 后的同步 reply、event credit、EOF、等待中的 reply 被 EOF 释放、缺失 reply 拒绝、独立连接的 event fence、Progress 倒退与 Stage 越窗。另以真实 IPv4 loopback TCP 传送 64 MiB Stage 并记录耗时/MiB/s;socketpair correctness 结果不充作 TCP 吞吐。
|
||||
|
||||
2026-09-22 开发中 build4 曾产生 server `NoteStage` fatal。只读 objdump 证明是编辑 virtual 接口与同轮并行构建交叠:旧 `Ring.cpp.o` 的 NotifyClient 跳 vptr+0xc0,新 StreamLink 此 slot 已为 NoteStage,ProgressChanged 已挪一格。该产物不作验收证据;接口冻结后重建所有受头影响的 object 才可验证。
|
||||
|
||||
## 最后一次退休进度的 red-once
|
||||
|
||||
核心 `StreamPair.StagingArrivesBeforeItsCommandAndLastRecordProgressFlushesOnIdle` 在稳定产物上曾真红:收到 applied=1 后 retired 仍为 0。原因不是网络可见性,而是 receiver 先调用 `AdvanceRetired`;此 helper 会按本地 applied(仍为旧值)夹紧退休值。若此后再无 apply,最后一次退休永远丢失,大 stage 窗口回收可因此互等。
|
||||
|
||||
修复是按依赖顺序先应用 incoming applied,再应用 incoming retired,随后通知。测试分别等待两种语义,不假设 applied 是 retired 的同步屏障;它只有一次 idle progress,不能靠后续批次掩盖这个错误。
|
||||
|
||||
WSL 真 TCP 64 MiB stage 记录(该退休修复前、传输字节已核对的测量):0.069763 秒,917.397 MiB/s。它只代表本机 loopback 的框架与复制吞吐,不代替 Redmi/Wi-Fi 测量。
|
||||
|
||||
## Present 与 glFlush 的提交边界
|
||||
|
||||
阶段审查的真实负控发现:本地 `PublishAndNotify` 不是 stream delivery;run-ahead Present 可以在没有任何后续 wait 的情况下返回,最后一个 present 因此永远留在 client。credit=3 的前三帧尤其能暴露它。
|
||||
|
||||
修复把传输 Flush 放在每次 Present publish 后,并给 exported `glFlush` 接入只提交、不等待 applied 的 client 路径。run-ahead、present credit 和一般记录的批处理均保留;纯 pull 的 glFlush 经预处理仍是原空函数。
|
||||
|
||||
`StreamClientPublicationTest` 用真实 CapsSnapshot 启动 run-ahead ClientSession 和 StreamLink reader,peer 故意不 apply。它断言前三个 Present 各自到达 peer、以及 exported glFlush 发送之前发布的 MemoryBarrier,同时 client waits=0、applied=0。测试没有调用 client wait、事件 drain 或日志同步来暗中冲刷;五秒 alarm 会抓住误加同步等待的回归。
|
||||
|
||||
## 挂断发生在 staging 时的取消
|
||||
|
||||
设备日志曾记录真实顺序:DrawVbo 等待已报告 DEVICE LOST,随后大 BufferSubData 仍进入 stage allocator,并以 `RetirementWaitFailed` 终止 client。现有 codec 与 emitter 没有传播这个已确认的会话取消。
|
||||
|
||||
取消现在是 encoder 本地状态,借用 session 的 lost atomic,并只在 staging/失败等待边界询问生产 doorbell。只有 `PeerHungUp` 会触发 session latch;普通 Dead 可取消 teardown,但不伪造设备丢失。`StageAllocate` 返回 null 时,`StageBytes` 不执行 memcpy 或 NoteStage;session/encoder 在 EncodeRecord 前拒绝取消请求,不产生新 seq 或无效 blobref。stage 的生产等待预算对齐 120 s barrier,给真实 TCP keepalive 检测留下余量;健康 peer 超时仍保持具名 Fatal,不把 deadline 解释成 loss。
|
||||
|
||||
没有发出记录时 seq=0;四个 mailbox emitter 保留调用者已 minted 的非零本地 ticket,避免 ReplyToNoSlot。ResourceSubData 的 buffer 快路径也保留取消的 DECLINED,不再在 wire emitter 或 route 中强制改成 OK。
|
||||
|
||||
回归共三条:已断后大于 stage window 的上传不拷贝/不发记录;填满 stage 后在 producer 确认 park 时 SIGKILL 一个真实 reader child,第二个 blob 不覆盖窗口且无新 seq;健康 peer 的 5 ms 测试预算仍以 RetirementWaitFailed 结束,signal 侧确认 device_lost=0。生产预算不受该单测缩短。
|
||||
@@ -0,0 +1,83 @@
|
||||
# P6.5 第一波证据索引
|
||||
|
||||
本次实现与验收的总入口。完整 trace 和性能表仍在采集,不能将本索引理解为阶段收官。
|
||||
|
||||
> **2026-09-22 收尾追加**:四切片代码审查完成(数据面/wire/握手无硬缺陷),两项修复已落地并再验收——见
|
||||
> [code-review-findings.md](code-review-findings.md)。修复:`SocketTransport::AcceptPair` 重试 `EINTR`/`ECONNABORTED`
|
||||
> (Medium,防常驻 server 因 accept 瞬态整体退出)、supervisor 自设 `MOBILEGL_IPC_ROLE=server`(Low);均在
|
||||
> `MG_Remote/` 门内,G1 不受影响。固定制品(client `e17f82f1` + APK `780bb00e`,同 stamp `p65-acceptfix-20260922`)
|
||||
> 再验收:主机 unit 2399/2399、integration-tcp loopback 102/102、**device-102 102/102 全 ARMED**、代表性 device
|
||||
> retrace 3/3 ARMED golden(OpenRA 1.0)。**残余**:完整 39 例 device golden 矩阵与全套必测数按用户「本地代表性、
|
||||
> CI 兜底」定为 CI/后续;本收尾未宣布 P6.5 阶段收官。临时环境(host route / idle 白名单 / server)已恢复。
|
||||
|
||||
## 源码与制品身份
|
||||
|
||||
- 基线:远端 `feat/disaggregated` 的 `e6c51d0711595f579decfaf78c1f5b0040ccd7fe`。
|
||||
最后一次 fetch 已确认没有更新;该提交是当前分支的祖先。
|
||||
- 开发工作树:`codex/p65-all-tcp`,HEAD `52ffc6a7` 加未提交修改。
|
||||
用户纠正提交偏好之前已有的两个本地提交随后只做了 rebase;之后未创建开发提交、未 push。
|
||||
- 两端显式 build stamp:`410dfa94c3d92241e9ec01ddbba1bb911eb60d4b`。
|
||||
它是本轮共享的构建标识,不代表当前 HEAD 或一份已提交的最终源码。
|
||||
- Android:NDK 27.3、arm64-v8a、debuggable traceRelease,实际 native `-O2 -DNDEBUG`。
|
||||
|
||||
| 制品 | SHA-256 | 使用它的证据 |
|
||||
|---|---|---|
|
||||
| READY7 host libMobileGL.so | `29fcff6b23557be6b1cc3765db382b3422ed0780643c719937616259298d3116` | host/device 102 与修后 TCP CPU |
|
||||
| 优化 APK | `f2a957c3c6ce1c3c77dd0b99f233f40eed9e47896830ee7767af6b7fbb738f50` | READY7 真机与正式 trace |
|
||||
| 最终 ALL 后 host libMobileGL.so | `25ca45d756bc5a4e5bd56ad4ce231e4ef89d45ba41131f389575cda0842cd6be` | 全 unit 与正式 trace |
|
||||
|
||||
最后一次 ALL 增量只重编测试和 SPIRV-Cross 的 `spirv_cross_c.cpp`;未重编 MobileGL 生产 object。
|
||||
其 CMake 每次 configure 都生成 gitversion 时间戳,这次值为 `2026-09-22T08:02:51`,
|
||||
导致重新链接后 SHA 改变。保留两份身份,不能把较早样本改标为新制品。
|
||||
|
||||
## 已完成的验证
|
||||
|
||||
所有 `/home/swung/` 路径位于 WSL Arch,日志/XML/原始样本保留在对应位置。
|
||||
|
||||
| 检查 | 实际结果 | 证据 |
|
||||
|---|---|---|
|
||||
| 最终 ALL | exit 0 | `/home/swung/p65-final-tests-build.log` |
|
||||
| 全 unit | 2389 PASS、0 FAIL、10 个原有条件性 skip | `/home/swung/p65-ready7-unit.{log,xml}` |
|
||||
| TCP loopback | 102 PASS、0 FAIL、0 SKIP;102 条实际 run-ahead ARMED | `/home/swung/p65-ready7-tcp.{log,xml}`、`p65-ready7-tcp-lane.json` |
|
||||
| Redmi TCP | 102 PASS、0 FAIL、0 SKIP;102 条实际 run-ahead ARMED,72.23 s | `/home/swung/p65-armed-device.{log,xml}`、`p65-armed-device-lane.json`、204 份 `p65-armed-device-rolelogs/` |
|
||||
| 名集合 | split 105 中可比 102 = spawn 102 = TCP 102 = device 102 | `/home/swung/p65-ready7-lane-parity.log` |
|
||||
| G14 | 4016 → 4257,0 删名、241 新增(含可选 device 102) | `/home/swung/p65-ready7-test-name-parity.json` |
|
||||
| 最终 G1 | 符号 0 增/删/resize/rename;`.text` 10,822,147 B 逐字节相同 | `/home/swung/p65-g1-ready7-{report.md,symbols.json,verification.json}` |
|
||||
| 真机 SIGKILL | 133 ms,生产挂断路径闩 device loss | `/home/swung/p65-device-peerloss/kill.log` |
|
||||
| 真机 Wi-Fi 半开 | 5053 ms,低于 10 s;Wi-Fi 已恢复 | `/home/swung/p65-device-wifi-loss/{probe.log,timing.json}` |
|
||||
| 真实生产 idle flush 负控 | 原库绿 → 仅删除 idle publication 后 8 s 抓到停滞 → 恢复绿 | `/tmp/p65-idle-redonce-c_n59aqs/results.json` |
|
||||
| 日志前送负控 | 三个 server marker 各 ON 绿 / OFF 缺指定 marker 红 | `/home/swung/p65-lf-controls2/summary.json` |
|
||||
| CI 修复 | role-log 正反控通过;真实两后端 RSP 2 PASS;设备离线分类 5/5 | `/home/swung/p65-ci-runtime-proof.{log,xml,json}`、`scripts/ci/test_trace_infrastructure.py` |
|
||||
|
||||
初始 caps 的三个新回归包含在全 unit 中:真实 TCP/ControlInbox 延迟快照正确武装,
|
||||
健康但不发快照的 peer 在 5 s 内具名启动失败且不伪造 device loss,坏快照拒绝。
|
||||
之后的能力更新仍只能 demote,不能重新 promote。
|
||||
|
||||
此前的保留车道是 spawn 102/102、inproc 186/186、零 skip,见 `p65-final-{spawn,inproc}.{log,xml}`。
|
||||
它们与 G1 细节见 [wire-and-validation.md](wire-and-validation.md)。早期 TCP/device 的 lockstep 样本
|
||||
仍保留作历史证据,不能替代上表的实际 run-ahead 结果。
|
||||
|
||||
最终 G1 更新独立 source snapshot 后只增量构建 after;before 制品与固定的 hash 头未变。
|
||||
双方 `.text` SHA-256 为 `35115edd2c265162c7f845a87d1a2cb9849609a40ba0febac317b91370b9163c`。
|
||||
|
||||
## trace、测量与审查
|
||||
|
||||
- 正式 GLES 39 项:`/home/swung/p65-final-matrix-gles/`。使用原有 golden 与逐例实际 ARMED 门;进行中。
|
||||
- 已完成条目中 `minecraft-1.21.11-main-menu` 为 FAIL(SSIM 0.890161)。原样主机 TCP 对照通过;
|
||||
只从临时 trace 删除 3,878 个不满足 Redmi 32 字节 UBO 对齐的 bind,便能在主机复现缺失,
|
||||
与设备实际图 SSIM 0.998729。该诊断不计正式通过,设备本地对照尚待;
|
||||
详见 [mainmenu-trace-difference.md](mainmenu-trace-difference.md)。
|
||||
- CPU 前后与正式 TCP/spawn 对比:[performance.md](performance.md)。保留非零差值、线程测量范围、
|
||||
样本散布和 before 制品身份限制;没有把性能“只记录”解释成可以不测。
|
||||
- 阶段审查发现 Present/glFlush 尾批可能留在本地;已补真实传输边界并验证前三个 present credit
|
||||
各自到达 idle peer,client waits=0、applied=0。后续窄查未发现正常关闭路径死锁/UAF;
|
||||
`WaitClosed=true` 也可能表示 terminal protocol error,不能独自作为正常 EOF 证明。
|
||||
- link seam 明确保留 cached endpoint、旧白盒 raw-ring constructor 和共享段 bootstrap accessor。
|
||||
ownership/dispatch gate 与七个负控通过;没有声称所有历史 accessor 或字面 grep 命中归零。
|
||||
|
||||
唯一已知的 verify+split 前置债仍为 `PipeRespecifyScope`,inproc/spawn/TCP 同因复现。
|
||||
LF 第四个 PipeVerify marker 属于 client,本来就不能成为 server forwarding 的负控;
|
||||
未执行到的断言不计通过。说明见 [validation-status.md](validation-status.md)。
|
||||
|
||||
临时设备 idle 豁免与 WSL 手机 host route 要在全部真机工作结束后恢复;当前仍在使用。
|
||||
闲置的本机 40614 supervisor 与 adb forward 40615 已清理。
|
||||
@@ -0,0 +1,141 @@
|
||||
# P6.5:1.21.11 主菜单 GLES 像素差异诊断
|
||||
|
||||
**状态:正式设备矩阵仍记 FAIL;独立主机负控已复现同位置缺失,强烈支持 trace 不满足目标 GPU 的 UBO 对齐要求;相同 APK 的设备本地对照仍待补。**
|
||||
本记录不修改源码、trace fixture、golden 或 SSIM 阈值,也不把该失败归入既有 Vulkan 债务。
|
||||
|
||||
## 正式失败与可比阳性
|
||||
|
||||
| 对照 | 结果 | SSIM / 阈值 | 用时 | 实际 arming |
|
||||
|---|---|---|---|---|
|
||||
| Linux client → Android/Adreno TCP+stream,credit=2 | FAIL,完成回放后图像不符 | 0.890161090 / 0.99 | 272.684 s | ARMED,无 lockstep/DISARMED |
|
||||
| WSL 同 ABI/驱动 TCP+stream loopback,credit=2 | PASS | 0.993474922 / 0.99 | 14.018 s | ARMED,无 lockstep/DISARMED |
|
||||
|
||||
两次目标 call 均为 `205347`,分辨率 `854×480`。正式失败的 `statusCode=6`、
|
||||
`returncode=1`、`timeout_kind=null`,不是 watchdog 超时;其 mismatchPixels 为 79,246。
|
||||
客户端和服务端没有 `Fatal{`、device loss、Refuse 或握手失败证据。客户端完成 38,884 次 reply wait;
|
||||
服务端最后一帧计 11,551 draws。没有遗留进程。
|
||||
|
||||
目视检查可见背景、标题与文字仍在,主要缺失 Singleplayer、Multiplayer、Realms、Options、Quit
|
||||
的灰色按钮底图,以及语言/右侧辅助功能按钮的图标或底图。loopback 中这些元素正常。
|
||||
图中 Mali/Tensor 文字属于捕获的游戏画面,不能据此判定当前服务端 GPU;实际服务端日志为 Adreno。
|
||||
|
||||
正式 attempt:
|
||||
`/home/swung/p65-final-matrix-gles/DirectGLES/credit-2/minecraft-1.21.11-main-menu/attempt-a1c1263d9b814620b04ff4c8b8d6cbf1`。
|
||||
原始结果、图像和角色日志位于其 `work/output/`,golden 副本位于 `artifacts/`。
|
||||
loopback 证据索引为 `/home/swung/p65-mainmenu-loopback-control/control-summary.json`。
|
||||
该索引记录主机 library SHA256 为
|
||||
`25ca45d756bc5a4e5bd56ad4ce231e4ef89d45ba41131f389575cda0842cd6be`。
|
||||
仅 loopback 阳性还不能单独区分 ABI/wire 与设备驱动差异。
|
||||
|
||||
## 只读 trace 与源码证据
|
||||
|
||||
设备 `mobilegl.server.log:145` 及 `:358` 报告
|
||||
`GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: 32`(SSBO 为 64)。
|
||||
trace 的 UBO offset 有 16 字节粒度,但未找到录制时 alignment 查询值;不能声称捕获日志明确报告 16。
|
||||
|
||||
`MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp:1553` 的
|
||||
`ValidateBufferRangeOffsetAndSize` 查询当前 context 的 alignment;`:1580` 判断 offset 整除性,
|
||||
不符合时记录 `InvalidValue` 并返回 false。`:1627` 在 `TouchBufferBindingPoint` 和修改绑定之前返回,
|
||||
因此保留之前合法的 buffer/range。远端 client 采用远端能力,不能用 WSL 原生 GPU 的较小对齐要求解释该分支。
|
||||
|
||||
`MobileGL/MG_State/GLState/ErrorState/Error.cpp:20` 仅以 `MGLOG_D` 打印 GL error。
|
||||
现有 INFO 日志没有逐次 `RecordError` 文本;下列“应被拒绝”是调用参数加现行代码得到的预测,
|
||||
不是声称已有逐 call 动态错误日志。
|
||||
|
||||
完整只读 `apitrace dump` 中有 14,149 次 `glBindBufferRange`,没有 `glBindBuffersRange`。
|
||||
其中 **3,878** 次满足 `target=GL_UNIFORM_BUFFER && offset % 32 != 0`,首 call `9683`,
|
||||
末 call `205116`;全部发生在 program 158(2,808 次)或 program 15(1,070 次)。
|
||||
program 158/15 的 uniform block 0 都映射到 UBO binding 0(call `6734`/`6661`)。
|
||||
|
||||
这两个 program 的顶点 shader 13(call `6651`)明确声明 `SpriteAnimationInfo`,内含
|
||||
`ProjectionMatrix`、`SpriteMatrix`、`UPadding`、`VPadding`、`MipMapLevel`,并计算
|
||||
`gl_Position = ProjectionMatrix * SpriteMatrix * vec4(positions[index], 0, 1)`。
|
||||
program 158 的 fragment shader 157(call `6727`)通过 `textureLod(Sprite, texCoord0, MipMapLevel)`
|
||||
填充 sprite;program 15 通过两个 sprite 采样做动画插值。由此可将不合对齐的绑定定位到 atlas 生成,
|
||||
而非笼统归因于最终主菜单 draw。
|
||||
|
||||
与缺失按钮直接相关的调用链如下:
|
||||
|
||||
| call | 事实 |
|
||||
|---|---|
|
||||
| `80415` | FBO 16 的 COLOR_ATTACHMENT0 设为 texture 868,后续 viewport 1024×1024 |
|
||||
| `80426`, `80428` | UBO buffer 44 / offset 0 / size 140,随后 atlas draw |
|
||||
| `80434`, `80436` | UBO buffer 44 / offset 144 / size 140(不满足 32),随后 atlas draw |
|
||||
| `80442`, `80444` | UBO buffer 44 / offset 288 / size 140,随后 atlas draw |
|
||||
| `205215`, `205221` | program 181 采样 texture 868,DrawElementsBaseVertex count 90 / basevertex 4 |
|
||||
| `205254`, `205262` | program 181 再采样 texture 868,count 12 / basevertex 68 |
|
||||
|
||||
FBO 16 一共 607 次 atlas draw,其中 286 次前置 UBO bind 不满足 32 字节对齐;
|
||||
该 FBO 最后一次不合对齐绑定为 `197198`(buffer 43 / offset 144 / size 144)。
|
||||
最终 GUI program 181 使用的 UBO offset 是 0 或 160,本身满足 32。
|
||||
它的 fragment shader 27 对 `texture(Sampler0, texCoord0)` 的零 alpha 执行 discard。
|
||||
|
||||
**获得独立负控支持的机制:** atlas 生成时,非法绑定保留旧 `SpriteMatrix`,新 sprite 仍写入旧区域,目标格留空或错误;
|
||||
最终 GUI 从 texture 868 采样时因零 alpha 丢弃,从而出现按钮文字正常、底图/图标缺失。
|
||||
下面的 blob/UV 对应进一步把缺失区域映射到具体 atlas draw。独立负控已复现主要视觉缺陷,
|
||||
与设备失败图 SSIM 为 0.9987292763;这不声称两个驱动的全部像素完全一致。
|
||||
|
||||
只读 `apitrace dump --blobs --calls=80413,205170,205177` 把诊断副本写到
|
||||
`/tmp/p65-mainmenu-blobs-ub31dw3f`。`80413` 为 buffer 44 的 69,264 字节初始化内容,
|
||||
每个 `SpriteAnimationInfo` record 以 144 字节步进;`205170`/`205177` 分别是最终 buffer 39
|
||||
中 15 个按钮底图 quad 和两个图标 quad 的顶点内容(每顶点 24 字节)。
|
||||
将顶点 UV 乘 atlas 尺寸 1024,再与 UBO 内的 SpriteMatrix 比较,得到:
|
||||
|
||||
| GUI 元素 / 最终采样像素区域 | buffer 44 record / atlas 矩形 | 生成调用与对齐 |
|
||||
|---|---|---|
|
||||
| 15 个底图 quad,包括三行主按钮及底部四个按钮切片;x=723…923, y=1…21 | record 279,矩形 (722, 0, 202, 22) | bind `82658` offset=40176,余数 16;draw `82660`,源 texture 1168 |
|
||||
| 语言图标;x=659…674, y=122…137 | record 125,矩形 (658, 121, 17, 17) | bind `81426` offset=18000,余数 16;draw `81428`,源 texture 1014 |
|
||||
| 右侧辅助功能图标;x=659…674, y=88…103 | record 148,矩形 (658, 87, 17, 17) | bind `81610` offset=21312 合法;draw `81612` 后紧跟 record 149 |
|
||||
|
||||
record 149 原定矩形为 (658, 155, 17, 17),bind `81618` offset=21456 余数 16,
|
||||
draw `81620` 的源 texture 1038。如果该 bind 被拒绝,它沿用 record 148 的合法矩阵,
|
||||
因而会覆盖右侧图标刚生成的位置。按钮背景被拒绝时沿用 record 278 的矩形 (376, 194, 22, 22),
|
||||
语言图标则沿用 record 124 的矩形 (610, 287, 18, 18),都不是最终 GUI 预期采样的区域。
|
||||
|
||||
## 独立控制与证据边界
|
||||
|
||||
原 trace 的同 ABI TCP loopback 已通过。独立代理根据
|
||||
`/home/swung/p65-mainmenu-ubo32-rejected-calls.json` 的 3,878 个 call 编号,
|
||||
仅在临时 trace 副本中移除这些本应被设备 client 拒绝的绑定,保留对应 draw,然后做主机 TCP 负控。
|
||||
该主机结果复现了设备的按钮矩形、语言按钮和右侧图标缺失。
|
||||
|
||||
| 图像比较 | 全图 RGB SSIM | 对原 golden 的判断 |
|
||||
|---|---:|---|
|
||||
| 原 trace 主机 loopback vs 原 golden | 0.9934749217 | PASS |
|
||||
| 原 trace 设备 TCP vs 原 golden | 0.8901610899 | FAIL |
|
||||
| 临时删绑定 trace 主机 TCP vs 原 golden | 0.8892457298 | FAIL;仅诊断负控 |
|
||||
| 临时删绑定 trace 主机 TCP vs 原 trace 设备 TCP | 0.9987292763 | 比较两张失败图,不是 golden 验收 |
|
||||
|
||||
比较使用项目 `trace_replay_core.cpp` 的全图 RGB SSIM(C1=6.5025、C2=58.5225),
|
||||
不 crop、忽略 alpha,且已校验原设备和原 loopback 的 runner 结果。四张图像的路径与 SHA256
|
||||
均保存在 `/home/swung/p65-mainmenu-ubo32-diagnostic/comparison-summary.json`。
|
||||
|
||||
处理过程和逐 call 验证保存在
|
||||
`/home/swung/p65-mainmenu-ubo32-diagnostic/preparation-summary.json`。
|
||||
安装的 apitrace 14.0 不支持 `--exact`;实际使用显式保留 call 补集的
|
||||
`trim --calls=@keep-calls.txt`,并核实该版本直接写出所选调用,没有增加依赖闭包。
|
||||
随后完整 dump 两份 trace,逐项比较所有保留调用的顺序、thread、参数和每个 blob 的 SHA;
|
||||
仅规范化 call 编号前缀和 blob 文件名,确认除名单中的 3,878 个绑定之外没有变化,headers 也一致。
|
||||
原 trace 共 205,348 个 call,临时 trace 共 201,470 个,最后的 `eglSwapBuffers` 从
|
||||
`205347` 重编号为 `201469`。临时 trace SHA256 为
|
||||
`92e47f93ddcb7b5f3eaece05229fa8980e92adc5d24bbff3d6fe1c1b948ef6b4`。
|
||||
|
||||
同目录 `replay-summary.json` 记录负控用时 12.188 秒、returncode=6,实际 ARMED,
|
||||
无 lockstep/DISARMED,双角色均为 TCP+stream 且 Fatal=0;结束后 supervisor 正常停止、
|
||||
state 移除且端口释放。该负控使用与原 loopback 相同 SHA256 的主机库。
|
||||
`apitrace-tool-evidence.json` 保留版本和 `--exact` 不支持的实际输出,`README.md` 汇总复现步骤。
|
||||
原 trace 与 golden 在负控回放后重新计算 SHA256,确认均未改变。
|
||||
|
||||
这一负控、远端 alignment=32、frontend 拒绝路径以及精确 UV 对应共同强烈支持
|
||||
**捕获 trace 对目标 GPU 的 UBO 对齐有效性问题**。它是独立于原设备 TCP 回放的机制复现,
|
||||
不能把修改后的 trace 当作正式 GLES 阳性,也不能将正式 case 改记 PASS。
|
||||
**相同 APK/后端的设备本地 inproc/spawn 原 trace 对照尚未执行**;需待正式设备矩阵释放设备后再补,
|
||||
本记录没有将它写成已完成,也不把负控宣称为完全排除所有跨机器差异。
|
||||
|
||||
原 trace 保持不动,SHA256:
|
||||
`7abd871cce098e93dd15a5e799fdfe093d9c85784716b00fd97c94833b8b83af`。
|
||||
原 golden SHA256:`ea8db1c1c1414d3b564d65b1559a708277417b06895900bc947644d2f658bb86`。
|
||||
|
||||
两条 `GL_STENCIL_INDEX8` NormalizePixelFormat ERROR 及 layered-blit 探测 warning 也见于通过的
|
||||
1.21.4 startup/main-menu,因此不把它们单独作为此失败原因。历史 P4a 的 1.21.11 depth-sampler
|
||||
失败有独立的 sampler refusal 证据,现日志没有同一 refusal;不能把旧原因直接套用到本次。
|
||||
@@ -0,0 +1,60 @@
|
||||
# P6.5 真实 peer-loss 探针
|
||||
|
||||
构建目标 `MobileGLPeerLossProbe`,产物位于 `MobileGL/MG_Test/Wire/MobileGLPeerLossProbe`。它是手动工具,不注册为无设备时自动 skip 的 unit。
|
||||
|
||||
探针复用生产 `ClientSession::StartSpawned` 的 Connect 路径及 Hello/Welcome;计时期间不发送 GL 命令、应用 heartbeat 或人为 ACK。它先观察生产 data doorbell 的 `PeerHungUp()`,随后走真实 `FenceStatus -> EmitAndWait -> ShutDown` 路径触发 session latch,并调用生产 `GetGraphicsResetStatus` handler 检查 `GL_UNKNOWN_CONTEXT_RESET`。没有直接调用 `LatchDeviceLost`。
|
||||
|
||||
## S2:真 kill server child
|
||||
|
||||
先启动与 client 同源码的 supervisor。以下杀的是 Welcome 声明的会话 child,不是 supervisor:
|
||||
|
||||
```bash
|
||||
cmake --build /home/swung/p65-split --target MobileGLPeerLossProbe -j 12
|
||||
export MOBILEGL_IPC_CONTROL=tcp://PHONE_IP:40613
|
||||
export MOBILEGL_IPC_TOKEN=devtoken
|
||||
export MOBILEGL_IPC_REQUIRE_SAME_BUILD=1
|
||||
export MGITEST_PEER_KILL_CMD='adb -s 2f7cbe2e shell run-as top.mobilegl.plugin.trace kill -9 {pid}'
|
||||
/home/swung/p65-split/MobileGL/MG_Test/Wire/MobileGLPeerLossProbe --kill --deadline-ms 10000
|
||||
```
|
||||
|
||||
loopback supervisor 的模板可以是 `MGITEST_PEER_KILL_CMD='kill -9 {pid}'`。模板必须含 `{pid}`;probe 只把它替换成经 Welcome 获取的正数 PID。命令跑在 probe 自己的 helper process group,超时会清理并回收 helper。
|
||||
|
||||
## Wi-Fi 半开:由父侧执行断网
|
||||
|
||||
该门必须用直连手机 IP;`adb forward` 走 USB,不会因为手机 Wi-Fi 关闭而断开,不能充作 Wi-Fi 门。
|
||||
|
||||
```bash
|
||||
export MOBILEGL_IPC_CONTROL=tcp://PHONE_IP:40613
|
||||
export MOBILEGL_IPC_TOKEN=devtoken
|
||||
export MOBILEGL_IPC_REQUIRE_SAME_BUILD=1
|
||||
run=$(mktemp -d /tmp/p65-wifi.XXXXXX)
|
||||
probe=/home/swung/p65-split/MobileGL/MG_Test/Wire/MobileGLPeerLossProbe
|
||||
"$probe" --external --deadline-ms 10000 \
|
||||
--ready-file "$run/ready" --start-file "$run/start" >"$run/probe.log" 2>&1 &
|
||||
probe_pid=$!
|
||||
# READY 文件只有 Welcome PID;等待它出现后才允许注入故障。
|
||||
while [ ! -s "$run/ready" ]; do kill -0 "$probe_pid" || exit 1; sleep 0.05; done
|
||||
trap 'adb -s 2f7cbe2e shell svc wifi enable' EXIT
|
||||
# 同一个父侧操作内先打时间起点标记,随即关闭手机 Wi-Fi。
|
||||
touch "$run/start"
|
||||
while ! grep -q P65_PEER_LOSS_ARMED "$run/probe.log"; do kill -0 "$probe_pid" || exit 1; sleep 0.005; done
|
||||
adb -s 2f7cbe2e shell svc wifi disable
|
||||
wait "$probe_pid"
|
||||
cat "$run/probe.log"
|
||||
```
|
||||
|
||||
marker 的观测周期是 5 ms。计时从 probe 观察 marker 开始;父侧写 marker 后等待 ARMED 行,再立即断网,避免故障抢在计时开始之前。该数包含少量父侧与 adb 启动延迟,对 10 s 上限是保守测量。也可省略 start-file,在 READY 后向 stdin 输入 `GO`,适合手动终端。
|
||||
|
||||
成功行形如:
|
||||
|
||||
```text
|
||||
P65_PEER_LOSS_PASS pid=N mode=external peer_hung_up_ms=N device_lost_ms=N deadline_ms=10000 device_lost=1 gl_reset=0x8255 source=production-barrier
|
||||
```
|
||||
|
||||
PASS 要求 descriptor hangup、dead bell、生产 latch、GL reset 状态与 DECLINED 回复全部成立,且总时间严格小于 deadline。只有超时不会设置 latch;没有故障时 deadline 结束应返回非零,这本身可用作阴性对照。
|
||||
|
||||
退出码:0 成功;2 会话/READY 失败;3 计时或触发失败;4 kill 模板失败;5 生产 latch/GL 状态失败;64 参数错误。探针没有创建真实 EGL/GL context,因此不实现 `--stage-burst`,不把人为传输 ACK 伪装成上传完成。
|
||||
|
||||
## 本机验证
|
||||
|
||||
2026-09-22 独立临时 TCP supervisor 的 S2 真 `kill -9`:`peer_hung_up_ms=4`、`device_lost_ms=4`、`gl_reset=0x8255`,exit 0。无故障的 150 ms 阴性对照:exit 3、`peer_hung_up=0 dead=0 device_lost=0`。证据目录 `/home/swung/p65-peerloss-l2ktmltm`;未用手机,这个数不代替设备/Wi-Fi 门。
|
||||
@@ -0,0 +1,184 @@
|
||||
# P6.5 主机逐线程 CPU 前后记录
|
||||
|
||||
**已经取得前后数字,但不能称为“逐字不变”。** 本次记录覆盖本机 inproc 与 unix+shm spawn,
|
||||
用于观察整波改动对保留车道的影响;性能按路线图通用纪律只记录,不据此阻塞正确性验收。
|
||||
它不代表 TCP 吞吐,也不代表 Android Release 性能。
|
||||
|
||||
## 定义与条件
|
||||
|
||||
- WSL Arch、DirectGLES + llvmpipe;两臂均使用现有 Release 制品,同一个 retrace 可执行文件。
|
||||
- before:`/home/swung/lk-split/libMobileGL.so`;after:READY6 的
|
||||
`/home/swung/p65-split/libMobileGL.so`。各自启动同目录下的 server。
|
||||
before 是既存的 P6.5 前制品,以实际 SHA-256 定身份;旧 CMake 缓存中的 build stamp
|
||||
不足以声称它恰好对应当前远端源码头。
|
||||
- OpenRA 完整 trace 128 帧,选择最后 **100 帧**;rd12 in-world 完整 trace 251 帧,选择最后 **200 帧**。
|
||||
均排除起始资源准备窗口,不把全部 replay 时间除以帧数充作稳态结果。
|
||||
- 每个 case × transport × before/after 均为 **3 次完整 replay**,共 24 个样本。
|
||||
每组记录按 repeat 交替 inproc/spawn;全部 before 完成后等待构建结束,再采 after。
|
||||
不是版本间随机交错试验,也没有 CPU 定频,因此不据此宣称统计显著性或唯一因果。
|
||||
- 采集窗口内没有并发重型构建或另一条 host retrace。此前带
|
||||
`before-pilot-not-comparable` 标签的试跑仅用于校验采集器,不进入表格。
|
||||
- `PRESENT_CREDIT=1`、run-ahead=1、verb-barrier=1、batch-waits=1、spin=50us;
|
||||
PipeStats=0、strict=0、role-split-state=0、audit=0。完整有效环境随每条样本保存。
|
||||
- `--benchmark-finish=0`:runner 不额外在每帧插入 glFinish;trace 自己的同步行为仍保留。
|
||||
|
||||
**client CPU** 来自已有 runner 的 `CLOCK_THREAD_CPUTIME_ID` 与 `frameCpuTimesMs`,
|
||||
取选中尾窗口的平均值。它包括该 replay 线程上的解码与 MobileGL 调用,不是整个进程 CPU,
|
||||
也不是只计 MobileGL 函数的采样 profile。
|
||||
|
||||
**apply CPU** 来自 `/proc/<pid>/task/<tid>/schedstat` 的 execution runtime 纳秒计数。
|
||||
选择最早的、仍存活的 `mgl-srv-apply` TID;后建的 driver helpers 会继承该名字,不能相加冒充
|
||||
一个 apply 线程的 CPU。每条原始采样保留 pid、tid、线程名、采样时刻和累计 CPU。
|
||||
如果没有唯一线程完整覆盖选中窗口,采集器报无效,不填 0。
|
||||
|
||||
### apply 窗口的精度限制
|
||||
|
||||
runner 现有帧数组没有绝对 monotonic 起点,因此外部 apply 采样使用 benchmark JSON 的文件 mtime
|
||||
近似定位 `benchmark::End()`,再减去已有 `totalSeconds - sum(frameTimesMs)` 的非帧尾段,
|
||||
最后回退选中尾窗口的 wall 时间。两个边界在线程 CPU 采样点间线性插值。
|
||||
|
||||
这存在**未单独测量的 summary/JSON 序列化延迟**,不能写成严格帧边界同步或纳秒精度的结果。
|
||||
请求采样周期为 5 ms;before 实际最大间隔 **7.159784 ms**,after 为 **15.230268 ms**。
|
||||
实际间隔与原始点均保留,后续可重新归约。下面多保留的小数位用于复算,不提高测量精度。
|
||||
|
||||
## 结果
|
||||
|
||||
每项是三次 replay 的“尾窗口 CPU 均值”的中位数,单位 **ms/帧**。
|
||||
百分比为 `(after / before - 1) × 100`;完整未舍入值在 comparison JSON 中。
|
||||
|
||||
| trace | transport | 线程 | before | after | 差值 ms/帧 | 差值 % |
|
||||
|---|---|---|---:|---:|---:|---:|
|
||||
| OpenRA | inproc | client | 0.681840 | 0.705350 | +0.023510 | +3.448023% |
|
||||
| OpenRA | inproc | apply | 3.040668 | 3.108000 | +0.067333 | +2.214402% |
|
||||
| OpenRA | spawn | client | 0.806240 | 0.786330 | -0.019910 | -2.469488% |
|
||||
| OpenRA | spawn | apply | 3.242036 | 3.198453 | -0.043583 | -1.344321% |
|
||||
| rd12 | inproc | client | 8.287390 | 8.362680 | +0.075290 | +0.908489% |
|
||||
| rd12 | inproc | apply | 64.884249 | 64.917254 | +0.033006 | +0.050868% |
|
||||
| rd12 | spawn | client | 10.276510 | 10.285330 | +0.008820 | +0.085827% |
|
||||
| rd12 | spawn | apply | 67.614988 | 67.059490 | -0.555499 | -0.821561% |
|
||||
|
||||
逐轮均值的范围也必须保留,避免只给一个点:
|
||||
|
||||
| trace / transport / 线程 | before 三轮范围 | after 三轮范围 |
|
||||
|---|---:|---:|
|
||||
| OpenRA / inproc / client | 0.678730–0.688320 | 0.690650–0.715600 |
|
||||
| OpenRA / inproc / apply | 3.038111–3.112060 | 3.064185–3.172090 |
|
||||
| OpenRA / spawn / client | 0.799590–0.810700 | 0.780370–0.792480 |
|
||||
| OpenRA / spawn / apply | 3.239807–3.299042 | 3.187598–3.211357 |
|
||||
| rd12 / inproc / client | 8.195700–8.325585 | 8.311060–8.510350 |
|
||||
| rd12 / inproc / apply | 64.826829–64.939705 | 64.915537–65.039914 |
|
||||
| rd12 / spawn / client | 10.274680–10.279320 | 10.250475–10.306380 |
|
||||
| rd12 / spawn / apply | 67.489521–67.649413 | 67.010901–67.281044 |
|
||||
|
||||
存在双向变化:inproc client 的两个样本组上升,spawn client 一降一基本持平;
|
||||
apply 也不完全相同。没有删除正增量,没有扩大阈值把它改写成“零开销”。
|
||||
整波还补齐了独立 client 的死亡记录等正确性行为,故不能把全部差值唯一归因于 lk2 的调用形式。
|
||||
|
||||
## 制品与复现
|
||||
|
||||
共同 runner:
|
||||
`/home/swung/tr-split/tools/trace_replay/mobilegl_trace_replay`
|
||||
|
||||
| 制品 | SHA-256 |
|
||||
|---|---|
|
||||
| runner(前后相同) | `700907be83c2c1c1c83eec8de37300a6fdab4c7f06387116fa8aaee0169b7291` |
|
||||
| before libMobileGL.so | `a84d0c09b78b312c600e172c03bd9a6e4ce804585661859d888b20992b4e516d` |
|
||||
| after libMobileGL.so | `d783080c5e1cb7db209a362db4ad742634d7525ae0c9683c4f6e9c5c54803361` |
|
||||
| server launcher(前后相同) | `7a95cb4d276b40e4843c9d9f8c4d0f3486bfa6b5fc3e3b9a0dd842e1e9403ed6` |
|
||||
|
||||
server 是薄 launcher,`NEEDED libMobileGL.so`、`RUNPATH=$ORIGIN`;它自身字节相同并不表示加载了同一库,
|
||||
两臂分别从各自目录解析生产库。
|
||||
|
||||
```bash
|
||||
python3 <tree>/tools/trace_replay/measure_transport_cpu.py \
|
||||
--runner /home/swung/tr-split/tools/trace_replay/mobilegl_trace_replay \
|
||||
--library /home/swung/lk-split/libMobileGL.so \
|
||||
--server /home/swung/lk-split/libMobileGLServer.so \
|
||||
--fixtures /home/swung/w7/pipe/tools/trace_replay/fixtures \
|
||||
--inputs /home/swung/p65-host-cpu-input \
|
||||
--out /home/swung/p65-host-cpu-before --label before-p65 --repeats 3
|
||||
```
|
||||
|
||||
after 只将 library/server 换成 `p65-split` 目录,out/label 换成对应 after 名。
|
||||
脚本拒绝覆盖已存在的 benchmark 证据;重新测量应换新的 out。
|
||||
新工作树中的某些 fixture 是 LFS 指针,故本次使用已核实的 Linux fixture 实体,并保存每条 trace SHA-256。
|
||||
|
||||
证据位置:
|
||||
|
||||
- `/home/swung/p65-host-cpu-before/summary.json`
|
||||
- `/home/swung/p65-host-cpu-after/summary.json`
|
||||
- `/home/swung/p65-host-cpu-comparison.json`
|
||||
- 各目录的 `<transport>/<case>/run-N/{benchmark.json,cpu-summary.json,apply-samples.json,runner.log}`
|
||||
|
||||
这些数关闭了“必须真的量到逐线程 CPU”这一记录缺口,不关闭其他尚缺的 P6.5 设备/trace/吞吐指标,
|
||||
也不把性能变化当正确性失败。
|
||||
|
||||
## 当前 spawn 与 loopback TCP 的专门比较:首轮负控
|
||||
|
||||
另外启动了仅用于本机测量的 `tcp://127.0.0.1:40616` supervisor,使用当前库、同一 runner、
|
||||
credit=1,client/server 均开启 `MOBILEGL_PIPE_STATS=1`、`MOBILEGL_PIPE_STATS_PERIOD=1`。
|
||||
`measure_loopback_cpu.py` 用 `P65LinkMetrics` 与 `P65ServerMetrics` 的线程 CPU 时钟,
|
||||
逐个核对 client/server 帧号:OpenRA 29–128(100 帧),rd12 52–251(200 帧)。
|
||||
这组 apply 数据直接来自帧时钟,不使用上节的 `/proc` 外部窗口近似。
|
||||
|
||||
**首轮不能作为纯传输成本对照。** 虽然两臂都请求 run-ahead=1,实际日志证明 spawn 已 ARMED,
|
||||
而 TCP 在真实第一份 CapsSnapshot 到达之前,错误地用 placeholder 的零能力锁存为 lockstep,
|
||||
随后“只允许 demotion”的规则使它一直无法武装。该差异由真实测量揭露,不能当成 TCP 固有成本放过。
|
||||
|
||||
完整首轮样本保留在 `/home/swung/p65-loopback-cpu/summary.json` 与
|
||||
`summary-with-arm-proof.json`;OpenRA 每臂三轮,rd12 每臂一轮。
|
||||
其中 rd12 的实际 client/apply CPU 为 spawn **10.377163 / 66.994613 ms/帧**,
|
||||
错误 lockstep 的 TCP **105.151038 / 160.624839 ms/帧**。
|
||||
这是具名负控证据,不进入正式 transport 比较结论。
|
||||
|
||||
修复由启动路径等待真实首 caps 完成,不强制打开 run-ahead,也不放宽后续只允许 demotion 的规则。
|
||||
采集器已增加实际 ARMED、无 lockstep fallback、无 DISARMED 的检查;下节记录修复制品的正式重跑。
|
||||
|
||||
### 首 caps 修复后的正式两角色 CPU 数
|
||||
|
||||
修后 TCP 已完整重跑,所有样本均通过实际 run-ahead ARMED 检查,没有 fallback 或 DISARMED。
|
||||
OpenRA 各臂 3 次取逐轮均值的中位数;rd12 各臂 1 次,单次样本不用于统计显著性推断。
|
||||
两角色使用相同精确帧号窗口,不把 setup 算入稳态,也没有使用外部 `/proc` 插值。
|
||||
|
||||
| trace / 窗口 | 线程 | spawn unix+shm ms/帧 | TCP+stream ms/帧 | TCP − spawn ms/帧 | 差值 |
|
||||
|---|---|---:|---:|---:|---:|
|
||||
| OpenRA / 29–128 | client | 0.913889030 | 0.725938440 | -0.187950590 | -20.566019% |
|
||||
| OpenRA / 29–128 | apply | 3.414349090 | 3.123573070 | -0.290776020 | -8.516294% |
|
||||
| rd12 / 52–251 | client | 10.377163490 | 6.507507265 | -3.869656225 | -37.290115% |
|
||||
| rd12 / 52–251 | apply | 66.994613060 | 53.903945275 | -13.090667785 | -19.539881% |
|
||||
|
||||
这是**指定两个线程**的实测变化,不能据负差值宣称 TCP 的进程总 CPU 更低:
|
||||
TCP 另外有专用 I/O reader,以上 client/apply 时钟不包含那些线程的 CPU,也不包含其它 driver workers。
|
||||
本表开了 PipeStats,前节 P6.5 前后表关闭 PipeStats;两表不能交叉相减。
|
||||
|
||||
spawn 控制复用本轮首 caps 修复前已真实 ARMED 的样本,其运行中的数据路径未改变;
|
||||
TCP 使用修后制品。这个复用边界明确保留,不称两个 library 文件哈希相同:
|
||||
|
||||
- spawn library:`d783080c5e1cb7db209a362db4ad742634d7525ae0c9683c4f6e9c5c54803361`
|
||||
- TCP library:`29fcff6b23557be6b1cc3765db382b3422ed0780643c719937616259298d3116`
|
||||
- runner 与输入 trace 保持相同,完整哈希在各样本 `role-cpu.json` 中。
|
||||
|
||||
并发检查:最后一项 syntax 编译结束于 WSL 07:56:32.732;TCP OpenRA 三轮尾窗口分别从
|
||||
07:56:56、07:56:58、07:57:00 开始,rd12 尾窗口从 07:57:55 开始,均无编译重叠。
|
||||
这组精确帧时钟证据为 `/home/swung/p65-loopback-cpu-fixed/summary.json`,
|
||||
归约比较为 `/home/swung/p65-loopback-cpu-comparison.json`;旧 lockstep 数据仍原样保存为负控。
|
||||
|
||||
最小复现(在没有其它 host 重负载时运行;不占手机端口):
|
||||
|
||||
```bash
|
||||
p65_tree=/mnt/c/Users/geekerwan/.codex/worktrees/p65-all-tcp/MobileGL
|
||||
LIBGL_ALWAYS_SOFTWARE=1 EGL_PLATFORM=surfaceless \
|
||||
MESA_GL_VERSION_OVERRIDE=3.3 MESA_GLSL_VERSION_OVERRIDE=330 \
|
||||
python3 "$p65_tree/scripts/ci/tcp_server_fixture.py" start \
|
||||
--server /home/swung/p65-split/libMobileGLServer.so \
|
||||
--endpoint tcp://127.0.0.1:40616 --state /tmp/p65-cpu-server.json
|
||||
trap 'python3 "$p65_tree/scripts/ci/tcp_server_fixture.py" stop --state /tmp/p65-cpu-server.json' EXIT
|
||||
python3 "$p65_tree/tools/trace_replay/measure_loopback_cpu.py" \
|
||||
--runner /home/swung/tr-split/tools/trace_replay/mobilegl_trace_replay \
|
||||
--library /home/swung/p65-split/libMobileGL.so \
|
||||
--server /home/swung/p65-split/libMobileGLServer.so \
|
||||
--inputs /home/swung/p65-host-cpu-input --out /tmp/p65-role-cpu
|
||||
```
|
||||
|
||||
该命令用同一当前制品重测两臂;本次修复后仅 TCP 重测使用了 `--transport tcp`。
|
||||
脚本按帧号核对两份日志、拒绝缺帧/重复帧/非正 CPU,并复用 `p65_link_metrics.py` 的归约逻辑。
|
||||
@@ -0,0 +1,289 @@
|
||||
# P6.5 TCP 车道与设备验收记录
|
||||
|
||||
**状态:验收采证中,未宣布 P6.5 收官。** 历史 TCP 主机/设备 102 项功能阳性保留,
|
||||
但当时实际为 lockstep,不能充作 run-ahead 验收。首 caps race 修复后的 READY7 已取得主机 TCP
|
||||
及 Redmi 各 **102 PASS / 0 FAIL / 0 SKIP**,每条实际 ARMED;正式 trace 矩阵与同模式性能数仍待补。
|
||||
|
||||
当前源码基线为 `origin/feat/disaggregated@e6c51d07`,开发树 `codex/p65-all-tcp` 的
|
||||
HEAD 为 `52ffc6a7` 加未提交工作。两端曾共享的显式 `MOBILEGL_BUILD_STAMP` 是
|
||||
`410dfa94c3d92241e9ec01ddbba1bb911eb60d4b`,**它不是当前 HEAD**;后续 rebase 没有改变当时的
|
||||
生产字节,因此保留了这一制品标识。不能拿匹配的显式 stamp 替代每组产物 SHA、实际 arming
|
||||
状态和运行证据,也不能把较早制品的绿移记到新的修复头。
|
||||
|
||||
## 主机结果:历史功能阳性
|
||||
|
||||
环境:WSL Arch,clang/Release,Mesa llvmpipe/lavapipe;源码位于 Windows 工作树,
|
||||
构建目录 `/home/swung/p65-split`。`integration-split` 的完整标签有 186 条,
|
||||
其中共享注册宏的 DirectGLES 可比集合为 102 条;不能把 186 与 102 的标签总数直接比较。
|
||||
|
||||
| 车道 | PASS | FAIL | SKIP | 证据前缀 |
|
||||
|---|---:|---:|---:|---|
|
||||
| TCP loopback | 102 | 0 | 0 | `/home/swung/p65-final-tcp` |
|
||||
| unix + shm spawn | 102 | 0 | 0 | `/home/swung/p65-final-spawn` |
|
||||
| 完整 inproc 标签 | 186 | 0 | 0 | `/home/swung/p65-final-inproc` |
|
||||
|
||||
这张表保留当时的完整结果。**该次 TCP 102 条后来确认实际是 lockstep**:请求了
|
||||
run-ahead=1,却在真实首 CapsSnapshot 到达之前用 placeholder 的零能力锁存了回退状态。
|
||||
旧拓扑 proof 证明了 TCP/stream 与远端进程,不证明 run-ahead 已 ARMED。spawn/inproc 行保留其
|
||||
原功能结果,不因本表改称 READY7。
|
||||
|
||||
各前缀均有 `.log`、`.xml`。TCP 的两项 CTest supervisor fixture 另计,
|
||||
故 CTest 摘要显示 104 条,而真实渲染用例仍为 102 条。
|
||||
`p65-final-tcp-lane.json` 是 discovery;`junit_tally.py --require-tcp-ran --discovery ...`
|
||||
逐条读取私有角色日志,确认 `control=tcp data=stream server=... pid=N`,不是只看测试名。
|
||||
|
||||
`spawn_lane_parity.py` 比较规范化后的名字集合,保留现有 monolith-only 例外。
|
||||
`split_log_paths.py` 同时检查 Split、Spawn、Tcp、TcpDevice 的私有日志路径。
|
||||
TCP 用例还在客户端 `/proc/self/task/<pid>/children` 断言 Connect 没有偷偷启动本地 server。
|
||||
|
||||
### READY7 主机 TCP:真实 ARMED 复验
|
||||
|
||||
启动改为等待并采用真实首 CapsSnapshot 后再锁存能力;没有强制打开 run-ahead,也没有放宽
|
||||
后续只允许 demotion 的规则。READY7 主机结果为 **102 PASS / 0 FAIL / 0 SKIP**,含两个
|
||||
supervisor fixture 的 CTest 总数为 104,耗时 18.35 秒。
|
||||
|
||||
逐条私有 client 日志实查:**102 条有 `run-ahead ARMED`,`running lockstep` / `run-ahead DISARMED`
|
||||
均为 0,缺日志为 0**。这组才是首 caps 修复后的 run-ahead 功能证据。
|
||||
证据:`/home/swung/p65-ready7-tcp.{log,xml}`、`p65-ready7-tcp-lane.json` 与其所列角色日志。
|
||||
完整 retrace 与同模式 TCP/spawn CPU 对照不能由这 102 个用例替代。
|
||||
|
||||
### READY7 最终 ALL、unit 与名字门
|
||||
|
||||
最终 ALL 增量退出 0;完整 unit 为 **2399 项 = 2389 PASS + 10 既有条件 SKIP,0 FAIL**,
|
||||
18.96 秒,新增三条 InitialCapsStartup 均通过。证据为 `/home/swung/p65-final-tests-build.log`、
|
||||
`p65-ready7-unit.{log,xml}`;没有把条件 skip 隐藏成 PASS。
|
||||
|
||||
最终 G14 为 **4016 → 4257,0 removed / 241 added**,新增包括设备 102 条。
|
||||
`--require-device` 名集合门实跑得到 split 105 条中可比 102,等于 spawn 102、TCP 102、device 102。
|
||||
证据:`/home/swung/p65-ready7-test-name-parity.json`、`p65-ready7-lane-parity.log`。
|
||||
完整标签、可比集合和 fixture 数仍分别记录,不能混成同一个计数。
|
||||
|
||||
必须另记制品身份:最后一次 CMake 重配置因 SPIRV-Cross git-version timestamp
|
||||
`2026-09-22T08:02:51` 重编 `spirv_cross_c.cpp` 并重新链接,最终 host library SHA-256 为
|
||||
`25ca45d756bc5a4e5bd56ad4ce231e4ef89d45ba41131f389575cda0842cd6be`。
|
||||
MobileGL 自有 production objects 未重编,但这依然是**不同制品**;READY7 device 102 与此前
|
||||
CPU 样本使用原 host library(SHA 前缀 `29fc...`),这些证据保留原身份,不改记成新 SHA。
|
||||
正式矩阵使用新的 `25ca45d7...` 制品,不能只凭相同显式 build stamp 混用二者。
|
||||
|
||||
### 被旧 skip 掩盖的问题
|
||||
|
||||
首次 TCP 与 spawn 都是 97 PASS / 5 SKIP。没有将其记成 102 PASS,随后补齐了五条:
|
||||
|
||||
- Triangle 的 verb-stamp 与 persistent-map counting 用例原本只在专门车道获得计数标记。
|
||||
现在共享宏和 small-ring 的对应条目也设置真实统计环境;persistent-map 的 acquisition/bytes
|
||||
属于 client,分进程时取客户端真实计数差,避免读取 server 的结构性零。
|
||||
- 三条 Ct 用例原本因为读不到 server 内存而直接 skip。现在复用 `LogFlush`:client 先等待命令前缀
|
||||
应用完成,server acquire 水位后输出已有 reset/serial/death 计数,client 读取同步后的角色日志。
|
||||
仅 `MOBILEGL_TEST_SERVER_COUNTERS=1` 开启此诊断,没有在 draw 路径加输出。
|
||||
- 删除死亡用例的 skip 后,真地发现 spawn/TCP 的 ObjectDeaths 一直是 0,而 inproc 正常:
|
||||
独立 client 没安装死亡通知。`WireTables.cpp` 为它安装复用现有 wire emitter 的回调,
|
||||
不覆盖 inproc 已有 dispatcher。修复后五条 × 三臂 **15 PASS / 0 SKIP**,
|
||||
证据 `/home/swung/p65-fivecases-fixed.{log,xml}`。
|
||||
|
||||
TCP harness 的 fork pre-flight 也曾先占用远端单会话,使真正测试收到 Busy。Connect 下的驱动
|
||||
初始化已经在 server child 隔离,因此不再另开本地 pre-flight;TCP 车道强制 REQUIRE_GPU,
|
||||
初始化失败是 FAIL,不能作为“本机没有 GPU”而 skip。
|
||||
|
||||
## 日志前送与 CI
|
||||
|
||||
`tcp_log_forwarding_control.py` 直接执行原有 arming 场景,分别给 client 和 supervisor 设置真实特性。
|
||||
`/home/swung/p65-lf-controls2/summary.json` 及六臂角色日志证明:
|
||||
|
||||
| 原有场景 | 后端 / 特性 | forwarding ON | forwarding OFF |
|
||||
|---|---|---|---|
|
||||
| UnlocatedIoBlock arming | DirectGLES / `MOBILEGL_ESPRYT_UNLOCATED_IO_BLOCKS=1` | PASS | 缺指定 server marker,FAIL |
|
||||
| PrimitivesGenerated reroute arming | DirectVulkan / `MOBILEGL_MAGMA_PRIMGEN_QUERY_REROUTE=1` | PASS | 缺指定 server marker,FAIL |
|
||||
| PointSizeDemotion arming | DirectGLES / `MOBILEGL_POINT_SIZE_DEMOTION=1` | PASS | 缺指定 server marker,FAIL |
|
||||
|
||||
六臂均无 skip;关闭前送时 server 本地仍真实产出 marker,client 本地没有同名替代 marker,
|
||||
且失败必须发生在该 marker 断言,不能拿无关失败当负控成功。
|
||||
|
||||
第四条 `PipeVerifyArmingScenario.Armed` 的 marker 来自 client 的 `PipeFill`,所以正确预期是
|
||||
关闭 peer forwarding 后仍绿,不应硬造一个 server 负控。已配置并真实执行当前 verify+split 构建,
|
||||
但它在 arming 前遇到旧 `PipeRespecifyScope` 断言;同代码 inproc/spawn 同样复现。
|
||||
这是既有 verify-only “全资源 respecify”断言与后来合法 per-level producer 的冲突,
|
||||
不是 TCP 前送失败。证据 `/home/swung/p65-lf-verify/` 与 `/home/swung/p65-verify-controls/`;
|
||||
此项尚未宣称通过。
|
||||
|
||||
CI 的 `runtime_mode_proof.py` 曾读取无角色后缀的日志名,导致真实两后端用例通过后仍 FileNotFoundError。
|
||||
修复为读取 client/server 两份,并保留任一缺失为硬失败。除了正反 self-test,
|
||||
还真实执行了 strict + role-split-state + run-ahead 下的两条 P5fRsp 用例,**2 PASS / 0 SKIP**,
|
||||
随后运行完整 `logs` proof 成功;证据 `/home/swung/p65-ci-runtime-proof.{log,xml,json}`。
|
||||
|
||||
TCP 工具自身有名字漂移、伪 arm marker、ready 探针不消耗 accept 连接、PID 复用、
|
||||
设备 idle 配置恢复等正反控制;`tcp_lane_tools_test.py` 在 WSL 为 **4/4 PASS**。
|
||||
link seam 的七个负控与生产 ownership 门已接入 `test.yml`,结果见相邻实现报告。
|
||||
|
||||
正式 trace driver 为 `tools/trace_replay/run_tcp_matrix.py`,工具 stub 回归 **12/12 PASS**;
|
||||
没有用 stub 冒充真实渲染。默认按正规 manifest loader 选择 39 个 CI split case,非 CI 的 rd12
|
||||
只能显式选择且单列。新尝试独立目录,失败/超时/陈旧结果不作为 passed checkpoint;严格 resume
|
||||
不能复用旧 lockstep 图像阳性。
|
||||
|
||||
正式 GLES 矩阵使用 `--require-run-ahead`:显式请求 RUN_AHEAD=1 与 VERB_BARRIER=1,逐例要求
|
||||
私有 client 日志 ARMED 且没有 lockstep / DISARMED,并保存 requested_arm / actual_arm。
|
||||
默认 300 秒日志无进展截止与 7200 秒绝对上限分开,不沿用本机 main-menu 的 180 秒预算;
|
||||
旧脚本误杀 CMake 而遗留 retrace 子进程造成 Busy 的失败保留诊断,不计为 GPU 差异或矩阵通过。
|
||||
新 driver 的超时清理覆盖整个进程组并回收孤儿,正式 39 条完成结果仍待登记。
|
||||
|
||||
## 真机进展与环境事实
|
||||
|
||||
设备为 Redmi `2f7cbe2e`,aarch64 / Adreno 830,IP `192.168.21.181`。
|
||||
已安装并启动 trace flavour 的前台 Service,supervisor 监听 `tcp://0.0.0.0:40613`,
|
||||
两端令牌一致;使用显式设置的 `MOBILEGL_BUILD_STAMP`,不依赖 APK 的 `nogit` 文件名。
|
||||
当前沿用的 `410dfa94...` 是共享制品标识,不是当前 `52ffc6a7` 源码 HEAD。
|
||||
已经收到真实 Welcome 与 Adreno caps,wire/build 指纹均接受。
|
||||
此前安装的 traceDebug 原生实际只有 `-g`、没有优化,以上只作功能诊断,不能作为 release 性能数。
|
||||
后续功能复验已使用原生 `-O2/NDEBUG` 的 debuggable traceRelease APK,并保持受信任签名;
|
||||
各组模式与边界见下,不能把 Debug 诊断数当优化制品性能。
|
||||
|
||||
必须区分已经定位出的三类问题:
|
||||
|
||||
1. 手机 Dozing 时曾看到 native supervisor `wchan=do_freezer_trap`,前台 Service 的 partial wake lock
|
||||
显示 DISABLED。仅给测试包增加 deviceidle 白名单不足以立即解除所有冻结;Awake 下进程与 wake lock
|
||||
恢复。没有关闭全局 Doze/freezer,也没有靠延长控制超时掩盖冻结。
|
||||
2. Awake 后仍有 LAN 回包只到第一个 MSS 的独立问题。WSL 默认到手机经 `eth2`、源 `172.18.0.1`,
|
||||
对应 Windows `xray_tun`。USB `adb forward` 对照通过 EGL;加一条仅针对手机的临时 host route 后,
|
||||
LAN 同样通过 EGL,完整 peer 日志由十余行恢复到数百行。该环境修复不是 transport timeout 改动。
|
||||
3. 真正开始跨 ABI draw 后,暴露 archive 头对 native C++ `sizeof` 的比较(Linux 1056 / Android 0)。
|
||||
portable archive v2/schema 已落地,并进入握手指纹;重编后的两端已通过真实 LAN shader/draw 与
|
||||
64 MiB 上传阳性。最终 golden retrace 和性能数仍须使用优化制品采集。
|
||||
|
||||
### Debug 真机首轮 102 条
|
||||
|
||||
archive v2 的 Debug 制品首轮结果为 **73 PASS / 29 FAIL / 0 SKIP**,61.44 秒。
|
||||
29 条全在 `eglInitialize` 前失败:20 条为明确 `Refuse{Busy}`,9 条为 Welcome 前 transport closed;
|
||||
没有理由把它们称为 GPU 像素或能力差异。当前证据指向连续用例的客户端退出与远端 child 清理完成
|
||||
之间的会话收尾竞态,必须处理后再跑完整车道,不能用 skip 消掉失败。
|
||||
|
||||
逐名诊断在 `/home/swung/p65-debug-device-differences.json`,完整 `.log/.xml` 为同前缀。
|
||||
175 份已存在的角色日志已复制到 `/home/swung/p65-debug-device-rolelogs/`,
|
||||
避免后续同名用例覆盖首轮证据。Discovery 与正常 Awake 维持记录分别为
|
||||
`p65-debug-device-lane.json`、`p65-debug-device-awake.json`。
|
||||
|
||||
### 优化 Release 真机复验:历史 lockstep 功能阳性
|
||||
|
||||
有序会话收尾修复后,客户端等待 server EOF 完成退出;Busy 拒绝先消费 Hello,
|
||||
避免带未读请求关闭 socket 时的 RST 丢失拒绝帧。优化 APK 的 native 实际编译参数为
|
||||
`-O2 -DNDEBUG`,签名与已安装调试证书相容。
|
||||
|
||||
该制品 SHA-256 为 `70a4a3c776a61e03a3c0ad02cbdee38fd6af483a6c7cedeaf33bb1f8531fd228`,
|
||||
真机完整车道为 **102 PASS / 0 FAIL / 0 SKIP**,98.59 秒。
|
||||
全部 client 日志中 `Refuse{Busy}`、`no Welcome`、`ALIVE BUT SILENT` 均为 **0**;
|
||||
逐条 TCP/stream/远端 endpoint/pid arm proof 通过,名字集合与 spawn 的 102 条完全一致。
|
||||
|
||||
证据:`/home/swung/p65-release-device.{log,xml}`、`p65-release-device-lane.json`、
|
||||
`p65-release-device-awake.json`,以及已保全的 204 份角色日志目录
|
||||
`/home/swung/p65-release-device-rolelogs/`。没有删用例、放宽像素断言或恢复 skip。
|
||||
|
||||
**这组 102 条后来确认实际为 lockstep,而非 ARMED。** 它关闭的是当次连续会话的 Busy/Welcome
|
||||
初始化失败,保留为有意义的功能阳性;它没有关闭 run-ahead 形态下的设备验收。
|
||||
上面的 APK SHA 只属于这组历史制品,不移记为 READY7 的产物身份。
|
||||
|
||||
### 首 caps race 与 READY7 真机复验
|
||||
|
||||
性能配对的日志揭露了启动竞态:控制 reader 尚未交付真实首 CapsSnapshot 时,client 就把
|
||||
placeholder 的零 capability 当作 server 的回答;后续“只能 demotion”使本次 session 一直停留在
|
||||
lockstep。修复要求先收到并采用真实首 caps,再宣布 session started 并锁存 run-ahead。
|
||||
|
||||
READY7 Redmi 车道已经完成:**102 PASS / 0 FAIL / 0 SKIP**,72.23 秒。
|
||||
严格 `--require-run-ahead` proof 通过:102 条实际 ARMED,lockstep / DISARMED / Busy / noWelcome
|
||||
均为 0。证据为 `/home/swung/p65-armed-device.{log,xml}`、`p65-armed-device-lane.json`,
|
||||
204 份角色日志保全于 `/home/swung/p65-armed-device-rolelogs/`。
|
||||
这组与 READY7 主机结果构成首 caps 修复的实际模式复验;正式 39 条 CI split golden 矩阵与
|
||||
同模式性能对照仍待验证,不以这一组结果宣布整个阶段关闭。
|
||||
|
||||
### 真实对端死亡与 Wi-Fi 半开连接门
|
||||
|
||||
以下故障注入已有当次独立证据,无需把它们继续列作“从未采集”:
|
||||
|
||||
| 故障 | 观测到 peer hangup / device-lost | 结果与证据 |
|
||||
|---|---:|---|
|
||||
| 真正 kill server child(PID 18824) | 133 ms / 133 ms | PASS;`/home/swung/p65-device-peerloss/kill.log` 与两角色日志 |
|
||||
| 直连 LAN 禁用 Wi-Fi(PID 18979) | 5053 ms / 5053 ms | PASS;`/home/swung/p65-device-wifi-loss/probe.log`、`timing.json` 与两角色日志 |
|
||||
|
||||
两个 probe 都通过生产 barrier 观察挂断并闩 device loss,`gl_reset=0x8255`,10 秒截止内通过;
|
||||
不是发送“请退出”控制消息,也不是把 apply timeout 冒充挂断。Wi-Fi 门使用 **LAN direct eth0,
|
||||
不是 adb forward**;父控制器从 disable 计到返回为 5.090431 秒,probe 自身记 5053 ms。
|
||||
它们证明故障闩机制,不代替 READY7 完整图像/性能验收。
|
||||
|
||||
### 临时环境的恢复责任
|
||||
|
||||
`tcp_device_server.py --allow-idle` 是显式选项,不默认修改设置。原状态已保存为
|
||||
`/home/swung/.cache/mobilegl/tcp-server/2f7cbe2e-top.mobilegl.plugin.trace.json`,
|
||||
内容 `originally_whitelisted=false`。重复 start 不覆盖这个原值。所有设备工作完成后,在 WSL 运行:
|
||||
|
||||
```bash
|
||||
python3 <tree>/tools/trace_replay/tcp_device_server.py stop --serial 2f7cbe2e \
|
||||
--state-file /home/swung/.cache/mobilegl/tcp-server/2f7cbe2e-top.mobilegl.plugin.trace.json
|
||||
```
|
||||
|
||||
它停止本测试包并撤销本次添加的包级 idle 豁免。root 另负责撤回原本不存在的网络辅助配置:
|
||||
|
||||
```bash
|
||||
ip route del 192.168.21.181/32 via 192.168.31.1 dev eth0 metric 10 # WSL root
|
||||
adb -s 2f7cbe2e forward --remove tcp:40615
|
||||
```
|
||||
|
||||
## 尚未关闭的出口项
|
||||
|
||||
- READY7 真正 ARMED 的主机 TCP 和设备 102 已取得;仍需把最终冻结制品的 ALL、必要回归、
|
||||
discovery/逐条 mode proof 与阶段结论对应起来,不能引用旧 lockstep 102 代替。
|
||||
- 正式 WSL → Redmi **39 个 CI split case** 的 golden 矩阵(DirectGLES 按现有阈值,OpenRA 1.0);
|
||||
`ci:false` 的 rd12 作为额外 golden/性能负载单列。旧 scratch 的前两条阳性保留,不能自动变成
|
||||
新 driver/checkpoint 的通过。DirectVulkan 按本波口径记录,不作为相同的硬像素门。
|
||||
- 同一真实 ARMED 模式下 OpenRA / MC in-world 的 wait-reply、RTT、Stage bytes/frame 与链路
|
||||
吞吐对应、credit 1/2/3、loopback TCP 对 spawn 的逐线程 CPU 配对数。旧 TCP lockstep 的 CPU
|
||||
样本是揭露错误模式的负控,不作为传输成本结论。
|
||||
- inproc/spawn 的 before/after 逐线程 CPU 已测,但结果不是“逐字不变”;其口径和局限见
|
||||
[performance.md](performance.md)。数据不会被抹除,也不能把变化全部归因于 lk2 虚调用。
|
||||
- lf 第四条仍有具名 verify+split 前置债,且其 client-owned marker 本来不能作 server forwarding
|
||||
负控。三个 server marker 的正负控与故障闩门已有证据,不重复列成缺采。
|
||||
- 阶段审查已完成,见下;剩余验收结果与最终制品证据索引仍需收口,本账本不宣布 P6.5 收官。
|
||||
|
||||
## 阶段审查状态
|
||||
|
||||
原上下文已完成一次 `phase_review` 阶段审查,以及一次针对 half-close 的极窄 follow-up。
|
||||
按 ID-66 不再另跑完整阶段审查。
|
||||
|
||||
阶段审查发现 Present / `glFlush` 的尾批在 client 随后空闲时未投递;已修复为发送边界,并用
|
||||
真实生产入口的零等待回归证明没有偷加 apply wait:
|
||||
|
||||
- `StreamClientPublication.AllThreePresentCreditsReachAnIdlePeerWithoutAnyClientWait`
|
||||
- `StreamClientPublication.ExportedGlFlushDeliversPublishedCommandsWithoutWaitingForApplied`
|
||||
|
||||
证据在 `MobileGL/MG_Test/Wire/StreamClientPublicationTest.cpp` 和对应定向测试记录。
|
||||
half-close follow-up 未发现 normal-path 死锁或 UAF;它指出 `WaitClosed == true` 也包含 terminal
|
||||
protocol error,不能仅凭该布尔值声称正常 EOF。该语义限制保留,不把 follow-up 改写为所有错误
|
||||
路径均正常关闭的保证。最终证据索引由收尾报告统一串联。
|
||||
|
||||
## 主机 CPU 配对采集方法
|
||||
|
||||
`tools/trace_replay/measure_transport_cpu.py` 复用同一个已有 retrace runner,分别载入旧、新 library
|
||||
和与之配套的 server。OpenRA 的完整 128 帧取尾 100 帧,rd12 的 251 帧取尾 200 帧;
|
||||
每条臂保留完整 benchmark JSON、逐线程原始采样和三个制品的 SHA-256。
|
||||
client 读现有 `CLOCK_THREAD_CPUTIME_ID` 帧数组;apply 读取 `/proc/<pid>/task/<tid>/schedstat`
|
||||
的执行纳秒数,选最早的 `mgl-srv-apply` TID,排除继承该名字的 driver helpers,不以进程 CPU 代替。
|
||||
|
||||
apply 的帧窗口用 benchmark JSON 的写入时间和已有 wall-frame 数组近似对齐,边界在外部采样点间插值。
|
||||
结果明确保留实际最大采样间隔,并说明尚有 summary/JSON 写入延迟;不能把它写成周期精确的测量。
|
||||
已有 `before-pilot-not-comparable` 试跑只验证采集机制,发生在并发构建期间,不纳入正式 A/B。
|
||||
正式 before 已在重型构建停止后完成,原始记录为 `/home/swung/p65-host-cpu-before/summary.json`。
|
||||
使用现存的 P6.5 之前 `lk-split` 制品;三个库/runner 与 trace 的哈希均随样本保存,
|
||||
不把缓存中的旧 build stamp 冒充精确源码基线。以下是各三轮逐轮均值的中位数,单位 ms/帧:
|
||||
|
||||
| trace / transport | client CPU | apply CPU(外部窗口近似) |
|
||||
|---|---:|---:|
|
||||
| OpenRA / inproc | 0.68184 | 3.04067 |
|
||||
| OpenRA / spawn | 0.80624 | 3.24204 |
|
||||
| rd12 / inproc | 8.28739 | 64.88425 |
|
||||
| rd12 / spawn | 10.27651 | 67.61499 |
|
||||
|
||||
after 已按同参数完成,各 case/transport 前后均为三轮;完整差值和精度限制见
|
||||
[performance.md](performance.md)。这组前后数包含整波正确性修复(例如补齐独立 client 的死亡记录),
|
||||
不能把全部差值归因于 lk2 虚调用,也不能称为“逐字不变”。
|
||||
|
||||
|
||||
上述 inproc/spawn before/after 表不是 READY7 的 TCP 传输成本表。此前另做的 TCP/spawn 比较中,
|
||||
spawn 已 ARMED 而 TCP 被首 caps race 留在 lockstep;原样保留在
|
||||
`/home/swung/p65-loopback-cpu/{summary,summary-with-arm-proof}.json`,不进入正式传输结论。
|
||||
正式 TCP 对照与 golden driver 必须检查实际 `run-ahead ARMED`,同时拒绝 lockstep fallback / DISARMED。
|
||||
@@ -0,0 +1,143 @@
|
||||
# P6.5 wire、计量与主机验证记录
|
||||
|
||||
基线是 `origin/feat/disaggregated@2ec8e7f4`,实现树是 `410dfa94c3d92241e9ec01ddbba1bb911eb60d4b` 加本轮未提交修改。没有推送。以下数字注明采集边界,不代表整个 P6.5 已收官;设备、完整 integration 与最终阶段审查另记。
|
||||
|
||||
## wire 事实与握手
|
||||
|
||||
`gen_pipe.py` 从 `PipeFields.def` 生成 82 个 payload/value struct 的成员名、`offsetof`、成员 `sizeof`,以及 81 个 opcode 的有序目录(payload、flags、WaitClass)。摘要还覆盖记录头、handle、render-state chunk 边界、caps codec 版本、caps 尺寸、协议版本、字节序与指针宽度。git stamp 与函数指针表尺寸不再混入 wire 指纹。`DynamicBackendParameters` 的三处 `SizeT` 改为 `Uint64`,两处 `GLenum` 改为 `Uint32`;本波 payload/blob 数值区没有裸 `char` 成员。
|
||||
|
||||
Hello/Welcome 新字段采用 append;保留旧 FlatBuffers 字段槽。`wireFingerprint` 必须一致;Fork 必须同 build,Connect 的不同 build 默认警告,`MOBILEGL_IPC_REQUIRE_SAME_BUILD=1` 时拒绝。握手不兼容经 `Refuse` 返回,不调用 abort。LinkTerms 的四个窗口由 server 陈述。SurfaceReply 的 `eventHead` fence 使控制回复不能越过尚未送达的数据面事件。
|
||||
|
||||
使用 WSL clang 与 NDK 27.3 arm64 的**实际 CapsCodec 编译参数**分别编译 constexpr probe,结果如下;不是凭 LP64 推测一致。
|
||||
|
||||
| 事实 | x86_64 Linux | arm64 Android |
|
||||
|---|---:|---:|
|
||||
| 成员布局摘要 | 4304347197452401705 | 4304347197452401705 |
|
||||
| 有序目录摘要 | 16257371160882448404 | 16257371160882448404 |
|
||||
| render-state 边界摘要 | 2319517018389825580 | 2319517018389825580 |
|
||||
| DynamicBackendParameters | 352 B | 352 B |
|
||||
| MGPCaps | 408 B | 408 B |
|
||||
| 指针宽度 | 64 bit | 64 bit |
|
||||
| format 维度 | 76 | 76 |
|
||||
| target 维度 | 12 | 12 |
|
||||
|
||||
证据:WSL `/tmp/p65-crossabi-80fz3t4f/{probe.cpp,x86_64.s,arm64.s}`。
|
||||
|
||||
### wf 控制
|
||||
|
||||
- 真正复制到临时树后,互换 `MGPRange::Offset`/`Size` 两个同宽 `Uint64` 成员;成员布局摘要由 `4304347197452401705` 变为 `6038841773737773369`,两次使用同一未改动 build header。证据 `/tmp/p65-wire-control-ehave5w9/{before.s,after.s}`。生产树没有被临时改坏。
|
||||
- `SessionHandshakeTest` 的生产 Accept 路径测试了 major=99、错误 wire 摘要的具名 Refuse、空 union 拒绝、Connect 异 build 成功、Fork 异 build 拒绝、Connect 强制同 build 拒绝;9/9 通过。
|
||||
- 真实 TCP supervisor 的开发期控制 `/home/swung/p65-supervisor-smoke/protocol-controls.json` 记录 major=99 → code 1、错误布局 → code 2、不同 build 的 Connect → Welcome、强制同 build → code 3,并验证拒绝后 supervisor 仍活着。该记录采于 rebase 前的 `2bd86664` 开发产物;不能据此冒称最新产物的所有进程退出条件均已重新取证。最终 control 复跑由阶段主报告记载。
|
||||
|
||||
## G1 与生成器
|
||||
|
||||
在同一 `/home/swung/p65-g1-src` 源路径、同一 `/home/swung/p65-g1-build` build 路径先编基线再覆盖 P65 源码,保持 clang/Release、pull、LTO OFF 等选项相同。第三方依赖复用同一只读来源;覆盖后更新时间戳,实际重新编译了受影响对象。
|
||||
|
||||
- 定义符号:**27837 → 27837,新增/删除/resize/rename = 0/0/0/0**。
|
||||
- `.text`:**10822147 → 10822147 B**,抽出后逐字节相同。
|
||||
- 两侧 `.text` SHA-256:`35115edd2c265162c7f845a87d1a2cb9849609a40ba0febac317b91370b9163c`。
|
||||
- `.data`、`.bss`、`.rodata` 也各自尺寸不变。
|
||||
|
||||
证据:`/home/swung/p65-g1-report.log`、`p65-g1-symbols.json`、`p65-g1-before.so`、`p65-g1-{before,after}.text`。这次 G1 包含 wf 的宿主类型改动;此后的 server/stream/计量收尾均在 disaggregated-only 源中。
|
||||
|
||||
`gen_pipe.py --check/--self-test`、`gen_pipe_field_ownership.py --check/--self-test` 全绿;flatc 在临时目录重生的 body 与提交文件逐字相同;ROADMAP/ARCHITECTURE/CURRENT_STAGE_PROGRESS 的 78 条文档引用检查零问题。
|
||||
|
||||
## unit 与唯一环境项
|
||||
|
||||
最终全 unit 跑了 **2389 项**(`/home/swung/p65-unit-final.log`):第一次为 **2378 PASS、10 既有条件 SKIP、1 环境 FAIL**。唯一红是 `PipeCatalogue.FrontendNeverTakesAnApplierAddress` 从离树 build 的 cwd 向上查源码,错误落到 `/MobileGL/MG_Impl`;不是发现了前端持有 applier 地址。
|
||||
|
||||
已仅为该测试设置 source-root `WORKING_DIRECTORY`,保留测试名和其他测试的 cwd。重配后只重跑这一项,CTest **1/1 PASS、退出 0**(`/home/swung/p65-unit-cwd-fixed.log`)。因此本轮完整计数为 **2379 个已验证通过用例 + 10 个既有条件 skip**,没有把全 2389 又跑一遍。
|
||||
|
||||
249 项定向 wire/session/codec/loop/remote/protocol/surface/socket/framing 测试也全绿。最初正则漏了 fixture 名 `StreamPair.*`,不能把这 249 项称为覆盖所有 StreamLink 用例。补跑 8 项时抓到真实接收顺序缺陷:`AdvanceRetired` 先按旧 applied 夹紧,最后 retired 永久丢失。修为先 applied 后 retired 后,8/8 通过(`/home/swung/p65-streampair-fixed.log`),随后纳入上述全 unit。详情见 [数据面实现记录](data-link-implementation.md)。
|
||||
|
||||
## OpenRA 真实计量
|
||||
|
||||
首条 loopback TCP OpenRA retrace:SSIM **1.0**、零差异像素、外部运行耗时 **2.118 s**。日志在 `/home/swung/p65-retrace-loopback-smoke/OpenRA/output/mobilegl.{client,server}.log`。这次 smoke 在上述退休顺序修复前采集,只作为当次图像与计量记录;修复后的功能验收另记。
|
||||
|
||||
计量内部检查:client/server 都恰有 frame 1..29;client 每帧固定 32 桶之和 = `rtt_samples` = `wait_replies`,全跑 reply **221 次**;server 首帧只建基线(valid=0),随后 28 帧有效。两侧有效记录均满足 `0 < thread CPU <= wall`。计时仅在 `MOBILEGL_PIPE_STATS=1` 武装;reply 从 publish 前计至 applied wait 完成,包含 Flush,不包含先前编码/command 空间等待;RTT 分位数明确是桶上界。
|
||||
|
||||
OpenRA 的第 5 帧含大批纹理上传,不能仅丢前三帧就把均值叫作平稳性能。保留全跑数据,同时明确取 **frame 6..29** 的 24 帧:
|
||||
|
||||
| 指标 | 本次 TCP loopback 单臂 |
|
||||
|---|---:|
|
||||
| reply / 帧 | 2.000 |
|
||||
| RTT 均值 | 288.066 μs |
|
||||
| RTT p50 / p99 桶上界 | 512 / 1024 μs |
|
||||
| Stage / 帧 | 130614 B |
|
||||
| 帧流量速率 | 10.328 MiB/s |
|
||||
| client 线程 CPU / 帧 | 3.0800 ms |
|
||||
| apply 线程 CPU / 帧 | 5.5496 ms |
|
||||
| fps | 82.917 |
|
||||
|
||||
全跑 Stage 合计 **233980258 B**;P6 文档的历史 OpenRA 合计为 233979394 B,相差 864 B,不能声称历史两跑逐字相同。当前 snapshot 提前退出、不走 Destroy,所以 client 没有 PipeStats JSON/最终摘要;server 的 `seg=0` 是生产端计数属于 client 的结果,不可用作交叉校验真值。当前两个采样点在同一个 StageAllocate 成功路径、同用 `size`,彼此不相加;这批日志没有提供同跑上游 `TotalBytes(StageSegmentBytes)` 的独立数值证据。
|
||||
|
||||
聚合结果:`/home/swung/p65-openra-metrics.json`(warmup 3,仍含尖峰)与 `p65-openra-steady-metrics.json`(warmup 5)。解析器为 `scripts/ci/p65_link_metrics.py`,`--server-arm LABEL:LOG` 合并 apply 线程 CPU;尚不是 spawn/TCP 配对 A/B 结论。真 TCP 64 MiB burst 另测 **917.397 MiB/s**,不可把帧流量速率充作链路峰值,也不可将 loopback 数字代表 Wi-Fi/adb 设备。
|
||||
|
||||
## 具名前置债:verify + split 阻止 LF 第四例
|
||||
|
||||
`PipeVerifyArmingScenario.Armed` 的 TCP verify 臂在测试 draw 前就遇到:
|
||||
|
||||
```text
|
||||
Fatal{PipeRespecifyScope} resource_respecify {slot=12, gen=0}:
|
||||
scope (target=258, level=0), and no path in this phase may set one
|
||||
```
|
||||
|
||||
使用同一 fresh `/home/swung/p65-verify` 库、server 和 itest,控制臂也得到同因首阻塞:
|
||||
|
||||
| transport | 结果与证据 |
|
||||
|---|---|
|
||||
| TCP stream | 既有 scope pin;`/home/swung/p65-lf-verify/verify/forward-on/peer.server.log` |
|
||||
| inproc | 同一 slot/target/level 的 scope pin;`/home/swung/p65-verify-controls/inproc/test.server.log` |
|
||||
| spawn | 同一 slot/target/level 的 scope pin;`/home/swung/p65-verify-controls/spawn/test.server.log` |
|
||||
|
||||
不是本波 wire 布局差异,也不是不同库混配。`PipeApply.cpp` 的 `PinWholeResourceRespecifyScope` 在 `MOBILEGL_PIPE_VERIFY` 下仍禁止任何 per-level scope,来自 `38f34c13`(2026-09-11);`WireTables.cpp` 在合法 per-level respecify 上调用 `MGPipeSetRespecifiedLevel` 的 producer 来自 `02f15bb6`(2026-09-16),两处均已存在于 P6 基线。旧 pin 未随 producer 落地退役;本任务没有顺手改这条既有生产语义。
|
||||
|
||||
此外 `MGPipe: verify armed` 是 **client PipeFill 的 marker**,即使 verify+split 前置债关闭,关闭 server 日志前送也不应让它消失;它不能成为 server forwarding 的反控。第四例目前是**具名前置阻断,未执行到 arming 断言**,不是 LF 转发失败,也没有被计成通过。其他三个 server-owned marker 的 LF 正负控另由阶段主报告记载。
|
||||
|
||||
|
||||
## 真机发现后的补充:program archive 的宿主尺寸误作 wire 事实
|
||||
|
||||
八项 POD 布局相同并不意味着所有 blob codec 都跨工具链兼容。WSL client → Android server 经 adb-forward TCP 已完成 EGL,但首次 draw 在 `CreateShaderState.Reflection` 拒绝 archive(`/home/swung/p65-device-usb-probe/mobilegl.server.log`)。实际原因是旧 ProgramArtifactsCodec v1 的第二个头字段:Linux 写 `MGL_LINKARTIFACTS_SIZE=1056`,Android 未 pin 的 libc++ 分支期待 0,尚未读取任何逐字段 payload 就拒绝。
|
||||
|
||||
使用两端实际编译参数导出常量,结果为:
|
||||
|
||||
| 宿主事实(不是 wire 格式) | Linux libstdc++ | Android libc++ |
|
||||
|---|---:|---:|
|
||||
| sizeof(LinkArtifacts) | 1056 | 1000 |
|
||||
| sizeof(String) | 32 | 24 |
|
||||
| sizeof(ResourceReflection) | 128 | 120 |
|
||||
| 旧 v1 size echo | 1056 | 0 |
|
||||
|
||||
证据 `/tmp/p65-archive-portable-0bzpmyxr/{linux,android}-sizes.s`。不能通过简单删除该检查解决:字段顺序与 scalar representation 仍需断言。
|
||||
|
||||
修复在 disaggregated 构建启用 archive v2:第二个头字段改为从实际 `VisitFields` 顺序、字段名、容器类别/元素 schema、固定数组长度、scalar 宽度/符号性/浮点格式递归得到的 wire-schema 摘要。字符串只描述计数和内容字节;没有任何 `sizeof(string/vector/map)` 或宿主偏移混入。默认空 record 仅供取字段类型,容器递归 `value_type`,不遍历空元素;摘要每进程只计算一次。glslang UniformInitializer 的八字段表由 writer/reader/schema 共用。原 payload 的逐 scalar 序列化算法保持不变,旧 `LinkArtifacts::program` 仍不运输。
|
||||
|
||||
archive codec 版本和该 schema 摘要同时纳入 Hello 的 WireFingerprint,使真正不兼容的 archive 在握手先拒绝。新增负控要求 v2 拒绝旧 native echo 1056、0 和旧 v1;既有测试名不删除。非 disaggregated 分支保留 v1 头和旧读写语句;现有 G1 pull graph 不编译 ProgramArtifactsCodec.cpp。
|
||||
|
||||
此补充写入时,Linux/NDK 的 codec 与 CapsCodec、Linux 的两份相关测试已按实际 compile_commands 做独立语法检查,六项全部通过;没有另起 ninja。双端重编后的 codec 单测与真实设备 draw 结果由最终阶段报告更新,不把语法检查写成设备验收。
|
||||
|
||||
|
||||
### portable codec 的窄审与后续实证
|
||||
|
||||
按 serializer/deserializer 的分支逐项核对 schema:scalar(类型类别、宽度、enum underlying、浮点格式)、string、map、set、固定数组、vector、UniformInitializer、VisitFields record 均有对应描述;容器的元素类型即使运行时为空也会递归描述。五张实际字段表分别为 TypeFacts 20、ResourceReflection 14、XfbVarying 11、LinkArtifacts 57、SpirvArtifacts 8,名字无重复且与成员一致;唯一跳过的 `LinkArtifacts::program` 仍是既有明确豁免。UniformInitializer 的 8 字段由三个方向共用同一表。该检查针对**实际序列化字段的覆盖**,没有把宿主成员偏移重新引入 wire;未发现漏掉现有 serialized field 的分支。
|
||||
|
||||
root 统一重编后,`/home/swung/p65-final2-targeted.log` 的 54 项定向测试全部通过,包括 fully-populated archive、截断/版本拒绝、新 portable header 负控、两项 archive fingerprint 输入的敏感性检查、已有握手正负控。两端 v2 的 Debug 制品已在真实 LAN 上完成 GL shader 与 64 MiB 上传;这是功能通过,不能充作 Release 性能或完整设备车道收官。
|
||||
|
||||
最后一次源码冻结(含 glFlush、Present、stage cancellation、portable codec)后又用原路径更新 G1 snapshot,只重编 after、不重建 before。最新结果仍是 **27837→27837,0/0/0/0,`.text` 10822147 B 逐字相同**,SHA-256 与前表一致。证据为 `/home/swung/p65-g1-latest-{build,report}.log`、`p65-g1-latest-symbols.json`、`p65-g1-latest.text`。没有降低 G1 判据,也没有将只看尺寸当作字节恒等。
|
||||
|
||||
|
||||
## 真实 ServerLoop idle publication 的 red-once
|
||||
|
||||
此控制没有删除测试里的手动 flush。仅复制生产 `ServerLoop.cpp` 到临时目录,删除 `ApplyThreadMain` 真实 idle 分支的 `session.FlushDataProgress()`;保留 `SessionConsumer::WaitForWork` 的 flush、PostReply 的 progress、64 条/1 ms 批量发布及所有其他代码。使用当前 `compile_commands.json` 只编该 object,再从 `ninja -t commands` 的生产 link 命令只替换该 object 与输出路径,生成临时 `libMobileGL.so`。原 client 不变,复制的 server wrapper 通过子进程 `LD_LIBRARY_PATH` 加载临时库。没有在共享 build 目录执行 ninja build。
|
||||
|
||||
具体用例:`ClearThenReadPixelsScenario.ClearWithNoDrawIsVisibleToDefaultFramebufferReadPixels`,真实 TCP 控制与数据连接,三个独立 loopback 端口对;没有使用设备的 40613。透明 TCP proxy 原样转发并记录 MGLD 帧,观测提交序号、Reply 序号与 Progress 水位,不修改 codec 或 payload。
|
||||
|
||||
| 臂 | 结果 | 实际耗时 | 最后 submitted / Reply / applied |
|
||||
|---|---|---:|---|
|
||||
| 原库(先) | 1 PASS / 0 SKIP | 0.665425 s | 57 / 56 / 57 |
|
||||
| 仅删除生产 idle flush | 8 s 短截止抓到挂住 | 8.000486 s | **1 / 1 / 0** |
|
||||
| 恢复原库(后) | 1 PASS / 0 SKIP | 0.215740 s | 57 / 56 / 57 |
|
||||
|
||||
阴性明确卡在该用例初始化阶段的 **seq 1、opcode 2 `ResourceCreate`**(PipeCalls 的 `kWaitReply` 行,96 B record),不是冒称已进入 ReadPixels。server 已发送 `Reply{seq=1}`,但最后到达 client 的 applied 仍是 0;没有后续命令替它推进水位。8 s 截止时 client、supervisor、session child 仍活着,无 EOF、无 proxy 错误,`mgl-srv-apply` 位于 `futex_do_wait`。这证明健康连接下最后一个真实 reply record 需要生产 idle publication;测试只声明超过短截止,不把观察时间说成无限等待。
|
||||
|
||||
三臂都有真实 `control=tcp data=stream ... dial=connect` marker。主 `libMobileGL.so` 与生产 `ServerLoop.cpp` 的 SHA-256 在试验前后相同;APK 与主设备端口未动。证据目录 `/tmp/p65-idle-redonce-c_n59aqs/` 包含原始/变异单 TU、object、临时 library、link argv、`run-control.py`、`results.json`、各臂 `data-frames.json`/角色日志/XML 以及主产物 hash manifest;控制台记录 `/home/swung/p65-idle-redonce-run.log`。
|
||||
@@ -0,0 +1,17 @@
|
||||
# P7 集成者裁定日志
|
||||
|
||||
> 形式沿用 P5e 的 `INTEGRATOR-DECISIONS-P5E.md`:一条裁定一个 ID,只记「定了什么、为什么、影响哪些文件」,不记来回。计划正文见 [`PLAN-PH-P34B-P7.md`](PLAN-PH-P34B-P7.md)。
|
||||
|
||||
| ID | 日期 | 裁定 | 理由 | 影响 |
|
||||
|---|---|---|---|---|
|
||||
| ID-P7-1 | 2026-09-22 | PH-1「`Session::Fail` 翻成每会话闩」按四片重定界:(1) supervisor 读 `waitpid` status 并命名子进程死亡;(2) 两处头层裸 `abort`(`Server/StagedShadow.h:115`、`Server/StagedTextureStore.h:344`)改走漏斗;(3) 只对对端字节可达站点做 latch-and-decline;(4) 负控。**98 处 `SessionFail` 的字面翻转拒做**。 | ≥9 处返回引用的站点没有诚实返回值;§12.3 进程级 `eglTerminate` 使闩住的进程也服务不了第二会话;P6.5 fork-per-session 已给出「下一连接照常服务」。 | `ServerMain.cpp`、`Server/Staged*.h`、`PipeWireCodec.cpp`、`PipeApplier.cpp`、`ServerLoop.cpp`、`SurfaceOpCodec.cpp` |
|
||||
| ID-P7-2 | 2026-09-22 | PH-6 取 drop-with-latch:`ReserveEventOrBlock` 两处 BUSY 拒绝改置 forfeit 闩 + `CountDrop()` + 返回 scratch,`ServerLoop` park 谓词见闩走正常 Stop;`kEventBacklogWaitMs` 改 `MOBILEGL_IPC_EVENT_WAIT_MS`(默认 2000)。**不等 PH-1**。 | 一个函数、一个标志、一个配置字段即闭;30 s 的「测量」从来不是测量;解耦掉 6–10 天的闩迁移。 | `ServerSession.cpp:215-263`、`ServerLoop.cpp:403-406`、`ConfigLoader` |
|
||||
| ID-P7-3 | 2026-09-22 | OQ-21:**令牌足够,不做 TLS**。令牌常量时间比较、≥16 字节、无令牌只 loopback;数据面以 `Welcome.dataNonce`(CSPRNG 128 位)绑定到已认证的控制连接,认证在 fork 之前完成。TLS 作为 P12 的开放项保留。 | Ph 门的威胁模型是「任何人都能连的远程代码路径」,不是窃听:局域网 GL 命令流不含凭据。令牌 + 连接绑定关掉前者;TLS 是另一个多天项且应有自己的路线图行。 | `protocol.fbs`(`Welcome` 追加字段 → `wireFingerprint` 随之变)、`SocketTransport.cpp`、`Handshake.h`、`ServerMain.cpp` |
|
||||
| ID-P7-4 | 2026-09-22 | 出口门 3(真机 ssim 1.0)的分母排除 `minecraft-1.21.4-rd12-odinlite-in-world` 与 `create-indirect`;`iterationrp` 按 `apk.yml:460-462` 带三个 Magma 旋钮。 | OQ-17:两者在 `dev@81b17c0b` 就在 Adreno 830 上坏,非本分支造成。 | `CONTRACT-P7.md`、设备矩阵跑器 |
|
||||
| ID-P7-5 | 2026-09-22 | `SetupDrawSnapshot` 探测字段塌 dirty mask、`VertexInputStateFactory` 内容寻址 CSO **本阶段拒做**,记入优化阶段。 | `VulkanRenderer::SetupDraw` 在非 monolith 传输下分支到 `SetupWireDraw`(`:6946`),monolith 快照机制在 split 下不跑;无性能门;改 monolith 表动 pull `.text`。 | 无 |
|
||||
| ID-P7-6 | 2026-09-22 | D18 取 21-memo 普查的读法(节点稳定容器纪律;负控 C 必须仍能到达已发货臂)。 | 两名反驳者对指涉不一致,必须由集成者定一个。 | `CONTRACT-P7.md` 一句 |
|
||||
| ID-P7-7 | 2026-09-22 | 184 符号棘轮归 P7 wave 0;baseline 存符号列表而非计数;`--assert-monotone` 只对新增符号红,消失只提示重基线。 | 裸计数的棘轮在「清一个加一个」时通过;P6.5 行从未接收该移交。 | `scripts/link_ratchet.py`、`scripts/data/link_ratchet_baseline.txt`、`test.yml` |
|
||||
| ID-P7-8 | 2026-09-22 | 实现方 `opus`、审查方 `fable`;每包合并前聚焦审查一次,阶段收官整体审查一次。 | ID-66「实现方与审查方错开」;本环境无 Codex。 | 过程 |
|
||||
| ID-P7-9 | 2026-09-22 | 性能只记录不设门(沿用 2026-09-08);wave 2-B 若实测 CSO 缓存为热点才做 P7-5 的 server 半边。 | 路线图纪律。 | 过程 |
|
||||
| ID-P7-10 | 2026-09-22 | wave 0 之前不派任何 `@P7` 拒绝退役的活。 | 今天没有一条车道能让 Magma 两进程用例变红,每个修复都需要 red-once。 | 过程 |
|
||||
| ID-P7-11 | 2026-09-22 | pull 构建(`MOBILEGL_PIPE_PUSH=OFF`)必须**连测试一起**编过:`MG_Test/Util/PipeStatsTest.cpp:137` 用了 push-only 的 `PipeStats::Gauge`,已加 `#if MOBILEGL_PIPE_PUSH` 并保留用例名以维持名集合奇偶。CI 的 pull control 作业关了 `MOBILEGL_BUILD_TEST` 所以看不见——这是 CI 的一处盲区,随 wave 0 的 CI 改动补一条「pull 构建含测试」的编译步骤。 | 「默认 ALL target 必须完整构建」。 | `PipeStatsTest.cpp`、`test.yml` |
|
||||
@@ -0,0 +1,150 @@
|
||||
# Ph / P3b-P4b / P7 统筹计划(2026-09-22,基线 `feat/disaggregated@a96875bf`)
|
||||
|
||||
> 用户指令:「查看 ROADMAP,统筹并推进实现,直到 P7 结束。先计划,看看 Ph、P3/4 深化、P7 有哪些任务已经完成、哪些不必要、哪些是必须的,然后开工实现直到 P7 结束。」
|
||||
>
|
||||
> 本文是那份计划。判定来自一次对树的逐项审计(19 组读者、每个 done / obsolete / unnecessary 判定两名反驳者、一名完整性评审;66 个代理、3080 次工具调用),**每条判定都要求 `file:line` 证据,不接受文档句子**。原始产出在会话 scratchpad(`audit-digest.md` 411 KB),本文只留结论与可调度的剩余工作。
|
||||
|
||||
## 0. 一句话结论
|
||||
|
||||
P7 收官的关键路径是:**先造仪器(wave 0)→ 真机诊断(wave 1)→ 三簇 `@P7` 拒绝退役 + Magma 死亡表 + 深度 mip 烘焙(wave 2,并行)→ verify×split + 全门 + 40% 检查点(wave 3)→ 真机 ssim 1.0 + CTS(wave 4)**。P3b/P4b 的 Espryt 项与 P7 的文件完全不相交,作为并行流推进;Ph 按路线图本来就排在 P12 之前而不是 P7 之前,本轮只做它「必需且小」的部分(观测子进程死亡、两处漏斗旁路、五处无界分配、常量时间令牌 + 数据面绑定、SEG_EVENT 弃投闩),fuzz 臂 2(对端字节可达站点的逐站点闩转换)排在 P7 之后。
|
||||
|
||||
三个最重要的发现,都是路线图文本没写的:
|
||||
|
||||
1. **Magma 今天没有任何两进程集成覆盖。** `mgl_itest_register_split_arms` 的四条臂(Split / Spawn / Tcp / TcpDevice)全部硬编码 `MOBILEGL_BACKEND_TYPE=DirectGLES`(`MG_IntegrationTest/CMakeLists.txt:2002/:2025/:2031`),`MGL_ITEST_MAGMA_WIRE_ENVIRONMENT` 硬编码 `MOBILEGL_TRANSPORT=inproc`(`:2456`);三个共享标签 `integration-split / -spawn / -tcp` 里 DirectVulkan 条目为 **0**。P7 出口门 1 不只是未达成,它**不可测**。retrace 半边有 Magma × {inproc, spawn}(`test.yml:2449/:2470`),集成半边没有。
|
||||
2. **184 符号棘轮(契约 §12.1)没有仪器。** `scripts/ci/` 里没有任何脚本算这个数;P6 说「移交 P6.5」,P6.5 行从未接收。P7 出口门 4 与 P3b/P4b 的 14 符号都写在它之上。
|
||||
3. **真机 DirectVulkan 分歧从未被诊断。** 树上只有两个点值(0.988998 / 0.976494,`CURRENT_STAGE_PROGRESS.md:158`),无 per-case 归属、无重复次数、原始证据不在树内;判别力最高的实验(inproc + `MOBILEGL_IPC_RUN_AHEAD=0` 在 golden 口径下)**从未跑过**,且不需要改任何代码。
|
||||
|
||||
## 1. 逐项判定
|
||||
|
||||
判定词:**done** = 代码已在树上且有证据;**partial** = 一半落地;**not_started**;**obsolete** = 后续阶段用另一条路关掉了需求。必要性:**必须**(P7 收官或该行出口门依赖)/ **可选** / **不必要**(明确拒做并说明理由)。标 ⚠ 的是审计员判 done/unnecessary 但被两名反驳者高置信推翻、本文采纳反驳意见的项。
|
||||
|
||||
### 1.1 Ph(不可信对端加固 + 配对)
|
||||
|
||||
| 项 | 判定 | 必要性 | 剩余工作(可调度) | 规模 | 波次 |
|
||||
|---|---|---|---|---|---|
|
||||
| PH-1 `Session::Fail` 翻成每会话闩 | partial | **必须,但重新定界** | 路线图写的「每个 `[[noreturn]]` 站点造真实返回路径」(98 处 `SessionFail` + 6 处 `WireLogFatal`)**拒做**:≥9 处返回引用(`ServerSession&`、`RingControl&`、`Doorbell&`、`ClientSession&`,`ServerSession.cpp:270/283/740/765/774/784/790`、`WireTables.cpp:118`、`EmitTables.cpp:212`)没有诚实返回值;且 §12.3 的进程级 `eglTerminate` 使「闩住但活着的 server 进程」也服务不了第二个会话。P6.5 的 `--serve` fork-per-session(`ServerMain.cpp:302`)**已经**给出「下一连接照常服务」。真正欠的四片:(1) supervisor **观测并命名**子进程死亡——三处 `waitpid(active, nullptr, WNOHANG)`(`:279/:289/:294`)换成读 status、记 `pid exit=/signal=`、计 `sessionsFaulted`;(2) 两处绕过漏斗的裸 `abort`(`Server/StagedShadow.h:115`、`Server/StagedTextureStore.h:344`)改走 `SessionFail`;(3) **只对对端字节可达的站点**做 latch-and-decline(`PipeWireCodec.cpp` R-2 诚实臂 + 解码边界、`PipeApplier.cpp` 七处、`ServerLoop.cpp` 四处、`SurfaceOpCodec.cpp` 三处——它们都已在 `Bool`/`MobileGLResult` 返回的函数里),`DrainRing` 顶部加闩检查;(4) 负控:喂畸形帧 → 会话闩住 → 下一连接得到 Welcome。 | (1)+(2) 1 天;(3)+(4) 2–2.5 天 | (1)(2) 与 P7 wave 0 同一提交(费用极低);(3)(4) 在 P7 之后 |
|
||||
| PH-2 slot 预算(`SlotTables.h:347/:371` 两条 `MOBILEGL_ASSERT`) | partial | 必须 | 提升为 release 下具名拒绝(先经 `SessionFail`,闩落地后改闩) | 0.5 天 | 与 D11 五处一起 |
|
||||
| PH-3 readback 尺寸门(`PipeApplier.cpp:444`) | not_started | 必须 | 绝对上限取 P6.5 `LinkTerms.maxReplyBytes`(server 自陈),在 resize **之前**比较,超限回 `PostReply(kStatusError)` 而非 Fatal | 4–6 h | D11 |
|
||||
| PH-4 `StagedTextureStore` 按 level 范围设界(`:440`) | not_started | 必须 | `CopyRunInto` 传入 level 宣告 extent,`imageOffset+byteSize` 越界即拒绝 | 1 天 | D11 |
|
||||
| PH-5 `ArchiveVector` 上限(`ProgramArtifactsCodec.cpp:309`) | not_started | 必须 | `TakeCount` 带元素大小,`raw*sizeof(T)` 对 `Remaining()` 设界 | 4–8 h | D11 |
|
||||
| D11 第一行 `create_render_state` 的 `Cso.Slot+1` 无界 resize(`PipeApply.cpp:1575`) | not_started | 必须 | 加 `kMGPipeMaxRenderStateCsoSlots`,走同族 `RecordAt(table, slot, limit)` | 2–3 h | D11 |
|
||||
| PH-6 `SEG_EVENT` 不排空对端 | not_started | 必须 | 取 **drop-with-latch** 形状(不依赖 PH-1):`ReserveEventOrBlock`(`ServerSession.cpp:215-263`)两处 BUSY 拒绝改为置 `m_reverseChannelForfeit` + `CountDrop()` + 返回 scratch,`ServerLoop` park 谓词见闩走正常 Stop;`kEventBacklogWaitMs=30000` 改成 `MOBILEGL_IPC_EVENT_WAIT_MS`(默认 2000);先判 `Dead()` 免把对端死亡误报成 30 s 超时。两条单测(stonewall / trickle)。路线图「60 秒」实为 30 s(两轮)且涓流对端毫秒级触发 `:259` | 1.5–2 天 | P7 之后 |
|
||||
| PH-7 配对 / 认证 | partial ⚠ | 必须 | 已有:非 loopback 无令牌拒绝监听(`SocketTransport.cpp:160`)、Hello 带 token、Refuse。欠:(1) **常量时间比较**且两处策略(`ServerSession.cpp:498` / `ServerMain.cpp:93`)合一;(2) 名字 `Refuse{AuthenticationRequired}` 不在 `RefuseCode` 枚举里——用 `Authentication` 或追加枚举,并给 `fatal_census.py` 加 `Refuse{Word}` 词表门;(3) 令牌最小长度 ≥16 字节;(4) **数据面未认证**:`AcceptPair` 按到达顺序配对、从不查 peer(`SocketTransport.cpp:371/:391`)——`Welcome` 带 `dataNonce`,第二连接首帧必须回它;认证挪到 fork 之前;(5) 有界的预认证工作 + 失败退避;(6) OQ-21 裁定(见 §5 ID-P7-3) | (1)(2)(3) 1 天;(4)(5) 2 天 | (1)(2)(3) 与 wave 0 同期;(4)(5) P7 之后 |
|
||||
| PH-8 尺寸由 server 钳制 | partial | 必须 | 已陈述;补「client Hello 要 64 GiB 时 server 钳到上限而非分配」的单测 | 0.5 天 | P7 之后 |
|
||||
| 门:`Session::Fail` 站点普查零新增 | partial ⚠ | 必须 | `scripts/ci/fatal_census.py` 存在且在 CI(`test.yml:2011`),但 (a) `SCAN_ROOT` 只有 `MG_Remote`,server 进程里 ~79 处 abort(DirectGLES.cpp 16、Managers.cpp 12、VkBufferManager.cpp 11、PipeRoute.cpp 7……)看不见;(b) `abort_sites` 记了从不比较;(c) 12 个 family 词无 `.def` 行。改:SCAN_ROOT 扩到 server 镜像(MG_Remote / MG_Pipe / MG_Backend / MG_Impl/Pipe / MG_State),`abort_sites` 变棘轮,补 `.def` 行 | 1 天 | **wave 0**(P7 需要它看见 `@P7` abort) |
|
||||
| 门:fuzz 臂 1 畸形控制帧 | partial | 必须 | 机制已在(`Framing.h:168` latch、`ControlInbox`),欠端到端脚本 `scripts/ci/ph_fuzz_control_frames.py`(五种畸形)+ `ServerMain.cpp:193` 补 `CtrlEnvelopeBufferHasIdentifier` + ctest 车道 | 1.5 天 | P7 之后 |
|
||||
| 门:fuzz 臂 2 超界计数 | not_started | 必须 | = PH-1 (3)(4) + D11 五处 | 见上 | P7 之后 |
|
||||
| 门:fuzz 臂 3 不排空对端 | not_started | 必须 | = PH-6 + 场景 | 见上 | P7 之后 |
|
||||
| 门:非 loopback 无令牌具名拒绝 | done(机制)⚠ | 必须 | 见 PH-7 (2):名字不在词表;`tcp_supervisor_smoke.py` **未接 CI**(全仓无引用) | 含在 PH-7 | 同期 |
|
||||
| OQ-21 令牌够不够 / TLS | 未答 | 必须裁定 | 见 ID-P7-3 | 0 | 本文 |
|
||||
| OQ-24 E1 对照重定义(ID-122) | 无主 | 可选 | 挂到普查门的 S8 (`SessionFaultCount()==0`) 负控设计上 | 0.5 天 | P7 之后 |
|
||||
|
||||
### 1.2 P3b / P4b 深化(Espryt)
|
||||
|
||||
| 项 | 判定 | 必要性 | 剩余工作 | 规模 | 波次 |
|
||||
|---|---|---|---|---|---|
|
||||
| 按存储属主键控的发射游标 + view 索引重映射 | **代码半 done**(P4a:`TextureEmit.h:1075-1108` 游标按属主 `{slot,gen}`;`TextureObjectView::ToOwner*` 一直存在;wire 半 P5e tx2) | 验证半必须 | 新 `TextureViewAliasScenario`(view 上传 / 属主采样、跨 draw 两次 drain,断言 `SubDataCount()`/`DrainListSize()`),注册 split 三臂并给 `MGL_ITEST_GLES_{SPLIT,SPAWN,TCP}_ENVIRONMENT` 加 `MOBILEGL_ESPRYT_ENABLE_TEXTURE_VIEW=1`;red-once:让 view 自己 `PipeNoteLevelDirty` | 1–1.5 天 | wave 2-D |
|
||||
| `g_fboTextureSyncList` | 分离安全(`DirectGLES.cpp:3922` 记录臂先返回;退路是 `Fatal{UnmigratedPipeInput}`)⚠ | 小件必须;文本删除**不属本阶段** | `ResolveFramebufferSubsystemArm`(`Managers.cpp:4299-4344`)及三个同族 resolver 在有传输且 verdict≠Handles 时改成启动期具名 stop(`StopOnArmlessPipeSubsystem`),把帧中 Fatal 变成启动期拒绝;文本删除受 P5e 裁定 1 / `Config.h:398` 约束,归 P13 | 2–4 h | wave 2-D |
|
||||
| `ResolvedTextureBindingMemo` / `SamplerPassMemo` / image sweep / program registry 重键 | done(P4a/P5f) | 门必须 | 一条纯度 grep 门:split 构建下这些 memo 键里不得出现前端指针类型;接 CI | 0.5 天 | wave 2-D |
|
||||
| XFB scatter 搬到 client | **不做搬迁**(P5c/P5f 走了相反的路:server 读自己的 staged shadow,经 `OnBufferWriteback` 回)⚠ | 两处真洞必须 | (1) 孤儿目标:`ScatterCapturedRecords` `:1946` 的 `continue` 把 `HasDefinedContent==0` 的合法目标**静默丢弃**——改成 monolith 的行为(零填充 staged 再上传),`RequireStagedCoverage` 以 `ResourceContentIsDeclared` 守卫;(2) **无界回写事件**:`:1969`/`:1782` 各投一条整段 `OnBufferWriteback`,>128 KiB(`EventRingBytes/2`)即 `Fatal{EventRingOverflow}`——按 `EventRingCapacityBytes()/4` 切片(`BufferObject.cpp:601-606` 的形状);(3) 删死声明 `OnXfbScatterReady`(`MGPipeCallbacks.h:49-51`,`kMGPipeCallbackCount` 10→9);(4) 注册 `XfbRepeatedCaptureScenario` / `XfbAfterClipDistanceScenario` split 三臂 | 1.5–2 天 | wave 2-D |
|
||||
| 删 fragColor 重推导 workaround 与 `g_broadcastMemo*` | partial | 可选(全删动 pull `.text`,归 P13) | 只做注释 / 标签修正 | 1 h | wave 2-E |
|
||||
| raw-depth-fetch sampler 的 monolith 清理 | partial | 可选 | 步骤 1+2(参数化测试) | 4 h | wave 2-D 尾 |
|
||||
| 回读 / pack state | **pack 半 done**(`set_pixel_pack_state` APPLIER_DERIVED、server 中性读、client 侧 PBO 散射 `EmitTables.cpp:994-1007`);**readback 半开**⚠ | 必须 | (1) 先武装车道:`F1WireScenario.TextureAndFramebufferReadsPreservePackBufferPadding` 等进 split 三臂 + `PixelStoreSweep` / `DepthStencilReadbackMatrix` / `PackedWordReadback` / `LayeredTextureReadback` 注册(DS 需镜像 `MOBILEGL_ESPRYT_FORCE_DS_READBACK_EMULATION`);(2) `get-tex-image-shadow` / `copy-image-shadow-mirror` 在非 monolith 下仍 `std::abort`(`DirectGLES.cpp:14851-14855` 自己写着归 P3b/P4b)——改具名拒绝或实现;(3) 新用例:绑定 PACK PBO + 非默认 `PACK_*` 读回;(4) 路线图 `:244` 的「P5 具名拒绝」是错的(`70df57bb` 起已实现) | 2–3 天 | wave 2-D |
|
||||
| P4a R-3 / R-4 / R-5 / R-7 / R-10 / R-11 | 混合 | R-5、R-11 必须;余可选 | R-5:D-K2 子系统依赖规则六处合一处(`MGPipe.h:115-125` 注释过期);R-11 = TUS 升门(下);R-3 契约一句话;R-4 G9 推导(1–2 天,可选);R-7 三通道 CPU mip 重武装(1–2 h,可选);R-10 ABA 对照 Magma 半依赖 P7 | R-5 0.5–1 天 | wave 2-D |
|
||||
| `ProgramArtifacts.h` NDK 尺寸钉 | **obsolete**(两名反驳者均维持):P6.5 portable archive v2 + 布局指纹取代了 `sizeof` 钉 | 不必要 | 只删两处过期文档句 | 1 h | wave 2-E |
|
||||
| D12 的 14 个符号 | not_started | 可选(P7 棘轮目标不含它们) | Tier 1(0.5 天)在棘轮落地后做 | 0.5 天 | wave 3 后 |
|
||||
| 门:`TextureUploadShapeScenario` 升级成门 | partial | 必须 | 把 `RecordProperty` 变 `EXPECT_EQ`(金标从当前游标实测,不用 P4a 的 emit=6 box=6);加第三张 view 上传纹理;加 split 臂(需 `PipeStatsWindow` 认识角色派生日志名);red-once 翻 union-box 谓词。**Mali 帧时增量不可调度**(只有一台 Redmi)——按 Adreno 记录并写明偏差 | 1–1.5 天 | wave 2-D |
|
||||
| 门:纹理 / program 场景 split 覆盖 | partial | 必须 | ~20 个候选场景(TextureView / TextureParamsWithoutASamplerView / SampledSetStaleness / ImageSizeAfterRespec / … / ProgramPipeline / PostLinkAttach / RelinkStageSet / UniformInitializer …)先在 inproc 跑一遍记首阻塞,按 P7/P8/P9 归属决定注册或具名排除,写 `notes/p34b/split-scenario-census.md`;DirectVulkan 臂等 P7 | 3–5 天 | wave 2-D(后半) |
|
||||
| 门:每一个 Iris trace | partial | 必须 | CI 管道 P6 已建(retrace-split 全矩阵 × 双后端 × {inproc, spawn});欠**结果**:在当前头重跑 39 case × 2 后端 × 2 传输的普查(上次是 P5b 的 72/6/1),写 `notes/p34b/split-trace-census.md`;唯一已知阻塞 `texture-remint-pull`(`Managers.cpp:6359/:6376`)归 P9——门文本按名排除并列 P9 票;模拟器臂 2–6 例/轮 flaky,分 gating / informational 两档 | 1–2 天 | wave 3 |
|
||||
| 门:CTS `texture_*` / `shader_image_*` / `packed_pixels`(+ P4a 欠的 `direct_state_access.framebuffers*`)0.5 pp | not_started | 必须 | `tools/cts/` 有完整 harness 但**无 caselist 入库、无 baseline、无 delta 工具、三个跑器不认 `MOBILEGL_TRANSPORT`**。做:caselist 入库(`tools/cts/caselists/`)、`$BASE`(monolith 读数)、`cts_delta.py`、`packed_pixels` 一条 split 臂 | 4–6 天(多为墙钟) | wave 1(`$BASE`)/ wave 4 |
|
||||
| OQ-14 memo 命中率(`sve ≈ draw 数`) | 无主 | 可选 | 四个重键 memo 家族的命中率计数 + 一次设备读数 | 0.5–1 天 | wave 4 同窗 |
|
||||
|
||||
### 1.3 P7 DirectVulkan(Magma)全量迁移
|
||||
|
||||
**已落地(只欠文档)**:`38919d45` server buffer consumers + Android 旋转 blit;`194382c9` run-ahead / 延迟退休 / VAO 身份碰撞;**`ed507b1a..d56c0e83` 29 个 DirectVulkan 提交的 shape 波**(占位图像 `WirePlaceholderImages.inc`、packed-float mip 原生 blit `5310ff62`、resolve `ec4ca06d`、copy-image 端点、XFB 捕获 span、纹理回读)——路线图 P7 行**一字未提**;`70fb6689` 链 inproc RD32 性能回归关闭(86.85→116.73 fps);占位纹理原生化 **done**(但无 Magma split 车道条目跑它);D-B8 具名 UBO 走了「直接描述符绑定常驻 `VkBuffer` range」的备选(`UniformManager.cpp:2375` 直绑分支)——欠一次测量 + 裁定;`DynamicBackendParameters` 定宽 **done**(P6.5 wf,两名反驳者维持)。
|
||||
|
||||
| 项 | 判定 | 必要性 | 剩余工作 | 规模 | 波次 |
|
||||
|---|---|---|---|---|---|
|
||||
| 出口门 1:集成 + trace 在 Magma push 与 split 下全绿 | partial | 必须 | (1) `mgl_itest_register_split_arms` 加 backend 维度(`MGL_ITEST_${backend}_${arm}_ENVIRONMENT`,新增 `MGL_ITEST_VULKAN_{SPAWN,TCP}_ENVIRONMENT` 拼 ICD 钉);(2) **`WireTables.cpp:740`** 死亡通知安装条件去掉 `ActiveBackendType == DirectGLES`(否则 Magma spawn 的 `CtWireScenario` 死亡用例静默 `ObjectDeaths=0`——P6.5 在 GLES 上踩过的同一个洞);(3) 73 条 `integration-magma-split` 重铺三臂(`test.yml:1570-1632` require_green 名单同步);(4) retrace-split 作业补 iterationrp × DirectVulkan 的三个旋钮导出(`test.yml:2575` 对齐 `:2183`);(5) 首轮红名单 = 后续工作清单 | 3–5 天 | **wave 0** |
|
||||
| 出口门 2:verify 零分歧 | partial | 必须 | verify 今天只注册 monolith(CMakeLists:1684-1760);verify+split 撞旧 `PipeRespecifyScope` 断言(`validation-status.md:118`)——放宽到「按 level 的 producer 各自覆盖其宣告范围」+ 正反单测;加 `integration-verify-split` 环境(双后端 × inproc);两条负控(VERIFY_CORRUPT / POISON_OMIT)在新臂各红一次 | 2–3 天 | wave 3 |
|
||||
| 出口门 3:真机 DirectVulkan split ssim 回到 1.0 | not_started | 必须 | 见 §3 wave 1 的实验 E0–E6;修复在定位前不估 | 定位 1–2.5 天;修 2 天–1 周 | wave 1 / wave 4 |
|
||||
| 出口门 4:184 符号棘轮下降 P7 的 101 个 | not_started | 必须(两名反驳者推翻「不必要」) | `scripts/link_ratchet.py`:按 a6-link-experiment-data.md 的路径规则分 SERVER / FRONTEND / SHARED 对象,`nm` 求 (SERVER undefined) − (SERVER defined) − (SHARED defined) ∩ (FRONTEND defined),输出**符号列表**(不是裸计数)+ `--bucket` 按引用对象分桶;baseline 入库 `scripts/data/link_ratchet_baseline.txt`;CI 步骤在 `build-linux` 作业内;red-once;`--self-test` | 1–1.5 天 | **wave 0** |
|
||||
| 出口门 5:CTS 0.5 pp | not_started | 必须 | `run_cts_local.py` 透传 `MOBILEGL_TRANSPORT` / `MOBILEGL_IPC_SERVER_PATH` + spawn 臂 arming 断言;块:`texture_*` / `shader_image_*` / `packed_pixels` / `direct_state_access.*` / `uniform_buffer_object*`;先 monolith×DirectVulkan baseline 入库,再 inproc×DirectVulkan 比对,pass 率差 ≤0.5 pp 且**新 crash = 0 单独硬红** | 2–4 天 | wave 1(baseline)/ wave 4 |
|
||||
| `@P7` 具名拒绝(树上 **15 处 / 4 文件**,路线图印 8 条) | partial | 分必须 / 可选 | **全部是 `std::abort()` 且绕过 `Session::Fail` 与普查门**。先 (0) `MagmaWireFatal`(`WireFramebuffer.inc:4-7`)/ `WireDescriptorFatal`(`UniformManager.cpp:68-71`)/ `WireBufferLegacyFatal` 改走 `MG_Remote::SessionFail`(wave 0)。**必须退役**:`.6 uniform-buffer-byte-tail`(`UniformManager.cpp:2391`,真机 MC 报告 §5 的活边界)、`.8 copy-image-in-place`(`VulkanRenderer.cpp:10383`,GENERAL 布局单次转换 + 重叠拒绝)、`.9 vertex-layout`(`WireDraw.inc:245`,保留 `buffer-window` 一种为协议错,其余六种改 monolith 的「屏蔽该属性继续画」)、`.11 default-color-blit-shape`(`WireFramebuffer.inc:601`,恒等变换回落 `vkCmdBlitImage`,旋转走 scratch)、`.12 multisample-blit-shape/-aspect`(`:631/:641`,scratch resolve-then-blit + 深/模板 resolve)、`.13 depth-stencil-mipmap`(`:753`,随深度 mip 烘焙)。**可选(改为 decline 即可)**:`.1 texel-buffer-native-format`、`.2/.3 unaligned-{texel,storage,atomic}-range`、`.4/.5 *-native-range`(钳/拆而非拒绝)、`.7 dynamic-offset >4 GiB`、`.10 vertex-format-conversion` | 必须簇 7–9 天;可选簇 2 天 | wave 2 A/B/C |
|
||||
| Magma 无 `StateObjectDeathOps` | not_started | 必须(车道前提) | 镜像 `g_glesStateObjectDeathOps`(`Managers.cpp:335-474`)装表;删六处 Magma 特判(`CtWireScenario.cpp:151`、`PipeFill.cpp:1882` 等);`PipeSlotPeek` 断言死亡后槽位回落 | 1–1.5 天 | wave 2-C |
|
||||
| 内部 shader 烘焙 | partial(blit 已烘 `WireColorBlitSpirv.h`,仅 split 臂) | (A)(D) 必须 | (A) 深度 mip 程序烘焙(`WireDepthMipmap.{vert,frag}` + `.inc`,`GenerateWireMipmap :752-769` 深度分支接入);(D) `MOBILEGL_BAKED_INTERNAL_SHADERS` 新鲜度门(表驱动,覆盖 `MG_Util/SelfTest` 两个已有烘焙头);(B) monolith 臂退役(动 pull `.text`,归 P13);(C) 直通 TCS 烘焙(64 模块,归 OQ-7 窄半,可选) | (A)+(D) 2.5 天 | wave 2-B |
|
||||
| 两处 `MagmaP7AllocatorDebtScope` | partial | 必须 | 证明在非 monolith 下从不武装(临时断言 + split / 双块车道),然后删;随 (A) 一起 | 0.5 天 | wave 2-B |
|
||||
| OQ-8 一份反射归档服务三个消费者 | partial | 必须(小) | `MagmaProgramSource::EnsureStorageBlocks`(`.h:191`)**每 draw 重跑 SPIRV-Reflect**——在 `LinkArtifacts` 加有序 `storageBlocks`(stage 序 + 规范名 + binding 去重),codec 版本 +1,wire 与 monolith 消费者都改读它(顺带删 `g_programResourceCaches` 的悬挂哈希风险 `DirectVulkan.cpp:884-895`);索引序等价单测 | 1.5–2 天 | wave 2-C |
|
||||
| OQ-10 `kCapResidentSubData` 未接线 | partial | 必须(小) | Magma 实现已补(`VkBufferManager.cpp:123/:148`),但 `Init.cpp:192-219` 从不 OR 该位 ⇒ **split 下两个后端都退回就地 memcpy**。按 server 自己的 wire 表判 `SubDataResident != nullptr` 发布;`RemoteClientTest.cpp:594` 改期望 + red-once;integration-magma-buffers 加白盒用例;26.3 in-world 回归 | 0.5–1 天 | wave 2-C |
|
||||
| `SetupDrawSnapshot` 探测字段塌成 dirty mask | not_started | **不必要(本阶段拒做)** | `VulkanRenderer::SetupDraw` 在任何非 monolith 传输下分支到 `SetupWireDraw`(`:6946`),monolith 的 `TrySetupDrawFastPath` / 快照数组在 split 下**根本不跑**;这是无性能门路径上的性能项,且改 monolith 探测表会动 pull `.text` | — | 记入 P13 / 优化阶段 |
|
||||
| `VertexInputStateFactory` 内容寻址 CSO | not_started | **不必要(本阶段拒做)** | 同上:`m_cache` 是 monolith 路径;只有 wave 2-B 的测量要求时才做 server 半边 | — | 同上 |
|
||||
| D18 容器纪律 | 歧义 | 可选 | 两名反驳者对「D18 指哪个」意见不同(BRIEF-P2 的 D18 vs 21-memo 普查的 D18)——由集成者一句话定读法(ID-P7-6)后 ~1 h | 1 h | wave 2-E |
|
||||
| D-B8 具名 UBO host payload / OQ-6 | partial | 必须(小) | 直绑备选已在树上;补一次 `stage-ubo-named` 字节/帧测量 + 在 CONTRACT-P7 里批准备选、关 OQ-6 | 0.5 天 | wave 2-E |
|
||||
| OQ-7 `MG_Util` 切割缝 | not_started | 可选 | 窄半 = 烘焙 (C);宽半(头/对象库拆分)归 P13 | — | P13 |
|
||||
| OQ-13 烘焙 shader 能否表达 uniform / UBO 布局 | 颜色 blit 已答 | 可选 | 窄化到深度 mip,随 (A) 关闭 | 0 | wave 2-B |
|
||||
| 债务表「22 → P4b/P7 texture readback」「3 → P7 query」 | 待核 ⚠ | 必须(一次比对) | 两条「obsolete」判定都建立在 inproc 硬门上,两进程半边无覆盖;`MEASUREMENTS.md` §7.2 的同名比对**自 P5b 起没重跑过**——在当前头重跑一次,四行债务一次结清 | 0.5 天 | wave 3 |
|
||||
| 「再基线检查点:中点完成子系统 < 40% 立即重定基线」 | **不可执行** | 必须定义 | 树上没有「子系统」分母、没有 `CONTRACT-P7.md`、没有 `notes/p7/`。wave 0 定:分母 = §4 的 9 个子系统,中点 = wave 2 合并完成 | 0.5 天 | **wave 0** |
|
||||
| OQ-17 create-indirect / rd12 Magma 在 Adreno 830 上的 dev 侧崩溃 | 已知 | 必须裁定 | 出口门 3 的分母排除这两条,写进 CONTRACT-P7(ID-P7-4) | 0 | wave 0 |
|
||||
|
||||
## 2. 路线图文本需要更正的地方(汇总,wave 0 的文档提交一并改)
|
||||
|
||||
- P7 行:`@P7` 清单 8 → 15(补 `vertex-layout`、`default-color-blit-shape`、`storage-buffer-native-range`、`uniform-block-native-range`;`unaligned-*-range` 展开三个;`multisample-blit` 两个名;`depth-stencil-mipmap` 已窄化到 D|S 合并);补 29 提交 shape 波;`内部 shader 烘焙` 半已落地;`DynamicBackendParameters` 定宽已由 P6.5 落地(`CONTRACT-P6.md:666` 仍写 P7);「§2.8」是死引用(`CURRENT_STAGE_PROGRESS.md` 已为 P6.5 重写);真机分歧改成「两次观测 0.988998 / 0.976494,case 归属与重复次数未记录,原始证据不在树内,且取自 run-ahead ARMED 下、lockstep 对照从未在 golden 口径下跑过」。
|
||||
- P3b/P4b 行:`XFB scatter 搬到 client` 删(改为两处真洞);`回读 / pack state` 拆成「pack 已关 / readback 开」;`g_fboTextureSyncList` 文本删除不属本阶段;`按存储属主…` 从交付列挪到门列;CTS 门补第四块 + 注明读数传输与基线;`每一个 Iris trace` 注明管道已在、欠结果与 P9 例外表;`:244` PACK-PBO「P5 具名拒绝」过期。
|
||||
- Ph 行:「~90 站点」→ 98 + 6;「收口到一处」→ 两个漏斗 + 两处头层旁路 + `PipeApply.cpp:70` 的第三个宏;「60 秒」→ 30 s / 涓流毫秒级;`非 loopback 无令牌拒绝` 已由 P6.5 ct 落地但名字不在词表、数据面未认证;「P12 非 loopback 监听之前」——P6.5 **已经**在 LAN 上跑了 `tcp://0.0.0.0`,顺序陈述落后于树。
|
||||
- 「184 棘轮移交 P6.5」——P6.5 行从未接收,本计划把它归 P7 wave 0。
|
||||
|
||||
## 3. 波次
|
||||
|
||||
资源模型:一名集成者(本会话)+ N 名实现代理(各自 git worktree,`~/w7/pipe` 派生)+ WSL `~/w7/pipe` + lavapipe 跑主机门 + **一台** Redmi `2f7cbe2e`(串行,设备需求成批)。无 Mali。
|
||||
|
||||
### wave 0 — 仪器(集成者,~3–4 天,无并行)
|
||||
今天 P7 没有一条门能被测;先造仪器,仪器没有之前不派活。
|
||||
1. **Magma 两进程车道**:`mgl_itest_register_split_arms` backend 维度 + `WireTables.cpp:740` + 三臂重铺 + retrace-split 旋钮导出。首次跑 `integration-magma` × {spawn, tcp}——**它的红名单取代本文所有猜测**。
|
||||
2. **`scripts/link_ratchet.py`** + baseline + CI 步骤 + red-once。一个脚本,退掉五个重复项。
|
||||
3. **普查门扩容**:`fatal_census.py` SCAN_ROOT 扩到 server 镜像、`abort_sites` 变棘轮、补 `.def` 行;同一提交把 Magma 三个 wire fatal 漏斗改走 `SessionFail`,两处 `Staged*` 裸 abort 改走漏斗,supervisor 读 `waitpid` status 并命名(Ph (1)(2) 顺手)。
|
||||
4. **`MG_Remote/CONTRACT-P7.md` + `notes/p7/`**:子系统分母(§4)、40% 检查点的中点定义、OQ-17 排除表、D18 读法、钉住的 `@P7` 普查数、OQ-21 裁定。
|
||||
5. **设备矩阵跑器**:`run_tcp_matrix.py` / `run_android_retrace_local.py` 能按 backend 选 DirectVulkan、`--matrix`、三行传输环境修正(`TraceReplayActivity.java:374-376`)。
|
||||
|
||||
### wave 1 — 设备窗口 #1(~1 天在手机上,与 wave 2 派活并行)
|
||||
一次 reboot-clean、钉频(`pin_device.sh 2f7cbe2e pin`),一个窗口打三笔债:
|
||||
- **P7-7 实验 E0–E3**(全部不改码):E0 归属与确定性(monolith / inproc 各三遍,存 actual 图,得出**哪些 case 分歧**、三遍是否逐位相同);**E1 `--env MOBILEGL_IPC_RUN_AHEAD=0` lockstep 配对**(判别力最高:回 1.0 ⇒ run-ahead 排队 / 延迟退休 / present credit;不变 ⇒ server 内容路径,run-ahead 整条线出局);E2 `PRESENT_CREDIT` 1/3 扫描;E3 两臂 caps 日志比对(`CapsMirror` placeholder 警告、`GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT`)。排除 rd12 与 create-indirect(OQ-17)。若 E0–E3 未定位:E4 重打包计数诊断补丁(`ResolveWireUniformBufferPayload` 逐帧 direct/repack/`EndRenderPass` 次数,设备 vs lavapipe)→ E5 `FORCE_REPACK=1` 主机强制复现(成立则后续全在桌面做)→ E6 RenderDoc。
|
||||
- **P6.5 残余 39 例 device golden 矩阵**(同跑器同窗口)。
|
||||
- **CTS `$BASE`**:monolith × DirectVulkan 的五个具名块——基线必须先于迁移落地。
|
||||
|
||||
### wave 2 — 并行实现(按**文件**分簇,不按项,避免合并冲突;以 wave 0 车道为门)
|
||||
- **A 对齐簇**(`UniformManager.cpp`):`.2/.3/.4/.5/.6/.7`。3–4 天。
|
||||
- **B blit/copy/mip 簇**(`WireFramebuffer.inc`、`VulkanRenderer.cpp`):`.8/.11/.12/.13` + 烘焙 (A)(D) + 两处 AllocatorDebtScope。5–6 天,最长,先派。
|
||||
- **C 顶点 + 对象簇**(`VertexInputStateFactory`、`WireDraw.inc`、`VkBufferManager`、`Init.cpp`、`MagmaProgramSource.h`):`.9/.10`、Magma `StateObjectDeathOps`、OQ-10 接线、OQ-8 归档 storageBlocks。4–5 天。
|
||||
- **D Espryt 流**(`MG_Backend/DirectGLES`、`MG_State`、`MG_Impl/Pipe`、`MG_IntegrationTest`——与 A/B/C 零文件重叠):XFB 两洞、readback 收口、TextureViewAlias + TUS 升门、四个 resolver 启动期 stop、memo 纯度 grep、R-5、raw-depth 步骤 1+2、纹理/program 场景普查。8–10 天。
|
||||
- **E 文档 / 裁定**(~1 天):已落地项的文档更正、OQ-6/13 关闭、`§7.2` 同名重跑、`TextureParamsWithoutASamplerView` 待核、D18 读法。
|
||||
- **F Ph 小件**(`MG_Remote/Transport`、`Server/ServerMain.cpp`、`Handshake.h`——与 A–D 零重叠):常量时间令牌合一 + 名字入词表 + 最小长度、D11 五处上限 + PH-2 提升、PH-8 单测。3–4 天。
|
||||
集成者串行合并,每次合并后重跑 Magma 三臂 + 棘轮 + G1,**任何让棘轮上升的提交拒收**。每包 red-once(R-16)。
|
||||
|
||||
### wave 3 — 集成者
|
||||
verify+split 前置债(`PipeRespecifyScope` 放宽)→ `integration-verify-split` → 主机全门(unit / integration-gpu 双传输 / split 三臂 × 双后端 / retrace 全矩阵 / G1 / G2 / G14 / 双生成器 / include 闭包 / doc citation)→ 棘轮逐符号归属 → Iris trace 普查 + P9 例外表 → `§7.2` 同名比对 → **按 wave 0 的分母评估 40% 检查点**:若完成子系统 < 40%,停下重定基线。
|
||||
|
||||
### wave 4 — 设备窗口 #2 + CTS
|
||||
出口门 3 复测到 1.0(同 case 三遍 + monolith 对照同会话)→ CTS AFTER 读数(五块,inproc × DirectVulkan)→ **同窗口取 P3b/P4b 的 CTS `$BASE`** 与 OQ-14 memo 命中率读数,免第三次设备窗口。
|
||||
|
||||
### wave 5 — P7 收官后
|
||||
P3b/P4b 余项(场景普查后半、CTS AFTER)→ Ph 大件(PH-1 (3)(4)、PH-6、PH-7 (4)(5)、fuzz 三臂)→ P12。每阶段收官一次异模型审查(ID-66)。
|
||||
|
||||
## 4. P7 子系统分母(40% 检查点用)
|
||||
|
||||
1. Magma 两进程车道(三臂 × 73 + 全量过滤器);2. `@P7` 必须簇六项退役;3. `StateObjectDeathOps`;4. 内部 shader 烘焙 (A)(D);5. OQ-8 反射归档;6. OQ-10 resident 接线;7. verify×split;8. 真机 ssim 1.0;9. CTS 五块 ≤0.5 pp。**中点** = wave 2 三簇全部合并之时;届时完成 < 4/9 即触发重定基线。
|
||||
|
||||
## 5. 裁定(ID-P7-*,正文见 `INTEGRATOR-DECISIONS-P7.md`)
|
||||
|
||||
- **ID-P7-1** PH-1 按四片重定界;98 站点的字面翻转拒做,引用返回的 9 处标 `@Ph-declined` 并写明理由。
|
||||
- **ID-P7-2** PH-6 取 drop-with-latch 形状,不等 PH-1。
|
||||
- **ID-P7-3** OQ-21:**令牌足够**——常量时间比较、≥16 字节、无令牌只 loopback、数据面以 `Welcome.dataNonce` 绑定到已认证的控制连接;**不做 TLS**(局域网 GL 命令流不含凭据;TLS 归 P12 作为开放项保留,理由:加密不是 Ph 门的威胁模型——威胁是「任何人都能连的远程代码路径」,令牌 + 绑定已关)。
|
||||
- **ID-P7-4** 出口门 3 的分母排除 `minecraft-1.21.4-rd12-odinlite-in-world` 与 `create-indirect`(OQ-17 dev 侧 Adreno 崩溃);`iterationrp` 带 apk.yml 的三个 Magma 旋钮。
|
||||
- **ID-P7-5** `SetupDrawSnapshot` dirty mask 与 `VertexInputStateFactory` 内容寻址 CSO **本阶段拒做**(monolith 路径、无性能门、动 pull `.text`),记入优化阶段。
|
||||
- **ID-P7-6** D18 取 21-memo 普查(`notes/recovered/wf2/final/part2.md:526`)的读法:节点稳定容器纪律;负控 C 必须仍能到达已发货臂;写进 CONTRACT-P7 一句话即闭。
|
||||
- **ID-P7-7** 184 棘轮归 P7 wave 0;baseline 存符号**列表**,`--assert-monotone` 只对新增红,消失只提示重基线。
|
||||
- **ID-P7-8** 实现方 `opus`、审查方 `fable`(本环境可用的两条模型线),以满足「实现方与审查方错开」;每包合并前一次聚焦审查,阶段收官一次整体审查。
|
||||
- **ID-P7-9** 性能只记录不设门(沿用 2026-09-08 用户裁定);wave 2-B 若测得 CSO 缓存是热点,才做 P7-5 的 server 半边。
|
||||
|
||||
## 6. 纪律(每个提交)
|
||||
|
||||
沿用 ROADMAP「通用纪律」:ALL target 完整构建(**含 pull 构建的测试**——a96875bf 的 `build-linux` 因 `PipeStatsTest.cpp:137` 编不过,已修);G1 pull `.text` 恒 `0xa52203`、符号 0/0/0/0(基线 `~/w7/p7-before/`);G2/G14 名集合只增不删(split 4155 / linux 3049);每门 red-once;性能只记录;拆分不顺手修 `dev`;先 commit+push 再进下一波(用户 2026-09-11 常规)。
|
||||
@@ -17,6 +17,11 @@ skipped are three different answers and the caller needs all three.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import re
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
||||
@@ -25,8 +30,36 @@ import xml.etree.ElementTree as ET
|
||||
ARM_PREFIXES = {
|
||||
'--require-split-ran': 'DirectGLES.Split.',
|
||||
'--require-spawn-ran': 'DirectGLES.Spawn.',
|
||||
'--require-tcp-ran': 'DirectGLES.Tcp.',
|
||||
'--require-tcp-device-ran': 'DirectGLES.TcpDevice.',
|
||||
}
|
||||
|
||||
TCP_ARM = re.compile(r'control=tcp data=stream server=\S+ pid=[1-9][0-9]*\b')
|
||||
|
||||
|
||||
def require_tcp_proof(path, prefix, discovery, require_run_ahead=False):
|
||||
helper_path = Path(__file__).resolve().parents[2] / 'MobileGL/MG_IntegrationTest/Harness/split_log_paths.py'
|
||||
spec = importlib.util.spec_from_file_location('split_log_paths', helper_path)
|
||||
helper = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(helper)
|
||||
logs = helper.marker_log_paths(json.loads(Path(discovery).read_text()))
|
||||
for case in ET.parse(path).getroot().iter('testcase'):
|
||||
if not case.get('name', '').startswith(prefix):
|
||||
continue
|
||||
if case.find('skipped') is not None or case.get('status') in ('notrun', 'disabled'):
|
||||
continue
|
||||
# The console sink is compiled out of CI builds, so system-out cannot
|
||||
# establish the transport. Read this entry's private role logs instead.
|
||||
name = case.get('name')
|
||||
if name not in logs:
|
||||
raise ValueError(f'{name}: discovery has no private log path')
|
||||
output = helper.read_role_logs(logs[name])
|
||||
if not TCP_ARM.search(output):
|
||||
raise ValueError(f"{case.get('name')}: missing TCP/stream endpoint and server pid arm proof")
|
||||
if require_run_ahead and ('run-ahead ARMED' not in output or 'running lockstep' in output
|
||||
or 'run-ahead DISARMED' in output):
|
||||
raise ValueError(f"{case.get('name')}: TCP runtime did not keep requested run-ahead armed")
|
||||
|
||||
|
||||
def tally(path, prefix=None):
|
||||
passed = failed = skipped = 0
|
||||
@@ -43,18 +76,29 @@ def tally(path, prefix=None):
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) not in (2, 3) or (len(sys.argv) == 3 and sys.argv[2] not in ARM_PREFIXES):
|
||||
print("usage: junit_tally.py <junit.xml> [" + " | ".join(sorted(ARM_PREFIXES)) + "]",
|
||||
file=sys.stderr)
|
||||
return 2
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('junit')
|
||||
arms = parser.add_mutually_exclusive_group()
|
||||
for flag, prefix in ARM_PREFIXES.items():
|
||||
arms.add_argument(flag, dest='prefix', action='store_const', const=prefix)
|
||||
parser.add_argument('--discovery', help='CTest --show-only=json-v1 output (required for TCP proof)')
|
||||
parser.add_argument('--require-run-ahead', action='store_true',
|
||||
help='Additionally prove actual run-ahead, without fallback or demotion, on each TCP case')
|
||||
args = parser.parse_args()
|
||||
if args.prefix in ('DirectGLES.Tcp.', 'DirectGLES.TcpDevice.') and not args.discovery:
|
||||
parser.error('TCP arm proof requires --discovery to locate each private role log')
|
||||
if args.require_run_ahead and args.prefix not in ('DirectGLES.Tcp.', 'DirectGLES.TcpDevice.'):
|
||||
parser.error('--require-run-ahead requires a TCP arm selection')
|
||||
try:
|
||||
prefix = ARM_PREFIXES[sys.argv[2]] if len(sys.argv) == 3 else None
|
||||
passed, failed, skipped = tally(sys.argv[1], prefix=prefix)
|
||||
prefix = args.prefix
|
||||
passed, failed, skipped = tally(args.junit, prefix=prefix)
|
||||
if prefix in ('DirectGLES.Tcp.', 'DirectGLES.TcpDevice.'):
|
||||
require_tcp_proof(args.junit, prefix, args.discovery, args.require_run_ahead)
|
||||
except Exception as exc: # a malformed file is not "zero of everything"
|
||||
print(f"junit_tally: cannot parse {sys.argv[1]}: {exc}", file=sys.stderr)
|
||||
print(f"junit_tally: cannot prove {args.junit}: {exc}", file=sys.stderr)
|
||||
return 1
|
||||
print(f"{passed} {failed} {skipped}")
|
||||
if len(sys.argv) == 3 and (passed == 0 or failed):
|
||||
if prefix is not None and (passed == 0 or failed):
|
||||
print(f'{prefix} baseline FAILED: no successful entries with that arm prefix, or an '
|
||||
f'already-red selection', file=sys.stderr)
|
||||
return 1
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python3
|
||||
"""P6.5 ownership and dispatch boundary, with explicit compatibility limits.
|
||||
|
||||
The old raw constructors and Session::Control/Shm test/bootstrap accessors remain
|
||||
source compatible. Ring endpoints are cached, non-owning setup handles, shared
|
||||
by both data planes. This gate does not pretend that their type names disappeared;
|
||||
it rejects ownership and concrete-link dispatch outside Transport instead.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SOURCES = [
|
||||
"MobileGL/MG_Remote/Client/ClientSession.h",
|
||||
"MobileGL/MG_Remote/Client/ClientSession.cpp",
|
||||
"MobileGL/MG_Remote/Server/ServerSession.h",
|
||||
"MobileGL/MG_Remote/Server/ServerSession.cpp",
|
||||
"MobileGL/MG_Remote/Server/ServerLoop.cpp",
|
||||
"MobileGL/MG_Remote/Wire/PipeWireCodec.h",
|
||||
"MobileGL/MG_Remote/Wire/PipeWireCodec.cpp",
|
||||
"MobileGL/MG_Impl/Pipe/ResourceTracker.h",
|
||||
]
|
||||
PHYSICAL = r"(?:SessionSegments|ReplySlotPool|RingProducer|RingConsumer|EventRingProducer|EventRingConsumer)"
|
||||
|
||||
def code_only(source: str) -> str:
|
||||
return re.sub(r"/\*.*?\*/|//[^\n]*", "", source, flags=re.S)
|
||||
|
||||
def violations(path: str, text: str) -> list[str]:
|
||||
code = code_only(text)
|
||||
found: list[str] = []
|
||||
rules = [
|
||||
(rf"\b{PHYSICAL}\s+m_\w+\s*(?:[;{{=])", "physical data-plane ownership outside Transport"),
|
||||
(r"\bm_shm\s*\.", "session bypasses its link for segment access"),
|
||||
(r"(?:new\s+(?:Transport::)?|make_unique\s*<\s*(?:Transport::)?)(?:ShmLink|StreamLink)\b", "concrete link selected outside Transport factory"),
|
||||
(r'#\s*include\s*[<"][^>"\n]*(?:ShmLink|StreamLink)\.h', "concrete link included above Transport"),
|
||||
]
|
||||
if path.endswith("ServerLoop.cpp"):
|
||||
rules.append((r"\bRingControl\b|(?:\.|->)Control\(\)", "apply loop reads a physical control page"))
|
||||
if path.endswith("PipeWireCodec.h"):
|
||||
rules.append((r"\bRingControl\s*\*\s*m_", "codec stores physical page instead of setup progress/signals"))
|
||||
if path.endswith("ResourceTracker.h"):
|
||||
rules.append((r"Segments\(\)\.Resolve", "writeback bypasses ILink span resolution"))
|
||||
for pattern, message in rules:
|
||||
for match in re.finditer(pattern, code):
|
||||
line = code.count("\n", 0, match.start()) + 1
|
||||
found.append(f"{path}:{line}: {message}")
|
||||
return found
|
||||
|
||||
def self_test() -> None:
|
||||
controls = [
|
||||
(SOURCES[0], "Transport::SessionSegments m_segments;"),
|
||||
(SOURCES[0], "Transport::ReplySlotPool m_replies;"),
|
||||
(SOURCES[1], "m_shm.Close();"),
|
||||
(SOURCES[1], "auto link = std::make_unique<Transport::StreamLink>();"),
|
||||
(SOURCES[4], "auto& page = session.Control();"),
|
||||
(SOURCES[5], "Transport::RingControl* m_control = nullptr;"),
|
||||
(SOURCES[-1], "session->Segments().Resolve(4, offset, size);"),
|
||||
]
|
||||
for path, source in controls:
|
||||
assert violations(path, source), f"negative control did not turn red: {source}"
|
||||
assert not violations(SOURCES[0], "Transport::RingProducer* m_cmd = nullptr;")
|
||||
print(f"link seam negative controls: {len(controls)} named failures observed")
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--self-test", action="store_true")
|
||||
args = parser.parse_args()
|
||||
if args.self_test:
|
||||
self_test()
|
||||
failures = [failure for name in SOURCES for failure in violations(name, (ROOT / name).read_text(encoding="utf-8"))]
|
||||
if failures:
|
||||
print("\n".join(failures))
|
||||
return 1
|
||||
print("link seam ownership/dispatch gate: PASS (cached endpoints and legacy test constructors retained)")
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user