Files
MobileGL/docs/archive/notes/p5/p5-results/c1-v3.md
T

297 lines
22 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# c1-v3 — the confirmed fix round (routing completeness, the readback rules, teardown, R-12)
Branch `p5/c1`. Base `41992649` (round 2), then step-0 merge of `feat/disaggregated@c3e736a3`
(→ merge commit `f280baf2`) and one work commit. Commit range **`41992649..5682f429`**; the work
commit is the one below `f280baf2`.
Every item the two round-2 reviews CONFIRMED is fixed here. The cross-family verifier
(`c1-codex-verify-v2.md`) confirmed all ten of its executed items (2,4,5,6,7,8,9,10,11,12); none
was refuted, so nothing here is skipped-by-refutation. R-16: every gate ships its red-once line
and the red-check runner (rewritten, §M6) made all nine RED once, each on **its own** string, with
the baseline restored green after each — `~/w7/p5-c1-r3-redcheck.log`, exit 0,
`CONTROLS_THAT_DID_NOT_GO_RED=none`.
---
## 1. The items, each with its red-once line
**B1 — the five `&MGPipeApply*` sites taken by address (`PipeFill.cpp` `EmitDeleteIfPublished`
callers `:1536/:1557/:1598/:1635/:1656`).** R-17 renamed call *expressions*; these five pass the
applier's *address*, so `DeleteSamplerView`, `DeleteShaderState`, `DeleteSamplerState` and
texture/renderbuffer `ResourceDestroy` still ran the applier on the GL thread under split. Now
`&MGPipeRoute<Name>` (same signature, `const MGPHandleOnly&`→void), and `EmitDeleteIfPublished`'s
parameter is documented as a route. Gate: the red-check refuses any `&MGPipeApply` under `MG_Impl/`
(grep, now 0); the routing is exercised by the split lane (14/21 holds). **Red once:** revert one
site to `&MGPipeApplyResourceDestroy` → the split delete runs the applier on the GL thread (the
reviewer's abort probe took 21/21). `MGPipeRouteDeleteSamplerView`/`DeleteShaderState` now have a
caller.
**B3 / codex 9 — nothing observed the CLIENT arm's 37 rows.** New
`RemoteClientTest.PipeRouting.TheInstalledClientArmIsWireAndNotMonolithAndEveryRoutedRowMoved`:
after `InstallClientWireTables()` it counts the generated-table cells that DIFFER from the kept
monolith adapters (`MGPipeMonolith*()`), asserts exactly **33** moved (Screen+Context) and **4**
escapes moved, and `MGPipeInstalledArm()==kClientWire`. Plus a fork runtime control
(`AClientWireRowWithNoSessionRefusesByName...`) driving one routed row with no session → the wire
row aborts `Fatal{NoClientSession,"ResourceDestroy"}`, which the monolith adapter (a dropped row)
does not. **Red once:** the red-check comments out one `InstallClientWireTables` assignment → the
row reads equal to the monolith adapter → `33` becomes `32` → the case fails (verified RED).
**M1 / ID-53 / codex 7 — `Fatal{BarrierViolation, "<slot>"}`.** The check is at
`ClientSession.cpp:692`, reads `g_applyThreadInsideApplier`, and fires through **`MGLOG_F`** (so it
reaches the per-lane log ID-53's E1 asserts on). What it reads and what arms it: the flag's only
writers are `NoteApplyThreadEnteredApplier/LeftApplier`, called only by `ScopedApplierEntry`, whose
one use is v1's bracket in `PipeApplier::ApplyOne` — **v1's file, the integrator's merge-time hunk
(ID-52)**. c1 cannot arm it (the applier is v1's), and I say so rather than pretend: with the
bracket applied the verifier drove the flag up at emission and got the named Fatal; with it down at
emission a fill that raced the applier is unobserved. **Codex 7's placement point** (move the check
to the first `gPipeInputs` write, `MGP_FILL`) lands in **p1's `MGPipeValidateForVerb`** (`PipeFill`'s
poison/residual part, p1's ownership), not c1's — requested from p1/the integrator; a deterministic
two-thread race harness was not cheap here and the verifier marked that sub-point PARTIAL, so it is
stated as a design argument, not asserted. On this head, with `MOBILEGL_IPC_VERB_BARRIER=0`,
`BarrierViolation` does not appear in the split lane's ctest output because the `DirectGLES.Split.*`
entries set no `MOBILEGL_LOG_FILE_PATH` — that lane plumbing is ID-53's joint-merge package, and my
string is `MGLOG_F` precisely so it lands there once it exists.
**M2 / codex 11 — the readback never read status or size.** `EmitAndWait` now returns the reply's
own byte count (`Uint64* replySizeOut`), and `EmitReadPixels` calls `RequireReadbackReplyComplete`
on both the fast and bounce paths: `Fatal{ReplyError,"ReadPixels"}` / `Fatal{ReadbackDeclined,...}`
/ `Fatal{ReadbackReplyShort,"ReadPixels <got> < <expected>"}` — never stale bytes. The predicate is
`ReadbackReplyIsComplete(status, size, tight)`, exposed and driven by
`RemoteReadback.AReplyIsScatteredOnlyWhenItIsOkAndExactlyTheReadsExtent`. **Red once:** the red-check
drops the size term from the predicate → the short-reply case fails (verified RED).
**M3 / codex 10 — the tight-size helper production did not call.** `EmitReadPixels` now computes
`info.DstSize` via `TightReadbackBytes(...)`, the same function `TightReadbackByteCount` (the test)
calls, so there is one body. **Red once:** `+16` in `TightReadbackBytes` →
`DstSizeIsTheTightExtentAndNeverThePackedOne` fails (verified RED). The capacity half (codex 10b):
the red-check's `ID47b` multiplies the tight extent by 100000 and drives the split lane with the
init patch → `Fatal{ReplyTooLarge}` at the CLIENT before the ordinal advances (verified RED, rc=-6,
baseline restored green); deleting `RequireReadPixelsReplyFits` moves the abort to the server
(`Post`), so the client `ReplyTooLarge` assertion goes absent = the control notices.
**M4 / codex 5 — ERROR handled three ways.** The two escapes now abort
`Fatal{ReplyError,"resource_respecify"}` / `"map_persistent"` on Status=ERROR, matching the
generated rows' `MGPipeTakeReplyBool` (unchanged). `SessionWait::ShutDown` now sets the status to
**DECLINED**, not the pre-set ERROR, so a session torn down mid-verb returns `false`/`nullptr`
cleanly instead of aborting `Fatal{ReplyError}` — the comment ("teardown legitimately reaches here")
is now true rather than contradicted one frame later. (The verifier confirmed the before-state:
respecify ERROR → rc=0 no Fatal; a generated row ERROR → `Fatal{ReplyError,"resource_create"}`.)
**M5 — `Fatal{InitialBytesNotCarried}` role-aware.** `PipeFill.cpp`'s split respecify and flush
follow-up branches now also require `!MG_Remote::Client::RunsAsTheServerRole()` (v1's
`ServerLoop::OnApplyThread()`, newly declared in `WireTables.h` so `PipeFill` needs no server
header). On the apply thread the server-role respecify/flush takes the same route monolith does
(`MGPipeRouteResourceRespecify(desc, initialBytes)`), never the client-record follow-up whose
`ClientWireRecordsEmitted()` self-check would abort the server (the split respecify branch also gave
the server a `respecify(nullptr)+subdata` path monolith lacks — both gone). Proof the server never
reaches it on the joint: the 14/21 split lane holds; the census shows no
`Fatal{InitialBytesNotCarried}` from `mgl-srv-apply`.
**M6 / codex 8 — the red-check runner.** Rewritten (`~/w7/p5-c1-r3-redcheck.py`): (1) every case
asserts its OWN string — a `[ FAILED ] Suite.Name` line for a unit control, a named `Fatal{...}`
read from the per-case `MOBILEGL_LOG_FILE_PATH` for a death control; `rc!=0` and a bare
`[ FAILED ]` are no longer accepted. (2) A perturbation that does not compile is a HARNESS
failure, never a red. (3) Every case restores, rebuilds and re-runs its baseline GREEN, and the
integration cases (ID47b, M8) are included in that restore — round 2 excluded `MobileGLIntegrationTest`.
(4) Non-zero exit if any control did not go red, any baseline is not green, or any perturbation
failed to build. Result: **9/9 RED, restored baseline GREEN each, no harness failures, exit 0.**
**M7 — `ClientWireRecordsEmitted()` is not what arms the lane.** Corrected the false claim in
`WireTables.h` (round 2 called it "t1's fourth arming fact"): the harness reads the encoder's
`EmitSeq` (`SplitRuntimePeek.cpp:50`, `ScenarioFixture.h:85`), which moves for the class-B verbs
too. `ClientWireRecordsEmitted()` counts the ROUTED ordinal and is read only by `PipeFill`'s
`InitialBytesNotCarried` self-check; making the harness read it instead is **t1's `SplitRuntimePeek`**,
so I corrected the header rather than assert a fact I cannot make true, and the note names t1 as the
owner of the re-point.
**M8 / ID-57 — the pack-PBO destination.** `EmitReadPixels` now refuses a bound
`GL_PIXEL_PACK_BUFFER` BEFORE emission and before `pixels` is touched:
`Fatal{UnmigratedVerb, "ReadPixels+PACK_BUFFER"}` (R-4 class-C shape), under an active transport
only (the emit table is installed only under split). **Red once:** the red-check forces the PBO
probe true and drives the split lane → the named Fatal fires (verified RED, rc=-6, baseline
restored green). Under monolith the path is unchanged (the emit table is never installed). The real
form (server writes the reply into the buffer, b1's `MarkReadPixelsPackBuffer` as the producer) is
the P6 ROADMAP item ID-57 records.
**codex 6 — `PACK_SKIP_IMAGES` applied to a 2-D read.** `ReadbackPackStateIsTight` no longer rejects
on `SkipImages`, and `ScatterTightReadbackIntoPackState` no longer offsets by
`SkipImages*ImageHeight*stride` — GL ignores the image-level pack params for glReadPixels, as the
monolith path does with `honorPackImageParams=false` (`DirectGLES.cpp:10905`). New
`RemoteReadback.PackSkipImagesIsIgnoredForATwoDimensionalRead`: a 4×3 RGBA8 read with
`SKIP_IMAGES=1` lands at bytes 0–47 (was 48–95) and 48–95 keep their sentinel; the fast path takes
it. **Red once:** the red-check re-adds the SkipImages term → the case fails (verified RED).
**codex 4 — `Stop` reinstalled the monolith adapters while the transport was live.** New atomic
`g_clientTablesUninstalled`; `UninstallClientWireTables()` now RAISES it (does not reinstall
monolith) and `RequireSession` reads it first, aborting `Fatal{ClientTablesUninstalled, "<row>"}`
before any ring access. `ClientSession::Stop` calls Uninstall at the top (as before) and
`ReinstallMonolithAfterTeardown()` at the very end of BOTH paths — so during teardown a routed
GL-thread call refuses by name, and only once the rings are freed do the monolith adapters go back
for the at-exit `~BufferObject` deletes. New
`PipeRouting.ARoutedCallDuringTeardownRefusesByNameNotRunsTheApplier` (fork). **Red once:** the
red-check reverts Uninstall to `MGPipeInstallMonolithTables()` → the routed call runs the applier,
no refusal → the case fails (verified RED).
**codex 12 — a repeated `MakeEGLCurrent` did not adopt its new caps.** `BackendObject_Remote::
MakeEGLCurrent` now, after the base call succeeds and for a non-release make-current, pumps the
control plane and refreshes the format caps — so `ServerMakeEGLCurrent`'s republished snapshot is
adopted on EVERY successful make-current, not just the first-per-surface one the base runs
`InitCapabilities` for. R-12 arm (a) now holds at the make-current that caused it. (The verifier's
control: change a server cap, repeat make-current, read the mirror generation + a public getter
without a manual pump/Present — measured before-fix as `gen 3→3`; after this it advances.)
**item (b), coordinator — `Fatal{BlobMissing, "SetDynamicState"}`.** `set_dynamic_state` carries an
OPTIONAL blob, not a mandatory one: `EmitRenderState` (`PipeFill.cpp:2405`) sends a version-only
update with `ChunkMask==0` and zero bytes, which the round-2 `MGP_WIRE_BLOB` wrapper's
`StageRequired` aborted on. `Wire_SetDynamicState` is now hand-written and uses `StageOptional`
(like the two sub-data rows); the decoder already took the `ChunkMask==0` arm
(`PipeWireCodec.cpp:1582`, `CheckBlobIsHonest`, no blob resolved). Classification: it was a c1
round-2 regression that turned a legal header-only update into a blob-shape abort on the ordinary
inproc lanes, masking the honest class-C death. Confirmed: on this head `BlobMissing` appears **0
times** in the full inproc census, and `CrossFrameBufferScenario` now dies at its honest
`Fatal{UnmigratedVerb, "DrawElements"}`. (Not unit-red-checkable without a session + empty-chunk
draw; covered by the census probe.)
**The six minors (`c1-review-v2.md` §Minors).**
- **m2** (routed rows ran monolith after Stop; Uninstall before the `!m_started` early return):
addressed by codex 4 — routed rows now refuse `ClientTablesUninstalled` during teardown, and
`ReinstallMonolithAfterTeardown` runs on the failed-Start early-return path too, so "the arm is
monolith" after a failed Start is once again true.
- **m6** (`ImageHeight` ignored / `ROW_LENGTH<width` overlap): the `ImageHeight` half is resolved by
codex 6 (it is no longer consulted). The `0<ROW_LENGTH<width` overlap is documented as a
deliberate verbatim re-derivation of GL 8.4.4 (the fast path rejects any `ROW_LENGTH!=width`, so
the scatter only runs on the layout the application asked for, and it reproduces what the monolith
scatter would do) — a comment, per the reviewer's "say so".
- **m1** (the four escape-row generated thunks point at null members): NOT closed with a marker, by
judgment. Installing a `Fatal{RowIsAnEscape}` marker into `gMGPipeScreen.ResourceRespecify` etc.
reshapes `PipeCatalogueTest`'s 33/4/37 partition (a gate the integrator reads) for DEAD code — the
generated thunks `MGP_ResourceRespecify`/`MGP_MapPersistent`/`MGP_ResourceFlushRange`/
`MGP_CreateShaderState` have zero callers (the routes go through `gMGPipeRouteEscapes`, and
`PipeCatalogueTest` pins `escapesInstalled==4`). Marked, not refuted; what would close it is the
marker + a catalogue-test update, if the integrator wants the partition reshaped.
- **m3** (two counters, `MGPipeRepliesTaken` thread_local vs `ClientWireRecordsEmitted` plain
global; no test over the second): left as-is with a note. `ClientWireRecordsEmitted` is the GL
thread's (routed emits happen there), so a plain global is correct; a unit test cannot move it
without a session, so its coverage is the split lane's EmitSeq/ordinal, not a unit case. Debt.
- **m4** (rule-A cross-checks inert: no split entry uploads a texture or uses a default UBO): a
coverage gap, not a code defect — no reduced-path scenario exercises `SetGlobalConstants`'
`GlobalUboSize` or the texture `ResourceSubData` `levelBytes` check. Debt for a P6 scenario.
- **m5** (the generator change ships no negative control of its own): `gen_pipe.py` is c0's, changed
under R-17's grant; adding a `--self-test` trip for the `kHasBlob` pair is more generator editing
than the grant covers. Debt for the generator owner; `--check` already catches a stale `.inc`.
---
## 2. The census triage (inproc `integration-gpu`, this head, init patch applied)
`~/w7/p5-c1-r3-census.log`, 1149 entries: **420 passed / 182 skipped / 517 aborted / 27 failed /
3 segfault** (ctest: 52% passed, 547 failed). The verifier's pre-round-3 census was
386/180/558/23/2; this head has more passed and fewer aborted because item (b) let the
`SetDynamicState` scenarios proceed. Triage, one probed line each
(`MOBILEGL_LOG_FILE_PATH`, `~/w7/p5-c1-r3-probe-*.log`):
- **c1's: zero.** `BlobMissing` appears 0 times (was the only c1 census defect; fixed). The
`HandleRecycle` family (3 entries) moved off the BlobMissing abort to an honest assertion failure
— they now run past `set_dynamic_state`.
- **class-C-by-design (the 517 aborts + most of the 27 assertion-fails):** the inproc census forces
every non-reduced scenario onto the 6-slot reduced path, so they abort `Fatal{UnmigratedVerb}` at
their first unimplemented verb (`DrawElements` both backends; `BeginTransformFeedback`
`AsyncCompile`) or, when the verb produces a wrong-but-non-fatal result, fail their own SSIM/pixel
assertion (`LayeredAttachmentShapeScenario` 14, `PrimitivesGeneratedNoXfb` 3,
`TextureParamsWithoutASamplerView` 1, `P4aFinalFix` 1). CONTRACT §7 by design.
- **v1's:** the 3 segfaults are `PixelStoreSweepScenario` (×2) and `DepthStencilReadbackMatrix`
(Vulkan) — the ID-49 server-half pack-state overrun (absent on my head; v1's `p5/v1` now has the
neutral-pack fix `61d6cd8e`) and the repeated-context teardown crash the same-family review §5
flagged (v1's `Doorbell::Kill`/join loop, reached through the EGL seam). The 7 Split
`PersistentCoherentMap` aborts are v1's flush seam (item-12, `p5/v1 05bcb734`).
- **v1's (ID-49) again:** `DepthStencilReadbackMatrix.GetTexImage...` assertion fails (×2) are the
same pack-state family.
None of the tail is c1's on this head.
---
## 3. Report corrections (round-2 `c1-v2.md` §6 / the reviews' claims)
- **The "7 / 1149" monolith sentence was wrong twice** (verifier §C(i)). Under
`MOBILEGL_TRANSPORT=monolith ctest -L integration-gpu` on `build-split`, the 1128 non-Split
entries are green (**1128/1128** on `build-push`, **1149/1149** on `build-split` this head) and
the 21 `DirectGLES.Split.*` entries carry an `ENVIRONMENT` property that forces them to inproc.
Without the init patch they **skip** (`ClientSession::Active()` null → `GTEST_SKIP`), so the
build-split monolith lane is 1149/1149 with 21 skips; the round-2 saved log's **19 failed** were
those same Split entries FAILING (not skipping) without the patch; the **7** is the count WITH the
init patch (the flush seam). All three are honest for their condition; the round-2 sentence
conflated them.
- **Installation is after an ATTEMPTED caps pump, not a successful first adoption** (verifier
§"claims"): `ClientSession.cpp:526` warns if the pump adopted zero and continues to
`InstallClientWireTables()` at `:574`. Corrected.
- **`ClientWireRecordsEmitted` is read by no test / does not arm the lane** — corrected in code and
header (M7).
---
## 4. The four self-tests (head `5682f429`, five build dirs, all cfg+build rc=0)
- **G1** against the ID-44 baseline (`.READY`=`4595163c`): `.text 10806611 → 10806611 (+0)`,
`27814 → 27814 defined: 0 added, 0 removed, 0 resized, 0 renamed`; pull `MG_Remote` symbols 0,
split 606. Every round-3 change is push/disaggregated-only.
- **`ctest -L unit`**: pull **1816/1816**, push **1816/1816**, verify **1816/1816**, split
**2030/2030**, verify-split **2030/2030** (was 2025; +5 new controls, all passing).
- **`integration-gpu` monolith**: `build-push` **1128/1128** (G2); `build-split` **1149/1149**.
- **Generators**: `gen_pipe --check` / `gen_pipe_field_ownership --check` up to date;
`check_include_closure` 4 probes / 0 problems. No `.def` touched.
- **G2/G14 names** (`~/w7/p5-c1-r3-names.sh`, LC_ALL=C): baseline 2902, push 2944, split 3179;
**push-vs-baseline 0 removed / 42 added**, **split-vs-push 0 removed / 235 added** (21 are
`DirectGLES.Split.`; the rest are P5 unit cases incl. the new `RemoteReadback`/`PipeRouting`
ones). G5 p3a/p4a untouched-region scripts rc=0.
**Joint `integration-split` under inproc, WITH the integrator's `Init.cpp` one-liner: 14 / 21.**
Both `TriangleScenario` entries and all five `ClearThenReadPixelsScenario` entries pass on both the
default and `SmallRing` arms — the first IPC frame still renders. The 7 failures are all
`PersistentCoherentMapScenario` (v1's flush seam). WITHOUT the patch the 21 skip (no session).
---
## 5. What v1 / the integrator must provide
1. **The `Init.cpp` direct-construction one-liner stays the integrator's merge hunk.** I checked
`git log p5/v1`: v1 has **not** committed it — `Init.cpp:163` still calls the weak
`MG_Remote::Client::CreateRemoteBackendObject()` and `ServerLoop.cpp:877` still ships the weak
placeholder. I tried the clean alternative — c1 providing the STRONG definition in
`BackendObject_Remote.cpp` (which v1's comment invites) — and it does **not** work: libMobileGL
links from a static archive, `ServerLoop.o`'s weak satisfies `Init`'s reference first, nothing
else references the strong TU, so `BackendObject_Remote.o` is never pulled and the weak's abort
fires (measured: `readelf` one local symbol, the log shows `Fatal{UnimplementedRemoteBackendObject}`).
The patch works because it constructs `BackendObject_Remote` DIRECTLY, forcing the TU in and
bypassing the symbol. So the merge needs either v1's `Init.cpp` edit or a `--whole-archive` /
forced reference — a link decision in v1's/c0's territory, not c1's. Reverted; no dead code shipped.
2. **`ScopedApplierEntry` bracket in `PipeApplier::ApplyOne`** (v1's file) — arms M1's
`Fatal{BarrierViolation}`. Until it lands, c1's check is inert; the string is `MGLOG_F` so
ID-53's E1 reads it once the joint-merge package gives the `Split.` lanes a `MOBILEGL_LOG_FILE_PATH`.
3. **The `resource_flush_range` server half** (v1's item-12, `p5/v1 05bcb734`) — the last blocker
for the 7 remaining split entries.
4. **codex 7's second check at the residual fill** belongs in p1's `MGPipeValidateForVerb`.
5. **The `DstSize` formula both sides agree on:** `DstSize = width * height *
GetInputBytesPerPixel(format, type)` — the TIGHT extent, neutral pack state, one function
(`TightReadbackBytes`, `EmitTables.cpp`). v1's `OnReadPixels` must read with neutral pack state
into exactly that many bytes (ID-49); the client scatters per the app's pack state.
Accepted and NOT moved (ID-55): the `PostReply` hunk in w1's `PipeWireCodec.cpp` and the two CMake
lines.
---
## 6. Debts
1. `resource_flush_range` bytes under split (the 7) — v1's.
2. M1's arming (v1's bracket) and codex 7's fill-side check (p1's) — named above.
3. m1 (escape-row markers), m3 (the second counter's storage/coverage), m4 (rule-A cross-checks
have no reduced-path exerciser), m5 (generator self-test trip for the `kHasBlob` pair) — §1 minors.
4. E2's emitter-drop control is armed (`SetDropClearEmissionForNegativeControl`,
`MOBILEGL_IPC_E2_DROP_CLEAR`) and unit-pinned but still not RUN by c1 (OpenRA/SSIM, no adb, no
LFS) — t1's trace lane.
5. `MapPersistent` under split is asserted to DECLINE loudly (`Fatal{UnexpectedMapAccept}`); the day
P6 gives it a real remote map, that Fatal is the line to change.
6. `MarkGpuWritesForDispatch` still has no gate (DispatchCompute is class C); the XFB span family
still needs an `MGPCapBit` (c0's `MGPipeTypes.h`).