mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-16 14:33:24 +09:00
[MG_Pipe, MG_Impl, MG_Remote, MG_State, MG_Test] (Disaggregated): P5e pg - the archive becomes server-owned and the bindings get a record
- MGPipeShaderCsoRecord gains Archive, a SharedPtr<const ProgramArchive> the create
ADOPTS under a transport. Before this the applier stored the descriptor and the two
companion pointers named the frontend's own LinkArtifacts/SpirvArtifacts, which
ProgramObject::Link() replaces in place - so every reflection read on the apply thread
was torn or stale by construction the moment the client runs ahead (gap G-A).
- MGPipeApplyCreateShaderState takes the archive as a fourth argument, undefaulted for
PipeRoute.h's stated reason: a caller that has one and forgets it would compile, and
the failure would be silent. Null on the monolith arm, which keeps its frontend arms
token for token (ruling 1 / ID-81).
- ProgramArtifactsCodec gains ProgramArchive and the FRAME. SpirvArtifacts carries no
stage list and MGPProgramDesc::StageMask cannot stand in for one: it is a bit set, and
GL lets two shader objects share a stage, so a list rebuilt from it can be shorter than
generatedSpirv - which the backend pairs with it by one running index.
- Codec completeness, as CONTRACT-P5E §5.5 asks: the skipped member is named
(LinkArtifacts::program, the live glslang TProgram) and proven unread by either backend
twin; the libc++ caveat at the size echo is read as what it is - a cross-toolchain
check, exact for an in-process split - and both verdicts are written where they were
asked for.
- set_program_bindings (opcode 80) lands end to end: EmitProgramBindings on the client,
the FIFTH ROUTE ESCAPE (three tails in three index spaces plus a parallel name array -
no generated row can express it, so op 80's gMGPipeContext slot stays null as
PipeCatalogueTest pins), the wire emitter, the decoder arm that resolves and
NUL-checks every name span, and the applier body that copies the names into the record
(rule C) and advances BindingsSerial.
- The record is emitted AFTER create_shader_state, not before as the draft note said: a
re-issued create clears all three tails because they index into the archive it just
replaced, so bindings published ahead of it are wiped by the create that follows.
- MGPProgramDesc::LinkStatus is filled, and ID-88 is VERIFIED rather than assumed:
ProgramObject::Link()'s prologue bumps m_linkVersion and assigns m_artifacts = {} -
"the complete not-linked state" - before the body runs, and every ProgramLinkTask
failure arm leaves linkStatus false. A failed relink therefore reports unlinked, the
re-issue carries LinkStatus = 0, and nothing needs an object_death.
- ID-87's measurement gets its instrument: the archive's byte count is added to
PipeStats' CsoBlobBytes where the bytes actually exist, one sample per link.
This commit is contained in:
@@ -1756,17 +1756,28 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
const void* archive = ResolveOrFatal(op, desc.Reflection);
|
||||
MG_State::GLState::LinkArtifacts link;
|
||||
MG_State::GLState::SpirvArtifacts spirv;
|
||||
if (!MG_State::GLState::DecodeProgramArtifacts(static_cast<const Uint8*>(archive),
|
||||
static_cast<SizeT>(desc.Reflection.Size),
|
||||
link, spirv)) {
|
||||
const void* archiveBytes = ResolveOrFatal(op, desc.Reflection);
|
||||
// P5e (pg), gap G-A: DECODED ONTO THE HEAP AND HANDED TO THE RECORD, not onto this
|
||||
// stack. Before P5e these were two locals that died at the closing brace and the
|
||||
// applier kept only the descriptor, so every reflection question the program twin
|
||||
// later asked went back to the frontend's own ProgramObject - which Link() replaces
|
||||
// in place, and which a run-ahead client is several records past by then. The
|
||||
// record adopts the archive here and answers from it for the rest of its life.
|
||||
//
|
||||
// AND THE FRAME, not the bare codec stream: ProgramArchive carries the stage of
|
||||
// each module beside the modules, because SpirvArtifacts does not and StageMask
|
||||
// cannot stand in for it (two shader objects may share a stage). See
|
||||
// ProgramArtifactsCodec.h.
|
||||
auto archive = MakeShared<MG_State::GLState::ProgramArchive>();
|
||||
if (!MG_State::GLState::DecodeProgramArchive(static_cast<const Uint8*>(archiveBytes),
|
||||
static_cast<SizeT>(desc.Reflection.Size),
|
||||
*archive)) {
|
||||
WireProtocolFatal("CreateShaderState.Reflection",
|
||||
"DecodeProgramArtifacts refused the archive - a truncated "
|
||||
"stream, a codec version mismatch or a struct-size mismatch");
|
||||
"DecodeProgramArchive refused the archive - a truncated "
|
||||
"stream, a codec version mismatch, a struct-size mismatch, or "
|
||||
"a stage list that does not match the modules it frames");
|
||||
}
|
||||
MGPipeApplyCreateShaderState(desc, &link, &spirv);
|
||||
MGPipeApplyCreateShaderState(desc, &archive->Link, &archive->Spirv, archive);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1861,12 +1872,11 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
return false;
|
||||
|
||||
case MGPWireOp::SetProgramBindings: {
|
||||
// P5e, opcode 80 (MG_Remote/CONTRACT-P5E.md §1). NO APPLIER ENTRY POINT EXISTS YET
|
||||
// and c0e does not invent one: the record's consumer is the program twin's
|
||||
// rebuild, which package pg writes. What the record needs NOW and cannot get later
|
||||
// is its shape - the three declared counts against their bounds and the three-tail
|
||||
// arithmetic, both of which MGPipeWireRecordLayout above has already run - plus the
|
||||
// honesty of every name span it carries.
|
||||
// P5e, opcode 80 (MG_Remote/CONTRACT-P5E.md §1). c0e wrote the shape check and left
|
||||
// the arm declining; PACKAGE pg COMPLETES IT. What the record needs before its
|
||||
// consumer sees it is its shape - the three declared counts against their bounds
|
||||
// and the three-tail arithmetic, both of which MGPipeWireRecordLayout above has
|
||||
// already run - plus the honesty of every name span it carries.
|
||||
//
|
||||
// THE SPANS ARE WALKED HERE RATHER THAN BY THE ENCODER'S BLANKET PASS because they
|
||||
// are MEMBERS of the third tail's 40-byte elements, not a bare MGHostSpan array:
|
||||
@@ -1874,17 +1884,48 @@ namespace MobileGL::MG_Remote::Wire {
|
||||
// pad} would read one span and a quarter of garbage. All four arms of
|
||||
// CheckHostSpanIsHonest run, the segment-range one included, so an override name
|
||||
// pointing outside SEG_STAGE is caught on the way in rather than at the rebuild.
|
||||
const auto& bindings = *static_cast<const MGPProgramBindings*>(payload);
|
||||
// RESOLVED HERE AND VALID ONLY FOR THIS CALL (rule C): the names live in the staged
|
||||
// run this record named, and the applier copies them into the record before it
|
||||
// returns. A Vector of resolved pointers rather than a second pass inside the
|
||||
// applier, because segment resolution is the decoder's job and the applier has no
|
||||
// segment table - it is reached by the monolith adapter too, where the names are
|
||||
// the frontend's own c_str()s and there is nothing to resolve.
|
||||
Vector<const char*> overrideNames;
|
||||
const MGPProgramStorageOverride* overrides = nullptr;
|
||||
if (layout.TailCount == 3 && layout.TailBytes[2] != 0 && m_segments != nullptr) {
|
||||
const auto* overrides = tailAt(2);
|
||||
overrides = reinterpret_cast<const MGPProgramStorageOverride*>(tailAt(2));
|
||||
const Uint64 count = layout.TailBytes[2] / sizeof(MGPProgramStorageOverride);
|
||||
overrideNames.reserve(static_cast<SizeT>(count));
|
||||
for (Uint64 i = 0; i < count; ++i) {
|
||||
MGPProgramStorageOverride entry{};
|
||||
std::memcpy(&entry, overrides + i * sizeof(MGPProgramStorageOverride),
|
||||
std::memcpy(&entry, reinterpret_cast<const Uint8*>(overrides) +
|
||||
i * sizeof(MGPProgramStorageOverride),
|
||||
sizeof(MGPProgramStorageOverride));
|
||||
CheckHostSpanIsHonest(entry.Name, *m_segments);
|
||||
// THE NUL IS THE CLIENT'S AND IS CHECKED, not assumed: the emitter stages
|
||||
// the name with its terminator (ProgramEmit.h), and a span whose last byte
|
||||
// is not 0 would make the applier's String(const char*) walk off the end of
|
||||
// SEG_STAGE. Honest-but-unterminated is the one shape CheckHostSpanIsHonest
|
||||
// cannot see.
|
||||
const auto* name = static_cast<const char*>(
|
||||
m_segments->Resolve(entry.Name.Seg, entry.Name.Offset, entry.Name.Size));
|
||||
if (entry.Name.Size == 0 || name == nullptr ||
|
||||
name[entry.Name.Size - 1] != '\0') {
|
||||
WireProtocolFatal("SetProgramBindings.StorageOverrides.Name",
|
||||
"an override name span is empty or is not "
|
||||
"NUL-terminated; the applier copies it as a C string");
|
||||
}
|
||||
overrideNames.push_back(name);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
MGPipeApplySetProgramBindings(
|
||||
bindings,
|
||||
layout.TailBytes[0] != 0 ? reinterpret_cast<const Int32*>(tailAt(0)) : nullptr,
|
||||
layout.TailBytes[1] != 0 ? reinterpret_cast<const MGPProgramSamplerUnit*>(tailAt(1))
|
||||
: nullptr,
|
||||
overrides, overrideNames.empty() ? nullptr : overrideNames.data());
|
||||
return true;
|
||||
}
|
||||
|
||||
case MGPWireOp::SetGlobalConstants: {
|
||||
|
||||
Reference in New Issue
Block a user