mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-19 07:51:57 +09:00
[Docs] (.claude/skills, .github/workflows, CMakeLists.txt, docs/archive, docs/Disaggregated, docs/MobileVA, docs/Performance, MG_Backend, MG_Backend/DirectGLES, MG_Backend/DirectVulkan, MG_Backend/Record, MG_Gbm, MG_Impl, MG_Impl/EGLImpl, MG_Impl/GLImpl, MG_Impl/GLXImpl, MG_Impl/Pipe, MG_IntegrationTest, MG_IntegrationTest/Harness, MG_IntegrationTest/Scenarios, MG_Pipe, MG_Pipe/generated, MG_Remote, MG_Remote/Client, MG_Remote/Server, MG_Remote/Transport, MG_Remote/Wire, MG_State/GLState, MG_Test/Pipe, MG_Test/Util, MG_Test/Wire, MobileGL, scripts, scripts/data, tools/device_bench, userguide): archive the planning notes and agent contracts under docs/archive
- DEBTS.md and OPEN-QUESTIONS.md stay maintained, now in docs/Disaggregated.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,275 @@
|
||||
# P3a integrator decisions (feat/disaggregated, 2026-09-08)
|
||||
|
||||
## ID-1 The base ref is `44c2b5cf`, not the brief's `55d2af9b`
|
||||
`BRIEF-P3A.md` was verified at `55d2af9b`. P2 landed four more commits before P3a started: `c73ae7d4` (pins
|
||||
`MOBILEGL_PIPE_PUSH=0x7f` in the itest Handles lanes: `MG_IntegrationTest/CMakeLists.txt`), `a9778eaa` + `738b289d`
|
||||
(the ABA generation-coverage fix: `MG_Backend/DirectVulkan/Renderer/{MagmaPipeArms.h, VertexInputStateFactory.cpp,
|
||||
VulkanRenderer.cpp}`, `MG_IntegrationTest/Scenarios/HandleRecycleScenario.cpp` (comment), `MG_Test/Pipe/CMakeLists.txt`
|
||||
+ new `MG_Test/Pipe/MagmaPipeIdentityTest.cpp`), and `44c2b5cf` (docs only). **Every P3a tree branches from `44c2b5cf`**
|
||||
and `$BASE` = `44c2b5cf` in every command the brief writes as `55d2af9b`. Brief line numbers are still exact for every
|
||||
file except those seven; a package touching `HandleRecycleScenario.cpp`, `MG_IntegrationTest/CMakeLists.txt` or
|
||||
`MG_Test/Pipe/CMakeLists.txt` re-opens the file before editing. The `~/w7/p3a-before-*` baselines were captured at
|
||||
`44c2b5cf` (2482 ctest names; pull lib; `RenderStateImpl` sha `d8fd1c48...`).
|
||||
|
||||
## ID-8 Landed so far (feat/disaggregated in ~/w7/pipe, pushed to origin)
|
||||
- contract c0: `39722687` (tag `p3a/contract`, packages branch here) rebased onto the P2 docs commits as
|
||||
**`e01c0ccc`** — pull symbols 0/0/0/0, unit 1571 x 3, +5 test names. Package branches rebase onto
|
||||
`refs/heads/feat/disaggregated` (spell branch refs fully: the tag makes `p3a/contract` ambiguous);
|
||||
the duplicate c0 patch drops out of the rebase automatically.
|
||||
- contract review v1: ACCEPT WITH MINORS; M1 (Coverage.def target split omits DispatchIndirect/Query) and
|
||||
item 9 (SetVertexBuffers Start+Count policing) go to wire's rework; M2 (GetOrCreate(MGPipeHandle) adopts a
|
||||
stale generation) goes to espryt's e1; item 11 (0x7f-pinned itest lanes need a 0x1ff arm) goes to gates.
|
||||
|
||||
- wire v1: db0c93bb / cede041d / e9b4a263 on p3a/wire; review v1 = REWORK (C1 records wiped on every
|
||||
make-current via Tracker.h:192-195's Reset; C2 serials zeroed on reset; M1; c2 zero test coverage; the
|
||||
PipeLiveHostWrites control; RecordAt bound; Blob rule). Rework in flight with a **granted waiver** to touch
|
||||
Tracker.h:192-195 minimally if the fix needs it (B rebases across it).
|
||||
- espryt v1: 9ae4ec09 / de13c588 / 855272e5 / 469f78b8 / a9a1d0eb / 203120fa on p3a/espryt; legacy arms
|
||||
461/461, default arm 202/461 red all attributed to the stub applier (expected until wire+client land);
|
||||
review v1 in flight. Accepted-in-principle deviations: g_pendingFetchBaseInstance/ScopedFetchBaseInstance
|
||||
stay under MOBILEGL_PIPE_LEGACY_MEMOS (deleting them is a G1 break, so C.2's "grep empty" line is not
|
||||
achievable in P3a - D.5 must say so); MGPipeSetResourceOps installed from RegisterBufferBackendOps;
|
||||
the fp64 stream's SyncGpuWrites stays frontend-side (D-N) - DoublePrecisionScenario is a post-rebase watch item.
|
||||
espryt review v1 = REWORK: C-1 the draw-clean test replaced IsMapped() with HasLiveHostWrites (pinned false
|
||||
=> mapped non-adopted buffers never resync), C-2 a cached raw hostBytes base dangles after adoption/resize
|
||||
(fp64 narrowing UAF, undeclared pool gate), majors: contract M2 unaddressed, attribute walk bounded by
|
||||
AttributeCount drops the disable arm, bit 8 without bit 7 advertised but non-functional, PipeLegacyMemos
|
||||
ignored by the new arms, memo safety silently depends on wire's serial rule. Rework in flight (rebases onto
|
||||
5cb826b0 first, ID-9/ID-10/ID-11 applied).
|
||||
|
||||
## ID-8b wire integrated: feat/disaggregated = `12e6bfcf` (pushed)
|
||||
wire v2 (six commits: c1 45c8f1a8, c2 6eb0e675, c3 355c60b9, then the rework 56366331 / e6452ce9 / 12e6bfcf)
|
||||
rebased onto 5cb826b0 and fast-forwarded; pull symbols 0/0/0/0 against the 5cb826b0 baseline, unit 1599 x 3,
|
||||
G2 0, G14 0 removed / +17. Applier rule from here on: object records survive make-current; only
|
||||
MGPipeApplierReleaseObjectRecords (unwired in monolith) drops them; refusals are counted; serials only advance;
|
||||
one Blob rule (0 = not declared). Client's rework runs against this tree.
|
||||
|
||||
## ID-8d client integrated: feat/disaggregated = `31e370be` (pushed)
|
||||
Between wire and client two version bumps landed on the branch (42d43af2 gradle 26.09, b9eaa474 CoreVersion
|
||||
26.9), so the G1/G14 baseline was re-captured at b9eaa474 before the merge. client v2 (eight commits, rework
|
||||
d9bde131 / f11e78b0 / 0c555605 / 31e370be) fast-forwarded; pull symbols 0/0/0/0, unit 1617 x 3, G2 0,
|
||||
G14 0 removed / +18; client's own tree had integration-gpu 920 x 3 arms, integration-verify 832, retrace
|
||||
79/79 verify-armed zero divergence. espryt v3 (verification round on this tree) in flight; gates integrates
|
||||
after espryt.
|
||||
|
||||
## ID-8e all four packages integrated: feat/disaggregated = `3e298c9a` (pushed)
|
||||
espryt v3 (`3c55e027` + the integrator's BufferTest fixture commit `83302ca2` — ID-14 below) then gates v2
|
||||
rebased and fast-forwarded (`3e298c9a`). On the finished tree: pull symbols 0/0/0/0 vs the b9eaa474 baseline,
|
||||
G5 ten functions byte-identical vs 5cb826b0 AND vs 44c2b5cf, G5 self-test, unit 1619 x 3, G2 0, G14 0 removed
|
||||
/ +58, HandleRecycle (verify) 60/60, mpr + ResourceSubsystemControl (push) 34/34, G7 tripped naming IsBgra.
|
||||
espryt v3's real-path round found and fixed three seam defects (vertex buffer resolved by GL binding point
|
||||
instead of attribute index; a stale descriptor consulted for the shadow on full re-upload; the shadow base not
|
||||
published for a lazily twinned store) - the verification round was load-bearing. In flight: the full
|
||||
five-part gate (three retrace sweeps) on ~/w7/pipe, the final whole-diff review (5cb826b0..3e298c9a), the
|
||||
pull/push trace APKs for the D.4.2 device A/B, and the P3a docs.
|
||||
|
||||
## ID-14 Ownership waiver: `MG_Test/Buffer/BufferTest.cpp`'s fixture
|
||||
C.5 gives that file to nobody. Under a push build the backend installs both `BufferBackendOps` and
|
||||
`MGPipeResourceOps` at bring-up, so `ScopedBackendOps` (which scoped only the former) let 26 of the 86
|
||||
BufferBackendOps dispatch cases route into the pipe. The integrator landed the one-scope fix espryt-v3 §7
|
||||
measured (`83302ca2`): the fixture now saves/nulls/restores the pipe table exactly as ResourceEmitTest's
|
||||
ApplierGuard scopes the applier. It weakens nothing (the pipe-side dispatch has ResourceEmitTest's own
|
||||
coverage). Follow-up for a later phase: a pipe-shaped mock so the same 86 assertions run over the handle path.
|
||||
|
||||
## ID-15 Final whole-diff review = REWORK; C-2 ruling supersedes ID-13's "outside any #if" sentence
|
||||
Full five-part gate on 3e298c9a: all green (G1 0/0/0/0, G5 byte-identical vs 44c2b5cf and 5cb826b0 + self-test,
|
||||
HandleRecycle 60/60, unit 1619 x 3, G2 0, G14 0/+58, integration-gpu 958/958 x {0x1ff, 0, 0x7f} + the
|
||||
ESPRYT_DISABLE_INVALIDATE_FLUSH arm, buffer/VAO family 202/202, g7 + G7 tripped, CsoContentAddressing +
|
||||
ResourceSubsystemControl 10/10, controls 64/64, integration-verify 842/842 zero Fatal, retrace verify 79/79
|
||||
armed zero Fatal, retrace push 79/79). The G3b named sub-sweep matched 0 cases because `retrace_gate.py
|
||||
--only` is a regex and the gate script passed a comma list (fixed in wsl_p3a_gate.sh; the five cases passed
|
||||
inside the full sweeps). final-review-v1: C-1 the client-minted VertexElementsCso slot has no backend-neutral
|
||||
death path (Magma installs no death ops: leak per VAO at 0x1ff, Fatal past 65536 slots); C-2 FlushPendingRangesNow
|
||||
sits inside the pull-only #else, so push builds compile only FlushPendingRangesFrom and G5's text hash does
|
||||
not cover the shipping ladder. **Ruling for C-2:** FlushPendingRangesFrom becomes the ELEVENTH G5 row with
|
||||
its own baseline sha (captured at 3e298c9a); FlushPendingRangesNow stays byte-identical where it is (G1 is
|
||||
what protects the pull build); the two-arm shape is stated at Managers.cpp:1127-1138. M-3 (the fp64 stream's
|
||||
dropped SyncGpuWrites site) is a RULED deviation for P3a. The rework runs on ~/w7/p3a-final (branch p3a/final
|
||||
from 3e298c9a); it lands as the last P3a commits. The device A/B and the bench are recorded against the
|
||||
3e298c9a APKs (the rework is lifecycle/seam correction, not a cost change) - the docs say so.
|
||||
|
||||
## ID-9 dev merged mid-phase: feat/disaggregated = `5cb826b0` (pushed), baseline re-captured there
|
||||
`dev@9eae9858` (two commits past our P2 base: `d7655247` rebinds VAOs when an adopted store is respecified -
|
||||
a 5-line fix in Managers.cpp's immediate retire path - and `9eae9858` adds the persistent-buffer ordering
|
||||
POST probe) was merged into `~/w7/pipe` as `5cb826b0` right after the contract, so every remaining package
|
||||
rebases across it once. **The `~/w7/p3a-before-*` baseline is now the pull build of `5cb826b0`** (2502 ctest
|
||||
names, 1582 unit); G1 for every later package is measured against that. Consequences: espryt's rebase
|
||||
conflicts in Managers.cpp and the d7655247 fix must be present in BOTH the legacy and the handle arm of the
|
||||
respecify/retire path (the handle arm duplicates that core); gates' rebase conflicts in
|
||||
LargeArenaAdoptionScenario.cpp (dev added cases there, gates added the mpr assertions and the second arena) -
|
||||
resolve by union, keep every test name from both sides. wire and client do not touch those files.
|
||||
|
||||
## ID-10 Ownership grant: the three `*BaseInstance` draw entry points in `MG_Impl/GLImpl/GL_Drawing.cpp`
|
||||
The brief's ownership table gives `MG_Impl/GLImpl/**` to nobody, yet D-H2 needs `MGPipeSetPendingBaseInstance`
|
||||
called from the three `glDraw*BaseInstance` entry points (client-v1 finding 1: no call sites, so the emitted
|
||||
BaseInstance is always 0). Package B's rework is GRANTED those three one-line call sites (and nothing else in
|
||||
GL_Drawing.cpp); the reset in `MGPipeLeaveVerb` stays B's. Until they land, espryt's handle arm reads a
|
||||
`VertexFetchBaseInstance` of 0 - the DrawParameters / VertexAttribBinding base-instance scenarios are the gate
|
||||
that must go red without the call sites and green with them, and the integrator checks both directions once
|
||||
on the finished tree. client v1: 73bab3d6 / 1ae6b4f4 / 71805d59 / a0ac79cc on p3a/client; review v1 in flight.
|
||||
|
||||
## ID-11 G5's byte-identical set is ten functions
|
||||
The brief's G5 row names nine (`IsPoolable`, `EnrollIntoPool`, `AcquireFromPool`, `TrimBufferPool`,
|
||||
`ClearBufferPool`, `ProcessDeferredBufferReleases`, `CreateRingStorage`, `RingAvailable`, `RingAllocate`) but its
|
||||
text (BRIEF-P3A.md:420, :1708) twice calls `FlushPendingRangesNow` G5-protected and names it as the only
|
||||
mitigation of the tier-drain p99 risk. Decision: **`FlushPendingRangesNow` is the tenth**. The handle arm must
|
||||
call the untouched function; a copy under `#if MOBILEGL_PIPE_PUSH` is a G5 break espryt's rework restores.
|
||||
gates v1: 1ef91dec / 588d25e9 / 80f6bf1b; review v1 = REWORK (four majors: three CSO stats lanes still pinned
|
||||
0x7f, the ResourceSubsystemOn/Off entries unreachable from CI's -R, the G7 script not rebuilding on its
|
||||
"did not trip" exit, FlushPendingRangesNow missing from G5); rework in flight, rebasing onto 5cb826b0 first
|
||||
and undoing the second-arena workaround that d7655247 makes unnecessary.
|
||||
|
||||
## ID-12 client review v1 = REWORK; cross-package items
|
||||
B-C1: Tracker.h:373 zeroes m_pendingBaseInstance in Reset() (called on every make-current) - delete the line.
|
||||
B-C2: no re-publication path for resource records after MGPipeApplierReset - **resolved together with wire's
|
||||
rework C1**: the applier keeps resource/vertex-elements records across make-current and clears them only at
|
||||
context destruction; the client therefore needs no re-publication on FreshlyPrimed, but must state that as
|
||||
the rule (not "absence as policy") and cover context destruction (ResourceDestroy from ~BufferObject is the
|
||||
only path). The client rework starts after wire-v2.md exists and reads it first.
|
||||
Majors for the client rework: the three call sites at GL_Drawing.cpp:662/684/713 (ID-10); Acquire mutating the
|
||||
global slot allocator on Espryt's off-thread SubData path; the sampled BindMask's DSA hole; the absent
|
||||
UnmapPersistent producer (record it or add it). Cross-package: the `hostBytes` base-vs-base+offset mismatch -
|
||||
B is brief-conformant, **espryt must change** (goes into espryt's post-rebase verify round, ID-13 when opened).
|
||||
|
||||
## ID-13 G1 vs G5 on `FlushPendingRangesNow`: one untouched definition, a separate handle-arm ladder
|
||||
gates v2 (`2bafb316`, 8 commits on 5cb826b0; rebased clean, D6 undone, M1-M4 closed, G5 = ten functions) reports
|
||||
G5 rc 2 against espryt (`cdbd5535`): espryt's push arm redefines `FlushPendingRangesNow` as a 3-line forwarder
|
||||
onto a new `FlushPendingRangesFrom` ladder (Managers.cpp:1051-1127), the original body living only in the
|
||||
`#else` copy. Decision: **`FlushPendingRangesNow` is defined exactly once, outside any `#if`, byte-identical to
|
||||
5cb826b0** (that satisfies G1 for the pull build and G5 for the text). The handle arm gets its own
|
||||
`FlushPendingRangesFrom(...)` under `#if MOBILEGL_PIPE_PUSH` that takes the record/twin instead of the frontend
|
||||
object; duplicating the tier ladder there is accepted for P3a (the same shape espryt already used for the
|
||||
respecify core; the legacy copy retires at P13 - ARCHITECTURE.md:367). The pull arm never calls the new one.
|
||||
A shared template over an accessor interface is NOT acceptable: it resizes the pull symbol (G1). espryt's
|
||||
post-rebase round applies this; gates' G5 must then be rc 0 against espryt's tree.
|
||||
|
||||
## ID-8c espryt v2 = `6a1a9bc7` (16 commits on 5cb826b0), gates v2 = `2bafb316` (8 on 5cb826b0)
|
||||
espryt v2: rebased onto 5cb826b0 (trap: the three-way merge put d7655247's ++g_bufferBackendIdGeneration into
|
||||
the legacy arm only; fixed, both arms symmetric), C-1/C-2/M-1..M-5 closed, ID-11/ID-13 satisfied (one
|
||||
definition of FlushPendingRangesNow, ten byte-identical), legacy arms 463/463, default arm 204/463 red with
|
||||
the identical failing set before and after (stub-applier attribution still expected until client lands).
|
||||
Next for espryt: after client integrates, a verify round on the rebased tree (default arm, buffer/VAO family,
|
||||
DoublePrecision, base-instance scenarios both directions per ID-10, retrace), then a focused re-review.
|
||||
|
||||
## ID-2 Integration order: contract -> wire -> client -> espryt -> gates
|
||||
The brief's D.1 order with `wire` inserted after `contract`: `client`'s emissions land in the applier's records only
|
||||
once `wire`'s apply bodies exist, and `espryt` reads those records. `wire` is behaviour-neutral on its own (nothing
|
||||
registers `MGPipeResourceOps` until `espryt`).
|
||||
|
||||
## ID-3 Tool ownership
|
||||
`~/w7/notes/tools/wsl_p3a_gate.sh` and `p3a_ab.sh` are written by the integrator, not by package D; package D's
|
||||
deliverables are the two `scripts/p3a_*.sh` in the repo, the scenarios, the itest CMake rows and `test.yml`. Tree
|
||||
creation is `wsl_tree.sh p3a <slug> <base> [verify]`, integration `wsl_integrate.sh p3a <slug>...` (generalised P2
|
||||
helpers; the phase is a parameter, not a copy of the script).
|
||||
|
||||
## ID-4 Models and rounds
|
||||
Package agents and reviewers run on opus (user rule 2026-09-08: fable only for genuinely hard single items). One
|
||||
adversarial review per package, at most two rework rounds; declared minors do not block integration.
|
||||
|
||||
## ID-5 Durable locations
|
||||
Brief `~/w7/notes/p3a/BRIEF-P3A.md`; scouts `~/w7/notes/p3a/scout-*.md`; package results and reviews
|
||||
`~/w7/notes/p3a/p3a-results/<package>-v<N>.md` and `<package>-review-v<N>.md`; A/B artefacts `~/w7/notes/p3a/ab/`.
|
||||
Package logs under `~/w7/p3a-<slug>-*.log` are deleted by their owner when the round ends.
|
||||
|
||||
## ID-6 Performance is recorded, not gated (user, 2026-09-08)
|
||||
Part 4 of the five-part gate and `ROADMAP.md:19`'s "MC 26.3 在 Adreno 上 p99 不变" are measure-and-publish items
|
||||
against P2's pull baseline (`MEASUREMENTS.md` §10-§12). Parts 1, 2, 3, 5 stay hard gates.
|
||||
|
||||
## ID-7 Working over UNC and WSL
|
||||
Package agents edit their worktree through `//wsl.localhost/Arch/home/swung/w7/p3a-<slug>/...` with the Read/Edit/Write
|
||||
tools (file writes work; `mkdir` does not - create directories from a WSL script). Builds and tests run through a script
|
||||
file: write `<scratchpad>/wsl/<name>.sh` (LF endings) and run
|
||||
`MSYS_NO_PATHCONV=1 wsl.exe -d Arch -- bash /mnt/c/<scratchpad path>/wsl/<name>.sh`; never pass `~` or `$vars` inline to
|
||||
`wsl.exe`. A build or test run longer than ~8 minutes is launched with `setsid nohup ... &` inside the script and polled
|
||||
through its log.
|
||||
|
||||
## ID-16 CI reds on 42d43af2 / b9eaa474 / 31e370be are GitHub artifact-download flakes
|
||||
Every failing job is a `retrace`/`retrace verify` matrix entry whose "Download Linux runtime" / "Download trace
|
||||
fixture" step died with `digest-mismatch` and `Artifact download failed after 5 retries`; no build or test
|
||||
step ran red. 12e6bfcf (wire) was green on the same tree family. The failed jobs of the 31e370be run were
|
||||
re-run; 83302ca2 and 3e298c9a are queued behind them. A red of this shape is not a code signal (the user's
|
||||
rule: only real retrace reds after a successful download matter).
|
||||
|
||||
## ID-17 P2's device A/B APKs were unoptimised; the Release baseline of record is P3a's pull arm
|
||||
The P3a pull APK's libMobileGL.so (Release, arm64) is 15.5 MB with a 9.4 MB .text; the P2 A/B's pull APK
|
||||
(`~/w7/notes/p2/apk/trace-pull.apk`) is 43.2 MB with a 21.8 MB .text, same clang 18.0.4, no .debug_info in
|
||||
either - a 2.3x larger .text is an unoptimised (Debug-flavour, -O0) build, and it replays 26.3 on the Oppo
|
||||
at 42 ms/frame CPU where the Release build takes 9.7 ms. So MEASUREMENTS.md §10's absolute numbers and its
|
||||
+8-18% deltas are -O0 readings (the tracker's inline-heavy code pays most at -O0). Decision: the P3a A/B on the
|
||||
3e298c9a Release APKs is the two-device baseline of record; its pull arm is symbol-identical to the P2-era pull
|
||||
path (G1 across P3a; only d7655247's 5 lines differ from 44c2b5cf). To re-derive P2's own cost at Release, a
|
||||
supplementary arm runs the SAME push APK with `--env MOBILEGL_PIPE_PUSH=0x7f` (P2 subsystems on, P3a off) =
|
||||
the device-side T2 (`p3a_ab_7f.sh`, nofinish only, its own reboot-clean session). The docs get an erratum on
|
||||
§10 and the corrected table; the user is told that the "~10% is acceptable" call was made on -O0 numbers.
|
||||
`wsl_build_trace_apks.sh` prints the lib size so an -O0 APK can never pass unnoticed again (Release .text ~9.4 MB).
|
||||
|
||||
## ID-8f final rework integrated: feat/disaggregated = `c20e2f2b` (pushed) = the P3a landing hash
|
||||
p3a/final (12 commits on 3e298c9a, final-v2.md) fast-forwarded: pull symbols 0/0/0/0 vs b9eaa474, G5 eleven
|
||||
functions byte-identical vs 3e298c9a AND the ten vs 5cb826b0, unit 1622 x 3, G2 0, G14 0 removed / +69,
|
||||
HandleRecycle+VertexElements+Leak (verify) 76/76, Magma CrossFrameBuffer verify 13/13 locally. Open: the
|
||||
CI-only teardown `double free or corruption` on DirectVulkan.Verify.CrossFrameBufferScenario.{Vertex,Index}
|
||||
CopyBufferSubData (3e298c9a run and its re-run; ASan reproduction in flight on a private worktree) - whether
|
||||
c20e2f2b's lifecycle fixes change it is answered by c20e2f2b's own CI run. Docs: P3ALANDHASH -> c20e2f2b;
|
||||
the device A/B and the bench remain recorded against the 3e298c9a APKs (ID-15/ID-17).
|
||||
|
||||
## ID-18 The CI-only teardown abort is a static-destruction-order UAF at exit; fix = never-destroyed singletons
|
||||
asan-doublefree-v1: `exit` -> `PipeInputs::~PipeInputs` (namespace-scope `gPipeInputs` holds a
|
||||
SharedPtr<VertexArrayObject>) -> `~VertexArrayObject` -> `~BufferObject` -> `MGPipeEmitResourceDestroyAndFree`
|
||||
-> `MGPipeSlotAllocator::FindByLifetimeId` on a hash table already freed by `~MGPipeSlotAllocator`
|
||||
(`MGPipeSlots()` is a Meyers singleton constructed at the first buffer, so it dies first). Every case executes
|
||||
the chain; only when the freed table still resolves does `Free()` write freed vectors and glibc reports
|
||||
`double free or corruption` - CI's allocator layout did, ours did not (native repro: `GLIBC_TUNABLES=
|
||||
glibc.malloc.tcache_count=0` makes exactly the two CI cases fail on c20e2f2b and none on the fix). Fix
|
||||
(p3a/asan, rebased onto c20e2f2b as d54ec57a): `MGPipeSlots()`, `MGPipeResourceTrackerInstance()` and
|
||||
`g_applier` become never-destroyed (heap-constructed, intentionally leaked at exit); the C-1 rework's second
|
||||
reaching path (`MGPipeEmitVertexElementsDestroyAndFree` from `~VertexArrayObject`) is covered by the same
|
||||
change. Integrated after the P3a bench finishes reading pipe's libraries.
|
||||
|
||||
## ID-19 P3a DriverBench (desktop, c20e2f2b libs) - recorded, not gated
|
||||
mc_vanilla_draw ns/draw: Espryt pull 5115 / push(0x1ff) 6162 / push(0x7f) 5463 / push(0) 5693; Magma pull 17099 /
|
||||
push 17709 / push(0x7f) 17287 / push(0) 17739. T1 = +1048 (+20.5%) / +611 (+3.6%); T2 (0x7f = P2's boundary) =
|
||||
+349 / +189; **P3a itself = +699 / +422 ns/draw** - the largest boundary cost so far (per-draw vertex-input emission +
|
||||
applier record + Espryt's record walk; Magma's share is pure client emission until P7). blend-toggle +5.2% / +2.8%;
|
||||
pass switch ~0; CSO content addressing ~0. Goes into the optimisation-phase list (per-draw suppression of
|
||||
unchanged vertex-input sets; in-place applier record updates). Device side (Release APKs, 3e298c9a): Oppo 26.3
|
||||
Espryt +8% / Magma +10%, rd12 +30% / +27%, sodium ~0 (sub-ms frames), create-instancing is a 2-frame fixture
|
||||
(not a benchmark). 0x7f arms and the Xiaomi pass in flight.
|
||||
|
||||
## ID-20 CI Test lane green at c20e2f2b
|
||||
The lifecycle changes of the final rework moved the allocator layout enough that CI's two teardown aborts
|
||||
(3e298c9a) no longer surface at c20e2f2b - not a fix, a layout change; the systematic exit-order closure
|
||||
(ID-18 + the 21 knob-only cases) lands as the last P3a commits on p3a/exit and is proven with
|
||||
GLIBC_TUNABLES=glibc.malloc.tcache_count=0 on both lanes before the docs push.
|
||||
|
||||
## ID-21 exit-order closure integrated: feat/disaggregated = `fde5fda3` (pushed) = the P3a landing hash
|
||||
p3a/exit (6515c8e6 leak-at-exit storage for the four static PipeInputs holders; fde5fda3 the four remaining
|
||||
MGPipe singletons never-destroyed) on d54ec57a, fast-forwarded. On pipe: pull symbols 0/0/0/0, G5 eleven
|
||||
byte-identical, unit 1622 x 3, G2 0, G14 0/+69, and with GLIBC_TUNABLES=glibc.malloc.tcache_count=0
|
||||
integration-verify 844/844 and push integration-gpu 966/966. Follow-up outside P3a: IntegerBorderColorScenario's
|
||||
stack-buffer-overflow (pre-existing test bug, ASan). Docs: landing hash -> fde5fda3.
|
||||
|
||||
## ID-22 CI at fde5fda3: every build/test job green; the run is red only in "remove artifact clutter"
|
||||
Its "Delete intermediate Linux retrace artifacts" step died on a GitHub HTTP 504 from `gh api --method DELETE`
|
||||
(housekeeping after all tests passed). Not a code signal. The Test lane's authoritative jobs (pipe-gates,
|
||||
include-graph-check, test, integration, build-linux-verify, integration-verify, retrace, retrace-verify,
|
||||
monolith-symbol-report) all succeeded on the P3a landing hash.
|
||||
|
||||
## ID-23 rd12 on Magma on the Xiaomi aborts on every arm (pull included): pre-existing, excluded from the table
|
||||
scudo map error inside a calloc from libMobileGL (frames 0x818b14 / 0x7e2c44, stripped) seconds after start,
|
||||
with 6 GB available - a giant/negative allocation on the Adreno 830 + Magma path for this fixture, not P3a's
|
||||
(the pull build is symbol-identical to the pre-P3a path). The same fixture runs on the Oppo/Magma and on the
|
||||
Xiaomi/Espryt. Task chip opened (symbolize + fix). Side effect: the GPU pwrlevel pin on the Xiaomi resets after
|
||||
the crash (pin_device reports "range 2..5"), so the Xiaomi's sodium and create-instancing rows after rd12 carry
|
||||
a DRIFT verdict on both arms (still paired). The P2 -O0 Xiaomi table did not include rd12, so nothing is lost
|
||||
against P2.
|
||||
|
||||
## ID-24 P3a closed: docs at `37da3c3a` (pushed); device A/B complete on both devices, three arms
|
||||
Release APKs from 3e298c9a; pull / P2-only (0x7f) / P3a (0x1ff), nofinish primary. P2's boundary at Release =
|
||||
+6-12% p50 on both devices and backends; P3a adds ~0 on 26.3 and sodium but +17-19 points on rd12 (Espryt
|
||||
+30%, Magma +27% total) - per-draw vertex-input emission on VAO/buffer-heavy frames; MC 26.3 p99 on Adreno
|
||||
pull 25.46 -> P3a 26.32 ms (+3.4%). mpr on device: 26.3 = 8 per run, sodium 1. Excluded: Xiaomi rd12/Magma
|
||||
(pre-existing abort, ID-23), create-instancing (2-frame fixture), sub-ms sodium rows (noise). Artefacts:
|
||||
~/w7/notes/p3a/ab (60 benchmark.json) and ab7f (15), ab3-final.md; bench ~/w7/notes/p3a/bench/driverbench.md.
|
||||
Next: P4a (handle wave 2: FBO / texture / sampler / program). Optimisation-phase list carries: the per-draw
|
||||
vertex-input emission cost, IntegerBorderColorScenario's ASan finding, rd12/Magma/Adreno abort, the
|
||||
harness pidof single-sample kill, create-indirect on dev.
|
||||
@@ -0,0 +1,117 @@
|
||||
# P3a — handle wave 1(Espryt):buffer、VAO(`fde5fda3`)
|
||||
|
||||
> 本页是该阶段的**阶段汇总**:阶段表行、实测与落地形状的完整文本(2026-09-24 从上层索引移入,原文照录)都在这里;上层只留摘要——[`ROADMAP.md`](../../../Disaggregated/ROADMAP.md)、[`MEASUREMENTS.md`](../../../Disaggregated/MEASUREMENTS.md)、[`ARCHITECTURE.md`](../../../Disaggregated/ARCHITECTURE.md)。文中 `file:line` 与"今天""当前"按各段写成时的头理解;文中的 `MEASUREMENTS.md §N` / `ARCHITECTURE.md §17.x` 编号保留,对照表见 [`../README.md`](../README.md)。
|
||||
|
||||
## 摘要
|
||||
|
||||
- 落地:九条 `resource_*` + 五条 vertex-input 调用接到句柄形 `MGPipeResourceOps`;第七张 Espryt slot 表;`ResourceRespecify` 的 `kNeedsAck` 谓词;VAO twin 六条身份 memo 在句柄臂退役、四条重键;`mpr` 定义;子系统位 7/8,push 默认 `0x1ff`。
|
||||
- 门:五部分门全绿,G1 0/0/0/0 `.text +0`;G5 十一函数;单元 1619×3;`integration-gpu` 958 五臂;verify 842;retrace 79/79 ×2。实际 1 天(绊线 27 天)。
|
||||
- 记录项:rd12(VAO 切换密)上 P3a 把 Release 帧 p50 差距从 +11% 推到 +27–30%;DriverBench 每 draw 多 Espryt 699 / Magma 422 ns。
|
||||
|
||||
## 阶段表行(原 `ROADMAP.md`)
|
||||
|
||||
- **阶段**:**P3a** handle wave 1(Espryt):buffer、VAO
|
||||
- **状态**:✅ `fde5fda3`
|
||||
- **落地什么 / 范围**:九条 `resource_*` + 五条 vertex-input 调用接线到句柄形 `MGPipeResourceOps`;第七张 Espryt slot 表;`ResourceRespecify` 的 `kNeedsAck` 谓词;VAO twin 六条身份 memo 在句柄臂退役、四条重键;`mpr` 定义;位 7/8,push 默认 `0x1ff`
|
||||
- **验收门 / 证据**:五部分门全绿:G1 0/0/0/0 `.text +0`;G5 十一函数;单元 1619×3;`integration-gpu` 958 五臂;verify 842;retrace 79/79 ×2。实际 1 天。§4
|
||||
|
||||
## 实测:P3a(`fde5fda3`,基线 `5cb826b0`,44 个提交,37 文件 / +9273 / −230)(原 `MEASUREMENTS.md` §4)
|
||||
|
||||
### 4.1 五部分门(本地 `~/w7/pipe`)
|
||||
|
||||
| 门 | 结果 |
|
||||
|---|---|
|
||||
| 构建 pull / push / verify | rc 0 / 0 / 0(fail-fast,绝不拿陈旧二进制下判决) |
|
||||
| A 门 include 闭包 / C 门 `pGLContext` / G13 | 4 probes 0 problem / 空 / 空 |
|
||||
| **G1** | `.text` 10806323 → 10806323(+0);27811 符号 **0 / 0 / 0 / 0** |
|
||||
| **G5** 十一函数(pool / 延迟释放 / ring / `FlushPendingRangesNow` 与 `FlushPendingRangesFrom`) | 对 `44c2b5cf` 与 `5cb826b0` 都逐字节相同;self-test 两个阴性对照按名变红 |
|
||||
| `integration-verify` / 79 retrace verify | 842/842 零 `Fatal{` / 79/79 armed 零分歧 |
|
||||
| G2 / G14 | 差 0 / 0 删除 +58 |
|
||||
| 单元 | 1619 × 3 |
|
||||
| `integration-gpu` | 958/958 × {pull, push, `PIPE_PUSH=0`, `0x7f`(G12 子系统关闭臂), `ESPRYT_DISABLE_INVALIDATE_FLUSH=1`} |
|
||||
| buffer/VAO 族 / `RenderStateSpans`+`Residual`+`VertexInputEmit`+`ResourceEmit` | 202/202 / 48/48 |
|
||||
| `HandleRecycle`(verify) / 子系统对照 / verify 对照组 | 60/60 / 10/10 / 64/64 |
|
||||
| G7 vertex-input 阴性对照 | 变红并点名 `IsBgra` |
|
||||
| 79 retrace push | 79/79 |
|
||||
| G3b 具名五条 | 桌面全绿(都在 79 例扫描内),但单独的具名扫描因门脚本把正则写成逗号清单而选中 0 例;设备侧按开放问题 17 排除 `create-indirect` → 记为"桌面全绿、设备侧部分" |
|
||||
| `gen_pipe` / `gen_pipe_dirty_surface`(扫描根扩到 `MG_State/GLState`) | self-test 7 / 21 个阴性对照全部触发;75 个 mutator 全映射,0 COARSE / 0 UNDECIDED |
|
||||
|
||||
### 4.2 "重键前红"与验证轮找到的三个缝隙缺陷
|
||||
|
||||
buffer 类的红前证据(package C 尚未注册 `MGPipeResourceOps` 时):`HandleRecycle` 的 `.AbaControl` 臂通过(它断言的就是被污染的内容)、`.Legacy` 通过、`.Handles` 可见地 skip;C 注册后两条 skip 转为断言,最终 60/60。
|
||||
|
||||
| # | 缺陷 | 表现与修法 |
|
||||
|---|---|---|
|
||||
| F1 | vertex buffer 条目按属性的 GL 绑定点解析,而不是按属性下标 | 两者只在 `KHR-GL43.vertex_attrib_binding` 题材上分叉;`VertexAttribBindingScenario` 6 → 3 |
|
||||
| F2 | ensure 路径读 `MGPResourceDesc::HasDefinedContent`(上一次 respecify 时的事实)判断影子有无字节 | `glBufferData(size, NULL)` + `glBufferSubData` 后应用字节被静默丢掉;改为持有前端对象时读 `HasDefinedContent()` |
|
||||
| F3 | 惰性生成的 twin 从不发布影子基址,fp64 收窄拒绝每个 draw | `hostBytes` 终身 null → Adreno workaround 禁用属性;在算出基址处补发布,只对非采纳资源 |
|
||||
|
||||
方法学:包 worktree 里 `tools/trace_replay/fixtures` 是 LFS 指针,对着指针跑 retrace 报 `passed 2 / 79`、`ssim=None`——**假红**;base-instance 对照在 llvmpipe 上要先关掉原生 `GL_EXT_base_instance` 才可证伪。
|
||||
|
||||
### 4.3 Track H 单位成本
|
||||
|
||||
日历:四个包(contract/wire、client、espryt、gates)各一轮实现 + 对抗性评审 + 至多两轮返工,全部在 2026-09-08 一天内,对 27 天绊线 1/27。memo 账:直接删除普查 11 条里的最后一条(`ConvertedVertexStreamKey::sourcePin`);句柄臂上退役 VAO twin 五个同步 memo 成员;重键 VAO twin 索引槽 memo、`ResolvedDrawBuffers`、twin 同步门、`ConvertedFloat64Stream`;**保留**(`MOBILEGL_PIPE_LEGACY_MEMOS` 下仍编译):以上全部成员、`g_pendingFetchBaseInstance` 族、D-K 那组——真删会移走 pull 符号或改 `sizeof`,G1 的 0/0/0/0 就是这条的度量,随 P13 退役。
|
||||
|
||||
### 4.4 两机 Release 配对 A/B、MC 26.3 的 p99、DriverBench(记录项)
|
||||
|
||||
协议:reboot-clean、`pin_device.sh` 钉频并前后 `check`、两臂背靠背、`--benchmark-repeats 3 --benchmark-tail-frames 200`、best-of-3、`--benchmark-no-finish` 主臂;APK 都是 `3e298c9a` 的 Release trace 构建(`.text` 9.4 MB)。臂:pull = pull 库;P2 = push APK `MOBILEGL_PIPE_PUSH=0x7f`;P3a = push APK 默认 `0x1ff`。`create-indirect` 排除(开放问题 17)。单位 ms/帧。
|
||||
|
||||
| 设备 | trace | 后端 | pull p50 | P2 p50 | P3a p50 | pull p99 | P3a p99 | 备注 |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| 小米 | `improved-transparency-minecraft-26.3` | Espryt | 10.810 | 11.485(+6.2%) | 11.697(**+8.2%**) | 25.457 | 26.322 | |
|
||||
| 小米 | 同上 | Magma | 10.675 | 11.473(+7.5%) | 11.459(**+7.3%**) | 25.014 | 26.035 | |
|
||||
| 小米 | `minecraft-1.21.4-rd12-odinlite-in-world` | Espryt | 8.220 | 9.117(+10.9%) | 10.650(**+29.6%**) | 21.895 | 24.487 | |
|
||||
| 小米 | 同上 | Magma | — | — | — | — | — | 三臂都 SIGABRT(`scudo::reportMapError`,`dev` 侧) |
|
||||
| 小米 | `minecraft-1.21.4-fabric-sodium-in-world` | Espryt | 1.292 | 1.349(+4.4%) | 1.382(**+7.0%**) | 2.418 | 2.443 | |
|
||||
| 小米 | 同上 | Magma | 0.485 | 0.504 | 1.010 | 1.469 | 2.187 | 亚毫秒帧,噪声 |
|
||||
| 小米 | `create-instancing` | Espryt / Magma | 944.4 / 1003.9 | 945.2 / 1019.5 | 949.9 / 1015.6 | — | — | 两帧 fixture |
|
||||
| Oppo | `improved-transparency-minecraft-26.3` | Espryt | 9.741 | 10.570(+8.5%) | 10.542(**+8.2%**) | 26.312 | 27.022 | |
|
||||
| Oppo | 同上 | Magma | 8.162 | 8.920(+9.3%) | 8.973(**+9.9%**) | 22.851 | 23.638 | |
|
||||
| Oppo | `minecraft-1.21.4-rd12-odinlite-in-world` | Espryt | 9.938 | 11.009(+10.8%) | 12.963(**+30.4%**) | 27.137 | 29.765 | |
|
||||
| Oppo | 同上 | Magma | 8.001 | 8.933(+11.6%) | 10.161(**+27.0%**) | 24.723 | 27.355 | |
|
||||
| Oppo | `minecraft-1.21.4-fabric-sodium-in-world` | Espryt / Magma | 1.896 / 0.399 | 1.770 / 0.431 | 1.841 / 0.437 | 2.993 / 1.206 | 3.079 / 1.409 | 噪声内 |
|
||||
| Oppo | `create-instancing` | Espryt / Magma | 1075.1 / 758.3 | 1045.1 / 731.0 | 1060.1 / 760.0 | — | — | 两帧 fixture |
|
||||
|
||||
读法:(1) **P2 边界在 Release 下的真实代价是 +6–12%**,两机两后端一致;(2) P3a 在 26.3 与 sodium 上几乎不再加价,**但在 rd12 上把差距从 +11% 推到 +27–30%**——rd12 每帧 VAO/buffer 绑定切换远多于 26.3,每次切换走一遍 `set_vertex_buffers` 构造 + `ContentHash` + applier 记录 + 逐属性走查(P4a 补的 `csob-blob` 计数器给了字节口径:rd12 1.06 MB/帧,其余用例中位数 2.9 KB/帧;DirectVulkan 恒 0);(3) **MC 26.3 在 Adreno 上的 p99**:25.46 → 26.32 ms(+3.4%),仍在采纳基线的 21–26 ms 档;(4) `mpr` 在设备上成立(26.3 两机都是 8,P2 臂恒 0);(5) 计数器三臂逐字相同。
|
||||
|
||||
小米 rd12 + Magma 三臂(含 pull)都 `SIGABRT`:`scudo::reportMapError` ← `scudo_calloc`,pull 库与 P3a 前的 Magma 路径符号一致——既有 bug,`dev` 侧任务。
|
||||
|
||||
DriverBench(`wsl_p3a_bench.sh`,`c20e2f2b`,`mc_vanilla_draw` ns/draw;T2 = `0x7f` 臂):
|
||||
|
||||
| | Espryt | Magma |
|
||||
|---|---|---|
|
||||
| **T1** = push(`0x1ff`) − pull | **+1048**(+20.5%) | **+611**(+3.6%) |
|
||||
| **T2** = push(`0x7f`) − pull | +349 | +189 |
|
||||
| **T1 − T2 = P3a 自己加的** | **+699** | **+422** |
|
||||
| 位 63 − push | −6 | +20 |
|
||||
| blend-toggle / pass switch | +5.2% / ≈ 0 | +2.8% / ≈ 0 |
|
||||
|
||||
读法:P3a 的 buffer/VAO 句柄路径每 draw 多花 Espryt 699 / Magma 422 ns(Magma 没有句柄化的 VAO 消费者,全是 client 侧发射 + applier 记录);进优化清单:vertex-input 发射的 per-draw 抑制与 applier 记录就地更新。`DriverBench` 必须经 `DRIVERBENCH_EGL_LIB` 显式 `dlopen` provider,不得靠 `LD_LIBRARY_PATH`(glvnd 会把 GPU 悄悄换成 llvmpipe)。
|
||||
|
||||
### 4.5 决定与遗留
|
||||
|
||||
- **ID-15**:`Managers.cpp` 的三层 flush 排水梯每个预处理臂各一份——push 构建跑 `FlushPendingRangesFrom`,pull 构建跑逐字节不变的 `FlushPendingRangesNow`;两个名字都是 G5 行,各对自己的 pin 比。转发函数不可行(G5 提取器不认预处理)。
|
||||
- **M-3**:fp64 顶点数组收窄在句柄臂上少做一处 `SyncGpuWrites`(`SyncFloat64AttributeAsFloat32ByHandle` 手里只有句柄)——默认掩码下两臂唯一的行为差异(fp64 数组 + shader 写过的源 buffer + 无显式回读),P8 把拉取搬到 client 侧即关闭。
|
||||
- 整体 diff 终审抓出两个跨包接缝:client 为每个 VAO 铸的 `VertexElementsCso` 槽在 Magma 下泄漏(修为 `~VertexArrayObject` 走后端无关的死亡路径);`FlushPendingRangesFrom` 在 G5 覆盖之外(→ ID-15)。
|
||||
- CI 独有的 teardown 崩溃(`exit()` 时静态析构顺序 UAF):`MGPipeSlots()` 等单例与四个持有前端 `SharedPtr` 的静态 `PipeInputs` 改为退出时泄漏(`d54ec57a`、`6515c8e6`、`fde5fda3`),ASan 10/10 干净;复现钥匙 `GLIBC_TUNABLES=glibc.malloc.tcache_count=0`。
|
||||
- `dev` 侧跟进(拆分不顺手修):`g_uploadRing` 不被 `OnBackendContextDestroyed` 重置(良性,`RingAvailable` 自愈);`ScopedDefaultUnpackState::s_synced` 没有失效路径。
|
||||
- `MG_Test/Buffer/BufferTest.cpp` 的 fixture 只 scope 了 `BufferBackendOps` 不 scope `MGPipeResourceOps`,26 条被路由进 pipe——修后 86/86;给它一个 pipe 形 mock 是跟进项。
|
||||
- 峰值 RSS(push vs pull,79 例):`retrace_gate.py` 不报,没有数。
|
||||
|
||||
## 里程碑记录(原 `ROADMAP.md`)
|
||||
|
||||
- **P3a / P4a 出口(2026-09-08)**:各 1 天,远低于 27 / 39 天的再基线绊线,未触发重定基线。
|
||||
|
||||
## 本目录
|
||||
|
||||
| 文件 | 内容 |
|
||||
|---|---|
|
||||
| [`BRIEF-P3A.md`](BRIEF-P3A.md) | P3a implementation brief — handle wave 1 (Espryt): buffers and VAOs behind the `resource_*` / vertex calls |
|
||||
| [`INTEGRATOR-DECISIONS.md`](INTEGRATOR-DECISIONS.md) | P3a integrator decisions (feat/disaggregated, 2026-09-08) |
|
||||
| [`scout-docs-spec.md`](scout-docs-spec.md) | 1. The P3a row of the phase table |
|
||||
| [`scout-espryt-buffers.md`](scout-espryt-buffers.md) | P3a scout — Espryt (MobileGL/MG_Backend/DirectGLES) buffer surface |
|
||||
| [`scout-espryt-vao.md`](scout-espryt-vao.md) | P3a scout — Espryt's vertex-array surface |
|
||||
| [`scout-pipe-and-tests.md`](scout-pipe-and-tests.md) | P3a scout — the MGPipe scaffolding and the gates |
|
||||
| [`ab/`](ab/) | 3 个文件:两机 Release 配对 A/B |
|
||||
| [`bench/`](bench/) | 1 个文件:DriverBench |
|
||||
| [`p3a-results/`](p3a-results/) | 19 个文件:各包的实现、评审与终审稿 |
|
||||
@@ -0,0 +1,87 @@
|
||||
# P2 paired A/B - per-thread CPU per frame (ms), trailing window, push - pull
|
||||
|
||||
pin columns: before/after verdict per run (P=PINNED, D=DRIFT = a cluster clamped by thermal management, U=UNPINNED) @ cpuss temperature C
|
||||
p50/p99: the runner's best-of-N repeat (lowest mean wall frame time), trailing tailFrames window, device median rule / nearest-rank p99; 'best' says which repeat
|
||||
|
||||
| device | case | backend | mode | pull p50 | push p50 | d p50 | pull p99 | push p99 | d p99 | frames | best pull/push | pull acc/draw | push acc/draw | pin pull | pin push |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | finish | 771.937 | 769.946 | -1.991 | 1540.659 | 1536.544 | -4.115 | 2/2 | run 2/3 / run 1/3 | 15.27 | 15.27 | U@52.9/U@52.9 | U@52.1/U@54.0 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | nofinish | 825.877 | 775.026 | -50.851 | 1648.361 | 1546.747 | -101.614 | 2/2 | run 1/3 / run 2/3 | 15.27 | 15.27 | U@49.0/U@53.6 | U@52.1/U@55.2 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | finish | 838.626 | 846.970 | +8.344 | 1490.291 | 1507.965 | +17.674 | 2/2 | run 1/3 / run 3/3 | 11.27 | 11.27 | U@53.6/U@55.6 | U@52.5/U@57.1 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | nofinish | 839.236 | 849.688 | +10.452 | 1492.840 | 1511.462 | +18.622 | 2/2 | run 3/3 / run 2/3 | 11.27 | 11.27 | U@52.1/U@55.6 | U@52.5/U@54.4 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | finish | 3.546 | 2.859 | -0.687 | 6.761 | 6.936 | +0.175 | 200/200 | run 3/3 / run 2/3 | 15.64 | 15.64 | U@46.3/U@47.8 | U@46.7/U@48.2 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | nofinish | 3.598 | 3.828 | +0.230 | 6.881 | 6.945 | +0.064 | 200/200 | run 1/3 / run 2/3 | 15.64 | 15.64 | U@50.2/U@48.2 | U@46.3/U@47.1 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | finish | 1.474 | 1.486 | +0.012 | 3.213 | 3.353 | +0.140 | 200/200 | run 1/2 / run 3/3 | 19.51 | 19.51 | U@50.2/U@48.2 | U@47.5/U@49.4 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | nofinish | 0.565 | 0.647 | +0.082 | 1.411 | 2.150 | +0.739 | 200/200 | run 1/3 / run 1/3 | 19.51 | 19.51 | U@47.1/U@48.6 | U@47.8/U@49.4 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | finish | incomplete: push |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | nofinish | incomplete: push |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectGLES | finish | 9.625 | 10.698 | +1.073 | 25.806 | 26.407 | +0.601 | 200/200 | run 3/3 / run 3/3 | 8.39 | 8.39 | P@47.0/P@46.4 | P@45.3/P@47.7 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectGLES | nofinish | 9.741 | 10.542 | +0.801 | 26.312 | 27.022 | +0.710 | 200/200 | run 1/3 / run 3/3 | 8.39 | 8.39 | P@45.5/P@44.7 | P@46.1/P@45.8 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectVulkan | finish | 8.120 | 9.064 | +0.944 | 23.126 | 23.899 | +0.773 | 200/200 | run 3/3 / run 2/3 | 6.52 | 6.52 | P@47.8/P@50.0 | P@47.3/P@50.4 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectVulkan | nofinish | 8.162 | 8.973 | +0.811 | 22.851 | 23.638 | +0.787 | 200/200 | run 1/3 / run 3/3 | 6.52 | 6.52 | P@47.3/P@49.3 | P@49.5/P@47.6 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | finish | 1046.285 | 1048.879 | +2.594 | 2084.086 | 2089.778 | +5.692 | 2/2 | run 1/3 / run 2/3 | 15.27 | 15.27 | P@52.2/P@53.7 | P@52.9/P@54.2 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | nofinish | 1075.081 | 1060.064 | -15.017 | 2142.660 | 2110.799 | -31.861 | 2/2 | run 2/3 / run 1/3 | 15.27 | 15.27 | P@51.7/P@52.8 | P@52.6/P@53.7 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | finish | 760.555 | 776.948 | +16.393 | 1506.263 | 1538.494 | +32.231 | 2/2 | run 1/3 / run 3/3 | 11.27 | 11.27 | P@51.8/P@51.9 | P@50.1/P@49.7 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | nofinish | 758.298 | 760.035 | +1.737 | 1501.555 | 1504.494 | +2.939 | 2/2 | run 1/3 / run 1/3 | 11.27 | 11.27 | P@53.3/P@51.2 | P@51.0/P@50.4 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | finish | 1.732 | 1.839 | +0.107 | 3.085 | 2.966 | -0.119 | 200/200 | run 2/3 / run 1/3 | 15.64 | 15.64 | P@46.4/P@48.9 | P@46.5/P@47.8 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | nofinish | 1.896 | 1.841 | -0.055 | 2.993 | 3.079 | +0.086 | 200/200 | run 2/3 / run 2/3 | 15.64 | 15.64 | P@51.9/P@49.3 | P@47.9/P@47.6 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | finish | 0.402 | 0.457 | +0.055 | 1.186 | 1.265 | +0.079 | 200/200 | run 3/3 / run 2/3 | 19.51 | 19.51 | P@49.6/P@51.0 | P@50.9/P@52.1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | nofinish | 0.399 | 0.437 | +0.038 | 1.206 | 1.409 | +0.203 | 200/200 | run 3/3 / run 3/3 | 19.51 | 19.51 | P@47.4/P@50.8 | P@50.2/P@51.2 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | finish | 9.944 | 12.852 | +2.908 | 27.530 | 29.540 | +2.010 | 200/200 | run 1/3 / run 2/3 | 8.08 | 8.08 | P@50.4/P@52.3 | P@50.5/P@53.4 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | nofinish | 9.938 | 12.963 | +3.025 | 27.137 | 29.765 | +2.628 | 200/200 | run 3/3 / run 2/3 | 8.08 | 8.08 | P@49.8/P@50.8 | P@49.7/P@51.5 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | finish | 7.718 | 10.226 | +2.508 | 24.451 | 27.359 | +2.908 | 200/200 | run 2/3 / run 1/3 | 6.16 | 6.16 | P@52.8/P@54.3 | P@53.6/P@52.1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | nofinish | 8.001 | 10.161 | +2.160 | 24.723 | 27.355 | +2.632 | 200/200 | run 1/3 / run 2/3 | 6.16 | 6.16 | P@51.7/P@54.0 | P@53.2/P@55.7 |
|
||||
|
||||
## GO/NO-GO reading (items 3-4: p50 and p99 per-thread CPU deltas must not be negative for the push arm, i.e. push must not cost more)
|
||||
|
||||
Windows where push costs MORE CPU than pull (d > 0):
|
||||
- 35d0befa / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / finish: d p50 +8.344 ms, d p99 +17.674 ms
|
||||
- 35d0befa / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / nofinish: d p50 +10.452 ms, d p99 +18.622 ms
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / finish: d p50 -0.687 ms, d p99 +0.175 ms
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / nofinish: d p50 +0.230 ms, d p99 +0.064 ms
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / finish: d p50 +0.012 ms, d p99 +0.140 ms
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / nofinish: d p50 +0.082 ms, d p99 +0.739 ms
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectGLES / finish: d p50 +1.073 ms, d p99 +0.601 ms
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectGLES / nofinish: d p50 +0.801 ms, d p99 +0.710 ms
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectVulkan / finish: d p50 +0.944 ms, d p99 +0.773 ms
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectVulkan / nofinish: d p50 +0.811 ms, d p99 +0.787 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectGLES / finish: d p50 +2.594 ms, d p99 +5.692 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / finish: d p50 +16.393 ms, d p99 +32.231 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / nofinish: d p50 +1.737 ms, d p99 +2.939 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / finish: d p50 +0.107 ms, d p99 -0.119 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / nofinish: d p50 -0.055 ms, d p99 +0.086 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / finish: d p50 +0.055 ms, d p99 +0.079 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / nofinish: d p50 +0.038 ms, d p99 +0.203 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectGLES / finish: d p50 +2.908 ms, d p99 +2.010 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectGLES / nofinish: d p50 +3.025 ms, d p99 +2.628 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectVulkan / finish: d p50 +2.508 ms, d p99 +2.908 ms
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectVulkan / nofinish: d p50 +2.160 ms, d p99 +2.632 ms
|
||||
|
||||
## Memo gates, residual bytes and CSO counters (last complete window, push arm)
|
||||
|
||||
- 35d0befa / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectGLES / finish: gates[ers=9780/7883 etl=9341/8322 eub=6951/10712 mfp=0/0 mpm=0/0 mdt=0/0] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 35d0befa / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectGLES / nofinish: gates[ers=9780/7883 etl=9341/8322 eub=6951/10712 mfp=0/0 mpm=0/0 mdt=0/0] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 35d0befa / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / finish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=282/13912 mpm=9408/4504 mdt=7544/6650] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 35d0befa / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / nofinish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=282/13912 mpm=9408/4504 mdt=7544/6650] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / finish: gates[ers=81/859 etl=405/535 eub=405/535 mfp=0/0 mpm=0/0 mdt=0/0] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / nofinish: gates[ers=81/859 etl=405/535 eub=405/535 mfp=0/0 mpm=0/0 mdt=0/0] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / finish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=0/657 mpm=109/548 mdt=0/657] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 35d0befa / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / nofinish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=0/657 mpm=109/548 mdt=0/657] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 35d0befa / minecraft-1.21.4-rd12-odinlite-in-world / DirectGLES / finish: gates[ers=16038/224 etl=16148/114 eub=16159/103 mfp=0/0 mpm=0/0 mdt=0/0] resid=162.91 csom/csob=csom=0/csob=209
|
||||
- 35d0befa / minecraft-1.21.4-rd12-odinlite-in-world / DirectGLES / nofinish: gates[ers=16038/224 etl=16148/114 eub=16159/103 mfp=0/0 mpm=0/0 mdt=0/0] resid=0.0 csom/csob=-/-
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectGLES / finish: gates[ers=78960/1367 etl=75378/4949 eub=75199/5128 mfp=0/0 mpm=0/0 mdt=0/0] resid=185.36 csom/csob=csom=0/csob=1157
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectGLES / nofinish: gates[ers=78960/1367 etl=75378/4949 eub=75199/5128 mfp=0/0 mpm=0/0 mdt=0/0] resid=185.36 csom/csob=csom=0/csob=1157
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectVulkan / finish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=10740/68928 mpm=67660/1268 mdt=78800/868] resid=185.36 csom/csob=csom=0/csob=1157
|
||||
- 3B159D009VZ00000 / improved-transparency-minecraft-26.3 / DirectVulkan / nofinish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=10740/68928 mpm=67660/1268 mdt=78800/868] resid=185.36 csom/csob=csom=0/csob=1157
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectGLES / finish: gates[ers=9780/7883 etl=9341/8322 eub=6951/10712 mfp=0/0 mpm=0/0 mdt=0/0] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectGLES / nofinish: gates[ers=9780/7883 etl=9341/8322 eub=6951/10712 mfp=0/0 mpm=0/0 mdt=0/0] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / finish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=282/13912 mpm=9408/4504 mdt=7544/6650] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 3B159D009VZ00000 / minecraft-1.21.1-neoforge-create-instancing-in-world / DirectVulkan / nofinish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=282/13912 mpm=9408/4504 mdt=7544/6650] resid=30968.0 csom/csob=csom=29/csob=7741
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / finish: gates[ers=81/859 etl=405/535 eub=405/535 mfp=0/0 mpm=0/0 mdt=0/0] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectGLES / nofinish: gates[ers=81/859 etl=405/535 eub=405/535 mfp=0/0 mpm=0/0 mdt=0/0] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / finish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=0/657 mpm=109/548 mdt=0/657] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-fabric-sodium-in-world / DirectVulkan / nofinish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=0/657 mpm=109/548 mdt=0/657] resid=171.8 csom/csob=csom=2/csob=811
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectGLES / finish: gates[ers=16038/224 etl=16148/114 eub=16159/103 mfp=0/0 mpm=0/0 mdt=0/0] resid=162.91 csom/csob=csom=0/csob=209
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectGLES / nofinish: gates[ers=16038/224 etl=16148/114 eub=16159/103 mfp=0/0 mpm=0/0 mdt=0/0] resid=162.91 csom/csob=csom=0/csob=209
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectVulkan / finish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=0/16185 mpm=16027/158 mdt=16016/169] resid=162.91 csom/csob=csom=0/csob=209
|
||||
- 3B159D009VZ00000 / minecraft-1.21.4-rd12-odinlite-in-world / DirectVulkan / nofinish: gates[ers=0/0 etl=0/0 eub=0/0 mfp=0/16185 mpm=16027/158 mdt=16016/169] resid=162.91 csom/csob=csom=0/csob=209
|
||||
@@ -0,0 +1,39 @@
|
||||
# P3a device A/B - per-thread CPU per frame (ms), best-of-3 repeat, trailing window
|
||||
|
||||
| device | case | backend | finish | pull p50 | P2-only (0x7f) p50 | P3a (0x1ff) p50 | d P2 | d P3a total | pull p99 | P3a p99 | pins pull/7f/P3a | mpr 7f/P3a |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectGLES | on | 10.789 | - | 11.705 | - | +8.5% | 25.481 | 26.286 | P/P / - / P/P | - / 8 |
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectGLES | off | 10.810 | 11.485 | 11.697 | +6.2% | +8.2% | 25.457 | 26.322 | P/P / P/P / P/P | 0 / 8 |
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectVulkan | on | 10.710 | - | 11.486 | - | +7.2% | 25.046 | 26.020 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectVulkan | off | 10.675 | 11.473 | 11.459 | +7.5% | +7.3% | 25.014 | 26.035 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | on | 942.838 | - | 951.887 | - | +1.0% | 1881.772 | 1899.830 | P/P / - / P/P | - / 1 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | off | 944.367 | 945.239 | 949.916 | +0.1% | +0.6% | 1884.954 | 1896.098 | P/P / P/P / P/P | 0 / 1 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | on | 1002.282 | - | 1009.560 | - | +0.7% | 1881.965 | 1896.724 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | off | 1003.851 | 1019.461 | 1015.625 | +1.6% | +1.2% | 1884.710 | 1908.215 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | on | 1.286 | - | 1.389 | - | +8.0% | 2.382 | 2.461 | P/P / - / P/P | - / 1 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | off | 1.292 | 1.349 | 1.382 | +4.4% | +7.0% | 2.418 | 2.443 | P/P / P/P / P/P | 0 / 1 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | on | 0.984 | - | 0.500 | - | -49.2% | 2.106 | 1.165 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | off | 0.485 | 0.504 | 1.010 | +3.9% | +108.2% | 1.469 | 2.187 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | on | 8.241 | - | 10.656 | - | +29.3% | 21.905 | 24.415 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | off | 8.220 | 9.117 | 10.650 | +10.9% | +29.6% | 21.895 | 24.487 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | on | - | - | - | - | - | - | - | P/D / - / P/P | - / None |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | off | - | - | - | - | - | - | - | P/D / P/P / P/P | None / None |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectGLES | on | 9.625 | - | 10.698 | - | +11.1% | 25.806 | 26.407 | P/P / - / P/P | - / 8 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectGLES | off | 9.741 | 10.570 | 10.542 | +8.5% | +8.2% | 26.312 | 27.022 | P/P / P/P / P/P | 0 / 8 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectVulkan | on | 8.120 | - | 9.064 | - | +11.6% | 23.126 | 23.899 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectVulkan | off | 8.162 | 8.920 | 8.973 | +9.3% | +9.9% | 22.851 | 23.638 | P/P / ?/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | on | 1046.285 | - | 1048.879 | - | +0.2% | 2084.086 | 2089.778 | P/P / - / P/P | - / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | off | 1075.081 | 1045.102 | 1060.064 | -2.8% | -1.4% | 2142.660 | 2110.799 | P/P / P/P / P/P | 0 / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | on | 760.555 | - | 776.948 | - | +2.2% | 1506.263 | 1538.494 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | off | 758.298 | 731.023 | 760.035 | -3.6% | +0.2% | 1501.555 | 1504.494 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | on | 1.732 | - | 1.839 | - | +6.2% | 3.085 | 2.966 | P/P / - / P/P | - / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | off | 1.896 | 1.770 | 1.841 | -6.6% | -2.9% | 2.993 | 3.079 | P/P / P/P / P/P | 0 / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | on | 0.402 | - | 0.457 | - | +13.7% | 1.186 | 1.265 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | off | 0.399 | 0.431 | 0.437 | +8.0% | +9.5% | 1.206 | 1.409 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | on | 9.944 | - | 12.852 | - | +29.2% | 27.530 | 29.540 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | off | 9.938 | 11.009 | 12.963 | +10.8% | +30.4% | 27.137 | 29.765 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | on | 7.718 | - | 10.226 | - | +32.5% | 24.451 | 27.359 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | off | 8.001 | 8.933 | 10.161 | +11.6% | +27.0% | 24.723 | 27.355 | P/P / P/P / P/P | 0 / 0 |
|
||||
|
||||
d P2 = push(0x7f) vs pull; d P3a total = push(0x1ff) vs pull; the P3a-only share is the difference of the two.
|
||||
A '-' p50 means the run produced no result (rc != 0); see the runner.log in that directory.
|
||||
@@ -0,0 +1,39 @@
|
||||
# P3a device A/B - per-thread CPU per frame (ms), best-of-3 repeat, trailing window
|
||||
|
||||
| device | case | backend | finish | pull p50 | P2-only (0x7f) p50 | P3a (0x1ff) p50 | d P2 | d P3a total | pull p99 | P3a p99 | pins pull/7f/P3a | mpr 7f/P3a |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectGLES | on | 10.789 | - | 11.705 | - | +8.5% | 25.481 | 26.286 | P/P / - / P/P | - / 8 |
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectGLES | off | 10.810 | - | 11.697 | - | +8.2% | 25.457 | 26.322 | P/P / - / P/P | - / 8 |
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectVulkan | on | 10.710 | - | 11.486 | - | +7.2% | 25.046 | 26.020 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | improved-transparency-minecraft-26.3 | DirectVulkan | off | 10.675 | - | 11.459 | - | +7.3% | 25.014 | 26.035 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | on | 771.937 | - | 769.946 | - | -0.3% | 1540.659 | 1536.544 | U/U / - / U/U | - / 1 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | off | 825.877 | - | 775.026 | - | -6.2% | 1648.361 | 1546.747 | U/U / - / U/U | - / 1 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | on | 838.626 | - | 846.970 | - | +1.0% | 1490.291 | 1507.965 | U/U / - / U/U | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | off | 839.236 | - | 849.688 | - | +1.2% | 1492.840 | 1511.462 | U/U / - / U/U | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | on | 3.546 | - | 2.859 | - | -19.4% | 6.761 | 6.936 | U/U / - / U/U | - / 1 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | off | - | - | 3.828 | - | - | - | 6.945 | P/U / - / U/U | - / 1 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | on | 1.474 | - | 1.486 | - | +0.8% | 3.213 | 3.353 | U/U / - / U/U | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | off | 0.565 | - | 0.647 | - | +14.5% | 1.411 | 2.150 | U/U / - / U/U | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | on | 8.241 | - | 10.656 | - | +29.3% | 21.905 | 24.415 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | off | 8.220 | - | 10.650 | - | +29.6% | 21.895 | 24.487 | P/P / - / P/P | - / 0 |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | on | - | - | - | - | - | - | - | P/D / - / P/P | - / None |
|
||||
| 35d0befa | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | off | - | - | - | - | - | - | - | P/D / - / P/P | - / None |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectGLES | on | 9.625 | - | 10.698 | - | +11.1% | 25.806 | 26.407 | P/P / - / P/P | - / 8 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectGLES | off | 9.741 | - | 10.542 | - | +8.2% | 26.312 | 27.022 | P/P / P/P / P/P | None / 8 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectVulkan | on | 8.120 | - | 9.064 | - | +11.6% | 23.126 | 23.899 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | improved-transparency-minecraft-26.3 | DirectVulkan | off | 8.162 | 9.092 | 8.973 | +11.4% | +9.9% | 22.851 | 23.638 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | on | 1046.285 | - | 1048.879 | - | +0.2% | 2084.086 | 2089.778 | P/P / - / P/P | - / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectGLES | off | 1075.081 | 1045.102 | 1060.064 | -2.8% | -1.4% | 2142.660 | 2110.799 | P/P / P/P / P/P | 0 / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | on | 760.555 | - | 776.948 | - | +2.2% | 1506.263 | 1538.494 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.1-neoforge-create-instancing-in-world | DirectVulkan | off | 758.298 | 731.023 | 760.035 | -3.6% | +0.2% | 1501.555 | 1504.494 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | on | 1.732 | - | 1.839 | - | +6.2% | 3.085 | 2.966 | P/P / - / P/P | - / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectGLES | off | 1.896 | 1.770 | 1.841 | -6.6% | -2.9% | 2.993 | 3.079 | P/P / P/P / P/P | 0 / 1 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | on | 0.402 | - | 0.457 | - | +13.7% | 1.186 | 1.265 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-fabric-sodium-in-world | DirectVulkan | off | 0.399 | 0.431 | 0.437 | +8.0% | +9.5% | 1.206 | 1.409 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | on | 9.944 | - | 12.852 | - | +29.2% | 27.530 | 29.540 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectGLES | off | 9.938 | 11.009 | 12.963 | +10.8% | +30.4% | 27.137 | 29.765 | P/P / P/P / P/P | 0 / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | on | 7.718 | - | 10.226 | - | +32.5% | 24.451 | 27.359 | P/P / - / P/P | - / 0 |
|
||||
| 3B159D009VZ00000 | minecraft-1.21.4-rd12-odinlite-in-world | DirectVulkan | off | 8.001 | 8.933 | 10.161 | +11.6% | +27.0% | 24.723 | 27.355 | P/P / P/P / P/P | 0 / 0 |
|
||||
|
||||
d P2 = push(0x7f) vs pull; d P3a total = push(0x1ff) vs pull; the P3a-only share is the difference of the two.
|
||||
A '-' p50 means the run produced no result (rc != 0); see the runner.log in that directory.
|
||||
@@ -0,0 +1,27 @@
|
||||
# P3a DriverBench (desktop, lavapipe/llvmpipe) - median ns_per_op over repeats
|
||||
|
||||
| arm | mc_vanilla_draw | mc_state_toggle | mc_pass_switch |
|
||||
|---|---|---|---|
|
||||
| native | 4758.9 (n=5, min 4741.8) | 22714.8 (n=5, min 22390.5) | 438175.0 (n=5, min 433303.1) |
|
||||
| espryt-pull | 5114.6 (n=5, min 5089.5) | 23287.0 (n=5, min 23116.8) | 435814.7 (n=5, min 433424.2) |
|
||||
| espryt-push | 6162.3 (n=5, min 6114.3) | 24496.4 (n=5, min 24006.7) | 435974.8 (n=5, min 433336.2) |
|
||||
| espryt-push7f | 5463.1 (n=5, min 5393.5) | 24575.9 (n=5, min 24272.3) | 436031.2 (n=5, min 435819.3) |
|
||||
| espryt-push0 | 5692.8 (n=5, min 5648.5) | 24464.6 (n=5, min 24302.3) | 436598.1 (n=5, min 436019.1) |
|
||||
| espryt-nocso | 6156.1 (n=5, min 6090.0) | 24855.5 (n=5, min 24418.5) | 435275.8 (n=5, min 434381.4) |
|
||||
| magma-pull | 17098.6 (n=5, min 17004.4) | 32611.7 (n=5, min 32283.6) | 436748.0 (n=5, min 436116.7) |
|
||||
| magma-push | 17709.4 (n=5, min 17299.1) | 33536.9 (n=5, min 33295.5) | 437314.0 (n=5, min 436211.2) |
|
||||
| magma-push7f | 17287.4 (n=5, min 17207.1) | 33549.7 (n=5, min 33178.9) | 436457.5 (n=5, min 436283.2) |
|
||||
| magma-push0 | 17738.7 (n=5, min 17497.4) | 33799.6 (n=5, min 33588.7) | 440445.7 (n=5, min 439371.9) |
|
||||
| magma-nocso | 17728.9 (n=5, min 17359.6) | 34221.5 (n=5, min 34057.0) | 436465.2 (n=5, min 435002.8) |
|
||||
|
||||
## Deltas on mc_vanilla_draw (ns/draw)
|
||||
|
||||
- espryt: T1 = push(0x1ff) - pull = **+1047.7**; T2 = push(0x7f, P2 boundary) - pull = +348.5; T1 - T2 (what P3a added) = **+699.2**; push(PIPE_PUSH=0) - pull = +578.2; no-CSO-content-addressing - push = -6.2
|
||||
- magma: T1 = push(0x1ff) - pull = **+610.8**; T2 = push(0x7f, P2 boundary) - pull = +188.8; T1 - T2 (what P3a added) = **+422.0**; push(PIPE_PUSH=0) - pull = +640.1; no-CSO-content-addressing - push = +19.5
|
||||
|
||||
## Blaze3D blend toggle (mc_state_toggle, ns per toggle pair) and pass switch
|
||||
|
||||
- espryt mc_state_toggle: pull 23287.0, push 24496.4, delta +1209.4, native 22714.8
|
||||
- espryt mc_pass_switch: pull 435814.7, push 435974.8, delta +160.1, native 438175.0
|
||||
- magma mc_state_toggle: pull 32611.7, push 33536.9, delta +925.2, native 22714.8
|
||||
- magma mc_pass_switch: pull 436748.0, push 437314.0, delta +566.0, native 438175.0
|
||||
@@ -0,0 +1,322 @@
|
||||
# P3a — the CI `double free or corruption (!prev)` on `DirectVulkan.Verify.CrossFrameBufferScenario.{Vertex,Index}CopyBufferSubData`
|
||||
|
||||
Investigator: ASan round, 2026-09-08. Tree: private worktree `~/w7/p3a-asan` on branch `p3a/asan`, pinned at
|
||||
`3e298c9a` (the commit CI ran). Nothing in `~/w7/pipe` or `~/w7/p3a-final` was modified.
|
||||
|
||||
## VERDICT
|
||||
|
||||
**Reproduced, root-caused, and the fix is validated in both a sanitizer build and a plain Release build.**
|
||||
|
||||
It is **not a `CopyBufferSubData` bug and not a Magma bug.** It is a **static-destruction-order use-after-free
|
||||
that every one of the 26 `CrossFrameBufferScenario` case × backend combinations executes**, on both backends,
|
||||
at `exit()`. The two `CopyBufferSubData` cases are simply the two whose heap layout makes the corrupted write
|
||||
that follows the UAF *fatal* under CI's allocator arrangement; the other 24 execute the same use-after-free and
|
||||
survive it. The corruption is P3a's: `~BufferObject` is the first frontend-object destructor in the project's
|
||||
history to call into `MG_Pipe`'s process-lifetime singletons, and the objects that hold the last reference to a
|
||||
`BufferObject` are destroyed by `__run_exit_handlers` **after** those singletons. It is **not verify-only**
|
||||
either: the same crash reproduces with the comparator switched off, so a shipped `MOBILEGL_PIPE_PUSH` build is
|
||||
exposed identically.
|
||||
|
||||
The defect is still present on today's `feat/disaggregated` head (`c20e2f2b`, i.e. after the `p3a/final`
|
||||
rework); the rework's C-1 fix adds a **second** reaching path (`~VertexArrayObject` →
|
||||
`MGPipeEmitVertexElementsDestroyAndFree` → `MGPipeSlots()`), so the exposure is now larger, not smaller.
|
||||
|
||||
---
|
||||
|
||||
## 1. The mechanism, in one chain
|
||||
|
||||
```
|
||||
exit()
|
||||
__run_exit_handlers
|
||||
MobileGL::MG_Pipe::MGPipeSlotAllocator::~MGPipeSlotAllocator() <-- runs FIRST
|
||||
MG_Impl/Pipe/SlotAllocator.h:39 -> KindState::~KindState() SlotAllocator.h:84
|
||||
(frees Slots, FreeList and the ska::flat_hash_map ByLifetimeId entry block)
|
||||
...
|
||||
MobileGL::MG_Pipe::PipeInputs::~PipeInputs() <-- runs LATER
|
||||
MG_Backend/MGPipe/PipeInputs.h:678 SharedPtr<VertexArrayObject> m_boundVertexArray
|
||||
~VertexArrayObject MG_State/.../VertexArrayObject.cpp:54
|
||||
~BindingSlot<BufferObject> MG_Util/Types.h:181
|
||||
~BufferObject MG_State/GLState/BufferState/BufferObject.cpp:60
|
||||
MGPipeEmitResourceDestroyAndFree MG_Impl/Pipe/PipeFill.cpp:743
|
||||
tracker.Find(buffer) MG_Impl/Pipe/ResourceTracker.h:304
|
||||
MGPipeSlots().FindByLifetimeId MG_Impl/Pipe/SlotAllocator.cpp:100
|
||||
ska::flat_hash_map::find ***USE AFTER FREE***
|
||||
```
|
||||
|
||||
`MGPipeSlots()` (`MG_Impl/Pipe/SlotAllocator.cpp:170-173`) is a Meyers singleton:
|
||||
|
||||
```cpp
|
||||
MGPipeSlotAllocator& MGPipeSlots() {
|
||||
static MGPipeSlotAllocator allocator;
|
||||
return allocator;
|
||||
}
|
||||
```
|
||||
|
||||
Its `static` is constructed lazily, at the **first `BufferObject`** (`MGPipeMintResourceHandle`, PipeFill.cpp:610),
|
||||
i.e. deep inside the test. `gPipeInputs` (`MG_Backend/MGPipe/PipeInputs.h:691`, `inline PipeInputs gPipeInputs{}`)
|
||||
is a namespace-scope global, dynamically initialised **before `main`**. Reverse-order destruction therefore
|
||||
destroys the allocator **first** and `gPipeInputs` — with its live `SharedPtr<VertexArrayObject>` and, through
|
||||
the VAO's binding slots, live `SharedPtr<BufferObject>`s — **last**. Calling `MGPipeSlots()` after its static's
|
||||
destructor has run does **not** reconstruct it; it hands back the destroyed object.
|
||||
|
||||
The same holds for `MGPipeResourceTrackerInstance()` (`ResourceTracker.h:554-557`, another Meyers singleton
|
||||
that `~BufferObject` reads *and writes* via `WasPublished` / `NoteDestroy` / `Retire`) and for
|
||||
`g_applier` (`MG_Pipe/PipeApply.cpp:380`, a namespace-scope value global that `MGPipeApplyResourceDestroy`
|
||||
touches whenever the create was published — i.e. on every Espryt/DirectGLES buffer).
|
||||
|
||||
**What actually corrupts the heap.** The ASan report catches the first *read*. In a shipped (non-sanitizer)
|
||||
build the read usually returns garbage, and then one of two things happens:
|
||||
|
||||
* the garbage does not resolve to a live slot → `MGPipeHandleIsNull(handle)` → `~BufferObject` returns early and
|
||||
nothing is written. **This is the 24 surviving cases.**
|
||||
* the garbage still looks like a live `{slot, gen}` (the freed 288-byte hash-table block is usually still
|
||||
intact) → the destructor proceeds into `MGPipeSlotAllocator::Free` (`SlotAllocator.cpp:113-130`), which
|
||||
* `state.Slots[handle.Slot]` — writes into a **freed** `std::vector` buffer (`:116`, `:126-128`),
|
||||
* `state.ByLifetimeId.erase(it)` — mutates a **freed** hash table (`:123`),
|
||||
* `state.FreeList.push_back(...)` — **grows a freed `std::vector`**, i.e. `operator new` + `memcpy` +
|
||||
`operator delete` **on a pointer that was already freed** (`:129`).
|
||||
|
||||
That last line is a literal double free of the old `FreeList` buffer, and the writes at `:116`/`:126-128`
|
||||
scribble over whatever glibc has since placed in the freed chunks. Hence the two different glibc verdicts CI
|
||||
printed for the two cases — `double free or corruption (!prev)` and `corrupted size vs. prev_size in
|
||||
fastbins` — from the same defect.
|
||||
|
||||
Before P3a, `~BufferObject` touched only `g_bufferBackendOps`, a plain namespace-scope pointer that the backend
|
||||
nulls at shutdown, so the destructor was exit-safe. P3a's `MGPipeEmitResourceDestroyAndFree` is what made a
|
||||
frontend destructor depend on function-local statics.
|
||||
|
||||
## 2. Why only those two cases (and why the local box did not reproduce it)
|
||||
|
||||
The selection is pure allocator layout. `CopySubData` is the only mutation that creates a **third**
|
||||
`BufferObject` with a real store (`m_staging`, `glBufferData(GL_COPY_READ_BUFFER, …)` at
|
||||
`CrossFrameBufferScenario.cpp:327-330`), which shifts every subsequent allocation and, critically, the size and
|
||||
reuse history of the `ByLifetimeId` table that is read after free. Nothing about `glCopyBufferSubData`,
|
||||
`BufferObject::CopyDataFrom` or Magma's buffer teardown is implicated — `m_staging` never even acquires a
|
||||
`VkBufferResource` (`VkBufferManager::OnRespecify` returns early on `!resource`).
|
||||
|
||||
Two independent confirmations of "layout, not logic":
|
||||
|
||||
* under **ASan**, all 13 cases × 2 backends = 26 runs report the identical `heap-use-after-free` (§4);
|
||||
* on this box the native build is clean with the default allocator (40 × 2 runs, `MALLOC_CHECK_=3
|
||||
MALLOC_PERTURB_=165`), but **`GLIBC_TUNABLES=glibc.malloc.tcache_count=0` flips exactly the two CI cases,
|
||||
and only those two, to a hard SIGSEGV** — the same selection CI makes, with a one-variable change.
|
||||
|
||||
Local lavapipe vs CI:
|
||||
|
||||
| | renderer string |
|
||||
|---|---|
|
||||
| CI | `Magma (MobileGL Core) (llvmpipe (LLVM 20.1.2, 256 bits), Vulkan 1.4.318, Driver 25.2.8)` — Mesa 25.2.8 |
|
||||
| this box | `Magma (MobileGL Core) (llvmpipe (LLVM 22.1.6, 256 bits), Vulkan 1.4.354, Driver 26.1.4)` — Mesa 26.1.4 (`vulkan-swrast 1:26.1.4-1`) |
|
||||
|
||||
The driver difference is not the cause; it only changes the allocation history that decides fatality.
|
||||
|
||||
## 3. Exact commands that reproduce it
|
||||
|
||||
**A — native, no sanitizer, on any existing verify build (fastest; this is the one to hand to CI):**
|
||||
|
||||
```bash
|
||||
cd <build-verify>/MobileGL/MG_IntegrationTest
|
||||
MOBILEGL_BACKEND_TYPE=DirectVulkan MOBILEGL_PIPE_VERIFY=1 MOBILEGL_ITEST_REQUIRE_GPU=1 \
|
||||
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json \
|
||||
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json \
|
||||
GLIBC_TUNABLES=glibc.malloc.tcache_count=0 \
|
||||
./MobileGLIntegrationTest --gtest_filter=CrossFrameBufferScenario.VertexCopyBufferSubData
|
||||
# -> "[ PASSED ] 1 test." then Segmentation fault (rc 139)
|
||||
```
|
||||
|
||||
**B — ASan, which names the defect instead of the symptom (and fires on ANY case of the family):**
|
||||
|
||||
```bash
|
||||
bash ~/w7/notes/tools/wsl_tree.sh p3a asan 3e298c9a # or just: git worktree add ~/w7/p3a-asan 3e298c9a
|
||||
cd ~/w7/p3a-asan
|
||||
cmake -S . -B build-asan <wsl_p3a_gate.sh COMMON, minus -DCMAKE_BUILD_TYPE=Release> \
|
||||
-DMOBILEGL_PIPE_VERIFY=ON -DMOBILEGL_ITEST_REQUIRE_GPU=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
|
||||
-DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
|
||||
-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address -DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=address
|
||||
cmake --build build-asan -j 8 --target MobileGLIntegrationTest # NOT `all`: see the build note below
|
||||
cd build-asan/MobileGL/MG_IntegrationTest
|
||||
ASAN_OPTIONS=detect_leaks=0:abort_on_error=1 LSAN_OPTIONS= \
|
||||
MOBILEGL_BACKEND_TYPE=DirectVulkan MOBILEGL_PIPE_VERIFY=1 MOBILEGL_ITEST_REQUIRE_GPU=1 \
|
||||
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json \
|
||||
__EGL_VENDOR_LIBRARY_FILENAMES=/usr/share/glvnd/egl_vendor.d/50_mesa.json \
|
||||
./MobileGLIntegrationTest --gtest_filter=CrossFrameBufferScenario.VertexCopyBufferSubData
|
||||
```
|
||||
|
||||
Build note for whoever repeats this: `cmake --build build-asan` (the `all` target) **fails to link**
|
||||
`libSPIRV-Tools-shared.so` under `-fsanitize=address` — clang does not link the ASan runtime into a shared
|
||||
object and that target carries `-Wl,--no-undefined`. Build the `MobileGLIntegrationTest` target only.
|
||||
`valgrind` on this box is unusable (`valgrind-3.25.1` refuses to start: glibc's stripped `ld-linux` has no
|
||||
`memcmp` to redirect, and the debuginfo package is not installed), so ASan was the only sanitizer used.
|
||||
|
||||
## 4. The sanitizer report (trimmed; symbol soup collapsed, file:line verbatim)
|
||||
|
||||
```
|
||||
==1608571==ERROR: AddressSanitizer: heap-use-after-free on address 0x6db2b22b18d8 ...
|
||||
READ of size 1 at 0x6db2b22b18d8 thread T0
|
||||
#0/#1 ska::detailv3::sherwood_v3_table<...>::find(unsigned long const&) include/ska/flat_hash_map.hpp:543:39
|
||||
#2 MobileGL::MG_Pipe::MGPipeSlotAllocator::FindByLifetimeId(MGPipeKind, unsigned long) const
|
||||
MobileGL/MG_Impl/Pipe/SlotAllocator.cpp:100:44
|
||||
#3 MobileGL::MG_Pipe::MGPipeResourceTracker::Find(BufferObject const&) const
|
||||
MobileGL/MG_Impl/Pipe/ResourceTracker.h:304:34
|
||||
#4 MobileGL::MG_Pipe::MGPipeEmitResourceDestroyAndFree(BufferObject&)
|
||||
MobileGL/MG_Impl/Pipe/PipeFill.cpp:743:45
|
||||
#5 MobileGL::MG_State::GLState::BufferObject::~BufferObject()
|
||||
MobileGL/MG_State/GLState/BufferState/BufferObject.cpp:60:13
|
||||
#6..#8 std::_Sp_counted_base::_M_release / ~shared_ptr<BufferObject>
|
||||
#9 MobileGL::BindingSlot<BufferObject>::~BindingSlot() MobileGL/MG_Util/Types.h:181:11
|
||||
#10 MobileGL::MG_State::GLState::VertexArrayObject::~VertexArrayObject()
|
||||
MobileGL/MG_State/GLState/VertexArrayState/VertexArrayObject.cpp:54:5
|
||||
#11..#13 ~shared_ptr<VertexArrayObject>
|
||||
#14 MobileGL::MG_Pipe::PipeInputs::~PipeInputs() MobileGL/MG_Backend/MGPipe/PipeInputs.h:158:12
|
||||
#15/#16 __run_exit_handlers / exit (libc)
|
||||
#17..#19 __libc_start_main / _start
|
||||
|
||||
0x6db2b22b18d8 is located 24 bytes inside of 288-byte region [0x6db2b22b18c0,0x6db2b22b19e0)
|
||||
freed by thread T0 here:
|
||||
#0 operator delete(void*, unsigned long)
|
||||
#1 MobileGL::MG_Pipe::MGPipeSlotAllocator::KindState::~KindState()
|
||||
MobileGL/MG_Impl/Pipe/SlotAllocator.h:84:16
|
||||
#2 std::array<MGPipeSlotAllocator::KindState, 14ul>::~array()
|
||||
#3 MobileGL::MG_Pipe::MGPipeSlotAllocator::~MGPipeSlotAllocator()
|
||||
MobileGL/MG_Impl/Pipe/SlotAllocator.h:39:11
|
||||
#4/#5 __run_exit_handlers / exit (libc)
|
||||
|
||||
previously allocated by thread T0 here:
|
||||
#0 operator new(unsigned long)
|
||||
#4 ska::...::rehash(unsigned long) include/ska/flat_hash_map.hpp:636:34
|
||||
#5 ska::...::grow() include/ska/flat_hash_map.hpp:871:9
|
||||
#8 ska::flat_hash_map<...>::operator[](unsigned long const&) include/ska/flat_hash_map.hpp:1345:16
|
||||
#9 MobileGL::MG_Pipe::MGPipeSlotAllocator::AllocateFor(MGPipeKind, unsigned long)
|
||||
MobileGL/MG_Impl/Pipe/SlotAllocator.cpp:92:13
|
||||
#10 MobileGL::MG_Pipe::MGPipeResourceTracker::Acquire(BufferObject&)
|
||||
MobileGL/MG_Impl/Pipe/ResourceTracker.h:293:55
|
||||
#11 MobileGL::MG_Pipe::MGPipeMintResourceHandle(BufferObject&)
|
||||
MobileGL/MG_Impl/Pipe/PipeFill.cpp:610:41
|
||||
#12 MobileGL::MG_State::GLState::BufferObject::BufferObject(unsigned int)
|
||||
MobileGL/MG_State/GLState/BufferState/BufferObject.cpp:44:9
|
||||
... BufferState::CreateBufferObject -> GLImpl::BindBuffer_State (GL_Buffer.cpp:1457)
|
||||
-> CrossFrameBufferScenario::ApplyMutation (CrossFrameBufferScenario.cpp:327)
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-use-after-free include/ska/flat_hash_map.hpp:543:39 in ...::find(...)
|
||||
```
|
||||
|
||||
The same defect in a **plain Release verify build**, without any sanitizer, under gdb
|
||||
(`GLIBC_TUNABLES=glibc.malloc.tcache_count=0`, binary built from today's `feat/disaggregated` head `c20e2f2b`):
|
||||
|
||||
```
|
||||
Thread 1 "MobileGLIntegra" received signal SIGSEGV, Segmentation fault.
|
||||
#0 MGPipeSlotAllocator::FindByLifetimeId(MGPipeKind, unsigned long) const
|
||||
#1 MGPipeEmitResourceDestroyAndFree(BufferObject&)
|
||||
#2 MG_State::GLState::BufferObject::~BufferObject()
|
||||
#3 MG_State::GLState::VertexArrayObject::~VertexArrayObject()
|
||||
#4 MG_Pipe::PipeInputs::~PipeInputs()
|
||||
#5/#6 __run_exit_handlers / exit
|
||||
```
|
||||
|
||||
### ASan matrix at `3e298c9a`, unpatched (one process per case, `abort_on_error=1`)
|
||||
|
||||
| backend | cases run | `heap-use-after-free` at `SlotAllocator.cpp:100` |
|
||||
|---|---|---|
|
||||
| DirectVulkan | 13/13 | **13/13** |
|
||||
| DirectGLES | 13/13 | **13/13** |
|
||||
| controls (`StreamedArenaScenario`, `ResidentIndexScenario`), both backends | 4/4 | **4/4** |
|
||||
|
||||
Every one of them printed `[ PASSED ]` first, exactly as CI did.
|
||||
|
||||
## 5. Owning code
|
||||
|
||||
* **Introduced by:** package B (client). `MG_State/GLState/BufferState/BufferObject.cpp:49-60` (the
|
||||
`MGPipeMintResourceHandle` / `MGPipeEmitResourceDestroyAndFree` pair) and
|
||||
`MG_Impl/Pipe/PipeFill.cpp:741-758`.
|
||||
* **The unsafe singletons:** `MG_Impl/Pipe/SlotAllocator.cpp:170-173` (`MGPipeSlots`, P2 contract package),
|
||||
`MG_Impl/Pipe/ResourceTracker.h:554-557` (`MGPipeResourceTrackerInstance`, package B),
|
||||
`MG_Pipe/PipeApply.cpp:380` (`g_applier`, package A/wire).
|
||||
* **The holder that outlives them:** `MG_Backend/MGPipe/PipeInputs.h:678` + `:691` — `gPipeInputs`'
|
||||
`SharedPtr<VertexArrayObject> m_boundVertexArray`, pre-existing (P1/P2), never released. A verify build has
|
||||
two *more* of these (`MG_Impl/Pipe/PipeFill.cpp:366-367`, `g_snapshot` / `g_readScratch`), but they are
|
||||
**not** what makes it fire: the same two cases SIGSEGV identically with `MOBILEGL_PIPE_VERIFY=0`, i.e. with
|
||||
the comparator never filling those two blocks, so `gPipeInputs` alone is enough. **A shipped push build is
|
||||
exposed exactly as much as a verify build**; the verify lane is only where CI happened to run these cases.
|
||||
* **Not implicated:** `glCopyBufferSubData`'s frontend path (`GL_Buffer.cpp:784-843`,
|
||||
`BufferObject::CopyDataFrom`), `VkBufferManager`'s buffer teardown, `MGPipeApplierReset` /
|
||||
`MGPipeApplierReleaseObjectRecords`, and the `RecordAt` / blob bounds gates — all of those were read and are
|
||||
correct for this shape.
|
||||
|
||||
## 6. Recommended minimal fix (validated here, NOT committed to any shared branch)
|
||||
|
||||
Make every process-scope singleton a frontend destructor can reach outlive `__run_exit_handlers`. Three lines
|
||||
of substance, no behaviour change, no new allocation on any hot path, and G1-neutral (all three sites are
|
||||
inside `#if MOBILEGL_PIPE_PUSH` translation units, so the pull build's symbols do not move):
|
||||
|
||||
```cpp
|
||||
// MG_Impl/Pipe/SlotAllocator.cpp MGPipeSlots()
|
||||
- static MGPipeSlotAllocator allocator;
|
||||
- return allocator;
|
||||
+ static MGPipeSlotAllocator* allocator = new MGPipeSlotAllocator(); // never destroyed
|
||||
+ return *allocator;
|
||||
|
||||
// MG_Impl/Pipe/ResourceTracker.h MGPipeResourceTrackerInstance()
|
||||
- static MGPipeResourceTracker tracker;
|
||||
- return tracker;
|
||||
+ static MGPipeResourceTracker* tracker = new MGPipeResourceTracker();
|
||||
+ return *tracker;
|
||||
|
||||
// MG_Pipe/PipeApply.cpp
|
||||
- MGPipeApplierState g_applier{};
|
||||
+ MGPipeApplierState& g_applier = *new MGPipeApplierState{};
|
||||
```
|
||||
|
||||
(The `g_applier` line is a reference to a never-destroyed block precisely so that the ~60 `g_applier.X` uses in
|
||||
that file need no edit.) Each carries a comment naming the exit-order hazard.
|
||||
|
||||
**Validation performed, all in `~/w7/p3a-asan` at `3e298c9a`:**
|
||||
|
||||
| arm | result |
|
||||
|---|---|
|
||||
| ASan, unpatched, 13 cases × 2 backends + 4 controls | 26 + 4 aborts, all `heap-use-after-free` at `SlotAllocator.cpp:100` |
|
||||
| ASan, patched, same 30 runs | **30/30 clean, rc 0, zero ASan reports** |
|
||||
| plain Release verify build, unpatched, `tcache_count=0`, 13 × 2 | exactly `Vertex/IndexCopyBufferSubData` on DirectVulkan SIGSEGV — the CI selection |
|
||||
| plain Release verify build, patched, `tcache_count=0`, 13 × 2 | **26/26 rc 0** |
|
||||
| plain Release verify build, patched, full `ctest -L integration-verify` | **842/842 passed, 0 failed** |
|
||||
| plain Release verify build, unpatched, `MOBILEGL_PIPE_VERIFY=0`, `tcache_count=0` | both cases still SIGSEGV — the hazard is **not** verify-only |
|
||||
|
||||
**Alternatives considered and rejected as the *minimal* fix:**
|
||||
|
||||
* *Release `gPipeInputs`' object references at context teardown.* Correct in principle (it is also a real
|
||||
object leak: a VAO and its buffers stay alive for the whole process after the context dies) but it is a
|
||||
`MG_Backend/MGPipe` edit, it is contract-frozen territory, and it does not protect the next destructor that
|
||||
reaches a singleton. Worth a follow-up row, not this fix.
|
||||
* *A `g_slotsAlive` latch set in `~MGPipeSlotAllocator`, checked in `MGPipeEmitResourceDestroyAndFree`.* Only
|
||||
covers the one caller and leaves the same trap armed for `~VertexArrayObject`'s new path.
|
||||
* *Ordering the statics.* Not expressible portably; the construction order is decided by the first
|
||||
`glGenBuffers`, not by us.
|
||||
|
||||
**Where the patch lives.** It is **not merged anywhere**. It sits on the private branch **`p3a/asan`**
|
||||
(`82d9f314`, worktree `~/w7/p3a-asan`, parent `3e298c9a`) and, as a plain diff, at
|
||||
`~/w7/notes/p3a/p3a-results/asan-doublefree-v1.patch`. It is *not* landed on `feat/disaggregated` because it
|
||||
spans `SlotAllocator.cpp` (the contract package's file, behind the `p3a/contract` tag) and `PipeApply.cpp`
|
||||
(wire's), and the `p3a/final` rework is in flight on the same tree — the ownership call is the integrator's.
|
||||
It will need a rebase onto the current head (`c20e2f2b`); the three hunks are trivial and should apply as-is.
|
||||
|
||||
## 7. Regression check on the patched tree
|
||||
|
||||
`ctest -L integration-verify --no-tests=error -j 4` on the patched plain Release verify build of `3e298c9a`:
|
||||
**`100% tests passed, 0 tests failed out of 842`** (log: `~/w7/p3a-asan-iverify.log`). That is the same lane
|
||||
and the same 842 entries CI ran, with the two aborts gone and nothing else moved.
|
||||
|
||||
## 8. Follow-ups for the integrator
|
||||
|
||||
1. **The exposure grew with the `p3a/final` rework.** `~VertexArrayObject` now calls
|
||||
`MGPipeEmitVertexElementsDestroyAndFree`, which reaches `MGPipeSlots()` *and* `g_applier`
|
||||
(`delete_vertex_elements`) on the same exit path. Whatever fix lands must cover it; the three-singleton fix
|
||||
above does.
|
||||
2. **`gPipeInputs` never releases its `SharedPtr` GL objects.** Independently of this crash, a VAO, its
|
||||
buffers and their backend twins outlive the context that owned them for the life of the process. Worth its
|
||||
own row.
|
||||
3. **CI cannot see this class today.** Nothing in the gate runs a sanitizer. One cheap arm that would have
|
||||
caught it on day one: run the integration-verify lane once with
|
||||
`GLIBC_TUNABLES=glibc.malloc.tcache_count=0` — it costs nothing and turns this exact defect into a hard,
|
||||
deterministic red.
|
||||
4. `espryt-review-v1` asked for `StorageBufferRegrow` and an adopted-source `DoublePrecisionScenario` under
|
||||
ASan (final-review M-3). The ASan build recipe in §3 is now known-good; those two runs are cheap to add.
|
||||
@@ -0,0 +1,429 @@
|
||||
# P3a package B review — the client (`client-review-v1`)
|
||||
|
||||
Reviewed: `p3a/client` `73bab3d6 / 1ae6b4f4 / 71805d59 / a0ac79cc`, worktree `/home/swung/w7/p3a-client`, diffed
|
||||
against `39722687`. Read-only; a private worktree at `a0ac79cc` was used for the scanner experiments in §6 and
|
||||
removed (`git worktree list` is back to seven, `p3a-client` is clean at `a0ac79cc`).
|
||||
|
||||
## VERDICT: **REWORK**
|
||||
|
||||
Two critical defects, both latent on this tree and both live the moment the granted `*BaseInstance` call sites
|
||||
and package `wire` land underneath. Five majors, one of which (the missing call sites) is known and granted.
|
||||
The emission bodies themselves are, with the exceptions listed, careful and brief-conformant; the failures are
|
||||
at the seams — draw state parked in a container whose `Reset()` is context-scoped, and a re-publication path
|
||||
that was built for the CSO half and not for the resource half.
|
||||
|
||||
The package's own §5 evidence stands. I re-ran the four generator/closure gates and both scanner directions
|
||||
myself (§6); all green, and the scanner's new mechanism has a live control.
|
||||
|
||||
---
|
||||
|
||||
## 1. Critical
|
||||
|
||||
### B-C1 — the tracker's context `Reset()` zeroes the pending base instance that the same call is about to read
|
||||
|
||||
`MG_Impl/Pipe/Tracker.h:373` — `Reset()` does `m_pendingBaseInstance = 0;`. `Reset()` is called from
|
||||
`MGPipeTracker::Update` itself at `Tracker.h:194-197`:
|
||||
|
||||
```cpp
|
||||
if (m_context != &ctx) { Reset(); m_context = &ctx; }
|
||||
```
|
||||
|
||||
and the value is read two screens later at `Tracker.h:286` (bit 9's shutter) and at
|
||||
`MG_Impl/Pipe/PipeFill.cpp:1335` (`tracker.PendingBaseInstance()` → `EmitVertexBuffers`).
|
||||
|
||||
**Failure scenario.** `eglMakeCurrent(ctxB); glDrawArraysInstancedBaseInstance(..., baseinstance = 7);`
|
||||
The granted call site runs `MGPipeSetPendingBaseInstance(7)` immediately before `MGP_FILL`. `MGP_FILL` →
|
||||
`MGPipeValidateForVerb` → `tracker.Update(*ctxB, ...)` sees `m_context != &ctxB`, calls `Reset()`, and the 7 is
|
||||
gone before either reader sees it. `FreshlyPrimed` then sets every bit, so `set_vertex_buffers` **does** go out —
|
||||
carrying `BaseInstance = 0`. Espryt computes `fetchBaseInstance = UseNativeBaseInstance() ? 0 : 0` and, on a
|
||||
device without `GL_EXT_base_instance`, fetches every instanced array from element 0. One silently mis-shifted
|
||||
instanced draw per context switch, on the emulation path, with no gate: the desktop retrace corpus is
|
||||
single-context, `DrawParametersScenario` does not switch contexts between the setter and the draw, and the unit
|
||||
case that pins the hash (`VertexInputEmit.ABaseInstanceChangeAloneStillEmitsTheVertexBufferSet`) calls
|
||||
`EmitVertexBuffers(Ctx(), 7)` directly and never touches the tracker.
|
||||
|
||||
**Refutation attempted, three ways, all fail.** (a) *"Reset only happens at teardown"* — no; `Tracker.h:194`
|
||||
fires on every change of the current `GLContext`, which is what `wire-review-v1.md`'s C1 established for the
|
||||
applier through the same three lines. (b) *"the setter could run after Update"* — it cannot; D-H2.1 and B's own
|
||||
`PipeFill.h:65-70` put it immediately **before** `MGP_FILL`, and `Update` is inside it. (c) *"a fresh context is
|
||||
a fresh server, so clearing is right"* — the pending base instance is not context state, it is **this call's
|
||||
argument**. Everything else `Reset()` clears is a latch describing what the server was told; this one is an
|
||||
input that has not been read yet. The fact that `Reset()` clears it is the bug, not the mitigation.
|
||||
|
||||
**Fix (one line, in B's file):** delete `Tracker.h:373`. The value is already cleared unconditionally at the end
|
||||
of every verb (`PipeFill.cpp:1446`) and again in `MGPipeLeaveVerb` (`PipeFill.cpp:801`), so it is provably 0 at
|
||||
every `Update` except the one that immediately follows a setter — which is the one that must see it. Add the
|
||||
case that would have caught it (§7).
|
||||
|
||||
### B-C2 — the resource family has no re-publication path after `MGPipeApplierReset()`; the vertex-input family has one
|
||||
|
||||
`PipeFill.cpp:1404-1412`, the `FreshlyPrimed` arm, resets four things: the CSO cache, the applier, the set-hash
|
||||
suppressor and — B's addition, correctly — `MGPipeVertexInputEmitterInstance().Reset()`. Nothing resets or
|
||||
re-arms `MGPipeResourceTrackerInstance()`, and `MG_Impl/Pipe/ResourceTracker.h:390-393` states the absence as
|
||||
policy: *"A unit fixture's per-case reset. **Never called by the library**: a context change does not invalidate
|
||||
a handle."*
|
||||
|
||||
That is true of the handle and false of the **record**. `MGPipeApplierReset()` empties `g_applier.Resources`
|
||||
(`wire-review-v1.md` C1: *"At each switch `g_applier.Resources` is emptied (`:558`)"*), and the client's only
|
||||
producer of a record is `MGPipeEmitResourceCreate`, emitted from the `BufferObject` **constructor**
|
||||
(`MG_State/GLState/BufferState/BufferObject.cpp:44-45`), which a context switch does not re-run.
|
||||
|
||||
**Failure scenario.** Share-group buffer `B` created under `ctxA`. `eglMakeCurrent(ctxB)`; first draw →
|
||||
`FreshlyPrimed` → `MGPipeApplierReset()` empties `Resources`. Now `glBufferSubData(B)`: the client emits
|
||||
`ResourceSubData` for a handle whose record is no longer `Live`; the applier's `FindResource` returns null and
|
||||
the call is **dropped** — *"nothing stored, nothing dispatched, no serial"* — with the only trace a
|
||||
`MOBILEGL_ASSERT` that is inert at `INFO`, which is what both gate builds use. The upload is lost. Every later
|
||||
draw from `B` renders stale geometry, and `IsBufferDrawCleanByHandle` reports clean because no serial moved.
|
||||
|
||||
**Refutation attempted.** (a) *"wire owns the reset, so this is wire's defect"* — wire raised it and explicitly
|
||||
routed the decision here: *"B (whose `ResourceTracker.h` mints the handles) or the integrator must decide:
|
||||
re-emit `ResourceCreate` + `ResourceRespecify` on first use after a reset, or take `Resources` /
|
||||
`VertexElementsCsos` out of the reset … **This … must be settled before `p3a/client` lands**"*
|
||||
(`wire-v1.md` §5 item 1). `client-v1.md` does not mention the item anywhere — not in §4's deviations, not in
|
||||
§6's "left undone", not in §7's re-run list. (b) *"not reachable today"* — correct and irrelevant; it is
|
||||
reachable the moment `wire` + `espryt` are underneath, which is the tree the integrator is building. (c) *"the
|
||||
CSO precedent covers it"* — it does not, and B proved that by having to add `MGPipeVertexInputEmitterInstance()
|
||||
.Reset()` for exactly this reason (`PipeFill.cpp:1408-1411`). The asymmetry is the finding: B saw the problem
|
||||
for the half it could fix from the emitter and did not carry the reasoning to the half whose producer is a
|
||||
constructor.
|
||||
|
||||
**Fix (in B's files, the option wire named "re-emit on first use"):** give `MGPipeResourceTracker` a
|
||||
`Uint64 m_publishEpoch` and a per-`Entry` `PublishedEpoch`; bump `m_publishEpoch` from the `FreshlyPrimed` arm
|
||||
beside the emitter reset; in `MGPipeEmitResource{Respecify,SubData,FlushRange,Readback,MapPersistent}` and
|
||||
`…BufferSubDataResident`, when `entry.PublishedEpoch != m_publishEpoch`, emit `ResourceCreate` (and, for the
|
||||
non-respecify calls, a `ResourceRespecify` carrying the live `GetSize()/GetUsage()/GetStorageFlags()`) before the
|
||||
call and stamp the entry. That is the same shape `MGPipeVertexInputEmitter::EmitCreate` already has. If the
|
||||
integrator instead exempts `Resources` / `VertexElementsCsos` from the reset, B still owes the deletion of
|
||||
`ResourceTracker.h:390-393`'s claim and a line saying which decision was taken.
|
||||
|
||||
---
|
||||
|
||||
## 2. Major
|
||||
|
||||
### B-M1 — the three `MGPipeSetPendingBaseInstance` call sites (known, granted; here are the exact points)
|
||||
|
||||
`MG_Impl/GLImpl/Drawing/GL_Drawing.cpp`. The public entry points at `:1088`, `:1108`, `:1132` delegate to the
|
||||
`*_Backend` functions, and `MGP_FILL` is in the latter. One line each, **immediately above** the `MGP_FILL`:
|
||||
|
||||
| function | file:line of the `MGP_FILL` | line to insert above it |
|
||||
|---|---|---|
|
||||
| `DrawElementsInstancedBaseVertexBaseInstance_Backend` (`:655`) | `GL_Drawing.cpp:662` | `MG_Pipe::MGPipeSetPendingBaseInstance(baseinstance);` |
|
||||
| `DrawElementsInstancedBaseInstance_Backend` (`:678`) | `GL_Drawing.cpp:684` | `MG_Pipe::MGPipeSetPendingBaseInstance(baseinstance);` |
|
||||
| `DrawArraysInstancedBaseInstance_Backend` (`:707`) | `GL_Drawing.cpp:713` | `MG_Pipe::MGPipeSetPendingBaseInstance(baseinstance);` |
|
||||
|
||||
The value is the **raw** `baseinstance` argument, never `EmulatedFetchBaseInstance(baseinstance)`: whether to
|
||||
emulate the shift is the server's (`wire-v1.md` A1 stores `hdr.BaseInstance` unresolved and hands the decision to
|
||||
package C). Each site must be inside `#if MOBILEGL_PIPE_PUSH` or behind a pull-build no-op — `MGPipeSetPending
|
||||
BaseInstance` is declared in `PipeFill.h` outside any guard but defined at `PipeFill.cpp:783`, which is inside
|
||||
the file's push-only region, so a pull build would fail to link if the call is unguarded. **Check that when the
|
||||
lines land.**
|
||||
|
||||
**What the reset in `MGPipeLeaveVerb` must guarantee — and what it actually guarantees.** `grep` over
|
||||
`MobileGL/` finds `MGPipeLeaveVerb` called from exactly two places: `MG_Test/ScopedPipeVerb.h:73` and
|
||||
`MG_Test/Pipe/TrackerTest.cpp:651`. **No GL entry point calls it.** So `PipeFill.cpp:801`'s clear guarantees
|
||||
only that a unit case which opens a `ScopedPipeVerb` cannot leak a base instance into the next case. The
|
||||
production guarantee is entirely `PipeFill.cpp:1446`'s unconditional `tracker.ClearPendingBaseInstance()` at the
|
||||
end of step 3, and the property it must hold is: *the pending value is consumed by exactly the verb whose entry
|
||||
point set it, and is 0 at every other `Update`*. It holds — with one hole, `PipeFill.cpp:1371`'s
|
||||
`if (ctx == nullptr) return;`, which skips the clear; a base-instanced draw with no live context would leave the
|
||||
value standing for the next verb. Harmless in practice (a draw with no context is already a no-op) but it is the
|
||||
one path the "neither of them relies on the other" claim in `client-v1.md` §4 B-DEV-3 does not cover, and
|
||||
B-C1's fix makes `Reset()` no longer a second safety net. Move the clear above the `ctx == nullptr` return, or
|
||||
say why not.
|
||||
|
||||
### B-M2 — the content emitters mutate the process-global slot allocator on a path Espryt documents as off-thread
|
||||
|
||||
`PipeFill.cpp:622, 656, 669, 696` each open with `MGPipeResourceTrackerInstance().Acquire(buffer)`, which is
|
||||
`ResourceTracker.h:262-268`: `MGPipeSlots().Acquire(...)` (a `FindByLifetimeId` on a non-atomic map, then a
|
||||
free-list pop and a map insert on a miss) followed by `m_bySlot.resize(slot + 1)`.
|
||||
|
||||
D-A2's `SubData` row preserves *"the off-thread/stale queue"* arm of `Ops_SubData` verbatim, i.e. the design
|
||||
states that `BufferObject::NotifySubData` is reachable off the render thread. Today that path touches one
|
||||
`const BufferBackendOps*` read and the backend's own mutex. B adds an unsynchronised insert into a global map
|
||||
and a possible `Vector` reallocation to it. Two threads in `Acquire` for two different buffers, or one in
|
||||
`Acquire` while another is in `Free` from `~BufferObject`, is a data race with a torn free list and a dangling
|
||||
`m_bySlot` span as the outcomes.
|
||||
|
||||
**Refutation attempted.** *"Acquire is a lookup for an existing buffer, so it does not mutate"* — the lookup
|
||||
itself walks a map another thread may be rehashing, and `m_bySlot.resize` is reached whenever the slot index
|
||||
exceeds the vector, which a concurrent `Acquire` on the other thread can cause between the two statements.
|
||||
*"contract-review item 13 already accepts non-atomic parity"* — that item is about the `g_resourceOps` pointer,
|
||||
a single word written only at bring-up; this is a container mutated on the hot content path.
|
||||
|
||||
**Fix, and it is cheap and strictly better:** the handle is minted unconditionally in the constructor
|
||||
(`BufferObject.cpp:44`), so on every content path it already exists. Replace `Acquire(buffer)` with
|
||||
`Find(buffer)` (`ResourceTracker.h:273`, const, no allocator mutation) in
|
||||
`MGPipeEmitResource{SubData,FlushRange,Readback}`, `MGPipeEmitBufferSubDataResident` and
|
||||
`MGPipeEmitMapPersistent`, and treat a null handle as a loud `MGLOG_E_ONCE` + return (which is also the
|
||||
diagnostic B-C2 needs). `Acquire` then survives only in the constructor path and in the two validate-time
|
||||
vertex emitters, both of which are GL-thread by construction.
|
||||
|
||||
### B-M3 — `hostBytes` disagreement with package C: espryt latches the **shadow base**, the client sends **base + offset**
|
||||
|
||||
`espryt-v1.md` §1 e1: *"`GLESBufferResource` gains one push-only member, `const Uint8* hostBytes`: **the client's
|
||||
shadow base** as the last content-carrying resource call left it. It is what the three-tier flush, the pool
|
||||
reseed and the full re-upload read on the handle arm"*, and D10: *"(The three content-carrying calls that do
|
||||
record it — respecify / sub-data / flush-range — all carry the client's own shadow.)"*
|
||||
|
||||
The client sends, per D-A2 and correctly: `PipeFill.cpp:623` `base = buffer.MappedData()` then `base + at` per
|
||||
piece; `PipeFill.cpp:666` `buffer.MappedData() + offset`. Only `MGPipeEmitResourceRespecify`
|
||||
(`PipeFill.cpp:614`) passes the true base. So after any `glBufferSubData(b, 4096, …)` Espryt's `hostBytes` is
|
||||
`shadow + 4096`, and the next pool reseed or full re-upload reads 4096 bytes past the store's end.
|
||||
|
||||
**Refutation attempted.** *"B is wrong to add the offset"* — no: D-A2 spells `bytes = MappedData() + offset` for
|
||||
`SubData` and `MappedData() + Offset` for `FlushRange`, and the applier hands the pointer straight to
|
||||
`ops->SubData(res, record, bytes)` where the record's box carries the offset. B is brief-conformant; **espryt's
|
||||
latch is the side that must change** (`hostBytes = bytes - MGPipeSubDataBufferOffset(record)`, or drop the latch
|
||||
on the two ranged calls and keep it only on respecify). Recorded here because it is a merge-time defect that
|
||||
neither package's own gates can see, and `espryt-v1.md` §6 item 14's confirmation list does not include it.
|
||||
|
||||
### B-M4 — the sampled `BindMask` widens the D-A3 hole in exactly the direction the risk register names, and the stated ownership reason misquotes C.1
|
||||
|
||||
`ResourceTracker.h:332-380` (`RefreshBindMask`), called only from `MGPipeEmitResourceCreate`
|
||||
(`PipeFill.cpp:592`) and `MGPipeEmitResourceRespecify` (`PipeFill.cpp:606`).
|
||||
|
||||
Two separate problems.
|
||||
|
||||
**(a) The stated reason is wrong.** B-DEV-2 says the bind entry points *"are `MG_Impl/GLImpl/Buffer/GL_Buffer.cpp`'s,
|
||||
which C.5 assigns to no package and **C.1 does not list for this one**"*. C.1's file table **does** list
|
||||
`MobileGL/MG_State/GLState/BufferState/BufferState.{h,cpp}` with the note *"the sticky `everBoundAs` mask's bump
|
||||
points at the buffer bind entry points (D-A3), all `#if MOBILEGL_PIPE_PUSH`"*, and C.5 gives B
|
||||
`MG_State/GLState/BufferState/**`. I checked whether the brief was simply wrong about where the binds are:
|
||||
`BufferState` (`BufferState.h:38-43`) only *vends* `BindingSlot<BufferObject>&` / `BindingSlotRange1D&`, and the
|
||||
`.Bind()` calls are at `GL_Buffer.cpp:1463`, `:1518`, `:1531` and in `BindBufferRange_State` (`:1602`) — none of
|
||||
them B's. So the **substance** of the deviation survives; the **sentence** does not, and the difference matters
|
||||
because it reads as "no package owned it" when what is true is "the brief pointed at a file that turned out not
|
||||
to contain the entry points". Correct the record.
|
||||
|
||||
**(b) The hole is not the one B describes.** B says sampling *"widens it from 'a bind after the last respecify'
|
||||
to 'a bind after the last resource emission of any kind'"*. The real widening is a **transient** bind: with
|
||||
OR-at-bind the mask is correct in client state forever after the bind, and any later respecify publishes it;
|
||||
with sampling, `glBindBuffer(ELEMENT_ARRAY, ebo); glDrawElements(…); glBindBuffer(ELEMENT_ARRAY, 0);
|
||||
glNamedBufferSubData(ebo, …); glNamedBufferData(ebo, …)` publishes a respecify whose sample sees no binding at
|
||||
all, so `ELEMENT_ARRAY` is never set even though a respecify followed. The DSA idiom makes this the common case,
|
||||
not the corner: `TryAdoptLargeStorage`'s own comment (`BufferObject.cpp:215-217`) names `glNamedBufferSubData` as
|
||||
what MC 26.3 streams with, and a DSA-defined EBO may never be bound at any emission. `MGPResourceDesc::BindMask
|
||||
& ELEMENT_ARRAY` is the `kCapNeedsHostIndexBytes` switch; getting it wrong silently disables restart rewriting
|
||||
and multi-draw flattening under split, is invisible in monolith, and the brief's risk register says this is
|
||||
*"the one P3a deliverable whose only real gate is a unit test"*.
|
||||
|
||||
**Fix, entirely inside B's files and better than the handed-on `GL_Buffer.cpp` hook for the bit that matters:**
|
||||
`MGPipeVertexInputEmitter::EmitVertexBuffers` and `EmitIndexBuffer` already resolve, at every draw, exactly the
|
||||
attribute buffers and the element-slot buffer (`VertexInputEmit.h:200`, `:240`). Call
|
||||
`MGPipeResourceTrackerInstance().NoteBoundAs(handle, BufferTarget::Vertex)` / `…::Index` there. Any buffer ever
|
||||
drawn from then carries its bit for the rest of its life, whether or not it was bound at a storage op, and the
|
||||
`GL_Buffer.cpp` hook stays a P8 nicety for the seven bits nothing keys on. Also call `RefreshBindMask` from the
|
||||
other four emitters, not just create/respecify — the mask is only *published* on create/respecify, so extra
|
||||
sampling can only widen the sticky union.
|
||||
|
||||
Secondary, same function: `BindEpoch` (`ResourceTracker.h:414-425`) sums only the 14 global slot versions plus
|
||||
the bound VAO's element-slot version and identity. It does not see the 84×4 indexed binding points. That is
|
||||
sound today only because `BindBufferBase_State` also binds the generic slot (`GL_Buffer.cpp:1531`, with the
|
||||
comment saying why); if that ever stops being true, `CONSTANT`/`SHADER_BUFFER`/`ATOMIC`/`STREAM_OUTPUT` start
|
||||
being missed silently. One sentence in the comment, or fold `GetTouchedBufferBindingPointCount` into the epoch.
|
||||
|
||||
### B-M5 — `UnmapPersistent` has no producer, and the omission is not recorded
|
||||
|
||||
D-A2's row and my review brief both name the pair *"map/unmap persistent → `MapPersistent` / `UnmapPersistent`"*.
|
||||
`PipeMutation.h:1626-1657` declares eight emitters plus the mint; there is no `MGPipeEmitUnmapPersistent`, and
|
||||
`grep` finds no client call to `MGPipeApplyUnmapPersistent`. So a catalogue call that `wire` implemented is dead
|
||||
in P3a and its gate can never go red.
|
||||
|
||||
**Refutation attempted, and it succeeds on the substance:** `BufferBackendOps` has seven hooks and none of them
|
||||
is an unmap; `PipeResource::ReleasePersistentMap()` (`BufferObject.cpp:157`, from `RedefineStorage`) tells the
|
||||
backend nothing today and the backend learns from the `Respecify` that follows. Emitting `UnmapPersistent` would
|
||||
be **new behaviour**, which D-J forbids. So the right answer is "no producer in P3a, deliberately" — but
|
||||
`client-v1.md` §6 does not say it, and a reader of the catalogue cannot tell a deliberate absence from a missed
|
||||
hook. Add the row to §6 and a sentence beside the `MapPersistent` emitter.
|
||||
|
||||
---
|
||||
|
||||
## 3. Minor
|
||||
|
||||
| # | finding | file:line |
|
||||
|---|---|---|
|
||||
| m1 | `MGPipePendingBaseInstance()` has no caller anywhere, and its stated reason — *"Exists for the unit gate, which drives the emitter without a draw entry point to set it"* — is false: no test calls it (`grep` finds only the declaration and the definition). Either use it in the case B-C1 needs, or delete it. | `PipeFill.h:70`, `PipeFill.cpp:787` |
|
||||
| m2 | contract-review must-know item 10 (*"B must reject an attribute index ≥ 256 before narrowing"*) is not discharged: a bare `static_cast<Uint8>`. Safe only by an invariant of `VertexArrayObject`, which is another package's file — the same "assert rather than assume" rule B applies, correctly, to the staging mirror at `PipeFill.cpp:1288-1300`. Same class: `entry.Stride = static_cast<Uint32>(attrib.Stride)` narrows a signed value with no check (contract-review m6 asks for both directions). | `VertexInputEmit.h:89`, `:206` |
|
||||
| m3 | `MGPSubData::SourceIsVerbatimLevelShadow = 1` is set unconditionally by the shared builder, including on the `buffer_subdata_resident` path where the bytes are the application's staging store, and on the `FillSubData` path where they are a locally expanded pattern (`BufferObject.cpp:497-506`). The field's documented meaning is *"are these bytes an untransformed level shadow?"*; on those two callers the answer is no. Nothing reads it on the buffer path today. | `ResourceTracker.h:200`, `PipeFill.cpp:645` |
|
||||
| m4 | `MGPipeBuildSubDataRecord`'s `Bool` return is discarded inside both walk lambdas. Unreachable because the pre-pass at `ResourceTracker.h:235-237` proves every piece encodable first — but if that pre-pass is ever relaxed, a `false` emits a zeroed record (null handle, size 0) rather than refusing. One `if`. | `PipeFill.cpp:626-629`, `:644-647` |
|
||||
| m5 | `MGPipeClientOnGpuWritten` discards `rangeCount`/`ranges`. `espryt-v1.md` D8 makes the shape a contract point *"the client's `OnGpuWritten` must read it that way"*: one range of `kMGPipeWholeBuffer`, deliberately not zero ranges, because zero will mean a fully narrowed set at P8/P9. B's implementation would mark a whole buffer written for a zero-range announcement. Safe direction today; encode the contract (assert the shape, or name it in the comment). Same function resolves-to-null silently, unlike its sibling at `:461-464`. | `ResourceTracker.h:485-489` |
|
||||
| m6 | `ResourceEmit.EveryBufferTargetSetsItsBindMaskBit` asserts `respecified.BindMask == MGPipeBindMaskForBufferTarget(target)` — the emitted value against the table under test. It pins the plumbing, not the table, for 14 of the 15 targets; only `Index` gets a literal (`:228`). The risk register calls this case the only real gate on the `ELEMENT_ARRAY` bit. Assert literals per target. | `ResourceEmitTest.cpp:214-216` |
|
||||
| m7 | `set_index_buffer` has no content suppressor and bit 10's shutter mixes `vaoIdentity`, which includes `GetConfigVersion()`. Any VAO reconfiguration therefore re-emits an identical `MGPIndexBuffer` and moves the applier's `IndexBufferSerial`, which is precisely the memo espryt's `m_syncedIndexSerial` early-out reads. Correctness is fine (over-fire); it is a measurable per-draw cost for a reconfiguring app. Latch `m_lastIndex` and skip the apply when unchanged. | `VertexInputEmit.h:235-245`, `Tracker.h:293-301` |
|
||||
| m8 | `DirtySurface.def:292-294`'s new comment states that `MarkVertexArrayForDeletion` *"→ `delete_vertex_elements`, published through the death notice"*. By B-DEV-8 this package emits no `delete_vertex_elements`; the row's comment asserts a publication that becomes true only when package C lands. Mark it "(from `espryt`)". | `DirtySurface.def:292-294` |
|
||||
| m9 | Bits 7 and 8 are documented as an independent per-subsystem A/B, and are not: `EmitVertexBuffers`/`EmitIndexBuffer` name buffer handles by `{slot,gen}` whether or not the resource family created a record for them, so a mask with bit 8 set and bit 7 clear sends the server handles it cannot resolve. Not reachable from `0x1ff` or from G12's `0x7f`; state the coupling where an operator reads it. | `VertexInputEmit.h:200`, `:240` |
|
||||
| m10 | `desc.Width = static_cast<Uint32>(buffer.GetSize())` truncates silently for a store ≥ 4 GiB; the applier's range gate then aborts a legal write as `Fatal{ProtocolCorruption}`. The 32-bit `Width` is the contract's, not B's, but the truncation should be a refusal or a `MOBILEGL_ASSERT`. | `ResourceTracker.h:180` |
|
||||
| m11 | `MGPSubData::Blob` is filled (`Seg`, `Size`) while `wire-review-v1.md` M-E leaves it an open one-rule decision (*"either gate `Blob.Size` when non-zero, or state … that B must not fill it"*). Harmless — the applier never reads it — but B and wire must not settle it differently. | `ResourceTracker.h:201-203` |
|
||||
| m12 | Create/destroy pairing is gated in two different places: the create at the call site (`BufferObject.cpp:45`), the destroy inside the helper (`PipeFill.cpp:699`). A buffer constructed while a table is registered and destroyed after `UnregisterBufferBackendOps()` frees its slot without emitting `ResourceDestroy`, leaving the applier record `Live` and Espryt's twin (a driver buffer id) alive on a slot about to be re-handed-out. Espryt's M2 (`GetOrCreate(MGPipeHandle)` adopting a stale generation) is the only thing standing between that and a cross-buffer id mix-up. Latch the decision on the `Entry` at mint time and use the latched value in both places. | `BufferObject.cpp:45`, `:55-57`; `PipeFill.cpp:695-706` |
|
||||
|
||||
---
|
||||
|
||||
## 4. Judgement of the nine declared deviations
|
||||
|
||||
| dev | verdict |
|
||||
|---|---|
|
||||
| **B-DEV-1** declarations in `PipeMutation.h` | **Correct, and the only shape available.** `MG_State` may not include `MG_Impl/Pipe/ResourceTracker.h`; the closure probe still reports `mutation-header OK, 84 headers, 0 forbidden` (I re-ran it). The forward declaration of `BufferObject` is the whole coupling. Accept. |
|
||||
| **B-DEV-2** sampled `BindMask` | **Accept the mechanism, reject the reasoning and the hole assessment.** See B-M4. |
|
||||
| **B-DEV-3** bit 9's shutter gains the pending base instance | **Correct and necessary; keep it.** D-H4 read literally does not work, for exactly the reason B gives: neither `GetAnyVaoAttributeGeneration` nor `vaoIdentity` moves on a base-instance-only draw, so the emitter is never reached and the content hash never gets its chance to refuse suppression. The over-fire is bounded to draws that carry one and the first plain draw after. **But** it is what makes B-C1 fatal: the deviation put draw state into the shutter without moving it out of the container whose `Reset()` is context-scoped. Accept with B-C1's fix. |
|
||||
| **B-DEV-4** what the widened scan found | **Accept.** Both rows are real (`BumpSamplingResolutionGeneration` had no row at all; `NoteUnitTouched` is unreachable by `pGLContext->`), the `kPulledPartialShutter|NEW_SAMPLER_VIEWS` answer is derived and checked, and declining to mint a `kNoteMutation` prose word was the right call — a new prose answer is a row no derivation can back. I verified the mechanism has a live control (§6). |
|
||||
| **B-DEV-5** `TrackerTest` follows `kMGPipeDirtyEmittedAtP3a` | **Accept.** The name is unchanged (G14), the property is unchanged, the P2 constant was not edited in place, and the three new arms are asserted by name. |
|
||||
| **B-DEV-6** the splitter is a capped walk, cap as a parameter | **Accept, and it is better than the brief.** D-A2's "the emitter must split" is genuinely unreachable at the record's own bounds — a second piece starts ≥ 2³²−1 past the first, already past the 2³¹−1 offset cap — and refusing whole (all-or-nothing, nothing emitted before the decision) is the only safe answer for a content write. The unit case drives the split at 32 MiB, which is the bound P5 will actually hit. |
|
||||
| **B-DEV-7** `kMGPipeResourceTargetBuffer` / `MGPipeBindBit` spelled client-side | **Accept, with the coordination item live.** `Target = 0` for the buffer arm matches `MGPipeTypes.h:148`'s documented order and a zero-initialised record. Nothing in `wire-v1.md` or `espryt-v1.md` states a different value; the integrator must still confirm it once, as B asks. |
|
||||
| **B-DEV-8** no `delete_vertex_elements` here | **Accept.** C.1's emitter list names only three, and the consumer is `MG_Backend`'s. See m8 for the `.def` comment. |
|
||||
| **B-DEV-9** the two client callbacks are installed over a null slot only | **Accept.** Installing from the mint's one-shot means they exist before any backend can call them, and never over an entry a backend claimed. See m5 for the shape. |
|
||||
|
||||
Two things `client-v1.md` claims that I could not sustain: §4 B-DEV-3's *"neither of them relies on the other
|
||||
being called"* (B-M1 — `MGPipeLeaveVerb` is called by no GL entry point, so in production there is only one
|
||||
clear, and `PipeFill.cpp:1371`'s early return skips it), and §2's *"the verify lane cannot regress on account of
|
||||
a skipped field — there is none"*, which is true and which I re-derived independently (§5).
|
||||
|
||||
---
|
||||
|
||||
## 5. Dimension-by-dimension, where I did not raise a finding
|
||||
|
||||
**(1) Emission correctness.** All eight/nine dispatch sites carry exactly one call and fall through unchanged:
|
||||
`~BufferObject` (`:50-57`), `NotifyRespecify` (`:67-71`), `NotifySubData` (`:83-87`), `NotifyFlushMappedRange`
|
||||
(`:99-106`), `TryAdoptLargeStorage` (`:233-237`), `SyncGpuWrites` (`:371-379`), `LandBytesIntoResidentStore`
|
||||
(`:430-452`), `FillSubData`'s nullability probe (`:488-495`), `EnsureGpuResidentStorage` (`:598-604`),
|
||||
`AcquireMemoryRange`'s persistent arm (`:650-658`). I diffed each push arm against the pull arm below it
|
||||
statement by statement; the guards (`m_size != 0`, `bytes.size > 0`, `!IsGpuResident && Write && !FlushExplicit`)
|
||||
are reproduced exactly, and the `size == 0` and decline fall-throughs land on the same code. `NotifyRespecify` is
|
||||
called after `m_size`, `m_storageFlags`, `m_isImmutableStorage` and `m_hasDefinedContent` are all final
|
||||
(`:187-189`, `:206-210`), so `Immutable` — the `kNeedsAck` predicate's discriminator — is right for both idioms.
|
||||
`initialBytes` is `MappedData()` only under `HasDefinedContent`, which preserves the orphaning idiom.
|
||||
`MGPipeResourceOpsHaveSubDataResident()` discharges `wire-review-v1.md` n7 *before* wire wrote it down — the
|
||||
client's dispatch gate on the resident path is the member, not the subsystem predicate. The `BufferTarget`
|
||||
`static_assert` is complete (no `default:`, `kMGPipeBindUnmapped` sentinel, a second assert pinning
|
||||
`Index ⇒ ELEMENT_ARRAY`).
|
||||
|
||||
*"`ResourceSubData` on a buffer with no prior respecify"*: not reachable from a legal GL sequence. A
|
||||
`glBufferSubData` on an unsized buffer is `INVALID_OPERATION`/`INVALID_VALUE` at the GL layer and never reaches
|
||||
`NotifySubData`; a zero-size `glBufferData` followed by a non-empty `glBufferSubData` is likewise rejected
|
||||
upstream (and `NotifySubData` early-returns on `size == 0` at `:82` before any emission). The applier's `Width`
|
||||
gate is therefore armed against a client bug, not against an application. B-C2 is the one way it fires.
|
||||
|
||||
**(2) Vertex input.** The wire conversion is field-for-field (`VertexInputEmit.h:80-91`) and I checked that each
|
||||
of the eleven copied members is individually detectable by
|
||||
`EveryAttributeFieldSurvivesTheWireConversion`: the fixture's three configuration families give every field at
|
||||
least one non-default value across the 32 slots (`Offset` 64+4i, `Stride` 16+i / a binding-model 0, `Type`
|
||||
cycling six values, `Size` 1..4, `Enabled` alternating, `Normalized` i%3, `IsInteger` i%5, `IsLong` on the two
|
||||
L-format doubles, `IsBgra` on the tail, `BindingIndex` deliberately `(i+5)%32 ≠ i`). Each assertion is a
|
||||
separate `EXPECT_EQ` naming both sides, under a `SCOPED_TRACE` carrying the index, so G7's scripted drop answers
|
||||
by field name — B's hand-run of the `IsBgra` drop is representative, not lucky. `AttributeCount`/
|
||||
`BindingPointCount` are both 32 and `Blob.Size = 32*24 + 32*16 = 1280` exactly, which is what
|
||||
`wire-v1.md` §5 item 2's `Fatal{ProtocolCorruption}` gate requires. `Start = 0`, `Count = highest enabled + 1`
|
||||
means no *enabled* attribute can ever index past `Count`, so wire's "entries outside the window are not cleared"
|
||||
cannot bite. `BindingIndex == attribute index` matches what `espryt-v1.md` §6 item 14 says
|
||||
`VertexBufferForBindingIndex`'s fast path assumes. The per-handle latch is per handle and includes `Gen`
|
||||
(`VertexInputEmit.h:172-174`), so a recycled slot re-creates. The suppressor's reserved-0 rule is the
|
||||
suppressor's own (`SetHashSuppressor.h:62-63` remaps a computed 0 to 1); the emitter does not need to.
|
||||
`SetIndexBuffer` is emitted independently of the CSO's configuration version. `SyncClientSideAttributesForDraw
|
||||
Arrays` is untouched and `Res == kMGPipeNullHandle` for a client array is emitted as designed.
|
||||
|
||||
**(3) Tracker.** The three `MGPipeSubsystemForDirty` arms are present and paired
|
||||
(`Tracker.h:141-148`, asserted by the P2 `static_assert`s with no edit, exactly as the contract commit asked).
|
||||
Bit 10's narrowing is real and its two cases are well built — in particular the wrap case cycles **three**
|
||||
buffers, because two would put the version and the bound object on the same parity and the wrap would be
|
||||
unobservable; that is the one construction that makes the identity half load-bearing.
|
||||
|
||||
**(4) Verify-lane soundness.** With bits 7 and 8 in `kMGPipeWiredSubsystems` (`PipeFill.cpp:918-924`), `supplied`
|
||||
at `PipeFill.cpp:1470` can newly be true only for a field whose `SubsystemForEmitter` returns one of the two.
|
||||
`kMGPipeSubsystemResources` is returned for no `MGPipeFieldEmitter` (the resource family has no `Coverage.def`
|
||||
emitted row), and `kMGPipeSubsystemVertexInput` names exactly `GetBoundVertexArray`, for which
|
||||
`EmittedCallSuppliesTheWholeField` returns `false` (`PipeFill.cpp:964-969`). **No field is newly skipped; P3a
|
||||
retires no pull.** That discharges contract-review must-know item 3, which said the omission would be silent and
|
||||
catchable only by G4 — and the 79/79 verify-armed retrace with zero divergence and zero unarmed cases is the
|
||||
independent confirmation. Ordering: the seven resource hooks emit after the frontend state they read is final
|
||||
(above); the three vertex emitters run at validate time, after the entry point's state writes.
|
||||
|
||||
**(5) G1.** `BufferObject.h` is untouched; no member, no virtual, no base was added; every edit is inside
|
||||
`#if MOBILEGL_PIPE_PUSH` and the constructor and destructor are out-of-line. `sizeof(BufferObject)` and its
|
||||
vtable cannot move in a pull build, which is what the 0/0/0/0 reading against the original baseline says. The
|
||||
one resize B found and fixed during b1 (`SyncGpuWrites`'s dropped `m_size == 0 ||`) is exactly the failure mode
|
||||
D-K predicts and is the evidence the gate can go red. Per ID-1/ID-8/ID-9 the reading is valid against the
|
||||
baseline it was taken against; the re-measure is the rebase's.
|
||||
|
||||
**(6) The scanner.** I ran all three directions myself in a throwaway worktree at `a0ac79cc`:
|
||||
inserting a row for a mutator that does not exist → `rc=1`, *"STALE row SetSomethingThatDoesNotExist"*; deleting
|
||||
the `BumpSamplingResolutionGeneration` row → `rc=1`, *"UNMAPPED mutator BumpSamplingResolutionGeneration"*;
|
||||
and — the control B did not run — removing the new `MGP_NOTE_MUTATION` attribution from `scan_file` → `rc=1`,
|
||||
*"STALE row NoteUnitTouched"*, so the **new mechanism itself has a live negative control**. `--check` reports
|
||||
75 mutators, 0 UNDECIDED, 0 COARSE; `--self-test` trips all 21 canned controls; `--summary` renders and its
|
||||
known-limits line is down to the two blind spots the `.def` still declares. `gen_pipe.py --check`,
|
||||
`git diff --exit-code -- MG_Pipe/generated` and `check_include_closure.py` (4 probes, 0 problems) are green.
|
||||
|
||||
**(7) Tests.** All eleven names C.1 asks for are present, in the two suites C.1 names, as plain `TEST`s with an
|
||||
RAII scope — B's reason for refusing `TEST_F` is right and is worth propagating: a fixture files cases under the
|
||||
fixture's name and would silently move them out of `ctest -R 'VertexInputEmit\.'`, disarming G6 and G7. The pull
|
||||
build declares the same names and skips, so the G2 name-set identity holds. No vacuous assertions except m6. Two
|
||||
coverage gaps, both named above: nothing drives the pending base instance through `MGPipeValidateForVerb`
|
||||
(B-C1), and nothing drives an emission after a `FreshlyPrimed` reset (B-C2).
|
||||
|
||||
**(8) Hygiene.** Four commits, single-line messages in `[Type] (Scope): description` form, no bodies, no
|
||||
attribution lines; b1/b2/b3's messages are the brief's verbatim. Fourteen files, all B's by C.5 except
|
||||
`MG_Test/Pipe/TrackerTest.cpp`, which C.5 assigns to nobody and which B-DEV-5 justifies. `git status` clean.
|
||||
|
||||
---
|
||||
|
||||
## 6. Rework list (ordered; 1-3 are blocking)
|
||||
|
||||
1. **B-C1.** Delete `Tracker.h:373` (`m_pendingBaseInstance = 0;` inside `Reset()`), leaving the two verb-scoped
|
||||
clears. Add `TrackerWalk.ABaseInstanceSurvivesTheFirstWalkOnAFreshContext`: set the pending value, `Walk()`
|
||||
against a *different* `GLContext` than the previous case used, assert `PendingBaseInstance() == 7` at the
|
||||
emitter and that bit 9 fired. Move `PipeFill.cpp:1446`'s clear above the `ctx == nullptr` return at `:1371`,
|
||||
or record why not.
|
||||
2. **B-C2.** Implement the publish-epoch re-emission described in §1, **or** carry the integrator's decision to
|
||||
exempt `Resources` / `VertexElementsCsos` from `MGPipeApplierReset()`; either way delete the claim at
|
||||
`ResourceTracker.h:390-393` and add a §6 row. Add `ResourceEmit.AResetApplierGetsTheResourceRepublishedBefore
|
||||
TheNextWrite`.
|
||||
3. **B-M1.** The three `MGPipeSetPendingBaseInstance(baseinstance)` lines at `GL_Drawing.cpp:662`, `:684`, `:713`,
|
||||
guarded so the pull build still links, plus one integration assertion that a base-instanced draw reaches the
|
||||
emitter with a non-zero value.
|
||||
4. **B-M2.** `Find` instead of `Acquire` in the five content emitters; null handle → `MGLOG_E_ONCE` + return.
|
||||
5. **B-M4.** `NoteBoundAs` from `EmitVertexBuffers`/`EmitIndexBuffer`; `RefreshBindMask` from the other four
|
||||
resource emitters; correct B-DEV-2's citation of C.1 in the result file; one sentence on `BindEpoch`'s
|
||||
dependence on `BindBufferBase_State` also binding the generic slot.
|
||||
6. **B-M5.** Record the deliberate absence of an `UnmapPersistent` producer, with the reason (no
|
||||
`BufferBackendOps` unmap hook exists to convert).
|
||||
7. **B-M3** is *not* B's to fix — hand it to the integrator and package C verbatim (§2).
|
||||
8. Minors m1-m12 at B's discretion; m2, m5, m6 and m12 are the ones I would insist on, because each is a
|
||||
contract point stated elsewhere that this package is the last chance to encode.
|
||||
|
||||
## 7. Post-rebase verification the integrator must insist on
|
||||
|
||||
Rebase order is `feat/disaggregated@5cb826b0` → `wire` (post-rework) → `client`. B touches none of the files
|
||||
ID-9 names as conflict-prone (`Managers.cpp`, `LargeArenaAdoptionScenario.cpp`), so the rebase should be clean
|
||||
apart from the `ResourceEmitTest.cpp` / `VertexInputEmitTest.cpp` append that C.5 predicts — **resolve by union,
|
||||
never by choosing a side**.
|
||||
|
||||
1. **Re-take both baselines at `5cb826b0`** and re-run G1 (`--threshold 0 --fail-on-symbol-set-change
|
||||
--fail-on-added-bytes 0`) and G14 (`ctest -N` name sets, pull vs push vs verify, and `comm -23` against the
|
||||
baseline). B's §5 caveat about the replaced baseline is correct and is now moot under ID-9; the reading has
|
||||
to be retaken, not inherited.
|
||||
2. **The mirror-image assertions B's §7.1 owes.** Every `ResourceEmit` / `VertexInputEmit` case gains a second
|
||||
`EXPECT` on `MGPipeApplier()`: the stored `MGPipeResourceRecord::Desc` (Width, Usage, StorageFlags, Immutable,
|
||||
HasDefinedContent, BindMask), `MGPipeVertexElementsRecord::Attributes[]` / `BindingPoints[]`,
|
||||
`MGPipeApplierState::VertexBuffers[]`, `VertexFetchBaseInstance`, and the three `Serial`s.
|
||||
`EveryAttributeFieldSurvivesTheWireConversion` becomes a round trip; G6's statement is only then about what
|
||||
the backend reads.
|
||||
3. **The `Blob.Size` gate, exercised.** `wire-review-v1.md` M-B measured that disabling it leaves the suite
|
||||
green. With `client` underneath, a deliberate `Blob.Size` off-by-one in `EmitCreate` must produce
|
||||
`Fatal{ProtocolCorruption}` in the verify build. Run it once as a negative control.
|
||||
4. **B-C1's and B-C2's scenarios on a real applier.** A two-context integration case: draw with a base instance
|
||||
immediately after a make-current (assert `VertexFetchBaseInstance == 7`), and a `glBufferSubData` on a
|
||||
share-group buffer immediately after a make-current (assert the applier's `Serial` moved and, once C1b lands,
|
||||
that `RefusedResourceCalls` is 0).
|
||||
5. **B-M3, before `espryt` is trusted.** Confirm what Espryt latches as `hostBytes` for `Ops_H_SubData` /
|
||||
`Ops_H_FlushRange`; if it is the raw `bytes` pointer, it is `shadow + offset` and must be corrected. A
|
||||
`StreamedArenaScenario` recycle plus a `CrossFrameBufferScenario` flush at a non-zero offset is the shape that
|
||||
catches it.
|
||||
6. **The two contract points `espryt-v1.md` §6 item 14 lists**, now answerable: `OnGpuWritten` is announced as
|
||||
one `kMGPipeWholeBuffer` range (m5 — the client currently ignores the shape), and
|
||||
`MGPVertexBuffer::BindingIndex` is the attribute index for every entry (it is; `VertexInputEmit.h:207`).
|
||||
Add `kMGPipeResourceTargetBuffer == 0` (B-DEV-7) as a third.
|
||||
7. **`map-persistent-roundtrips` becomes non-zero** the moment `espryt` registers the table (G10), and
|
||||
`MOBILEGL_PIPE_PUSH=0x7f` vs `0x1ff` becomes a behavioural A/B (G12) rather than an emission-only one.
|
||||
Both are currently unprovable and both are on the merged tree's critical path.
|
||||
8. **The four lanes and the verify-armed retrace re-run on the merged tree**, with the note that
|
||||
`integration-gpu`'s `TheXIsActuallyArmedWhenTheEnvironmentPinsItOn` family races on shared log files under
|
||||
concurrent load (`MG_IntegrationTest/CMakeLists.txt:1040` records the shape); B's chase-down was correct and
|
||||
the quiet run is the result to record.
|
||||
@@ -0,0 +1,434 @@
|
||||
# P3a package B, commits b1..b4 — the client (`client-v1`)
|
||||
|
||||
Branch `p3a/client`, worktree `/home/swung/w7/p3a-client`, based on `39722687` (tag `p3a/contract`, ID-1's
|
||||
base ref). Not pushed. Four commits, single-line messages, no bodies, no attribution lines.
|
||||
|
||||
| step | hash | message |
|
||||
|---|---|---|
|
||||
| b1 | `73bab3d6` | `[Feat] (Pipe, State): mint a {slot, gen} handle for every buffer object and publish its create, respecify, sub-data, flush, readback and destroy as pipe calls` |
|
||||
| b2 | `1ae6b4f4` | `[Feat] (Pipe): push the bound VAO's format, its vertex buffers with an explicit baseInstance, and its index binding as their own calls` |
|
||||
| b3 | `71805d59` | `[Feat] (Pipe): widen the dirty-surface scan to MG_State so the MGP_NOTE_MUTATION sites stop being outside the gate` |
|
||||
| b4 | `a0ac79cc` | `[Test] (Pipe): pin the buffer and vertex-input emitters - every attribute field survives the wire, a bare baseInstance change still emits, and the index-buffer bit ignores unrelated writes` |
|
||||
|
||||
**b1's safety property holds as specified**: nothing in the tree registers `MGPipeResourceOps`, so
|
||||
`MGPipeResourceSubsystemEnabled()` is false in every build, every buffer dispatch falls through to
|
||||
`g_bufferBackendOps`, and the tree behaves exactly as it did. G1 is 0/0/0/0 after each of the four.
|
||||
|
||||
---
|
||||
|
||||
## 1. Per-file summary
|
||||
|
||||
10 files, +1613 / -45. Every one is in C.1's table except the three marked **[outside C.1]**, each of which is
|
||||
a required consequence and is argued in §4.
|
||||
|
||||
| file | what changed |
|
||||
|---|---|
|
||||
| `MG_Impl/Pipe/ResourceTracker.h` | **new.** D-A3's twelve `MGPipeBindBit`s and the `constexpr BufferTarget -> mask` table with `MGPipeEveryBufferTargetIsMapped()`'s completeness `static_assert` (no `default:` arm, so a new enumerator is a build break); the two buffer discriminators; the pure builders `MGPipeBuildResourceDesc` / `MGPipeBuildSubDataRecord`; the record-range walk `MGPipeForEachSubDataRecordRange` with its cap parameter; `MGPipeResourceTracker` (handle mint, the `slot -> BufferObject*` inverse with its `Gen` compare, the sticky bind mask with its epoch guard, the four emission observables); D-D's client callbacks `MGPipeClientOnBufferWriteback` / `MGPipeClientOnGpuWritten` and their one-shot installer. Header-only, push-only. |
|
||||
| `MG_Impl/Pipe/VertexInputEmit.h` | **new.** D-G2's two pure wire conversions; D-H2.3's `MGPipeVertexBufferSetContentHash` (Start, Count **and BaseInstance** mixed in); `MGPipeVertexInputEmitter` with D-G3's three arms, the **per-handle** `Latch{Published, Gen, ConfigVersion}` table, D-H3's `MGPVertexBuffer[]` build, D-I's index record, the staging buffers that double as the emitted-record observable at no copy, and `Reset()` for a fresh context. Header-only, push-only. |
|
||||
| `MG_Impl/Pipe/PipeFill.{h,cpp}` | the three stub emitters get bodies (no call site moved); the nine `MGPipeEmitResource*` definitions plus `MGPipeResourceSubsystemEnabled` / `MGPipeResourceOpsHaveSubDataResident` / `MGPipeMintResourceHandle` / `MGPipeEmitResourceDestroyAndFree`; `MGPipeSetPendingBaseInstance` + `MGPipePendingBaseInstance` and the **two** clears (the validate point consumes it after emission, `MGPipeLeaveVerb` clears it too); the emitter's `Reset()` on `FreshlyPrimed`; `kMGPipeWiredSubsystems` gains bits 7 and 8 (§3); `EmittedCallSuppliesTheWholeField` gains `GetBoundVertexArray` (§2). |
|
||||
| `MG_Impl/Pipe/Tracker.h` | D-M's three `MGPipeSubsystemForDirty` arms (bits 5, 9, 10 -> `kMGPipeSubsystemVertexInput`); D-I's **narrowed** bit-10 shutter (the bound VAO's own element-slot version, widened, mixed with the bound object's lifetime id and the VAO identity) and its `MGPipeWidenedCounter`; bit 9 gains the pending base instance (§4 B-DEV-3); `SetPendingBaseInstance` / `PendingBaseInstance` / `ClearPendingBaseInstance` and their `Reset()`; `kMGPipeDirtyEmittedAtP3a`; the `:64-78` comment corrected (bits 9/10 are P3a) and the composite-shutter note re-scoped now that three composed bits are load-bearing. |
|
||||
| `MG_Impl/Pipe/SetHashSuppressor.h` | comment only: slot `SetVertexBuffers` marked wired at P3a, plus the requirement a wired slot puts on its hash (why `BaseInstance` is in it). |
|
||||
| `MG_Pipe/PipeMutation.h` | **declarations only**, beside the two notices: the eleven resource entry points and a forward declaration of `MG_State::GLState::BufferObject`. Why here rather than an `MG_Impl` include from `MG_State`: §4 B-DEV-1. |
|
||||
| `MG_State/GLState/BufferState/BufferObject.cpp` | D-A1's dispatch branches at all nine op sites (`OnDestroy`, `Respecify`, `SubData`, `FlushMappedRange`, `ResidentSubData`, `ReadbackFromGpu`, and `AcquirePersistentMap` at its three call sites) plus the `ResidentSubData` **nullability probe** in `FillSubData`; `ResourceCreate` + the handle mint from the constructor; `ResourceDestroy` then `MGPipeSlots().Free` from `~BufferObject`, in that order. Every edit inside `#if MOBILEGL_PIPE_PUSH`, and the pull build's text is byte-for-byte what it was (G1 proves it). |
|
||||
| `MG_Pipe/DirtySurface.def` | two new rows the widened scan found (§4 B-DEV-4); the header's "scans MG_Impl/GLImpl" corrected to both roots and both mechanisms; blind spot 3 marked CLOSED; `MarkBufferObjectForDeletion` / `MarkVertexArrayForDeletion` gain the comment naming the call that makes each true. |
|
||||
| `scripts/gen_pipe_dirty_surface.py` | G9: `SCAN_ROOT` -> `SCAN_ROOTS` (`MG_Impl/GLImpl` + `MG_State/GLState`), `NOTE_MUTATION_RE` and the enclosing-function attribution, `scan_all` / `main`'s existence check / the report header updated. `--check`, `--self-test` and `--summary` all still work; the 21 canned negative controls all still trip. |
|
||||
| `MG_Pipe/FillPoints.def` | comment only: the `MOBILEGL_PIPE_POISON_OMIT` sweep's verdict lands with the G15 caselist run, every row stays in place. |
|
||||
| **[outside C.1]** `MG_Test/Pipe/TrackerTest.cpp` | `OnlyTheFiveEmittedBitsNameASubsystem` follows `kMGPipeDirtyEmittedAtP3a` instead of `...AtP2` (a mandatory consequence of D-M — see §4 B-DEV-5), **name unchanged**; the two `TheIndexBufferBit*` cases C.1's list asks for, plus their rows in the pull-skip list. |
|
||||
| `MG_Test/Pipe/ResourceEmitTest.cpp` | four cases appended, disjoint from the contract commit's one. |
|
||||
| `MG_Test/Pipe/VertexInputEmitTest.cpp` | seven cases appended, disjoint from the contract commit's one. |
|
||||
|
||||
---
|
||||
|
||||
## 2. `EmittedCallSuppliesTheWholeField`, field by field
|
||||
|
||||
The predicate answers "may the residual fill stop pulling this field, because an emitted call supplies it
|
||||
completely". It is consulted only for a field whose emitter's subsystem is in `kMGPipeWiredSubsystems`, so
|
||||
P3a's decision set is exactly the emitted-list rows whose emitter names one of the two new subsystems.
|
||||
|
||||
| field | emitter | decision | reason |
|
||||
|---|---|---|---|
|
||||
| `GetBoundVertexArray` | `BindVertexElements` | **false — keep pulling** | The storage is a `SharedPtr<VertexArrayObject>`, a frontend heap reference. The call carries an eight-byte `{slot, gen}` and nothing else, and the applier stores it in `MGPipeApplierState::BoundVertexElements`. It has no way to produce the pointer and P3a deliberately does not give it one — a payload never contains a pointer, and the whole point of the conversion is that the server stops holding frontend references. Skipping the pull would leave `m_boundVertexArray` **null on every draw of every push build**: not subtle staleness, every backend read of the bound VAO reading nothing. The row is therefore *emitted-and-still-pulled*, exactly like `GetPixelStoreParameters`. What retires the pull is not a better applier, it is P8, where the backend stops reading a frontend VAO at all. `Coverage.def`'s note asks for this decision to be taken here deliberately rather than inherited from the row's presence; it is, and the reasoning above is written into `PipeFill.cpp` beside the arm. |
|
||||
| *(no other field)* | — | — | `MGP_COVERAGE_EMITTED_LIST` gained exactly one row at `c0` (`C4`). `GetBufferBindingSlot` is deliberately **not** in the emitted list (five of its targets are still pulled), and the resource family has no emitted row at all and cannot have one: its calls are dispatched at the GL call that causes them rather than filled into a `PipeInputs` field. |
|
||||
|
||||
The two pre-existing `false` rows (`GetPixelStoreParameters`, `GetCurrentVertexAttribute`) are untouched.
|
||||
|
||||
**Consequence, stated so the integrator does not have to derive it:** P3a retires **no** pull. Every field the
|
||||
residual fill copied at `c0` it still copies. That is the correct answer for this phase and it is also why the
|
||||
verify lane cannot regress on account of a skipped field — there is none.
|
||||
|
||||
---
|
||||
|
||||
## 3. The `kMGPipeWiredSubsystems` change
|
||||
|
||||
```
|
||||
c0: RenderState | PixelPack | PatchState | VertexAttribDefaults
|
||||
b1: ... | kMGPipeSubsystemResources
|
||||
b2: ... | kMGPipeSubsystemVertexInput
|
||||
```
|
||||
|
||||
Each bit is added by the commit that gives *its own* emitters their bodies, which is what B2 asks for. Both
|
||||
additions are recorded in place with the reason they change nothing about the fill loop:
|
||||
|
||||
- **bit 7, `kMGPipeSubsystemResources`, names no emitted field at all.** `SubsystemForEmitter` can never
|
||||
return it — there is no `Coverage.def` emitted row for the resource family and there cannot be one. The bit
|
||||
is in the constant so that it states what this build emits for, which is what an operator reading a
|
||||
recorded `MOBILEGL_PIPE_PUSH` value has to be able to trust.
|
||||
- **bit 8, `kMGPipeSubsystemVertexInput`, names exactly one emitted field**, `GetBoundVertexArray`, and §2
|
||||
says false for it. So the bit switches the **emission** on and changes nothing about the residual fill.
|
||||
|
||||
`MGPipeSubsystemForDirty`'s three new arms make `PipeFill.cpp`'s three conditional pairing `static_assert`s
|
||||
(B1) hold as the equalities D-M asks for, with **no edit to them** — the contract commit wrote "no later edit
|
||||
is required, and none is invited", and none was made.
|
||||
|
||||
---
|
||||
|
||||
## 4. Deviations, each with its reason
|
||||
|
||||
### B-DEV-1 — the resource entry points are declared in `MG_Pipe/PipeMutation.h`, not in `ResourceTracker.h`
|
||||
|
||||
D-A1 puts the dispatch in `BufferObject.cpp`, which is `MG_State`'s. `MG_State` may not include
|
||||
`MG_Impl/Pipe/ResourceTracker.h`: that is the layering the `mutation-header` closure probe exists to protect
|
||||
(*"it may only DECLARE the notice: reaching MG_Impl would pull the fill implementation into the state machine
|
||||
that calls it"*). So the eleven entry points are **declared** in `PipeMutation.h` — B's file, already included
|
||||
by `BufferObject.cpp`, and the one header in the tree whose job is exactly this — and **defined** in
|
||||
`MG_Impl/Pipe/PipeFill.cpp`, the same split `MGP_NOTE_MUTATION` already has. The coupling is one forward
|
||||
declaration of `BufferObject`; the probe still reports `mutation-header OK, 0 forbidden`.
|
||||
|
||||
### B-DEV-2 — the sticky `BindMask` is accumulated by sampling, not ORed at `glBindBuffer`
|
||||
|
||||
D-A3 asks for the OR *"at every `glBindBuffer` / `glBindBufferBase` / `glBindBufferRange` / VAO element-slot
|
||||
bind"*. Those entry points are `MG_Impl/GLImpl/Buffer/GL_Buffer.cpp`'s (`BindBuffer_State`,
|
||||
`BindBufferBase_State`, `BindBufferRange_State`), which C.5 assigns to **no package** and C.1 does not list for
|
||||
this one, and hard rule (5) is "only your files". The mask is therefore accumulated by **sampling the
|
||||
frontend's live binding state at every resource emission** — the only place its value is read — and ORed into
|
||||
a per-slot sticky field that is never cleared. The scan is skipped unless a binding-slot version moved since
|
||||
the last one (one `Uint16` load per global target, none per binding point), so a `glBufferSubData` pays a
|
||||
compare and nothing else.
|
||||
|
||||
What this is exactly as good as the specified design for: the GL idiom the bit exists for — bind, then define
|
||||
or update the store — which is what `glGenBuffers; glBindBuffer; glBufferData` is. It is sticky across
|
||||
unbinds and across respecifies (both pinned by `ResourceEmit.ABindMaskBitIsStickyAcrossARespecifyThatDoesNotRebind`).
|
||||
|
||||
**What it cannot see, and this is handed on rather than hidden:** a bind that happens *after* the buffer's last
|
||||
storage or content operation and is never followed by another one. Such a buffer would never publish that
|
||||
bind. The specified design has a narrower version of the same hole (`BindMask` rides only on create and
|
||||
respecify, so a bind after the last respecify is unpublished there too), but sampling widens it from "a bind
|
||||
after the last respecify" to "a bind after the last resource emission of any kind". **The fix is three
|
||||
one-line calls to a `MGPipeNoteBufferBoundAs(target, buffer)` in `GL_Buffer.cpp`'s three `*_State` binders,
|
||||
and it belongs to whoever owns that file.** Nothing in P3a can observe the difference (the bit is read only
|
||||
under split), so this is a P8 correctness item, recorded here and in `ResourceTracker.h` beside the function.
|
||||
|
||||
### B-DEV-3 — bit 9's shutter gains the pending base instance
|
||||
|
||||
D-H4 says *"Keep the shutter; wire the emission; add `BaseInstance` to the hash."* Kept literally, the design
|
||||
does not work: bit 9's shutter is `MixShutter(anyVaoAttributeGeneration, vaoIdentity)`, and a draw whose only
|
||||
change is its base instance moves **neither** — so the emitter is never reached, the content hash never gets
|
||||
the chance to refuse suppression, and the server keeps the previous fetch shift. That is the same
|
||||
silently-wrong-geometry the backend's `baseInstanceDirty` flag exists to prevent, one level further out, and
|
||||
it is the under-firing direction `ARCHITECTURE.md 13.2` calls the dangerous one.
|
||||
|
||||
So the shutter is `MixShutter(MixShutter(anyVaoAttributeGeneration, vaoIdentity), pendingBaseInstance)`. It
|
||||
over-fires only on the draws that actually carry a base instance and on the first plain draw after one — which
|
||||
is exactly the set that has to re-publish. `VertexInputEmit.ABaseInstanceChangeAloneStillEmitsTheVertexBufferSet`
|
||||
pins the hash half; the shutter half is what makes that half reachable.
|
||||
|
||||
Related: the pending value is **consumed and cleared by the validate point** after step 3, as well as by
|
||||
`MGPipeLeaveVerb`. D-H2.1 names only `MGPipeLeaveVerb`, which nothing in the GL entry points calls — so on its
|
||||
own it would leave a base-instanced draw's value standing for the next plain draw, which is precisely the
|
||||
property `DrawParametersScenario.APlainDrawAfterABaseInstancedOneSeesZeroAgain` asserts. Both clears are
|
||||
present and neither relies on the other.
|
||||
|
||||
### B-DEV-4 — what the widened scan actually found, and the two rows it produced
|
||||
|
||||
G9 says the scan root is widened "so the four `MGP_NOTE_MUTATION` sites in `TextureState.h` stop being outside
|
||||
it". Widening the root alone does **not** do that: `MUTATOR_RE` matches `pGLContext->Set*` and finds nothing at
|
||||
all under `MG_State/GLState` that was not already found elsewhere. So the widening also teaches the scanner to
|
||||
read `MGP_NOTE_MUTATION` as a publish mechanism of its own, attributed to its **enclosing function** (a notice
|
||||
carries a field name, not a mutator name). Both halves were load-bearing:
|
||||
|
||||
- `BumpSamplingResolutionGeneration` — a mutator with **no row at all**, because every caller of it lives in
|
||||
`MG_State/GLState` (`SamplerObject::BumpVersion`, `TextureObjectBase`'s shape bump) and the scan did not
|
||||
read that directory. Its sibling `BumpTextureBindGeneration` had a row. Answer: `NEW_SAMPLERS`, derived and
|
||||
matching.
|
||||
- `NoteUnitTouched` — which no `pGLContext->` pattern can ever see, because every texture and sampler bind
|
||||
routes *through* it. Answer: `kPulledPartialShutter|NEW_SAMPLER_VIEWS`, derived and matching, because the
|
||||
bind generation moves only on the `bindingChanged` arm while the high-water mark has no shutter at all.
|
||||
|
||||
`--check` went 73 -> 75 mutators, 8 -> 10 derived bit answers, 0 UNDECIDED, 0 COARSE. No new prose vocabulary
|
||||
was minted: a `kNoteMutation` answer was drafted and dropped, because the existing `kPulledPartialShutter`
|
||||
already states what is true and is *checked*, while a new prose word would have been another row no derivation
|
||||
can back.
|
||||
|
||||
### B-DEV-5 — `TrackerTest.cpp` and the phase constant
|
||||
|
||||
Mapping bits 5/9/10 makes `TrackerWalk.OnlyTheFiveEmittedBitsNameASubsystem` fail, exactly as the contract
|
||||
package's `PipeCatalogueTest` had to move `kMGPipeVerifiedPayloadCount` 69 -> 71 (its D2). The case now
|
||||
compares against a new `kMGPipeDirtyEmittedAtP3a` (Tracker.h, beside the P2 constant, neither edited in place)
|
||||
and asserts the three new arms by name. **The test name is unchanged** — G14 forbids removing one, and the
|
||||
property it has always asserted ("a bit names a subsystem if and only if this build emits a call for it") is
|
||||
the property it still asserts. The reason the name outlives the literal five is written into the case.
|
||||
|
||||
`MG_Test/Pipe/TrackerTest.cpp` is not in C.5's table (it is one of the "nobody" files), so no package can
|
||||
conflict on it.
|
||||
|
||||
### B-DEV-6 — the sub-data splitter is a capped walk, and the cap is a parameter
|
||||
|
||||
D-A2 says a `false` from `MGPipeSetSubDataBufferRange` means "the emitter must split". With the record's own
|
||||
bounds that instruction is **unreachable**: a second piece begins at least `2^32-1` bytes past the first, which
|
||||
is already past the box's `2^31-1` offset cap. So an over-long range is *refused whole* (nothing emitted, one
|
||||
log line) rather than split, and the walk's chunk cap is a parameter defaulting to the record's size bound —
|
||||
because the transport segment is the tight one and is where splitting becomes live. The unit case drives the
|
||||
split at a reachable cap (32 MiB) and the refusals at the record's, so the contiguity and
|
||||
all-or-nothing properties P5 will rely on are pinned now rather than written under pressure later.
|
||||
|
||||
### B-DEV-7 — `kMGPipeResourceTargetBuffer` and the bind bits are spelled client-side
|
||||
|
||||
`MGPResourceDesc::Target` documents a discriminator (`Buffer | Tex1D.. | Renderbuffer | TexBuffer`) for which
|
||||
the contract package minted no enum, and `BindMask` documents twelve bits with no names. Both are spelled in
|
||||
`ResourceTracker.h` (`kMGPipeResourceTargetBuffer = 0`, since `Buffer` leads the documented list and is what a
|
||||
zero-initialised record already says; `MGPipeBindBit` in the documented order) with a note that the integrator
|
||||
moves them beside the fields when a second producer appears — P4a's texture family. **Coordination item: if
|
||||
`espryt` or `wire` assumes a different value for the buffer arm of `Target`, one of the two has to move, and
|
||||
the client is the cheaper side.**
|
||||
|
||||
### B-DEV-8 — `delete_vertex_elements` is not emitted by this package
|
||||
|
||||
D-G1 frees the CSO on the VAO's existing death notice, which `~VertexArrayObject` already raises and
|
||||
`Managers.cpp`'s `OnFrontendStateObjectDestroyed` already consumes for the `VertexElementsCso` kind. That
|
||||
consumer is `MG_Backend`'s, so the `delete_vertex_elements` emission and the slot free ride with package C's
|
||||
`e1`/`e4`. C.1's emitter list agrees (it names only the three). **On this tree, VAO CSO slots are therefore
|
||||
never freed** — harmless for a test binary, and closed the moment `espryt` lands. Recorded so the integrator
|
||||
does not read the leak as a client defect.
|
||||
|
||||
### B-DEV-9 — the client's reverse-channel callbacks are installed, not just written
|
||||
|
||||
D-D says "the client's implementation of that callback". `MGPipeCallbacks` is owned by nobody, so the two
|
||||
client-side entries (`OnBufferWriteback`, `OnGpuWritten`) are installed from `MGPipeMintResourceHandle`'s
|
||||
one-shot installer and **only over a null slot** — a backend that installs its own is never overwritten. They
|
||||
are unreachable until a backend calls them.
|
||||
|
||||
---
|
||||
|
||||
## 5. Verification transcript
|
||||
|
||||
All commands in `/home/swung/w7/p3a-client`, `CCACHE_BASEDIR=/home/swung/w7`, at `a0ac79cc` unless a row says
|
||||
otherwise. Every gate below was also run after b1, b2 and b3 individually and was green at each.
|
||||
|
||||
**G1 — pull build symbol identity**
|
||||
|
||||
```
|
||||
python3 scripts/symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so \
|
||||
--threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0 rc 0
|
||||
symbol-report: Total 17209979 -> 17209979 (+0)
|
||||
symbol-report: 27799 -> 27799 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
|
||||
`.text` 10792739 -> 10792739 (+0, +0.000%)
|
||||
```
|
||||
|
||||
Run three times — after b1, after b2 and after b4 (b3 touches no C++) — clean every time. P3a's
|
||||
admitted-resize set is empty and stayed empty.
|
||||
|
||||
**One resize was found and fixed during b1** rather than admitted: an early edit to `SyncGpuWrites` dropped
|
||||
`m_size == 0 ||` from the *pull* arm of its guard while moving the check into the push arm, which shrank the
|
||||
function by 7 bytes and, through inlining, six of its callers. The gate caught it on the first run; the fix
|
||||
restored the pull text verbatim. It is recorded because it is exactly the failure mode D-K predicts (an edit
|
||||
that escaped a `#if MOBILEGL_PIPE_PUSH` guard) and because it is the evidence that G1 can go red for the
|
||||
reason it exists.
|
||||
|
||||
> **THE SHARED BASELINE WAS REPLACED MID-ROUND — this needs the integrator's attention, and it is not this
|
||||
> package's doing.** At the final sweep the same command reads `27811 -> 27799: 0 added, 12 removed, 1
|
||||
> resized`, and `~/w7/p3a-before-libMobileGL.so` / `~/w7/p3a-before-ctest-names.txt` both have an mtime
|
||||
> *later* than this package's last build. The twelve "removed" symbols are all
|
||||
> `MG_Util::SelfTest::*PersistentBufferOrdering*` and the resized one is
|
||||
> `SelfTest::(anonymous namespace)::kGlesDriverBugProbes` — i.e. the POST probe of `dev@9eae9858`, which is
|
||||
> **not in P3a's base ref**; the replaced ctest-name file likewise carries
|
||||
> `PersistentBufferOrderingProbeTest.*` (15 names, `dev@9eae9858`) and
|
||||
> `LargeArenaAdoptionScenario.Respecified*` (`dev@d7655247`). So the baselines were re-taken from a tree ahead
|
||||
> of `44c2b5cf`, and a comparison against them says nothing about P3a. This package touches no `MG_Util` file
|
||||
> and adds no `SelfTest` symbol; its `build-linux/libMobileGL.so` is 19,100,448 bytes, byte-size-identical to
|
||||
> the pull build of **every** P3a worktree including `p3a-contract`'s at the tag, while the replaced baseline
|
||||
> is 19,114,360. **The integrator should re-take both baselines at `44c2b5cf` and re-run G1/G14 for every
|
||||
> package**, or the gate is measuring the wrong thing for all four.
|
||||
|
||||
**Generators and closure**
|
||||
|
||||
```
|
||||
python3 scripts/gen_pipe.py --check rc 0 "generated files are up to date"
|
||||
71 calls, 71 verify payloads,
|
||||
63 PipeInputs fields (7 sticky, 34 emitted)
|
||||
git diff --exit-code -- MobileGL/MG_Pipe/generated rc 0 (clean)
|
||||
python3 scripts/gen_pipe_dirty_surface.py --check rc 0 "75 mutators, all mapped, no stale rows;
|
||||
45 render-state answers derived and matching;
|
||||
10 other answers derived; 0 COARSE; 0 UNDECIDED"
|
||||
python3 scripts/gen_pipe_dirty_surface.py --self-test rc 0 "21 negative controls, all tripped;
|
||||
positive controls OK"
|
||||
python3 scripts/gen_pipe_dirty_surface.py --summary rc 0 (report renders; scan roots printed)
|
||||
python3 scripts/check_include_closure.py rc 0 "4 probes, 0 skipped, 0 problem(s)"
|
||||
mutation-header OK 84 headers, 0 forbidden
|
||||
python3 scripts/check_include_closure.py --mode both --compiler clang++ --self-test --require-all rc 0
|
||||
"6 negative-control trip(s), parser checks OK"
|
||||
```
|
||||
|
||||
(`--compiler clang++-20` does not exist on this host; the contract package recorded the same substitution.)
|
||||
|
||||
**Three builds** — `cmake --build <dir> --parallel 24`, rc 0 in all three (`build-linux`, `build-push`,
|
||||
`build-verify`).
|
||||
|
||||
**Three unit runs** — `ctest --test-dir <dir> -L unit -j 12 --no-tests=error`:
|
||||
|
||||
```
|
||||
build-linux 100% tests passed, 0 failed out of 1584
|
||||
build-push 100% tests passed, 0 failed out of 1584
|
||||
build-verify 100% tests passed, 0 failed out of 1584
|
||||
```
|
||||
|
||||
**Name sets (G2's name half, G14)** — taken against the ORIGINAL baseline, before it was replaced (above).
|
||||
|
||||
```
|
||||
ctest -N names: build-linux 2500, build-push 2500, build-verify 3328
|
||||
diff <build-linux names> <build-push names> -> empty
|
||||
comm -23 ~/w7/p3a-before-ctest-names.txt <build-linux names> -> empty (nothing removed)
|
||||
comm -13 ... -> 18 added: the contract's 5, plus
|
||||
ResourceEmit.{EveryBufferTargetSetsItsBindMaskBit,
|
||||
ABindMaskBitIsStickyAcrossARespecifyThatDoesNotRebind,
|
||||
ADestroyedBufferReleasesItsSlotAndAStaleHandleResolvesToNothing,
|
||||
AWholeBufferSubDataBeyondTheRecordBoundIsSplitIntoContiguousRecords}
|
||||
VertexInputEmit.{EveryAttributeFieldSurvivesTheWireConversion,
|
||||
ABindingModelStrideOfZeroSurvivesAsZero,
|
||||
IsLongAndFloat64TravelSeparately,
|
||||
ABaseInstanceChangeAloneStillEmitsTheVertexBufferSet,
|
||||
AnUnchangedSetWithAnUnchangedBaseInstanceEmitsNothing,
|
||||
RebindingTheSameVaoEmitsABindAndNoCreate,
|
||||
PingPongingBetweenTwoVaosNeverRecreatesEither}
|
||||
TrackerWalk.{TheIndexBufferBitDoesNotFireOnAnUnrelatedBufferWrite,
|
||||
TheIndexBufferBitFiresWhenTheSlotVersionWrapsOntoADifferentBuffer}
|
||||
ctest --test-dir build-push -N -R 'VertexInputEmit\.|ResourceEmit\.' -> Total Tests: 13
|
||||
```
|
||||
|
||||
The suites are `ResourceEmit` and `VertexInputEmit` and the new cases are plain `TEST`s with an RAII scope,
|
||||
**not** `TEST_F`: a fixture files its cases under the *fixture's* name, which would put every one of them
|
||||
outside `ctest -R 'VertexInputEmit\.'` and silently disarm G6 and G7. (This was caught by running the
|
||||
binaries; the first draft used `TEST_F` and produced `VertexInputEmitFixture.*`.)
|
||||
|
||||
**G7's property, verified by hand** (the script itself is package D's): with
|
||||
`wire.IsBgra = attrib.IsBgra ? 1 : 0;` deleted from `MGPipeBuildVertexAttribWire`,
|
||||
`VertexInputEmit.EveryAttributeFieldSurvivesTheWireConversion` fails **naming `wire.IsBgra` / `attrib.IsBgra`**
|
||||
(six occurrences, one per BGRA slot). Reverted and re-run: 8/8 pass. So G6 can go red for the reason it exists
|
||||
and G7's scripted control has a target that answers by field name.
|
||||
|
||||
**The four integration lanes** — all green.
|
||||
|
||||
```
|
||||
ctest --test-dir build-push -L integration-gpu -j 8 100% passed, 916 tests
|
||||
MOBILEGL_PIPE_PUSH=0 ctest --test-dir build-push -L integration-gpu -j 8 green (all-pull arm)
|
||||
MOBILEGL_PIPE_PUSH=0x7f ctest --test-dir build-push -L integration-gpu -j 8 green (P3a subsystems off, G12)
|
||||
ctest --test-dir build-verify -L integration-verify -j 4 green
|
||||
```
|
||||
|
||||
**A flake worth recording, because a reader of the raw log would otherwise read it as a regression.** The
|
||||
first `integration-gpu` run — taken while the 79-case retrace was running beside it — failed four cases, all
|
||||
of the shape `TheXIsActuallyArmedWhenTheEnvironmentPinsItOn`:
|
||||
`DirectGLES.UnlocatedIoBlocks.*`, `DirectVulkan.PrimGenReroute.*` and both `PointSizeDemotion.*`. Every one of
|
||||
them asserts by **reading back a shared log file** whose path the lane's ctest `ENVIRONMENT` sets, and
|
||||
`MG_IntegrationTest/CMakeLists.txt:1040` already records that shape as racing a neighbour's bring-up. Chased
|
||||
down rather than waved off:
|
||||
|
||||
- re-run serially while the retrace was still running: 3 of the 4 passed, 1 (`PrimGenReroute`) still failed;
|
||||
- that one, run alone: passes at the default mask, at `0x7f`, at `0x1ff`, at `0`, and in the **pull** build —
|
||||
i.e. it passes with this package's emission compiled out entirely, so nothing here can be its cause;
|
||||
- the whole lane re-run **alone**, with no competing load: `100% tests passed, 0 failed out of 916`.
|
||||
|
||||
So the four are load-induced races on shared log files, not regressions. The recorded lane result is the
|
||||
quiet one.
|
||||
|
||||
**The retrace gate, verify-armed** — `MOBILEGL_PIPE_VERIFY=1 python3 ~/w7/retrace_gate.py --tree
|
||||
~/w7/p3a-client --lib build-verify/libMobileGL.so --out ~/w7/retrace-out/p3a-client -j 4`:
|
||||
|
||||
```
|
||||
passed 79 / 79; failed: []
|
||||
grep -l 'Fatal{' ~/w7/retrace-out/p3a-client/*.log -> empty
|
||||
grep -L 'MGPipe verify:' ~/w7/retrace-out/p3a-client/*.log -> empty (every case armed)
|
||||
```
|
||||
|
||||
This is the strongest single result in this document: with the emission live in a verify build, whose
|
||||
compare-at-read re-reads **every** field from the live context at **every** backend read, the whole corpus
|
||||
replays with zero divergence and zero unmigrated reads on both backends. `~/w7/retrace-out/p3a-client` was
|
||||
deleted afterwards.
|
||||
|
||||
**A trap the next package will hit.** This worktree's `tools/trace_replay/fixtures/*` were **Git-LFS pointers**,
|
||||
not archives, so the first retrace run failed all 79 cases in 0 s with `Unrecognized archive format` — which
|
||||
looks exactly like a catastrophic regression and is not one. The fix is to copy the real files from
|
||||
`~/w7/pipe/tools/trace_replay/fixtures/` and `git update-index --assume-unchanged` them, which is what the
|
||||
tree script normally does; `git status` is clean afterwards and the fixtures are left materialised for the
|
||||
next package. (Second trap, same run: an inner script written to `/tmp` and launched with `setsid nohup`
|
||||
vanishes when the WSL VM cycles — `/tmp` is tmpfs. Put the inner script under `~/w7/`.)
|
||||
|
||||
---
|
||||
|
||||
## 6. Left undone, and what it costs
|
||||
|
||||
1. **The three `MGPipeSetPendingBaseInstance` call sites.** D-H2.1 asks for one line immediately before
|
||||
`MGP_FILL` at `MG_Impl/GLImpl/Drawing/GL_Drawing.cpp`'s `DrawElementsInstancedBaseVertexBaseInstance`,
|
||||
`DrawElementsInstancedBaseInstance` and `DrawArraysInstancedBaseInstance`. That file is outside this
|
||||
package's ownership (C.5: nobody; C.1: not listed), so the setter, its consumption, its shutter input, its
|
||||
content-hash input and its unit coverage all landed here and **the three call sites are owed**. Until they
|
||||
exist the emitted `BaseInstance` is 0 on every draw — which is what the tree does today and is therefore
|
||||
behaviour-neutral, but it means package C **must not** delete `g_pendingFetchBaseInstance` before those
|
||||
three lines exist, or instanced-array base-instance emulation loses its input. This is the single highest
|
||||
priority follow-up in this document. The exact line is `MG_Pipe::MGPipeSetPendingBaseInstance(baseinstance);`
|
||||
and it is documented beside the declaration in `MG_Impl/Pipe/PipeFill.h`.
|
||||
2. **The `GL_Buffer.cpp` bind hook** (B-DEV-2): three one-line `NoteBoundAs` calls that would close the
|
||||
sampling window. Invisible in monolith; a P8 correctness item.
|
||||
3. **`delete_vertex_elements` and the VAO CSO slot free** (B-DEV-8): package C's, by the ownership split.
|
||||
4. **`map-persistent-roundtrips` reads 0 on this tree**, necessarily: the counter is incremented at the
|
||||
`MapPersistent` *emission*, and nothing registers `MGPipeResourceOps`, so the emission never happens. It
|
||||
becomes non-zero the moment `espryt` registers the table, which is where G10 is scheduled anyway.
|
||||
5. **The `MOBILEGL_PIPE_POISON_OMIT` caselist sweep** was declared off the critical path by the task; the
|
||||
`FillPoints.def` comment now says the verdict lands with the G15 caselist run and every row stays.
|
||||
|
||||
---
|
||||
|
||||
## 7. What could NOT be verified on the contract base, and must be re-run after the rebase onto `wire`
|
||||
|
||||
The applier's fourteen entry points are **stubs** at `39722687`, so on this tree every call this package emits
|
||||
is applied to nothing. That is not a gap in the emission — it is the ordering `ID-2` chose — but it means the
|
||||
following are unproven here and are the integrator's re-run list once `wire` is merged underneath:
|
||||
|
||||
1. **Every assertion about an applier record.** The unit cases assert on what the *emitter built and handed
|
||||
over* (its own staging buffers, at no copy, plus the four/four emission counters), never on
|
||||
`MGPipeApplier()`. After the rebase, `ResourceEmit` and `VertexInputEmit` should gain the mirror-image
|
||||
assertions — the stored `MGPipeResourceRecord::Desc`, `MGPipeVertexElementsRecord::Attributes[]`,
|
||||
`VertexBuffers[]`, the three `Serial`s — and `VertexInputEmit.EveryAttributeFieldSurvivesTheWireConversion`
|
||||
in particular becomes a *round-trip* rather than a conversion check. G6's statement is about what the
|
||||
backend reads, and only the merged tree can say that.
|
||||
2. **The applier's blob-bounds gate and its protocol refusal.** `EmitCreate` sends
|
||||
`AttributeCount = BindingPointCount = 32` and a `Blob.Size` of exactly
|
||||
`32*24 + 32*16 = 1280`; the case asserts the arithmetic, but nothing on this tree refuses a record that
|
||||
disagrees. Re-run once the applier can.
|
||||
3. **`kNeedsAck`'s per-record predicate on a live path.** `MGPipeResourceRespecifyNeedsAck` is pinned by
|
||||
`PipeCatalogue` at `c0`; the emitter reads it only in prose (the monolith ack is `((void)0)`).
|
||||
4. **The reverse channel end to end.** `MGPipeClientOnBufferWriteback` / `OnGpuWritten` are installed and
|
||||
correct by inspection, and unreachable until a backend calls them. Their first real exercise is `espryt`'s
|
||||
`e3`.
|
||||
5. **`map-persistent-roundtrips`** — §6.4.
|
||||
6. **G12's substance.** `MOBILEGL_PIPE_PUSH=0x7f` versus the default `0x1ff` is green in both arms, but on
|
||||
this tree the two arms differ only in whether the *emission* happens; nothing consumes it, so the A/B
|
||||
cannot yet show a behavioural difference. `ResourceSubsystemControlScenario` (package D) is what makes it
|
||||
prove the switch is not dead.
|
||||
7. **The `Target` discriminator value** (B-DEV-7) needs one look from `wire`/`espryt`.
|
||||
8. **G1 and G14 themselves**, because the shared baselines were replaced mid-round (§5). Re-take them at
|
||||
`44c2b5cf` and re-run; this package's readings against the original files are in §5.
|
||||
|
||||
Nothing in this list is expected to change a line of this package; they are assertions to *add* on the merged
|
||||
tree, and the emitters are shaped so that adding them is a second `EXPECT` beside an existing one.
|
||||
|
||||
---
|
||||
|
||||
## 8. Intermediate logs and working state
|
||||
|
||||
Deleted: `~/w7/p3a-client-{lanes,retrace,laneA}.log`, their inner scripts under `~/w7/`, and
|
||||
`~/w7/retrace-out/p3a-client/`. The tree-creation logs (`p3a-client-{submodule,build-linux-*,build-push-*,
|
||||
build-verify-*}.log`) are the tree script's and were left alone.
|
||||
|
||||
`git status` in `/home/swung/w7/p3a-client` is clean at `a0ac79cc`. The trace fixtures are materialised (real
|
||||
archives, not LFS pointers) and hidden with `git update-index --assume-unchanged`, which is the state the next
|
||||
run of the retrace gate needs; nothing about them is committed.
|
||||
@@ -0,0 +1,461 @@
|
||||
# P3a package B, rework round 2 — the client (`client-v2`)
|
||||
|
||||
Branch `p3a/client`, worktree `/home/swung/w7/p3a-client`, **rebased onto `refs/heads/feat/disaggregated`
|
||||
(`12e6bfcf`, wire v2 + the dev merge)** and then four new commits on top. **Not pushed.**
|
||||
|
||||
| step | hash | message (single line, empty body, no attribution) |
|
||||
|---|---|---|
|
||||
| b1' | `a6851a26` | *(rebased, unchanged)* `[Feat] (Pipe, State): mint a {slot, gen} handle for every buffer object …` |
|
||||
| b2' | `13e4b6f4` | *(rebased, unchanged)* `[Feat] (Pipe): push the bound VAO's format, its vertex buffers with an explicit baseInstance …` |
|
||||
| b3' | `f656620d` | *(rebased, unchanged)* `[Feat] (Pipe): widen the dirty-surface scan to MG_State …` |
|
||||
| b4' | `5df05545` | *(rebased, ONE conflict resolved by union — §1)* `[Test] (Pipe): pin the buffer and vertex-input emitters …` |
|
||||
| **r1** | `2da442a7` | `[Fix] (Pipe): stop the tracker's context Reset eating the pending base instance the same call is about to read, and clear it on the validate point's no-context exit too` |
|
||||
| **r2** | `b6706362` | `[Feat] (Pipe, GLImpl): set the pending base instance from the three glDraw*BaseInstance entry points, through a pull-safe macro beside MGP_FILL` |
|
||||
| **r3** | `d1f684a7` | `[Fix] (Pipe, State): look the resource handle up on the content paths instead of minting it, publish the bind mask from the two draw-time emitters, pair the destroy with the create's own latch, and state the record-lifetime rule the applier now holds` |
|
||||
| **r4** | `dfaa8729` | `[Test] (Pipe): pin the base instance across a make-current and both of the validate point's exits, the record surviving one, the draw-time bind mask, the create-destroy pairing latch, and the bind-mask table against literals` |
|
||||
|
||||
`git diff --shortstat 12e6bfcf..HEAD` → **15 files changed, 2843 insertions(+), 69 deletions(-)**. The only file
|
||||
outside C.5's grant is `MG_Impl/GLImpl/Drawing/GL_Drawing.cpp`, **+3 lines, exactly the three ID-10 grants**
|
||||
(`:662`, `:685`, `:715` — each immediately above the `MGP_FILL` the review named at `:662/:684/:713`).
|
||||
`MG_Test/Pipe/TrackerTest.cpp` is C.5's "nobody" file, as at `client-v1` (B-DEV-5), and the review's own rework
|
||||
item 1 names a case in it.
|
||||
|
||||
---
|
||||
|
||||
## 1. The rebase, and how the conflict was resolved
|
||||
|
||||
`git rebase refs/heads/feat/disaggregated` replayed b1-b3 cleanly. **b4 conflicted in
|
||||
`MG_Test/Pipe/ResourceEmitTest.cpp`, not in `VertexInputEmitTest.cpp`** — the opposite of what the task
|
||||
predicted, and worth recording:
|
||||
|
||||
* `VertexInputEmitTest.cpp` **auto-merged**. Wire's rewrite of the placeholder case (`:67-110`, the two serial
|
||||
assertions now "moved forward" 43/44 and the two vacuous `…empty()` assertions gone) and B's seven appended
|
||||
cases do not overlap textually. Nothing was chosen; both sides are present.
|
||||
* `ResourceEmitTest.cpp` conflicted as one block-vs-block hunk (`<<<<<<<` at :118, `=======` at :1325,
|
||||
`>>>>>>>` at :1613), because at `39722687` the file held exactly ONE case and both packages appended to that
|
||||
same point. **Resolved by union, in that order: wire's whole block first, then B's whole block**, keeping
|
||||
every `#if !MOBILEGL_PIPE_PUSH` / pull-skip arm from both sides (the two use different pull-skip idioms —
|
||||
wire per-case, B a macro list — and they compose without collision).
|
||||
|
||||
**Every test name from both sides survives**, verified by enumerating the resolved file and by `ctest -N`:
|
||||
|
||||
```
|
||||
wire's 17 ACreateMarksTheSlotLiveAndCarriesItsDescriptor, ARespecifyReplacesTheDescriptorAndOnlyAMutation
|
||||
MovesTheSerial, ADestroyDropsTheRecordAndAStaleGenerationResolvesToNothing, NoResourcePathInThis
|
||||
PhaseLeavesHostWritesLive, TheSubDataRangeEncodingRefusesExactlyAtItsTwoBounds, EveryResourceCall
|
||||
DispatchesByHandleThroughTheInstalledTableOnly, MapPersistentCountsEveryAttemptWhetherItMintsOr
|
||||
Declines, AWriteOutsideTheDeclaredStorageIsRefusedNamingTheResource, TheObjectRecordsSurviveAMake
|
||||
CurrentAndOnlyTheWorkingStateIsReset, ACallOnARecordTheApplierDoesNotHaveIsCountedRatherThan
|
||||
SilentlyDropped, AVertexElementsBlobRoundTripsAndAShrinkLeavesNothingOfTheOneBeforeIt, AVertex
|
||||
ElementsRecordThatDoesNotDescribeItsOwnBlobIsRefusedNamingIt, TheVertexBufferWindowIsBoundedAndIts
|
||||
EntriesLandWhereItSays, SetIndexBufferMovesOnlyItsOwnSerialAndTheBindingFollowsTheHandle, Every
|
||||
ContentCallsOwnBoundsGateRefusesAndNamesTheResource, TheLiveHostWritesWireFiresOnTheCallA
|
||||
PersistentMapProducerWouldSetItOn, ASlotOutsideTheRecordTablesBoundIsRefusedRatherThanAllocated
|
||||
B's 4 EveryBufferTargetSetsItsBindMaskBit, ABindMaskBitIsStickyAcrossARespecifyThatDoesNotRebind,
|
||||
ADestroyedBufferReleasesItsSlotAndAStaleHandleResolvesToNothing,
|
||||
AWholeBufferSubDataBeyondTheRecordBoundIsSplitIntoContiguousRecords
|
||||
c0's 1 TheResourceOpTableIsUnregisteredUntilABackendInstallsOne (common prefix, never in the conflict)
|
||||
```
|
||||
|
||||
One mechanical consequence of the union was carried into b4' itself: `MGPipeBuildSubDataRecord` gained a
|
||||
parameter in r3, so the splitter case's call at `ResourceEmitTest.cpp:1574` passes it (r3, not b4').
|
||||
|
||||
**`feat/disaggregated` moved again while this round ran**, to `b9eaa474` — two version bumps
|
||||
(`42d43af2` the plugin version to 26.09, `b9eaa474` `CoreVersion` to 26.9). Neither touches a file this
|
||||
package edits, so the second rebase is a fast-forward with no conflict; every reading below was taken against
|
||||
`12e6bfcf`, which is the tree the task named and the tree `~/w7/p3a-before-libMobileGL.so` was captured at
|
||||
(`5cb826b0`, its ancestor). A `CoreVersion` bump does move `.rodata`, so **G1 must be re-taken with a baseline
|
||||
re-captured at `b9eaa474`** if the integrator lands those two underneath rather than on top.
|
||||
|
||||
**A second consequence of the rebase, taken in r4:** `MG_Test/Pipe/TrackerTest.cpp`'s
|
||||
`ResetTheServerSideSingletons()` (`:250`) now also calls `MGPipeApplierReleaseObjectRecords()` and
|
||||
`MGPipeVertexInputEmitterInstance().Reset()/ResetCounters()`. Wire's §6 item 2 requires the first
|
||||
(`MGPipeApplierReset` no longer empties the applier); the second is B's own (the emitter's latches describe an
|
||||
applier that is about to be emptied). Nothing in that fixture asserted `Resources.empty()`, so this is
|
||||
robustness for a by-hand run rather than a repair.
|
||||
|
||||
---
|
||||
|
||||
## 2. Per-finding disposition
|
||||
|
||||
### 2.1 Critical
|
||||
|
||||
| finding | disposition | where |
|
||||
|---|---|---|
|
||||
| **B-C1** `Reset()` zeroes the pending base instance the same call is about to read | **FIXED, one line deleted** — `Tracker.h`'s `Reset()` (`:378-396`) no longer clears `m_pendingBaseInstance`, with the reason written above it (`:368-377`): everything else `Reset()` clears is a latch describing what the server was told; this one is **this call's argument**, written one statement before `MGP_FILL` and not yet read. Both verb-scoped clears are kept. | `Tracker.h:368-396` |
|
||||
| **B-C2** no re-publication path for resource records after `MGPipeApplierReset()` | **RESOLVED PER ID-12, and the claim replaced by the rule** — no re-publication is added and none may be; `ResourceTracker.h:471-492` now states the actual rule in place of "absence as policy" (below). | `ResourceTracker.h:471-493` |
|
||||
|
||||
**B-C1's second half (the review's rework item 1, and B-M1's hole).** The review asked to *"move
|
||||
`PipeFill.cpp:1446`'s clear above the `ctx == nullptr` return at `:1371`, or record why not"*. Moving it there
|
||||
would clear the value **before** `EmitVertexBuffers` reads it, which is the bug in the other direction. What
|
||||
landed instead is the same guarantee on that exit only: `PipeFill.cpp:1440-1449` clears the pending value on
|
||||
the no-live-context early return, so the property *"consumed by exactly the verb whose entry point set it, and
|
||||
0 at every other `Update`"* holds on **both** of `MGPipeValidateForVerb`'s exits. That is now the whole
|
||||
production guarantee, and both the tracker's accessor comment (`Tracker.h:447-452`) and `MGPipeLeaveVerb`'s
|
||||
(`PipeFill.cpp:849-860`) say so in those words: **no GL entry point calls `MGPipeLeaveVerb`** — `grep` finds
|
||||
`MG_Test/ScopedPipeVerb.h` and `MG_Test/Pipe/TrackerTest.cpp` and nothing else — so `client-v1` §4 B-DEV-3's
|
||||
*"neither of them relies on the other being called"* was wrong and is withdrawn. The clear this package relies
|
||||
on is `PipeFill.cpp:1527`'s, at the end of step 3.
|
||||
|
||||
**B-C2, the rule as it now reads** (`ResourceTracker.h:471-492`, beside `ResetForTest`, replacing
|
||||
*"Never called by the library: a context change does not invalidate a handle"*):
|
||||
|
||||
> A buffer handle and the applier record it names are **share-group object state**. A GL object lives in a
|
||||
> share group, not in a context, so a make-current changes neither. `MGPipeApplierReset()` is a make-current
|
||||
> and deliberately keeps its `Resources` / `VertexElementsCsos`; the **only** things that drop a record are the
|
||||
> object's own death signal — `resource_destroy`, which `~BufferObject` raises through
|
||||
> `MGPipeEmitResourceDestroyAndFree`, and `delete_vertex_elements` — and
|
||||
> `MGPipeApplierReleaseObjectRecords()`, which is the served context's teardown and is deliberately wired to
|
||||
> nothing in the monolith. So this tracker needs no re-publication path on a fresh context **and must not have
|
||||
> one**: re-emitting `resource_create` for a record the applier still holds would move its `Serial` for
|
||||
> nothing. What the client owes instead is the destroy, which `~BufferObject` already emits in the fixed
|
||||
> emit-then-free order (D-L).
|
||||
|
||||
The one asymmetry the review pointed at is now explained rather than repeated: the vertex-input emitter's
|
||||
`Reset()` **stays** in the `FreshlyPrimed` arm, and `PipeFill.cpp:1484-1492` no longer says it is there
|
||||
"because the applier's records were dropped" (they are not). It is there because the emitter's *other* latch,
|
||||
`m_boundHandle`, mirrors `MGPipeApplierState::BoundVertexElements`, which `MGPipeApplierReset` **does** clear —
|
||||
without the reset the bind after a make-current would be suppressed as unchanged and the server would draw with
|
||||
no vertex elements bound. Re-creating an unchanged configuration alongside it is a bounded over-fire; a dropped
|
||||
bind is not.
|
||||
|
||||
Pinned by `ResourceEmit.ABufferCreatedBeforeAMakeCurrentStillLandsItsSubDataAfterOne`
|
||||
(`ResourceEmitTest.cpp:1686`), which is the client-side half of wire's applier-side case: a **real
|
||||
`BufferObject`** created and respecified under ctxA, then `MGPipeApplierReset()` + a fresh `GLContext`, then a
|
||||
real `glBufferSubData` — asserting the record is still `Live`, that the serial moved, that
|
||||
`RefusedResourceCalls == 0`, and that `CreateCount() == 1` (i.e. the client did **not** grow a re-publication
|
||||
path).
|
||||
|
||||
### 2.2 Major
|
||||
|
||||
| finding | disposition | where |
|
||||
|---|---|---|
|
||||
| **B-M1** the three `MGPipeSetPendingBaseInstance` call sites | **LANDED (ID-10)**, plus the `MGPipeLeaveVerb` correction above | `GL_Drawing.cpp:662, :685, :715`; `PipeFill.h:114-124` |
|
||||
| **B-M2** `Acquire` mutating the global slot allocator on the off-thread `SubData` path | **FIXED — the mint stays on the GL thread at creation only**; all five content emitters now look the handle up | `PipeFill.cpp:581-596, :649, :670, :691, :705, :727` |
|
||||
| **B-M3** `hostBytes` base-vs-base+offset | **NOT B'S** — handed on verbatim, §5 | — |
|
||||
| **B-M4** the sampled `BindMask`'s DSA hole, and the C.1 misquotation | **FIXED both halves**, by the primary mechanism the review named | `VertexInputEmit.h:219, :267`; `ResourceTracker.h:363-408, :516-522` |
|
||||
| **B-M5** the absent `UnmapPersistent` producer | **RECORDED, with the reason, beside the `MapPersistent` emitter** | `PipeFill.cpp:718-726` |
|
||||
|
||||
**B-M2.** Which of the two options the review allowed: **"make the mint happen on the GL thread at creation
|
||||
only."** It already did — `MGPipeMintResourceHandle` is called unconditionally from the `BufferObject`
|
||||
constructor — so on every content path the handle exists and a lookup is not merely safe but strictly correct.
|
||||
`MGPipeEmitResource{SubData,FlushRange,Readback}`, `MGPipeEmitBufferSubDataResident` and
|
||||
`MGPipeEmitMapPersistent` now go through one helper, `ContentHandleFor` (`PipeFill.cpp:581-596`), which calls
|
||||
`MGPipeResourceTracker::Find` (const; no free-list pop, no map insert, no `m_bySlot.resize`) and answers a null
|
||||
handle with `MGLOG_E_ONCE` naming the call and the GL buffer, then returns — rather than handing
|
||||
`kMGPipeNullHandle` to the applier, which would count as a refusal with no way back to the cause.
|
||||
`MGPipeEmitMapPersistent` returns `nullptr` on that path, which every one of its three call sites already
|
||||
treats as "the backend declined" (`BufferObject.cpp:600-606`, `:650-658`). `Acquire` now survives in exactly
|
||||
two places, both GL-thread by construction: the constructor's mint, and create/respecify.
|
||||
|
||||
**B-M4(a), the record corrected.** `client-v1` §4 B-DEV-2 said the bind entry points are *"`GL_Buffer.cpp`'s,
|
||||
which C.5 assigns to no package and **C.1 does not list for this one**"*. That last clause is **false**:
|
||||
`BRIEF-P3A.md:1130` lists `MobileGL/MG_State/GLState/BufferState/BufferState.{h,cpp}` for this package with
|
||||
the note *"the sticky `everBoundAs` mask's bump points at the buffer bind entry points (D-A3), all
|
||||
`#if MOBILEGL_PIPE_PUSH`"*, and C.5 gives B `MG_State/GLState/BufferState/**`. What is true is that the brief
|
||||
pointed at a file that turns out not to contain the entry points: `BufferState` only *vends*
|
||||
`BindingSlot<BufferObject>&` / `BindingSlotRange1D&`, and the `.Bind()` calls are `GL_Buffer.cpp`'s
|
||||
(`BindBuffer_State`, `BindBufferBase_State`, `BindBufferRange_State`), which C.5 assigns to nobody. The
|
||||
substance of the deviation survives; the sentence did not, and the corrected version is now written at
|
||||
`ResourceTracker.h:376-386`.
|
||||
|
||||
**B-M4(b), the hole closed at the place that matters.** The real widening is a **transient** bind, and the DSA
|
||||
idiom makes it the common case. `MGPipeVertexInputEmitter::EmitVertexBuffers` and `EmitIndexBuffer` already
|
||||
resolve, at every draw, exactly the attribute buffers and the element-slot buffer, so both now call
|
||||
`MGPipeResourceTrackerInstance().NoteBoundAs(handle, BufferTarget::Vertex | ::Index)`
|
||||
(`VertexInputEmit.h:219`, `:267`). `NoteBoundAs` (`ResourceTracker.h:363-374`) grows the table rather than
|
||||
dropping the note, and is GL-thread by construction (the validate point). **Any buffer ever drawn from carries
|
||||
its `ARRAY_BUFFER` / `ELEMENT_ARRAY` bit for the rest of its life**, whether or not it was bound at a storage
|
||||
op. `ResourceEmit.ADrawTimeIndexBindingPublishesElementArrayEvenWhenTheRespecifyCannotSeeIt`
|
||||
(`ResourceEmitTest.cpp:1729`) drives exactly the review's sequence, with a negative control first (a respecify
|
||||
with nothing bound publishes an empty mask), and goes red with the two calls removed (§4 M2).
|
||||
|
||||
**B-M4(b), the half NOT taken, and why.** The review also asked for `RefreshBindMask` from the other four
|
||||
resource emitters. It is **not** taken, and the reason is B-M2's: `RefreshBindMask` walks the whole context's
|
||||
binding state and writes the tracker, and one of those emitters (`resource_subdata`) is on the path D-A2
|
||||
preserves as reachable **off the render thread**. Extra sampling can only widen a sticky union, but not at the
|
||||
price of a context-wide read from the wrong thread — fixing one thread-safety finding by creating a larger one
|
||||
is not a trade this package will make. The reasoning is written at `ResourceTracker.h:400-408`. With
|
||||
`NoteBoundAs` in place the residue is strictly smaller than what the review's version would have left: a buffer
|
||||
that is bound, **never drawn from**, and never re-specified afterwards. That is the P8 `GL_Buffer.cpp` item,
|
||||
unchanged, and it is now the only thing on the list.
|
||||
|
||||
**B-M4 secondary, `BindEpoch`.** The sentence the review asked for is at `ResourceTracker.h:516-522`: the epoch
|
||||
does not see the 84×4 indexed binding points, and that is sound **only** because `BindBufferBase_State` /
|
||||
`BindBufferRange_State` also bind the generic slot (`GL_Buffer.cpp:1531`); if that stops being true,
|
||||
`CONSTANT` / `SHADER_BUFFER` / `ATOMIC` / `STREAM_OUTPUT` start being missed silently, and the repair is to
|
||||
fold `GetTouchedBufferBindingPointCount` into the epoch.
|
||||
|
||||
**B-M5.** Recorded, with the reason, at `PipeFill.cpp:718-726`: `BufferBackendOps` has seven hooks and none is
|
||||
an unmap; `PipeResource::ReleasePersistentMap()` tells the backend nothing today and it learns from the
|
||||
`Respecify` that follows; emitting `unmap_persistent` would be **new behaviour**, which D-J forbids. So the
|
||||
client emits none, deliberately, and the applier's `RefusedResourceCalls` stays at 0 for it. The producer lands
|
||||
with the phase that gives the backend an unmap hook.
|
||||
|
||||
### 2.3 Minors
|
||||
|
||||
| # | disposition | where |
|
||||
|---|---|---|
|
||||
| m1 | **taken** — `MGPipePendingBaseInstance()` now has a caller: `TrackerShippedEmitter.ABaseInstancedDrawAfterAMakeCurrentPublishesItsOwnBaseInstance` asserts on it three times (the setter took, the value was consumed, the no-context exit cleared it). Its declaration comment names that case. | `PipeFill.h:72-74`; `TrackerTest.cpp:862` |
|
||||
| m2 | **taken, both directions** — `MOBILEGL_ASSERT(bindingIndex < 256)` and `attrib.Size in [0,255]` before the two `Uint8` narrowings, and `MOBILEGL_ASSERT(attrib.Stride >= 0)` before the signed→unsigned one, each with the failure it prevents named (binding 256 wrapping to 0; a negative stride arriving as a ~4 GiB fetch distance) | `VertexInputEmit.h:83-90`, `:224-226` |
|
||||
| m3 | **taken** — `SourceIsVerbatimLevelShadow` is a **parameter** of `MGPipeBuildSubDataRecord`, `true` on `resource_subdata` (the client's own shadow) and `false` on `buffer_subdata_resident` (the application's staging store, or `FillSubData`'s locally expanded pattern) | `ResourceTracker.h:212-233`; `PipeFill.cpp:656`, `:678` |
|
||||
| m4 | **taken** — both walk lambdas now `if (!MGPipeBuildSubDataRecord(...)) return;` rather than discarding the `Bool`, with the comment saying the pre-pass makes it unreachable today | `PipeFill.cpp:654-658`, `:675-680` |
|
||||
| m5 | **taken** — `MGPipeClientOnGpuWritten` asserts the announced shape (exactly one range, non-null) and returns on `rangeCount == 0` rather than marking a whole buffer written; the resolve-to-null arm is now as loud as its sibling | `ResourceTracker.h:594-615` |
|
||||
| m6 | **taken** — a `LiteralBindMaskFor` oracle spelled as raw bit positions read off `MGPipeTypes.h`'s documented order (no `default:` arm, so a new `BufferTarget` is a build break in both places); the emitted mask is compared to the **literal**, the table is compared to the literal for the bindable targets, and a second loop compares the table to the literal for **all 15** enumerators | `ResourceEmitTest.cpp:1417-1462`, `:1484-1490`, `:1505-1512` |
|
||||
| m7 | **NOT taken** — §6 | — |
|
||||
| m8 | **taken** — the `.def` row now says the publisher is the backend's (`Managers.cpp`'s `OnFrontendStateObjectDestroyed` consumer, package espryt), and that until it lands the row states the design and not the tree | `DirtySurface.def:295-298` |
|
||||
| m9 | **taken** — the bit-7/bit-8 coupling is stated where an operator reads the constant: bit 8 without bit 7 sends handles the server cannot resolve and every such call lands in `RefusedResourceCalls`; neither `0x1ff` nor `0x7f` is in that arm | `PipeFill.cpp:978-988` |
|
||||
| m10 | **taken** — a store of ≥ 4 GiB is `MGLOG_E_ONCE` + `MOBILEGL_ASSERT` naming the buffer and the size, with the reason (a silent narrowing makes the applier's range gate report `Fatal{ProtocolCorruption}` for a corruption that is really a truncation here); the 32-bit `Width` is the contract's, so the value is still narrowed after the line | `ResourceTracker.h:174-190` |
|
||||
| m11 | **settled, and it agrees with wire** — wire's ONE Blob rule (0 = not declared; non-zero must be exact) makes filling optional. B **fills it, exactly**: `Blob.Seg = kMGHostSpanSegNone`, `Blob.Size` = the piece's own byte length, which is precisely what `SubDataBoxFault`'s `!= 0 && != MGPipeSubDataBufferSize` gate checks. The rule and the choice are written at the builder. | `ResourceTracker.h:218-224` |
|
||||
| m12 | **taken** — `MGPipeResourceTracker::Entry` gains `Published`, set at the create (`NotePublished`) and read at the destroy (`WasPublished`); `MGPipeEmitResourceDestroyAndFree` now **returns** whether the destroy went out and `~BufferObject` uses that answer instead of asking `MGPipeResourceSubsystemEnabled()` a second time. That closes both directions: a live applier record on a slot about to be re-handed-out, and a legacy backend object nobody releases. | `ResourceTracker.h:328-352`, `:505`; `PipeFill.cpp:623-626`, `:745-762`; `PipeMutation.h:116-125`; `BufferObject.cpp:55-60` |
|
||||
|
||||
---
|
||||
|
||||
## 3. What changed in the deviations `client-v1` declared
|
||||
|
||||
Only two of the nine move; the rest stand as the review accepted them.
|
||||
|
||||
* **B-DEV-2 (sampled `BindMask`)** — the C.1 citation is corrected (§2.2 B-M4(a)), the hole is re-described as
|
||||
the *transient* bind rather than "a bind after the last resource emission", and the fix for the two bits
|
||||
anything keys on is now **in this package** rather than handed on. What is handed on is smaller and stated:
|
||||
the three `GL_Buffer.cpp` binders, for the seven bits nothing keys on yet.
|
||||
* **B-DEV-3 (bit 9's shutter)** — the mechanism is unchanged and still correct; the claim that the two clears
|
||||
are independent is **withdrawn** (§2.1). There is one production clear, on two exits.
|
||||
* **B-DEV-1, -4, -5, -6, -7, -8, -9** — unchanged. B-DEV-7's coordination item (`kMGPipeResourceTargetBuffer
|
||||
== 0`) is still open for one look from `espryt`; nothing in `wire-v2` contradicts it, and
|
||||
`ResourceEmit.EveryBufferTargetSetsItsBindMaskBit` asserts `created.Target == 0` on every target.
|
||||
|
||||
Two **new** deviations this round:
|
||||
|
||||
**R1 — the three call sites go through a macro, `MGP_SET_BASE_INSTANCE`, not a bare call.** The review's line
|
||||
was `MG_Pipe::MGPipeSetPendingBaseInstance(baseinstance);` and warned to *"check that when the lines land"*.
|
||||
Checked: `PipeFill.h`'s whole declaration block is inside `#if MOBILEGL_PIPE_PUSH` (`:16-113`), so a bare call
|
||||
does not merely fail to **link** in a pull build, it fails to **compile**. The macro
|
||||
(`PipeFill.h:114-124`, `((void)0)` in the pull arm) is the shape `MGP_FILL` already has, one line per site,
|
||||
carrying the **raw** `baseinstance`. G1 is 0/0/0/0, which is the proof the pull text did not move.
|
||||
|
||||
**R2 — `RefreshBindMask` is deliberately not called from the content emitters** (§2.2 B-M4(b)). This is the one
|
||||
place this round declines a reviewer instruction, and the reason is another of the review's own findings.
|
||||
|
||||
---
|
||||
|
||||
## 4. Mutation evidence — 4 mutations, 4 reds, measured
|
||||
|
||||
Each applied to the rebased tree, `build-push` rebuilt, the suites run, the file restored with
|
||||
`git checkout --` (the tree was verified clean after every one).
|
||||
|
||||
| # | mutation | verdict | case that went red |
|
||||
|---|---|---|---|
|
||||
| M1 | **B-C1 reverted**: `m_pendingBaseInstance = 0;` put back into `Tracker.h`'s `Reset()` | **RED**, 2/2 failed | `TrackerWalk.ABaseInstanceSurvivesTheFirstWalkOnAFreshContext` **and** `TrackerShippedEmitter.ABaseInstancedDrawAfterAMakeCurrentPublishesItsOwnBaseInstance` |
|
||||
| M2 | **B-M4 reverted**: both `NoteBoundAs` calls commented out of `VertexInputEmit.h` | **RED**, 1/1 failed | `ResourceEmit.ADrawTimeIndexBindingPublishesElementArrayEvenWhenTheRespecifyCannotSeeIt` |
|
||||
| M3 | **B-M1's hole reopened**: the clear removed from the validate point's no-live-context exit | **RED**, 1/1 failed | `TrackerShippedEmitter.ABaseInstancedDrawAfterAMakeCurrentPublishesItsOwnBaseInstance` |
|
||||
| M4 | **m12 reverted**: the destroy gated on `MGPipeResourceSubsystemEnabled()` again instead of the create's latch | **RED**, 1/1 failed | `ResourceEmit.ADestroyFollowsTheCreateEvenIfTheOpTableWasUnregisteredMeanwhile` |
|
||||
|
||||
No mutation survived. The restored tree is `100% tests passed, 0 failed out of 70` on
|
||||
`ctest -R 'ResourceEmit\.|VertexInputEmit\.|Tracker'`.
|
||||
|
||||
---
|
||||
|
||||
## 5. For the integrator and for package C (espryt)
|
||||
|
||||
1. **B-M3, unchanged and still live — `hostBytes` is `shadow + offset` on two of the three content calls.**
|
||||
`espryt-v1.md` §1 e1 latches *"the client's shadow base"*; the client sends, per D-A2 and correctly:
|
||||
* `MGPipeEmitResourceRespecify` → `buffer.MappedData()` — the **true base** (`PipeFill.cpp:640`);
|
||||
* `MGPipeEmitResourceSubData` → `base + at` where `base = buffer.MappedData()` — **base + offset**
|
||||
(`PipeFill.cpp:650`, `:659`);
|
||||
* `MGPipeEmitResourceFlushRange` → `buffer.MappedData() + offset` — **base + offset**
|
||||
(`PipeFill.cpp:701`);
|
||||
* `MGPipeEmitBufferSubDataResident` → the application's staging store, which `espryt-v1.md` D10 already and
|
||||
correctly refuses to latch.
|
||||
|
||||
So after any `glBufferSubData(b, 4096, …)` Espryt's `hostBytes` is `shadow + 4096`, and the next pool reseed
|
||||
or full re-upload reads 4096 bytes past the store's end. **B is brief-conformant and does not change**;
|
||||
espryt's latch is the side that moves — `hostBytes = bytes - MGPipeSubDataBufferOffset(record)` /
|
||||
`bytes - record.Offset`, or drop the latch on the two ranged calls and keep it only on respecify.
|
||||
`espryt-review-v1.md`'s C-2 is a **different** defect (a cached base dangling after adoption/resize) and its
|
||||
fix does not touch this one. The shape that catches it is a `StreamedArenaScenario` recycle plus a
|
||||
`CrossFrameBufferScenario` flush at a non-zero offset.
|
||||
2. **`kMGPipeResourceTargetBuffer == 0`** (B-DEV-7) still wants one confirming look from espryt.
|
||||
3. **`MGPVertexBuffer::BindingIndex` is the attribute index for every entry** (`VertexInputEmit.h:222`), which
|
||||
is what `espryt-v1.md` §6 item 14 says `VertexBufferForBindingIndex`'s fast path assumes. Confirmed.
|
||||
4. **`OnGpuWritten` is announced as one `kMGPipeWholeBuffer` range** — the client now asserts that shape rather
|
||||
than ignoring it (m5). A backend that announces zero ranges gets nothing marked, deliberately.
|
||||
5. **The resident dispatch gate** (wire §6 item 7) is already the member, not the subsystem:
|
||||
`BufferObject::LandBytesIntoResidentStore` asks `MGPipeResourceOpsHaveSubDataResident()`
|
||||
(`BufferObject.cpp:435`), which reads `ops->SubDataResident != nullptr`.
|
||||
6. **`map-persistent-roundtrips` is still 0 on this tree** and becomes non-zero the moment espryt registers the
|
||||
table (G10). `MOBILEGL_PIPE_PUSH=0x7f` vs `0x1ff` is still emission-only (G12) until then.
|
||||
7. **The three `MGP_SET_BASE_INSTANCE` sites are now the gate ID-10 describes**: espryt's
|
||||
`DrawParameters` / `VertexAttribBinding` base-instance scenarios must be red without them and green with
|
||||
them, and the integrator checks both directions once on the finished tree. Package C may now delete
|
||||
`g_pendingFetchBaseInstance` without losing the emulation's input.
|
||||
|
||||
---
|
||||
|
||||
## 6. Left undone, and what it costs
|
||||
|
||||
1. **m7 — `set_index_buffer` has no content suppressor.** Bit 10's shutter mixes `vaoIdentity`, which includes
|
||||
`GetConfigVersion()`, so any VAO reconfiguration re-emits an identical `MGPIndexBuffer` and moves the
|
||||
applier's `IndexBufferSerial` — the memo espryt's `m_syncedIndexSerial` early-out reads. **Correctness is
|
||||
fine (over-fire only); the cost is a measurable per-draw one for a reconfiguring app.** Not taken because
|
||||
latching `m_lastIndex` changes emission counts that `TrackerWalk.TheIndexBufferBit*` and espryt's memo cases
|
||||
both observe, and ID-6 makes performance a recorded item rather than a gated one. The fix is a latch plus a
|
||||
skip and belongs with the phase that measures it.
|
||||
2. **The `GL_Buffer.cpp` bind hook** — three one-line `NoteBoundAs` calls in `BindBuffer_State`,
|
||||
`BindBufferBase_State`, `BindBufferRange_State`, for the seven `BindMask` bits nothing keys on yet. Now the
|
||||
*only* residue of B-DEV-2: a buffer bound, never drawn from, and never re-specified afterwards. Still
|
||||
nobody's file; still invisible in monolith.
|
||||
3. **`delete_vertex_elements` and the VAO CSO slot free** (B-DEV-8) — package C's, by the ownership split. On
|
||||
this tree VAO CSO slots are never freed.
|
||||
4. **`RefreshBindMask` from the content emitters** (R2) — declined with a reason, not forgotten.
|
||||
5. **The `MOBILEGL_PIPE_POISON_OMIT` caselist sweep** — declared off the critical path; the `FillPoints.def`
|
||||
comment still says the verdict lands with the G15 caselist run and every row stays.
|
||||
6. **The review's §7 items that are the integrator's, not a package's**: the `Blob.Size` off-by-one negative
|
||||
control on the merged tree (§7.3), and the `TheXIsActuallyArmedWhenTheEnvironmentPinsItOn` family's race on
|
||||
shared log files under concurrent load (`MG_IntegrationTest/CMakeLists.txt:1040`). This round's lanes were
|
||||
run **serially, with no competing load**, and were clean first time — see §7.
|
||||
|
||||
The review's §7.2 (mirror-image applier assertions on every case) is **partly** discharged: the new cases all
|
||||
read `MGPipeApplier()` directly (`VertexFetchBaseInstance`, `VertexBufferCount`, `Resources[slot].Live/Serial/
|
||||
Desc.Width`, `RefusedResourceCalls`), and wire's own nine cases do the same from the other side. Turning
|
||||
`EveryAttributeFieldSurvivesTheWireConversion` into a full round trip through
|
||||
`MGPipeVertexElementsRecord::Attributes[]` is **not** done: G7's negative control is defined over the
|
||||
conversion, and adding a second oracle to the same case would make a scripted field-drop fail twice for one
|
||||
reason. It is a second `EXPECT` beside an existing one whenever the integrator wants it.
|
||||
|
||||
---
|
||||
|
||||
## 7. Verification transcript
|
||||
|
||||
All in `/home/swung/w7/p3a-client` at `dfaa8729`, `CCACHE_BASEDIR=/home/swung/w7`, on the rebased tree.
|
||||
|
||||
**G1 — pull build symbol identity, against `~/w7/p3a-before-libMobileGL.so` (the `5cb826b0` baseline, ID-9)**
|
||||
|
||||
```
|
||||
python3 scripts/symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so \
|
||||
--threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0 rc 0
|
||||
symbol-report: before: /home/swung/w7/p3a-before-libMobileGL.so (19114360 bytes on disk)
|
||||
symbol-report: after : build-linux/libMobileGL.so (19114360 bytes on disk)
|
||||
symbol-report: .text 10806323 -> 10806323 (+0, +0.000%) .data +0 .bss +0 .rodata +0
|
||||
symbol-report: Total 17226471 -> 17226471 (+0)
|
||||
symbol-report: 27811 -> 27811 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
|
||||
symbol-report: 27072 -> 27072 normalised names, 27072 unchanged
|
||||
```
|
||||
|
||||
**0 / 0 / 0 / 0, and the two libraries are byte-identical in size.** `~/w7/p3a-before-head.txt` reads
|
||||
`5cb826b01e00dd28a6e62c1aab65e3edc50e5758`, which is this branch's base, so the baseline problem `client-v1`
|
||||
and `wire-v2` both raised is closed by the rebase. P3a's admitted-resize set stays empty.
|
||||
|
||||
**Three builds** (`cmake --build <dir> -j 24`): `build-linux` rc **0**, `build-push` rc **0**,
|
||||
`build-verify` rc **0**.
|
||||
|
||||
**Three unit runs** (`ctest --test-dir <dir> -L unit -j 12 --no-tests=error`):
|
||||
|
||||
```
|
||||
build-linux rc=0 100% tests passed, 0 failed out of 1617
|
||||
build-push rc=0 100% tests passed, 0 failed out of 1617
|
||||
build-verify rc=0 100% tests passed, 0 failed out of 1617
|
||||
```
|
||||
|
||||
(1599 at `12e6bfcf` + b4's 13 + this round's 5.)
|
||||
|
||||
**Names — G2's name half, and G14**
|
||||
|
||||
```
|
||||
ctest -N: build-linux 2537, build-push 2537, build-verify 3369
|
||||
diff <linux names> <push names> -> EMPTY (rc 0)
|
||||
comm -23 <p3a-before-ctest-names.txt> <linux names> -> 0 removed
|
||||
comm -13 ... -> 35 added
|
||||
```
|
||||
|
||||
The baseline is `p3a-before-ctest-names.txt`, 2502 names taken at `5cb826b0` (which already carries the
|
||||
contract's 5). The 35 added are therefore **wire's 17** (all `ResourceEmit.*`), **b4's 13**
|
||||
(4 `ResourceEmit`, 7 `VertexInputEmit`, 2 `TrackerWalk`) and **this round's 5**
|
||||
(`ResourceEmit.ABufferCreatedBeforeAMakeCurrentStillLandsItsSubDataAfterOne`,
|
||||
`ResourceEmit.ADrawTimeIndexBindingPublishesElementArrayEvenWhenTheRespecifyCannotSeeIt`,
|
||||
`ResourceEmit.ADestroyFollowsTheCreateEvenIfTheOpTableWasUnregisteredMeanwhile`,
|
||||
`TrackerWalk.ABaseInstanceSurvivesTheFirstWalkOnAFreshContext`,
|
||||
`TrackerShippedEmitter.ABaseInstancedDrawAfterAMakeCurrentPublishesItsOwnBaseInstance`).
|
||||
**Nothing removed, in any of the three builds.**
|
||||
|
||||
**Generators and closure**
|
||||
|
||||
```
|
||||
python3 scripts/gen_pipe.py --check rc 0 "generated files are up to date"
|
||||
71 calls, 71 verify payloads,
|
||||
63 PipeInputs fields (7 sticky, 34 emitted)
|
||||
inventory 477 rows, 0 UNMAPPED
|
||||
git diff --exit-code -- MobileGL/MG_Pipe/generated rc 0
|
||||
python3 scripts/gen_pipe_dirty_surface.py --check rc 0 "75 mutators, all mapped, no stale rows;
|
||||
45 render-state answers derived and matching;
|
||||
10 other answers derived; 0 COARSE; 0 UNDECIDED"
|
||||
python3 scripts/gen_pipe_dirty_surface.py --self-test rc 0 "21 negative controls, all tripped;
|
||||
positive controls OK"
|
||||
python3 scripts/check_include_closure.py rc 0 "4 probes, 0 skipped, 0 problem(s)"
|
||||
mutation-header OK 84 headers, 0 forbidden
|
||||
python3 scripts/check_include_closure.py --mode both --compiler clang++ --self-test --require-all rc 0
|
||||
"6 negative-control trip(s), parser checks OK"
|
||||
```
|
||||
|
||||
(`--compiler clang++-20` does not exist on this host; `clang++` is the substitution the contract and client
|
||||
packages both recorded.)
|
||||
|
||||
**G13 / layering**: `grep -c 'MG_State' MG_Pipe/PipeApply.h` → **0**; `grep -rc 'pGLContext' MG_Backend | grep
|
||||
-v ':0$'` → empty.
|
||||
|
||||
**The four lanes** — run **serially, with no competing load**, which is the protocol `client-v1` established
|
||||
after chasing the `TheXIsActuallyArmedWhenTheEnvironmentPinsItOn` race. All four green first time, no re-runs:
|
||||
|
||||
```
|
||||
ctest --test-dir build-push -L integration-gpu -j 8 rc 0 100% passed, 0 failed of 920
|
||||
MOBILEGL_PIPE_PUSH=0 ctest --test-dir build-push -L integration-gpu -j 8 rc 0 100% passed, 0 failed of 920
|
||||
MOBILEGL_PIPE_PUSH=0x7f ctest --test-dir build-push -L integration-gpu -j 8 rc 0 100% passed, 0 failed of 920
|
||||
ctest --test-dir build-verify -L integration-verify -j 4 rc 0 100% passed, 0 failed of 832
|
||||
```
|
||||
|
||||
With the applier bodies real and **no backend registered**, every emission still falls through: nothing
|
||||
registers `MGPipeResourceOps` anywhere in the tree outside `MG_Test/Pipe/ResourceEmitTest.cpp`, so
|
||||
`MGPipeResourceSubsystemEnabled()` is false in all three arms and the observable is unchanged. That is what
|
||||
makes the `0` and `0x7f` arms identical to the default one on this tree, and what makes G12 still an
|
||||
emission-only A/B until espryt lands.
|
||||
|
||||
**The retrace gate, verify-armed** — `MOBILEGL_PIPE_VERIFY=1 python3 ~/w7/retrace_gate.py --tree
|
||||
~/w7/p3a-client --lib ~/w7/p3a-client/build-verify/libMobileGL.so --out ~/w7/retrace-out/p3a-client -j 4`:
|
||||
|
||||
```
|
||||
retrace rc=0
|
||||
PASS MobileGLTraceReplay.minecraft-1.21.4-main-menu.DirectVulkan rc=0 3s ssim=0.997009
|
||||
PASS MobileGLTraceReplay.minecraft-1.21.4-rd12-odinlite-in-world.DirectGLES rc=0 63s ssim=1.0
|
||||
PASS MobileGLTraceReplay.minecraft-1.21.4-rd12-odinlite-in-world.DirectVulkan rc=0 79s ssim=0.999991
|
||||
PASS MobileGLTraceReplay.minecraft-1.21.4-startup.DirectGLES rc=0 1s ssim=1.0
|
||||
PASS MobileGLTraceReplay.minecraft-1.21.4-startup.DirectVulkan rc=0 1s ssim=1.0
|
||||
passed 79 / 79; failed: []
|
||||
|
||||
grep -l 'Fatal{' ~/w7/retrace-out/p3a-client/*.log -> empty
|
||||
grep -L 'MGPipe verify:' ~/w7/retrace-out/p3a-client/*.log -> empty (all 79 armed)
|
||||
ls ~/w7/retrace-out/p3a-client/*.log | wc -l -> 79
|
||||
```
|
||||
|
||||
This is again the strongest single result in the document, and this time it is on a tree where the applier's
|
||||
bodies are **real**: with the emission live in a verify build, whose compare-at-read re-reads every field from
|
||||
the live context at every backend read, the whole corpus replays with zero divergence and zero unmigrated
|
||||
reads on both backends. `~/w7/retrace-out/p3a-client` was deleted afterwards. No
|
||||
`Fatal{UnmigratedPipeInput,"F@V"}` appeared, so no `FillPoints.def` row was owed and none was added.
|
||||
|
||||
**Ownership**: `git diff --stat 12e6bfcf..HEAD` names `MG_Impl/Pipe/{PipeFill.h,PipeFill.cpp,Tracker.h,
|
||||
ResourceTracker.h,VertexInputEmit.h,SetHashSuppressor.h}`, `MG_Pipe/{PipeMutation.h,DirtySurface.def,
|
||||
FillPoints.def}`, `MG_State/GLState/BufferState/BufferObject.cpp`, `scripts/gen_pipe_dirty_surface.py`, the
|
||||
three `MG_Test/Pipe/*.cpp`, and `MG_Impl/GLImpl/Drawing/GL_Drawing.cpp` (**+3 lines, the ID-10 grant**). No
|
||||
`MG_Backend`. `git status` clean.
|
||||
|
||||
---
|
||||
|
||||
## 8. Intermediate logs and working state
|
||||
|
||||
Deleted at the end of the round: `~/w7/p3a-client2-lanes.log`, `~/w7/p3a-client2-lane-*.log`,
|
||||
`~/w7/p3a-client2-retrace.log`, `~/w7/client2-lanes-inner.sh`, and `~/w7/retrace-out/p3a-client/`. No mutation
|
||||
harness worktree was created — every mutation was applied in place and reverted with `git checkout --`.
|
||||
|
||||
`git status` in `/home/swung/w7/p3a-client` is clean at `dfaa8729`. The trace fixtures are materialised (real
|
||||
archives, not LFS pointers) and hidden with `git update-index --assume-unchanged`, which is the state the next
|
||||
run of the retrace gate needs.
|
||||
@@ -0,0 +1,362 @@
|
||||
# P3a package A `c0` — adversarial review of the contract (`contract-review-v1`)
|
||||
|
||||
Reviewed commit `39722687` (tag `p3a/contract`), parent `44c2b5cf`, worktree `/home/swung/w7/p3a-contract`.
|
||||
Everything below was checked by opening the file at the commit (a throwaway `git worktree` at
|
||||
`/home/swung/w7/p3a-review`, removed at the end, was used for `gen_pipe.py`; no build was run there).
|
||||
|
||||
## Verdict
|
||||
|
||||
**ACCEPT WITH MINORS — conditional.** The contract itself is right: every payload, flag, struct, subsystem
|
||||
bit, entry-point signature, record and generated table I checked matches the B decisions it claims to
|
||||
implement, and I could not find a path by which `c0` changes what a push or a verify build copies,
|
||||
suppresses or emits. The three other trees are already branched from the tag and should proceed.
|
||||
|
||||
Two **major** findings and seven minors are listed below. Neither major changes an ABI, a signature or a
|
||||
generated table, so **neither requires the tag to be re-cut**: M1 is a comment-only fix that A can land on
|
||||
`p3a/wire`, M2 is a four-line guard in a file `C.5` hands to package C at the tag. Both must be closed
|
||||
before D.1's `espryt` merge, not before the packages start.
|
||||
|
||||
---
|
||||
|
||||
## Findings
|
||||
|
||||
### M1 (major) — `Coverage.def`'s "target by target" split is not exhaustive: `DispatchIndirect` and `Query` are missing
|
||||
|
||||
`MobileGL/MG_Pipe/Coverage.def:41-47` (the new split), `:48-56` (the argument that rests on it).
|
||||
|
||||
The rewritten comment enumerates the split as ArrayBuffer / ElementArrayBuffer / DrawIndirectBuffer +
|
||||
ParameterBuffer / Uniform + ShaderStorage + AtomicCounter + TransformFeedback / CopyRead + CopyWrite +
|
||||
PixelPack + PixelUnpack + Texture — **13 of the 15 `BufferTarget` enumerators**
|
||||
(`MG_State/GLState/BufferState/BufferObject.h:15-33`: Vertex, Index, Uniform, CopyRead, CopyWrite,
|
||||
PixelPack, PixelUnpack, **Query**, Texture, TransformFeedback, AtomicCounter, **DispatchIndirect**,
|
||||
DrawIndirect, Parameter, ShaderStorage). `DispatchIndirect` and `Query` appear in no bucket at all, not even
|
||||
the "still pulled" one, while the block asserts "The split, target by target" and `:53-56` argues the row
|
||||
may stay one row *because* the split is stated here instead.
|
||||
|
||||
`DispatchIndirect` is not a hypothetical: it is a live backend read at
|
||||
`MG_Backend/DirectGLES/DirectGLES.cpp:725` (`SyncBoundBuffer(BufferTarget::DispatchIndirect, …)`) and
|
||||
`MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp:7423`, and it has **no call in the catalogue** —
|
||||
`MGPIndirectBuffers` (`MGPipeTypes.h:405-409`) carries `DrawIndirect` and `Parameter` only. So the one
|
||||
target that a reader would most plausibly assume `set_indirect_buffers` covers is exactly the one that
|
||||
silently does not travel.
|
||||
|
||||
Failure scenario: P4b (shader buffers) or P8 (indirect) reads this block as the authoritative per-target map,
|
||||
sees 13 targets accounted for and no residue, wires `EmittedCallSuppliesTheWholeField(GetBufferBindingSlot)`
|
||||
or retires the pull for the field on the strength of it, and `m_bufferBindingSlot[DispatchIndirect]` stops
|
||||
being written for every `glDispatchComputeIndirect`. No P3a gate can see it (the row is deliberately out of
|
||||
the emitted list), and `Coverage.def` is A-only in `C.5`, so no later package may correct it.
|
||||
|
||||
Refutation attempted, and it failed: I checked whether `Query` and `DispatchIndirect` might be excluded
|
||||
because no backend reads them — `Query` indeed has no backend read, but `DispatchIndirect` has two, so the
|
||||
omission cannot be "only backend-read targets are listed". I also checked whether they might be covered by
|
||||
another accessor row: `GetBufferBindingSlot` is the only row for that field, and `gen_pipe.py --check`
|
||||
reports 0 UNMAPPED, i.e. nothing else picks them up.
|
||||
|
||||
Fix: two lines in the comment — add `DispatchIndirect` to the still-pulled bucket with the reason (no call
|
||||
carries it; `MGPIndirectBuffers` is a two-handle payload) and `Query` beside it. Use the enum's own spelling
|
||||
(`Vertex`, `Index`, `DrawIndirect`, `Parameter`) rather than the GL token names, so the list can be
|
||||
cross-checked mechanically against `BufferObject.h:15-33`.
|
||||
|
||||
### M2 (major) — `BackendSlotTable::GetOrCreate(MGPipeHandle)` adopts a **stale** generation and destroys the live twin at the slot
|
||||
|
||||
`MobileGL/MG_Backend/DirectGLES/SlotTables.h:272-286`, specifically `:282-284`:
|
||||
|
||||
```cpp
|
||||
Entry& entry = EntryAt(handle.Slot);
|
||||
if (entry.Live && entry.Gen != handle.Gen) entry.backend.reset();
|
||||
entry.Gen = handle.Gen;
|
||||
entry.Live = true;
|
||||
```
|
||||
|
||||
The `!=` is symmetric; the comment above it (`:262-265`) argues only the asymmetric case ("the slot was
|
||||
recycled, so the twin at it describes driver ids the new resource never made"). For the *minting* overload
|
||||
(`:202-246`) the symmetric form is provably safe, because the handle comes straight out of
|
||||
`MGPipeSlots().Acquire` and can never be behind the entry. For the **handle** overload the handle "ARRIVED,
|
||||
in the call's payload" — that is the whole point of the overload — so `handle.Gen < entry.Gen` is a
|
||||
reachable input, and the code then destroys the *incumbent, live* twin (a driver buffer id, a persistent
|
||||
map, a pooled store) and stamps the slot back to the dead resource's generation. The successor's next
|
||||
`FindByHandle` (`:294-301`) then correctly refuses (`entry.Gen != handle.Gen`) and it is silently handed a
|
||||
fresh empty twin: the resource loses its storage with no diagnostic. That is the shape of the bug commit
|
||||
`d7655247` fixed, and it is exactly what `MGPipeHandle::Gen` exists to prevent
|
||||
(`MGPipeHandles.h:44-53`).
|
||||
|
||||
The two handle-keyed entry points A ships as the contract therefore give **opposite** answers to a stale
|
||||
generation: `FindByHandle` refuses it, `GetOrCreate` adopts it. `C.4` tells package C it may assume this
|
||||
overload, and the header's comment does not warn.
|
||||
|
||||
Refutations attempted:
|
||||
- *"It is unreachable in P3a monolith."* Largely true, and this is why it is not a critical: under D-L's
|
||||
fixed order (`~BufferObject` → `MGPipeEmitResourceDestroy` → `MGPipeSlots().Free`) the backend sees
|
||||
handles in order, and Espryt's off-thread queues (`pendingResidentWrites`, `g_deferredBufferReleases`) are
|
||||
keyed on the resource, not on a handle. I could not construct a P3a-monolith sequence that reaches it.
|
||||
But the contract is written for the split, the applier's own record *does* gen-check
|
||||
(`MGPipeResourceRecord::Gen`, `PipeApply.h:99-118`) and this one does not, and `MOBILEGL_ASSERT` is a
|
||||
no-op in Release (`Defines.h:114`), so there is no debug trip wire either.
|
||||
- *"C can fix it — `SlotTables.h` is C's from the tag on (`C.5`)."* True, and it is why this is not a
|
||||
REWORK: the fix does not re-open the tag. It is reported here because three packages are being written
|
||||
against the comment now, and because the result file's §1 states the behaviour as "resets a twin whose
|
||||
`Gen` no longer matches", which reads as complete and is not.
|
||||
|
||||
Fix (C's tree, or A's `c1`): refuse the backwards case rather than adopt it —
|
||||
`if (entry.Live && entry.Gen != handle.Gen) { if (entry.Gen > handle.Gen) return m_nullTwin; /* or a
|
||||
Fatal{ProtocolCorruption} */ entry.backend.reset(); }` — and say in the comment which direction each arm is.
|
||||
|
||||
Related, same call, worth one line of the same fix: `EntryAt(handle.Slot)` (`:427-430`) does
|
||||
`m_slots.resize(slot + 1)` on a **client-supplied** slot index with no bound. The applier's blob-bounds gate
|
||||
(`c1`/`c2`) does not sit between the payload and this call for the resource family — Espryt dispatches
|
||||
`ops->Create(record.Res, …)` straight through. C must bound-check `handle.Slot` before calling, and nothing
|
||||
in the contract says so.
|
||||
|
||||
---
|
||||
|
||||
### m1 (minor) — the new emitted row is inserted out of order
|
||||
|
||||
`Coverage.def:187`. `MGP_COVERAGE_EMITTED_LIST` was strictly `LC_ALL=C`-sorted (34 rows); the new
|
||||
`X(GetBoundVertexArray, BindVertexElements)` sits at position 2 instead of 4. Functionally inert —
|
||||
`gen_pipe.py:819` does `sorted(set(...))` for the emitter enum and `kMGPipeFieldEmittedBy` is indexed by the
|
||||
accessor list — but it is the one list in the file a reader diffs by eye.
|
||||
|
||||
### m2 (minor) — `MGPVertexElements::Blob`'s comment still names the frontend types
|
||||
|
||||
`MGPipeTypes.h:257`: `MGPBlobRef Blob; // VertexAttribute[] followed by VertexBufferBindingPoint[]`. Those
|
||||
are precisely the two types that **cannot** travel (each holds a `SharedPtr<BufferObject>` — D-G2, and the
|
||||
whole reason `c0` mints the wire views). The authoritative layout is now in `MGPipeValueTypes.h:552-559`
|
||||
and `PipeApply.h:311-316`, and this line contradicts both. `MGPipeTypes.h` is A-only.
|
||||
|
||||
### m3 (minor) — two comments now name the wrong default push mask, and one of them is in a file nobody owns
|
||||
|
||||
- `MG_Backend/DirectVulkan/Renderer/MagmaPipeArms.h:112-115`: the `Fatal{PipeLegacyMemosDisabled}` message
|
||||
tells the operator "or the default 0x%llx" and prints `kMGPipeSubsystemsMigratedAtP2`. The default is now
|
||||
`0x1ff`, and `0x7f` is the *control*, so the message now advises the operator to run the A/B's off-arm.
|
||||
`C.5` marks `MG_Backend/DirectVulkan/**` untouched for every package, so no package owns the fix — the
|
||||
integrator has to.
|
||||
- `ConfigLoader.cpp:11`: the include comment still reads "For `kMGPipeSubsystemsMigratedAtP2`, the push
|
||||
build's `PipePush` default" while `:256` now uses `kMGPipeSubsystemsMigratedAtP3a`.
|
||||
|
||||
### m4 (minor) — the three new pairing `static_assert`s are inconsistent in form
|
||||
|
||||
`PipeFill.cpp:688-701`. The `NewVertexElements` arm compares against
|
||||
`SubsystemForEmitter(MGPipeFieldEmitter::BindVertexElements)`; the `NewVertexBuffers` and `NewIndexBuffer`
|
||||
arms compare against the literal `kMGPipeSubsystemVertexInput`. Equivalent today (the first assert pins the
|
||||
two together), but a later edit that re-points the emitter would leave two of the three silently comparing
|
||||
against the old constant.
|
||||
|
||||
### m5 (minor) — `TEST(PipeCatalogue, SixValueStructsHaveFieldLists)` now asserts eight
|
||||
|
||||
`PipeCatalogueTest.cpp:352-362`. Correctly **not** renamed (G14 forbids it) and the comment was updated;
|
||||
recorded only so the next reader does not "fix" the name.
|
||||
|
||||
### m6 (minor) — `MGPVertexBuffer` and `MGPVertexAttribWire` disagree on the type of `Stride` and `BindingIndex`
|
||||
|
||||
`MGPipeTypes.h:363-370` has `Uint32 Stride; Uint32 BindingIndex;`; `MGPipeValueTypes.h:568-582` has
|
||||
`Int32 Stride; Uint8 BindingIndex;`. Pre-existing on the `MGPVertexBuffer` side and not a `c0` defect, but
|
||||
the two views of the same two numbers now sit in one contract and B has to convert and bound-check in both
|
||||
directions. Nothing says so anywhere.
|
||||
|
||||
### m7 (minor) — `PipeApply.h` has no `#if MOBILEGL_PIPE_PUSH` guard, contrary to D-K
|
||||
|
||||
D-K says the new declarations are "inside `PipeApply.h`'s existing `#if MOBILEGL_PIPE_PUSH` (`:30`)". There
|
||||
is no such guard: `:30` is a *comment* ("Compiled only under `MOBILEGL_PIPE_PUSH` (CMakeLists.txt)") and the
|
||||
push-only-ness comes from `CMakeLists.txt:482-493` appending `PipeApply.cpp` to `SOURCE_FILES` only under
|
||||
push. The landed code follows the file's actual convention, which is right; the brief is what is wrong. It
|
||||
matters because a pull TU that includes `PipeApply.h` **compiles** and then fails at link — see the B/C/D
|
||||
list below.
|
||||
|
||||
---
|
||||
|
||||
## Dimension-by-dimension verdicts
|
||||
|
||||
**(1) Does every change match the B decision it claims to implement? — yes, all of them.**
|
||||
|
||||
- *D-A5 predicate*: `MGPipeTypes.h:654-656` is `return desc.Immutable != 0;` verbatim; `PipeCalls.def:83`
|
||||
is `kNeedsAck`; the legend sentence landed at `PipeCalls.def:19-24`.
|
||||
`PipeCatalogueTest.cpp:509-529` pins the predicate against both idioms, pins that it is the **only**
|
||||
acking call, and pins opcode 3. ✔
|
||||
- *D-G2*: `MGPipeValueTypes.h:568-604`. Both structs field-for-field as the brief writes them, `IsLong`
|
||||
separate from `Type`, `Divisor` and `LegacyStride`/`LegacyPointer` absent with their reasons in place, the
|
||||
surviving "why the second view travels" argument at `:586-595`, blob layout at `:552-559`. Sizes 24 / 16
|
||||
pinned at `:623-628`. ✔ (`MGPVertexBindingPointWire` needs no `Pad0`: 8+4+4 = 16 exactly.)
|
||||
- *D-H1*: `MGPipeTypes.h:374-394`. `BaseInstance` + `Pad0` between `Count` and `ContentHash`,
|
||||
`MGP_ASSERT_POD(..., 24)`, the `ContentHash` requirement, the `MGPDrawInfo::StartInstance` distinction and
|
||||
the once-per-set rule all in the comment. `MGPVertexBuffer` untouched at 32 B. ✔
|
||||
- *D-M*: `MGPipe.h:84-85, 95` — bits 7 and 8, `0x1ff`, reserved comment moved to "bits 9..62",
|
||||
`kMGPipeSubsystemsMigratedAtP2` kept with the A/B rationale. ✔
|
||||
- *D-A1*: `PipeApply.h:74-91`. Nine members in the brief's order and signatures; `grep -c MG_State
|
||||
PipeApply.h` = **0**, so G13's grep half is satisfied. ✔
|
||||
- *D-G4*: `PipeApply.h:99-135` (both records) and `:176-210` (eleven members). `MGPipeApplierReset`
|
||||
(`PipeApply.cpp:414-427`) clears exactly those eleven and deliberately not `g_resourceOps`, which
|
||||
`ResourceEmit.TheResourceOpTableIsUnregisteredUntilABackendInstallsOne` pins. ✔
|
||||
|
||||
**(2) Are the fourteen stubs and the three stub emitters behaviour-neutral in push and verify? — yes, and
|
||||
B2's argument is correct.**
|
||||
|
||||
I re-derived it rather than reading it. The residual-fill skip is `PipeFill.cpp:1243-1249`:
|
||||
|
||||
```cpp
|
||||
const MGPipeFieldEmitter emitter = kMGPipeFieldEmittedBy[i];
|
||||
const Uint64 subsystem = SubsystemForEmitter(emitter);
|
||||
const Bool supplied = subsystem != 0 && (subsystem & kMGPipeWiredSubsystems) != 0 && …
|
||||
```
|
||||
|
||||
`kMGPipeWiredSubsystems` (`:718-721`) does not carry `kMGPipeSubsystemVertexInput`, so `supplied` is false
|
||||
for `GetBoundVertexArray` and `CopyField` still runs — with the bit added it would be true down the whole
|
||||
chain exactly as the result file traces, so **B2 is right and adding the bits at `c0` would have been a live
|
||||
bug**. `kMGPipeFieldEmittedBy` has exactly **one** consumer in the tree (`PipeFill.cpp:1243`),
|
||||
`kMGPipeEmittedFieldCount` has **none**, `kMGPipeFieldEmitterNames` has **none**, and `PipeCoverage.inc` is
|
||||
generated from the accessor list (unchanged), so there is no second path. `GetBoundVertexArray` is **not**
|
||||
sticky (`PipeFilled.inc:173` `false`), so the row is live once wired — the count 33 → 34 is real, not
|
||||
decorative.
|
||||
|
||||
The three stub emitters are unreachable, not merely empty: `wants()` (`PipeFill.cpp:1171-1175`) requires
|
||||
`MGPipeSubsystemForDirty(bit) != 0`, and `Tracker.h:119-135`'s `default:` arm returns 0 for bits 5/9/10. The
|
||||
0x1ff default reaches only `PipeFill.cpp:1170`'s `pushMask`, `Managers.cpp:241/288` (bit 5),
|
||||
`MagmaPipeArms.h:50` (bit 6) and `CsoCache.h:80` (bit 63) — no reader of bits 7/8 exists, and no code
|
||||
validates or rejects unknown bits. **Neutral in push and in verify.**
|
||||
|
||||
**(3) G1 — every reaching edit is guarded, and the 0-resize report is credible.** I checked the guards, not
|
||||
only the report:
|
||||
|
||||
| edit | why the pull build cannot see it |
|
||||
|---|---|
|
||||
| `MGPipeValueTypes.h` wire structs | new **types**, no members added to an existing type; `static_assert`s only |
|
||||
| `MGPipeTypes.h` `kMGPipeMaxVertexAttribs`, `MGPipeResourceRespecifyNeedsAck` | `inline constexpr` / `inline`, odr-used by nothing outside push TUs |
|
||||
| `MGPVertexBuffers` 16 → 24 | every use is a *pointer* or a struct definition: `PipeTables.inc:55` (function pointer, so `gMGPipeContext`'s size is unaffected), `PipeThunks.inc:144` (inline, unused), `PipeWire.inc:369-375` (definition + `sizeof`-expression assert, never instantiated), `PipeApply.{h,cpp}` (push-only) |
|
||||
| `PipeCalls.def` flag word | no generator materialises `Call.Flags` (`gen_pipe.py:155,160` consult only `kVarTail`/`kReplySlot`); `MGPWireRecHeader::Flags` is a runtime field, not a table |
|
||||
| `PipeApply.{h,cpp}` | `.cpp` appended to `SOURCE_FILES` only under push (`CMakeLists.txt:482-493`); the header's only non-test includer outside `MG_Impl/Pipe` is `VulkanRenderer.h:30-34`, and that include **is** `#if MOBILEGL_PIPE_PUSH` |
|
||||
| `PipeFill.cpp` | same push-only source list |
|
||||
| `SlotTables.h` | the whole `BackendSlotTable` is inside `#if MOBILEGL_PIPE_PUSH` (`:80` … `:497`) |
|
||||
| `PipeStats.{h,cpp}` | the enumerator, the name and the `FormatWindowLine` field are all inside the existing push block; `kCallClassNames[kCallClassCount]` stays exactly `Count` long |
|
||||
| `ConfigLoader.cpp` | the changed line is inside `#if MOBILEGL_PIPE_PUSH` (`:250-257`) |
|
||||
| `Config.h`, `Coverage.def`, `PipeFields.def`, tests | comments / macro definitions / non-library targets |
|
||||
|
||||
The one residual theoretical risk — `PipeFilled.inc`'s `inline constexpr` arrays being emitted in a pull TU
|
||||
(`MGPipe.h:120` includes it unguarded) — is closed by `kMGPipeFieldEmitterNames` having zero uses tree-wide
|
||||
and `kMGPipeFieldEmittedBy` keeping the same length. I did **not** rebuild the pull library; the report's
|
||||
`27799 → 27799, 0 resized` is consistent with this analysis and I have no reason to doubt it.
|
||||
|
||||
**(4) Generated interfaces — correct and consistent.** Verified in the review worktree:
|
||||
`python3 scripts/gen_pipe.py --check` rc 0 (`71 calls, 71 verify payloads, 63 fields (7 sticky, 34 emitted),
|
||||
69 verbs`); a full regenerate leaves `git diff --exit-code -- MobileGL/MG_Pipe/generated` rc 0;
|
||||
`--self-test` trips 7 negative controls. Exactly two `.inc` moved (`PipeFilled.inc`, `PipeVerify.inc`) —
|
||||
the other six are byte-identical **because they are generated from inputs that did not change**, which is
|
||||
the right reason, not a missed regeneration. `MGP_VERIFY_PAYLOAD_LIST` 69 → 71, both new entries appended
|
||||
before the blank line the parser terminates on (`gen_pipe.py:222`). Both field lists name every non-`Pad`
|
||||
direct member, in declaration order: `MGPVertexAttribWire` 10 of 11 (`Pad0` excluded),
|
||||
`MGPVertexBindingPointWire` 3 of 3, `MGPVertexBuffers` 4 of 5. `check_field_lists_cover_struct_members`
|
||||
(`gen_pipe.py:416-446`) is set-based, so the member ordering is convention rather than gate — it is
|
||||
nonetheless correct here. `PipeCatalogueTest.cpp:357`'s `kMGPipeVerifiedPayloadCount == 71` is the only
|
||||
consumer of that constant and was updated. ✔
|
||||
|
||||
**(5) `GetOrCreate(MGPipeHandle)` — never touches `MGPipeSlots()`; generation semantics half right.**
|
||||
Confirmed by reading `SlotTables.h:272-286`: no `Acquire`, no `FindByLifetimeId`, no `RememberHandle`, no
|
||||
`Entry::stateRef` write, and `EnsureProcessTeardownSentinel()` (`Managers.cpp:168-171`) is a
|
||||
`call_once`/`atexit` pair that touches nothing. The teardown sentinel is armed as the result file claims.
|
||||
The stale-generation half is M2.
|
||||
|
||||
**(6) PipeStats `mpr` — complete.** `PipeStats.h:116-127` (enumerator inside the push block),
|
||||
`PipeStats.cpp:173-179` (name inside the same guard, array length still `kCallClassCount`),
|
||||
`PipeStats.cpp:428-431` (` mpr=` beside `csom`/`csob`, inside the guard), `PipeStatsTest.cpp:159-162` and
|
||||
`:283` (both pins inside the guard). ✔
|
||||
|
||||
**(7) Traps for B/C/D — see the list below.** No signature I checked is unimplementable as D describes it:
|
||||
`MGPResourceDesc` (88 B) carries `Resource`, `Immutable`, `Usage`, `StorageFlags`, `HasDefinedContent`,
|
||||
`Width`, `BindMask`, `GlNameForDiag`; `MGPVertexElements::Blob` is an `MGPBlobRef` with a `Size`, so the
|
||||
applier's count-vs-blob refusal is expressible; `MGPSubData`/`MGPFlushRange`/`MGPReadback`/`MGPHandleOnly`
|
||||
all carry their handle. No missing include (`PipeApply.h` reaches the wire views through
|
||||
`MGPipeTypes.h:34` → `MGPipeValueTypes.h`, and both are in the enclosing `MobileGL` namespace, so the
|
||||
unqualified names in `MobileGL::MG_Pipe` resolve). No ODR problem: every new header-only definition is a
|
||||
type, an `inline constexpr` variable, an `inline` function or a member of a class template. No
|
||||
const-correctness trap: `MGPipeGetResourceOps()` returns `const MGPipeResourceOps*` and the members are
|
||||
plain function pointers. **No `static_assert` fires when B maps the dirty bits**: with bits 5/9/10 →
|
||||
`kMGPipeSubsystemVertexInput` the three conditional asserts each become the equality D-M asks for.
|
||||
|
||||
**(8) Commit hygiene — clean.** One line, no body, no `Co-Authored-By`/`Generated-with` (`git log -1`
|
||||
`---BODY---` is empty), author `Swung0x48 <swung0x48@outlook.com>`. 21 files, every one in C.0's table;
|
||||
the two C.0 rows not touched are §3 D1 and C1, both argued. `[Feat] (Pipe): …` matches the house style.
|
||||
|
||||
---
|
||||
|
||||
## Judgement on each declared deviation
|
||||
|
||||
| # | reason | judgement |
|
||||
|---|---|---|
|
||||
| **A1** minted `kMGPipeMaxVertexAttribs` | **Sound.** `MG_Pipe` may not include a frontend header (closure gate A), D-G4's bare `32` is a drift hazard, and `PipeFill.cpp:702-705` is genuinely the one TU that sees both constants. The drift assert is real and unconditional. |
|
||||
| **A2** plain `static_assert`, not `MGP_ASSERT_POD` | **Sound, and verified**: `MGP_ASSERT_POD` is defined at `MGPipeTypes.h:44` and `MGPipeTypes.h:34` includes `MGPipeValueTypes.h`, so the macro is genuinely unavailable there. The three-part spelling (trivially copyable + exact size + standard layout) is a superset of what the macro asserts on the two relevant axes. |
|
||||
| **A3** eleven members, not ten | **Sound.** D-G4's own block declares eleven; C.0's prose miscounts the two double-declaration lines. Nothing was dropped; the reset clears all eleven. |
|
||||
| **B1** three conditional pairing asserts | **Sound, and it is the strongest form available.** `Tracker.h:119-135`'s `default:` returns 0 for bits 5/9/10 at `44c2b5cf`, so a direct equality would not compile, and `Tracker.h` is B's under C.5. The `== 0 \|\|` hatch is closed by `kMGPipeWiredSubsystems` not carrying the bit — argued in place at `PipeFill.cpp:683-686`. The D-M vs C.0/C.5 contradiction is real and the integrator should correct D-M. See m4 for the one stylistic wrinkle. |
|
||||
| **B2** `kMGPipeWiredSubsystems` unchanged | **Sound, and the most important call in the commit.** Re-derived independently above: with the bits added, `supplied` is true for `GetBoundVertexArray` and `PipeInputs::m_boundVertexArray` goes unwritten in every push and verify build. This is not a deviation so much as a correction of D-M. |
|
||||
| **B3** stub emitters wired into step 3 | **Sound.** Unreachable via `wants()`'s `subsystem != 0` test, `return 0` keeps the payload histogram clean, and they are *called*, so no `-Wunused-function`. It genuinely reduces B's commit to a body replacement. |
|
||||
| **C1** `gen_pipe.py` needed no edit | **Sound, and I verified the underlying claim**: `MGPipeValueTypes.h` is already in `FIELD_LIST_STRUCT_HEADERS` (`gen_pipe.py:211-216`), `gen_verify` is driven off `MGP_VERIFY_PAYLOAD_LIST`, and `Call.Flags` is consulted only at `gen_pipe.py:155,160` for `kVarTail`/`kReplySlot`. The corollary is also right: **D-A5's "a flag-word edit changes the generated tables" is false in this tree**, and `PipeCatalogueTest.ResourceRespecifyAcksOnlyImmutableStorage` is what catches it instead. |
|
||||
| **C2** only `GetOrCreate(handle)` added | **Sound.** `FindByHandle(MGPipeHandle)` at `SlotTables.h:294-301` already refuses a null handle, an out-of-range slot and a generation mismatch, i.e. already meets C.0's wording verbatim. (It is also, per M2, *stricter* than the new sibling.) |
|
||||
| **C3** the row could not literally split | **Reason (i) sound, reason (ii) wrong — this is M1.** The structural argument (one row → one `MGPipeInputField` enumerator → one `PipeInputs` member, and the field is a single array) is correct and well made, and keeping the row out of the emitted list is right. But the substitute — "the split is therefore stated exhaustively in the rewritten comment" — is not exhaustive. |
|
||||
| **C4** exactly one emitted row | **Sound, and verified**: the accessor list holds exactly three vertex-input accessors — `GetBoundVertexArray` (`Coverage.def:36`), `GetBufferBindingSlot` (`:57`) and `GetCurrentVertexAttribute` (`:67`, emitted since P2). The note to the wiring commit is the right shape (see the B/C/D list, item 3, for what it does *not* say). |
|
||||
| **D1** root `CMakeLists.txt` untouched | **Sound, and verified**: the push block at `CMakeLists.txt:482-493` appends only `.cpp` files, `SOURCE_FILES` lists no headers anywhere, and D-N fixes P3a's new client files as headers. The caveat is correctly stated: a `.cpp` later would re-open A's file. |
|
||||
| **D2** `kMGPipeVerifiedPayloadCount` 69 → 71 | **Sound**, and mandatory — `PipeCatalogueTest.cpp:357` is the constant's only consumer. |
|
||||
| **D3** suites named without the `Test` suffix | **Sound, and load-bearing.** G6/G7 grep `VertexInputEmit\.` and the line-1488 gate greps `…\|VertexInputEmit\.\|ResourceEmit\.`; with `--no-tests=error` a `…Test` suite makes those gates *unrunnable*, i.e. a gate that can never go red. The directory convention (`RenderStateSpansTest.cpp` → suite `RenderStateSpans`) agrees. The brief's prose case names must indeed lose the `Test`. |
|
||||
| **D4** own `main()` + `GTest::gtest` | **Sound.** The stated reason (a case that reads a trip wire's line back out of `MOBILEGL_LOG_FILE_PATH` must set it before anything logs) is real, and both `main()`s do exactly that and clean up. It genuinely keeps B and C out of `MG_Test/Pipe/CMakeLists.txt`. |
|
||||
| **D5** the placeholders are permanent | **Sound.** G14 forbids removing a name, so a deletable placeholder would itself be a break. Both cases assert something real, and both `GTEST_SKIP()` visibly in a pull build, which keeps `ctest -N` name-identical between the pull and push trees (G2's name half). |
|
||||
|
||||
---
|
||||
|
||||
## What package B / C / D authors must know that the result file does not say
|
||||
|
||||
1. **`PipeApply.h` does not guard itself.** There is no `#if MOBILEGL_PIPE_PUSH` in it (m7); the push-only
|
||||
property comes from `CMakeLists.txt:482-493`. Including it from a pull TU compiles and then fails at
|
||||
link. Every call site must carry its own guard — as `VulkanRenderer.h:30-34` and both new test files do.
|
||||
2. **`MGPipeResourceSubsystemEnabled()` does not exist.** D-A1 writes B's dispatch shape around it; `grep`
|
||||
finds it nowhere in the tree. B mints it (in `MG_Impl/Pipe/ResourceTracker.h`) as
|
||||
`(MG_Config::Features.PipePush & kMGPipeSubsystemResources) != 0 && MGPipeGetResourceOps() != nullptr` —
|
||||
**both halves**, or a push build with no backend registered will emit into stubs and drop the mutation.
|
||||
3. **Wiring the subsystem bit and declaring the field "fully supplied" are two independent edits, and only
|
||||
one of them is a compile error.** When B adds `kMGPipeSubsystemVertexInput` to `kMGPipeWiredSubsystems`
|
||||
(`PipeFill.cpp:718`), it must in the *same* commit add `MGPipeInputField::GetBoundVertexArray` to
|
||||
`EmittedCallSuppliesTheWholeField`'s `false` list (`:742-750`) — the arm's `default: return true` means
|
||||
forgetting it is silent, and `m_boundVertexArray` stops being copied. Nothing fails to compile; the only
|
||||
gate that catches it is **G4**, at retrace time, through `EntryCompare` → `SnapshotFromGLContext`
|
||||
(`PipeFill.cpp:431-456`), which re-reads every non-sticky field in the mask.
|
||||
4. **The emitters go live before the residual-fill skip does.** `wants()` keys on
|
||||
`MGPipeSubsystemForDirty` (Tracker.h, B's) while `supplied` keys on `kMGPipeWiredSubsystems`
|
||||
(PipeFill.cpp). The moment B lands the three tracker arms the three emitters start running, whether or
|
||||
not the wired mask has the bit. That is intentional (emit and keep pulling — a free A/B), but it means
|
||||
B's `b2` commit must have working emitter bodies, not stubs.
|
||||
5. **The stub emitters take `GLContext&` and return `Uint64` payload bytes**
|
||||
(`PipeFill.cpp:1111-1124`), and their call sites are already in place at `:1213-1221`, after
|
||||
`EmitVertexAttribDefaults`. B replaces bodies only. Note the landed order puts attrib-defaults *before*
|
||||
vertex elements/buffers/index, where `ARCHITECTURE.md:194`'s recommended order lists them the other way;
|
||||
D-G3 says that ordering is code organisation and not contract, so this is fine — but do not "fix" it.
|
||||
6. **`GetOrCreate(MGPipeHandle)` trusts `handle.Slot` and adopts a stale `handle.Gen`** (M2). C must bound
|
||||
the slot and reject a backwards generation at the call site until the overload itself is fixed. Also:
|
||||
`Find(StateObject*)` and `HandleOf()` still go through `MGPipeSlots()`; a handle-keyed kind must use
|
||||
`FindByHandle` / `GetOrCreate(handle)` only. There is **no `const` overload of `FindByHandle`**.
|
||||
7. **A handle-keyed entry is invisible to `ForEachLive()`** (`SlotTables.h:373-389` skips entries whose
|
||||
`stateRef` does not lock, and the new overload never writes `stateRef`). Correct for buffers; C must not
|
||||
add a `ForEachLive`-based sweep over the buffer table.
|
||||
8. **`MGPipeApplyMapPersistent` returns `nullptr` at `c0`** — a decline. C's tree branches from the tag, so
|
||||
until it rebases onto `p3a/wire`'s `c1` every persistent-map acquisition in C's own push build declines
|
||||
silently, including `TryAdoptLargeStorage`. Do not read that as an Espryt regression.
|
||||
9. **`MGPipeApplySetVertexBuffers` must police `Start + Count`.** `MGPipeApplierState::VertexBuffers` is a
|
||||
flat `Array<MGPVertexBuffer, kMGPipeMaxVertexAttribs>` (`PipeApply.h:186`) with a separate
|
||||
`VertexBufferStart`; D-H3 always emits `Start = 0`, but the contract permits otherwise and nothing bounds
|
||||
it yet.
|
||||
10. **`MGPVertexBuffer` and `MGPVertexAttribWire` disagree on `Stride`'s signedness and `BindingIndex`'s
|
||||
width** (m6). `BindingIndex` is a `Uint8` on the wire view — B must reject an attribute index ≥ 256
|
||||
before narrowing, even though `MAX_VERTEX_ATTRIBS` is 32.
|
||||
11. **The `.Handles` and stats itest lanes still pin `MOBILEGL_PIPE_PUSH=0x7f`**
|
||||
(`MG_IntegrationTest/CMakeLists.txt:863, 965, 975`). With the default now `0x1ff` those lanes run with
|
||||
P3a's two subsystems **off**. Package D owns that file: G12's A/B needs an explicit `0x1ff` arm (or the
|
||||
pins re-read as the control they now are), or the itest matrix has no "P3a on" lane at all.
|
||||
12. **`ResourceEmit.TheResourceOpTableIsUnregisteredUntilABackendInstallsOne` asserts
|
||||
`MGPipeGetResourceOps() == nullptr` at process start.** It holds because no backend is linked into that
|
||||
unit-test target; if C ever links one in, the case fails by design. Keep the target backend-free.
|
||||
13. **`g_resourceOps` is a plain, non-atomic file static** (`PipeApply.cpp:383`), read on whatever thread the
|
||||
`BufferObject` dispatcher runs on. That is exact parity with `g_bufferBackendOps`
|
||||
(`BufferObject.cpp:18`), so it is not a regression — but C must install and uninstall it at bring-up and
|
||||
teardown only, never mid-frame.
|
||||
14. **`kMGPipeVerifiedPayloadCount` has exactly one consumer** (`PipeCatalogueTest.cpp:357`). Any package
|
||||
that adds a payload to `MGP_VERIFY_PAYLOAD_LIST` must bump it, and `Coverage.def`/`PipeFields.def` are
|
||||
A-only, so that means asking A.
|
||||
|
||||
---
|
||||
|
||||
*Review worktree `/home/swung/w7/p3a-review` was created at `39722687` for the generator checks and removed
|
||||
with `git worktree remove --force`. No file in `/home/swung/w7/p3a-contract` was modified.*
|
||||
@@ -0,0 +1,411 @@
|
||||
# P3a package A, commit c0 — the contract (`contract-v1`)
|
||||
|
||||
**Commit** `397226873c2fe06ed57a5b78058ff68bc1716896` (`39722687`) on branch `p3a/contract`, worktree
|
||||
`/home/swung/w7/p3a-contract`, parent `44c2b5cf` (ID-1's base ref, not the brief's `55d2af9b`).
|
||||
**Tag** `p3a/contract` points at it. Not pushed.
|
||||
|
||||
Message, single line, no body:
|
||||
|
||||
```
|
||||
[Feat] (Pipe): land the P3a contract - the handle-shaped resource op table, the applier's resource and vertex-elements records, the two vertex wire views, an explicit baseInstance on set_vertex_buffers, and the first kNeedsAck
|
||||
```
|
||||
|
||||
`p3a/{wire, client, espryt, gates}` can branch from the tag now.
|
||||
|
||||
---
|
||||
|
||||
## 1. Per-file summary
|
||||
|
||||
21 files, +1049 / -23. Every one of them is in C.0's table; C.0 lists two files that were deliberately not
|
||||
touched (§3 D1, D2).
|
||||
|
||||
| file | what changed |
|
||||
|---|---|
|
||||
| `MobileGL/MG_Pipe/MGPipeValueTypes.h` | **+`MGPVertexAttribWire` (24 B) and `MGPVertexBindingPointWire` (16 B)**, in `namespace MobileGL` immediately after the `MG_State::GLState` block that holds `VertexAttribute` / `VertexBufferBindingPoint`, with the blob-layout rule, the "stride 0 is meaningful" note, the reason `Divisor` and `LegacyStride`/`LegacyPointer` are absent, and the surviving reason the second view travels at all. Four `static_assert`s (trivially-copyable + exact size + standard layout) in the `:547` trip-wire block, spelled out rather than `MGP_ASSERT_POD` because that macro is `MGPipeTypes.h`'s and that header includes this one. |
|
||||
| `MobileGL/MG_Pipe/MGPipeTypes.h` | **`MGPVertexBuffers` 16 → 24 B**: `Uint32 BaseInstance; Uint32 Pad0;`, `MGP_ASSERT_POD(..., 24)`, comment naming the `ContentHash` requirement, the `MGPDrawInfo::StartInstance` distinction and the once-per-set rule. **+`MGPipeResourceRespecifyNeedsAck(const MGPResourceDesc&)`** next to `MGPipeSetSubDataBufferRange`. **+`kMGPipeMaxVertexAttribs = 32`** (see §3 A1). `MGPVertexBuffer` (per entry, 32 B) untouched. |
|
||||
| `MobileGL/MG_Pipe/PipeCalls.def` | `ResourceRespecify` flags `kNone` → **`kNeedsAck`**; the `:18` legend gains the "MAY require an ack; a per-record predicate decides" sentence naming the predicate. No row added, moved or reordered; `MGP_CALL_LIST_DOCUMENTED_COUNT` stays **71**. |
|
||||
| `MobileGL/MG_Pipe/PipeFields.def` | `MGP_FIELDS_MGPVertexBuffers` gains `F(BaseInstance)`; new `MGP_FIELDS_MGPVertexAttribWire` (10 fields, `Pad0` excluded) and `MGP_FIELDS_MGPVertexBindingPointWire` (3); **both appended to `MGP_VERIFY_PAYLOAD_LIST`** (69 → 71 payloads). |
|
||||
| `MobileGL/MG_Pipe/MGPipe.h` | `kMGPipeSubsystemResources` (bit 7), `kMGPipeSubsystemVertexInput` (bit 8), `kMGPipeSubsystemsMigratedAtP3a = 0x1ff`; the reserved-bit comment moves to "bits 9..62"; `kMGPipeSubsystemsMigratedAtP2` kept, with the note that each phase's constant survives as the next phase's A/B control. |
|
||||
| `MobileGL/MG_Pipe/PipeApply.h` | `MGPipeResourceOps` (9 members) + `MGPipeSetResourceOps` / `MGPipeGetResourceOps`; `MGPipeResourceRecord`; `MGPipeVertexElementsRecord`; **11 new `MGPipeApplierState` members**; **14 new entry points**, complete signatures, in two commented sections. No `MG_State` token anywhere in the file (G13). |
|
||||
| `MobileGL/MG_Pipe/PipeApply.cpp` | file-static `g_resourceOps` + the two accessors (real bodies); the 14 entry points as **no-op stubs** with the block comment saying why a no-op is unreachable here rather than merely empty; `MGPipeApplierReset` clears all 11 new members and deliberately does **not** clear the op table. |
|
||||
| `MobileGL/MG_Pipe/Coverage.def` | `GetBufferBindingSlot`'s comment **rewritten**: the per-target split is now stated target by target (vertex / index / indirect / shader-buffers / still-pulled), sourced from the emission site rather than from a re-vendored inventory, plus why the row stays one row and why it is not in the emitted list. `MGP_COVERAGE_EMITTED_LIST` gains **`X(GetBoundVertexArray, BindVertexElements)`** with a note for the commit that wires it. The `Buffer ops delta → ResourceRespecify` delta row is untouched. |
|
||||
| `MobileGL/MG_Impl/Pipe/PipeFill.cpp` | *(contract-commit-only, enum-coupled block)* `SubsystemForEmitter` gains the `BindVertexElements → kMGPipeSubsystemVertexInput` arm; four new `static_assert`s (one direct, three conditional pairings — §3 B1) plus the `kMGPipeMaxVertexAttribs` ↔ `VertexArrayObject::MAX_VERTEX_ATTRIBS` drift assert; `kMGPipeWiredSubsystems` **unchanged, with the reason recorded in place** (§3 B2); three **stub emitters** `Emit{VertexElements,VertexBuffers,IndexBuffer}` returning 0 and their three `wants()`-gated call sites in `MGPipeValidateForVerb` step 3, in the fixed order after the four P2 emitters. |
|
||||
| `MobileGL/MG_Pipe/generated/PipeVerify.inc` | regenerated: two forward decls, two `MGPipeHasFieldVerifier` specialisations, two comparators, `kMGPipeVerifiedPayloadCount` 69 → 71. |
|
||||
| `MobileGL/MG_Pipe/generated/PipeFilled.inc` | regenerated: `MGPipeFieldEmitter::BindVertexElements`, its name-table row, `kMGPipeFieldEmittedBy[GetBoundVertexArray]`, `kMGPipeEmittedFieldCount` 33 → 34. |
|
||||
| *(the other six `.inc`)* | regenerated, byte-identical (§3 C1). |
|
||||
| `MobileGL/MG_Backend/DirectGLES/SlotTables.h` | `BackendSlotTable::GetOrCreate(MGPipeHandle)` — never calls `MGPipeSlots()`, no `StatePtr`, arms the teardown sentinel, resets a twin whose `Gen` no longer matches. Header-only, uninstantiated, both arms compile. `FindByHandle(MGPipeHandle)` already existed and already met the requirement (§3 C2). |
|
||||
| `MobileGL/MG_Util/Metrics/PipeStats.{h,cpp}` | `CallClass::MapPersistentRoundtrips` inside the existing `#if MOBILEGL_PIPE_PUSH` block, name `"map-persistent-roundtrips"`, `FormatWindowLine` prints ` mpr=<n>` beside `csom`/`csob`. |
|
||||
| `MobileGL/MG_Test/Util/PipeStatsTest.cpp` | `mpr=` pinned in `SummaryLineCarriesEveryClassAndGate`, the name pinned in `CounterNamesAreStable`, both inside the push guard. |
|
||||
| `MobileGL/MG_Test/Pipe/PipeCatalogueTest.cpp` | `kMGPipeVerifiedPayloadCount` 69 → **71** (a required consequence the brief does not mention); two `MGPipeHasFieldVerifier` static asserts; **3 new cases** — `VertexBufferSetCarriesAnExplicitBaseInstance` (size 24, `Pad0` is not a field, comparator names `BaseInstance`, per-entry struct unchanged), `VertexWireViewsAreFlatAndCarryIsLongSeparately` (both sizes, comparator names `IsLong` and `Divisor`), `ResourceRespecifyAcksOnlyImmutableStorage` (the flag is on the call, it is the **only** call carrying it, the predicate is true for `Immutable=1` and false for a `STATIC_DRAW` + defined-content mutable store, and opcode 3 did not move). |
|
||||
| `MobileGL/MG_Test/Pipe/ResourceEmitTest.cpp` | **new**, suite `ResourceEmit`, own `main()`, one permanent case `TheResourceOpTableIsUnregisteredUntilABackendInstallsOne` (§3 D3). |
|
||||
| `MobileGL/MG_Test/Pipe/VertexInputEmitTest.cpp` | **new**, suite `VertexInputEmit`, own `main()`, one permanent case `AResetApplierCarriesNoVertexInputStateOver`. |
|
||||
| `MobileGL/MG_Test/Pipe/CMakeLists.txt` | both registered (`GTest::gtest`, own `main()`), `gtest_discover_tests(... PROPERTIES LABELS unit)`. Re-opened at `44c2b5cf` per ID-1: it already carried `MagmaPipeIdentityTest`. |
|
||||
| `MobileGL/Config.h` | bit-list comment gains `0x80 resources` and `0x100 vertex input`; the default now names `kMGPipeSubsystemsMigratedAtP3a` and records `0x7f` as the phase-by-phase control. |
|
||||
| `MobileGL/ConfigLoader.cpp` | push default `kMGPipeSubsystemsMigratedAtP2` → **`kMGPipeSubsystemsMigratedAtP3a`** (0x7f → 0x1ff). |
|
||||
|
||||
---
|
||||
|
||||
## 2. The contract, verbatim — what B, C and D compile against
|
||||
|
||||
### 2.1 The two wire structs (`MG_Pipe/MGPipeValueTypes.h`, `namespace MobileGL`)
|
||||
|
||||
```cpp
|
||||
struct MGPVertexAttribWire {
|
||||
Uint64 Offset; // 0
|
||||
Int32 Stride; // 8
|
||||
Uint32 Type; // 12 DataType
|
||||
Uint8 Size; // 16 1..4; GL_BGRA keeps 4
|
||||
Uint8 Enabled; // 17
|
||||
Uint8 Normalized; // 18
|
||||
Uint8 IsInteger; // 19
|
||||
Uint8 IsLong; // 20 carried separately from Type == Float64
|
||||
Uint8 IsBgra; // 21
|
||||
Uint8 BindingIndex; // 22 < kMGPipeMaxVertexAttribs
|
||||
Uint8 Pad0; // 23
|
||||
}; // sizeof == 24
|
||||
|
||||
struct MGPVertexBindingPointWire {
|
||||
Uint64 Offset; // 0
|
||||
Int32 Stride; // 8 initial value is 16, not 0
|
||||
Uint32 Divisor; // 12
|
||||
}; // sizeof == 16
|
||||
```
|
||||
|
||||
Blob layout on `CreateVertexElements`: `MGPVertexAttribWire[AttributeCount]` immediately followed by
|
||||
`MGPVertexBindingPointWire[BindingPointCount]`, both ascending, both counts `<= kMGPipeMaxVertexAttribs`.
|
||||
|
||||
### 2.2 `MGPVertexBuffers` (`MG_Pipe/MGPipeTypes.h`)
|
||||
|
||||
```cpp
|
||||
struct MGPVertexBuffers {
|
||||
Uint32 Start, Count;
|
||||
Uint32 BaseInstance; // NEW: the draw's raw vertex-FETCH base instance, one per set
|
||||
Uint32 Pad0; // NEW
|
||||
Uint64 ContentHash; // must include BaseInstance
|
||||
}; // sizeof == 24 (was 16)
|
||||
|
||||
inline constexpr Uint32 kMGPipeMaxVertexAttribs = 32; // NEW
|
||||
inline Bool MGPipeResourceRespecifyNeedsAck(const MGPResourceDesc& desc) { return desc.Immutable != 0; } // NEW
|
||||
```
|
||||
|
||||
`MGPVertexBuffer` (per-entry, 32 B) is unchanged; its `Pad0` stays padding.
|
||||
|
||||
### 2.3 `MGPipeResourceOps` (`MG_Pipe/PipeApply.h`, inside the existing push guard)
|
||||
|
||||
```cpp
|
||||
struct MGPipeResourceOps {
|
||||
void (*Create) (MGPipeHandle res, const MGPResourceDesc& desc);
|
||||
void (*Respecify) (MGPipeHandle res, const MGPResourceDesc& desc, const void* initialBytes);
|
||||
void (*SubData) (MGPipeHandle res, const MGPSubData& record, const void* bytes);
|
||||
void (*SubDataResident)(MGPipeHandle res, const MGPSubData& record, const void* bytes); // may be null
|
||||
void (*FlushRange) (MGPipeHandle res, const MGPFlushRange& record, const void* bytes);
|
||||
void (*Readback) (MGPipeHandle res, const MGPReadback& record);
|
||||
void (*Destroy) (MGPipeHandle res);
|
||||
void* (*MapPersistent) (MGPipeHandle res, Uint64 size, const void* seedBytes);
|
||||
void (*UnmapPersistent)(MGPipeHandle res);
|
||||
};
|
||||
void MGPipeSetResourceOps(const MGPipeResourceOps* ops); // nullptr uninstalls
|
||||
const MGPipeResourceOps* MGPipeGetResourceOps(); // nullptr until a backend installs one
|
||||
```
|
||||
|
||||
### 2.4 The fourteen apply entry points
|
||||
|
||||
```cpp
|
||||
void MGPipeApplyResourceCreate (const MGPResourceDesc& desc);
|
||||
void MGPipeApplyResourceRespecify (const MGPResourceDesc& desc, const void* initialBytes);
|
||||
void MGPipeApplyResourceSubData (const MGPSubData& record, const void* bytes);
|
||||
void MGPipeApplyBufferSubDataResident(const MGPSubData& record, const void* bytes);
|
||||
void MGPipeApplyResourceFlushRange (const MGPFlushRange& record, const void* bytes);
|
||||
void MGPipeApplyResourceReadback (const MGPReadback& record);
|
||||
void MGPipeApplyResourceDestroy (const MGPHandleOnly& handle);
|
||||
void* MGPipeApplyMapPersistent (const MGPHandleOnly& handle, Uint64 size, const void* seedBytes);
|
||||
void MGPipeApplyUnmapPersistent (const MGPHandleOnly& handle);
|
||||
|
||||
void MGPipeApplyCreateVertexElements (const MGPVertexElements& desc, const void* blobBytes);
|
||||
void MGPipeApplyBindVertexElements (const MGPHandleOnly& handle);
|
||||
void MGPipeApplyDeleteVertexElements (const MGPHandleOnly& handle);
|
||||
void MGPipeApplySetVertexBuffers (const MGPVertexBuffers& hdr, const MGPVertexBuffer* tail);
|
||||
void MGPipeApplySetIndexBuffer (const MGPIndexBuffer& record);
|
||||
```
|
||||
|
||||
All fourteen are **no-op stubs** at `c0`; `MGPipeApplyMapPersistent` returns `nullptr` (a decline, which is a
|
||||
supported answer).
|
||||
|
||||
### 2.5 The applier's records and state
|
||||
|
||||
```cpp
|
||||
struct MGPipeResourceRecord { // indexed by MGPipeHandle::Slot, kind Buffer; slot 0 never live
|
||||
Uint32 Gen = 0; Bool Live = false;
|
||||
MGPResourceDesc Desc{};
|
||||
Uint64 Serial = 0; // server-owned MGGen
|
||||
Bool HasLiveHostWrites = false; // always false in P3a
|
||||
};
|
||||
struct MGPipeVertexElementsRecord { // indexed by MGPipeHandle::Slot, kind VertexElementsCso
|
||||
Uint32 Gen = 0; Bool Live = false;
|
||||
Uint32 AttributeCount = 0, BindingPointCount = 0;
|
||||
Array<MGPVertexAttribWire, kMGPipeMaxVertexAttribs> Attributes{};
|
||||
Array<MGPVertexBindingPointWire, kMGPipeMaxVertexAttribs> BindingPoints{};
|
||||
Uint64 ContentSerial = 0; // server-owned MGGen
|
||||
};
|
||||
|
||||
// appended to MGPipeApplierState:
|
||||
Vector<MGPipeResourceRecord> Resources;
|
||||
Vector<MGPipeVertexElementsRecord> VertexElementsCsos;
|
||||
MGPipeHandle BoundVertexElements = kMGPipeNullHandle;
|
||||
Array<MGPVertexBuffer, kMGPipeMaxVertexAttribs> VertexBuffers{};
|
||||
Uint32 VertexBufferStart = 0;
|
||||
Uint32 VertexBufferCount = 0;
|
||||
Uint32 VertexFetchBaseInstance = 0;
|
||||
Uint64 VertexBuffersSerial = 0;
|
||||
MGPIndexBuffer IndexBuffer{};
|
||||
Uint64 IndexBufferSerial = 0;
|
||||
Uint64 MapPersistentRoundtrips = 0;
|
||||
```
|
||||
|
||||
`MGPipeApplierReset()` clears all eleven. It does **not** clear the op table.
|
||||
|
||||
### 2.6 Everything else B / C / D can rely on
|
||||
|
||||
- `kMGPipeSubsystemResources = 1ull << 7`, `kMGPipeSubsystemVertexInput = 1ull << 8`,
|
||||
`kMGPipeSubsystemsMigratedAtP3a = 0x1ffull`; push default is now `0x1ff`, `0x7f` is the P3a-off control.
|
||||
- `BackendSlotTable::GetOrCreate(MG_Pipe::MGPipeHandle)` and the pre-existing `FindByHandle(MGPipeHandle)`.
|
||||
- `PipeStats::CallClass::MapPersistentRoundtrips`, short name `mpr`, push-only.
|
||||
- Stub emitters `EmitVertexElements/EmitVertexBuffers/EmitIndexBuffer(GLContext&) -> Uint64` in
|
||||
`PipeFill.cpp`'s anonymous namespace, already called from step 3 in the fixed order. **B replaces the
|
||||
bodies without moving a call site.**
|
||||
- gtest suites `ResourceEmit` and `VertexInputEmit` (see D3).
|
||||
|
||||
---
|
||||
|
||||
## 3. Deviations from the brief, each with its reason
|
||||
|
||||
### A. Types
|
||||
|
||||
**A1 — `kMGPipeMaxVertexAttribs` was minted (not in the brief).** D-G4 writes the applier's arrays as
|
||||
`Array<..., 32>`. A bare 32 in `MG_Pipe` that must equal `VertexArrayObject::MAX_VERTEX_ATTRIBS` is a
|
||||
silent-drift hazard and `MG_Pipe` may not include a frontend header (purity gate A). So the constant is
|
||||
declared once in `MGPipeTypes.h` and `PipeFill.cpp` — the one translation unit that sees both — carries
|
||||
`static_assert(kMGPipeMaxVertexAttribs == VertexArrayObject::MAX_VERTEX_ATTRIBS)`.
|
||||
|
||||
**A2 — the wire structs use plain `static_assert`, not `MGP_ASSERT_POD`.** D-G2 writes `MGP_ASSERT_POD`, but
|
||||
C.0 places the structs in `MGPipeValueTypes.h` and that macro is defined in `MGPipeTypes.h`, which *includes*
|
||||
`MGPipeValueTypes.h`. The assertions are spelled out in the existing `:547` trip-wire block instead, in that
|
||||
block's own style, and cover trivial copyability, exact size and standard layout.
|
||||
|
||||
**A3 — eleven new `MGPipeApplierState` members, not "ten".** C.0 says ten; D-G4's own code block declares
|
||||
eleven (`VertexBufferStart` and `VertexBufferCount` are two members on one line, as are `IndexBuffer` and
|
||||
`IndexBufferSerial`). D-G4's block is what landed, verbatim. No member was dropped or added.
|
||||
|
||||
### B. `PipeFill.cpp`'s enum-coupled block
|
||||
|
||||
**B1 — three of the four new pairing `static_assert`s are conditional, not equalities.** D-M asks for
|
||||
`SubsystemForEmitter(...) == MGPipeSubsystemForDirty(...)` alongside three new `MGPipeSubsystemForDirty` arms
|
||||
"all four in one commit". `MGPipeSubsystemForDirty` lives in `MG_Impl/Pipe/Tracker.h`, which **C.5 assigns to
|
||||
package B**, and at `44c2b5cf` it returns 0 for bits 5/9/10. A direct equality would therefore fail to compile
|
||||
at `c0` for a reason that is not a defect, and the only way to make it hold would be to edit B's file — which
|
||||
hard rule (4) forbids and which would guarantee a rebase conflict. What landed:
|
||||
|
||||
- an unconditional `SubsystemForEmitter(BindVertexElements) == kMGPipeSubsystemVertexInput`;
|
||||
- three of the form `MGPipeSubsystemForDirty(bit) == 0 || MGPipeSubsystemForDirty(bit) == kMGPipeSubsystemVertexInput`,
|
||||
for `NewVertexElements`, `NewVertexBuffers`, `NewIndexBuffer`. The escape hatch is *only* the not-yet-mapped
|
||||
case: the moment B maps a bit onto anything, the assertion becomes the equality D-M asks for. No later edit
|
||||
is required, and none is invited.
|
||||
|
||||
This is recorded as a brief-internal contradiction (D-M vs C.0/C.5) rather than a design change; the integrator
|
||||
should correct D-M.
|
||||
|
||||
**B2 — `kMGPipeWiredSubsystems` does NOT gain the two bits at `c0`.** D-M asks for it in the same commit. It
|
||||
would be a live bug. Traced through `MGPipeValidateForVerb` step 4 with the new default push mask `0x1ff`:
|
||||
`supplied` for `GetBoundVertexArray` would evaluate `subsystem != 0` ✓, `subsystem & wired` ✓,
|
||||
`pushMask & subsystem` ✓, `EmittedCallSuppliesTheWholeField` ✓ (default arm), `applierDerives` ✓ — so
|
||||
`CopyField` would be **skipped** while the emitters are stubs and the applier's entry points are stubs, leaving
|
||||
`PipeInputs::m_boundVertexArray` unwritten in every push and verify build. That is precisely the failure the
|
||||
constant's own comment says it exists to prevent ("a field whose emitter is not wired here keeps being
|
||||
pulled"). The reason is written into the file beside the constant, and B adds the bits in the commit that gives
|
||||
the emitters their bodies.
|
||||
|
||||
**B3 — stub emitters are wired into step 3 at `c0`, not only declared.** C.0 says "stub emitters that emit
|
||||
nothing"; the call sites were added too, gated by `wants()`, so B's commit is a body replacement rather than a
|
||||
body plus a call-site edit at the validate point. They are unreachable today (their dirty bits map to no
|
||||
subsystem) and return 0 so the payload histogram gains no bucket for bytes nobody sent.
|
||||
|
||||
### C. Generators and `Coverage.def`
|
||||
|
||||
**C1 — `scripts/gen_pipe.py` needed no edit.** C.0 lists it as MODIFY, "whatever the two new payloads and the
|
||||
flag-word change require". Verified by reading the generator: `MGPipeValueTypes.h` is already in
|
||||
`FIELD_LIST_STRUCT_HEADERS`, `gen_verify` is driven entirely off `MGP_VERIFY_PAYLOAD_LIST`, and no generator
|
||||
materialises a call's flag word (`Call.Flags` is only consulted for `kVarTail` / `kReplySlot` signatures). So
|
||||
`gen_pipe.py` is unchanged and **only two** of the eight `.inc` files actually moved. Related: **D-A5's claim
|
||||
that "a flag-word edit changes the generated tables" is false in this tree** — `git diff --exit-code --
|
||||
MobileGL/MG_Pipe/generated` was still run and is clean, but it is not what catches a missing regeneration for
|
||||
that edit; `PipeCatalogueTest.ResourceRespecifyAcksOnlyImmutableStorage` is.
|
||||
|
||||
**C2 — only `GetOrCreate(MGPipeHandle)` was added to `SlotTables.h`.** C.0 asks for
|
||||
"`GetOrCreate(MGPipeHandle)` / `FindByHandle` overloads that never call `MGPipeSlots()`".
|
||||
`BackendSlotTable::FindByHandle(MGPipeHandle)` already exists at `44c2b5cf` and already meets the requirement
|
||||
verbatim, so adding a second one would be churn. No `const` overload was added either — nothing needs one yet
|
||||
and `MG_Backend/DirectGLES/**` is package C's from the tag on.
|
||||
|
||||
**C3 — `GetBufferBindingSlot`'s accessor row could not literally "split per target".**
|
||||
`MGP_COVERAGE_ACCESSOR_LIST` *is* the `MGPipeInputField` enum and the `PipeInputs` field set (one row → one
|
||||
enumerator → one member of `PipeInputs`' X-macro list, which is `MG_Backend`'s file), and the field is a single
|
||||
array `m_bufferBindingSlot[kBufferTargetCount]`. A duplicate row would be a duplicate enumerator. The split is
|
||||
therefore stated exhaustively in the rewritten comment (target → call, including the five targets that are
|
||||
still pulled) and lives in the emitters; the row stays one row naming `SetIndirectBuffers`, and the comment
|
||||
says why. It is deliberately kept **out** of the emitted list, because five of its targets are still pulled and
|
||||
a row there would be the same half-truth `GetPixelStoreParameters` is excluded for.
|
||||
|
||||
**C4 — the emitted list gained exactly one row, `GetBoundVertexArray → BindVertexElements`.** C.0 says
|
||||
"emitted-list vertex-input fields", plural. The accessor list contains exactly three vertex-input accessors:
|
||||
`GetCurrentVertexAttribute` (already emitted since P2), `GetBufferBindingSlot` (C3) and `GetBoundVertexArray`.
|
||||
The row is inert until B wires the subsystem (B2), and a note in `Coverage.def` tells the wiring commit that
|
||||
the field is a `SharedPtr` to the frontend VAO which the applier does not reproduce, so the
|
||||
`EmittedCallSuppliesTheWholeField` decision must be taken deliberately in `PipeFill.cpp` (B's file from the tag
|
||||
on) rather than inherited silently from the row's presence.
|
||||
|
||||
### D. Build files and tests
|
||||
|
||||
**D1 — root `CMakeLists.txt` was not touched.** C.0's row is "the new client sources inside
|
||||
`if (MOBILEGL_PIPE_PUSH)`". D-N fixes that P3a's new client files are **headers**
|
||||
(`MG_Impl/Pipe/{ResourceTracker.h, VertexInputEmit.h}`), and `SOURCE_FILES` lists no headers, so there is no
|
||||
source to add. The two other halves of that row — the push default and the bit-list comment — landed in
|
||||
`ConfigLoader.cpp` and `Config.h`. If B later needs a `.cpp`, the root `CMakeLists.txt` is still A's file and
|
||||
the contract would have to be re-opened; B was told the new files are headers for exactly this reason.
|
||||
|
||||
**D2 — `PipeCatalogueTest.cpp` also needed `kMGPipeVerifiedPayloadCount` 69 → 71.** Not in C.0's row, but a
|
||||
mandatory consequence of appending to `MGP_VERIFY_PAYLOAD_LIST`; without it the suite fails.
|
||||
|
||||
**D3 — the two new gtest suites are `ResourceEmit` and `VertexInputEmit`, not `…Test`.** The brief names cases
|
||||
as `VertexInputEmitTest.X` / `ResourceEmitTest.X` in prose (D-H2.3, C.1's list, E's risk table) but spells the
|
||||
gates as `ctest -R 'VertexInputEmit\.'` (G6, G7) and `-R '…|VertexInputEmit\.|ResourceEmit\.'` (line 1488).
|
||||
A suite named `VertexInputEmitTest` does not match `VertexInputEmit\.`, so with `--no-tests=error` G6 and G7
|
||||
could never run. The suite names follow the gates and this directory's own convention
|
||||
(`RenderStateSpansTest.cpp` → suite `RenderStateSpans`). **The prose case names in the brief must be read with
|
||||
the `Test` dropped**: `VertexInputEmit.ABaseInstanceChangeAloneStillEmitsTheVertexBufferSet`, and so on.
|
||||
|
||||
**D4 — the two stubs link `GTest::gtest` and carry their own `main()`.** C.0 only asks for "one placeholder
|
||||
`TEST`". The point of A owning the registration is that no later package edits
|
||||
`MG_Test/Pipe/CMakeLists.txt`; a `gtest_main` target would force exactly that edit the first time a case needs
|
||||
to read a trip wire's line back out of a log file (which both suites will: the applier's blob-bounds gate and
|
||||
its protocol refusal report that way, and abort under poison/verify). The `main()` shape is copied from
|
||||
`RenderStateSpansTest`/`PipeInputsTest`.
|
||||
|
||||
**D5 — the placeholders are permanent contract assertions, not throwaways.** G14 forbids removing a test name,
|
||||
so a placeholder that B deletes would itself be a gate break. `ResourceEmit.TheResourceOpTableIsUnregisteredUntilABackendInstallsOne`
|
||||
pins the fact the whole family's landability rests on (nothing is registered ⇒ every dispatch falls through)
|
||||
plus the set/get round trip and that `MGPipeApplierReset` does not clear the table;
|
||||
`VertexInputEmit.AResetApplierCarriesNoVertexInputStateOver` pins that a fresh context carries no handle, no
|
||||
window and no serial over. Both skip visibly in a pull build.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verification transcript
|
||||
|
||||
All commands in `/home/swung/w7/p3a-contract`, `CCACHE_BASEDIR=/home/swung/w7`, at the tagged commit.
|
||||
|
||||
**G1 — pull build symbol identity** (`symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after
|
||||
build-linux/libMobileGL.so --threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0`), rc **0**:
|
||||
|
||||
```
|
||||
symbol-report: Total 17209979 -> 17209979 (+0)
|
||||
symbol-report: 27799 -> 27799 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
|
||||
`.text` 10792739 -> 10792739 (+0, +0.000%). ... 27060 unchanged.
|
||||
### Removed (0) ### Added (0) ### Resized (0) ### Renamed only (same size) (0)
|
||||
```
|
||||
|
||||
P3a's admitted-resize set is empty, as §A.2 G1 requires.
|
||||
|
||||
**Generators**
|
||||
|
||||
```
|
||||
python3 scripts/gen_pipe.py --check rc 0 "gen_pipe: generated files are up to date"
|
||||
"71 calls (11 screen, 60 context), 71 verify payloads,
|
||||
63 PipeInputs fields (7 sticky, 34 emitted), 69 verbs, 9 classes"
|
||||
"inventory 477 rows: ... 0 UNMAPPED"
|
||||
python3 scripts/gen_pipe.py --self-test rc 0 "7 negative-control trip(s), positive control OK"
|
||||
git diff --exit-code -- MobileGL/MG_Pipe/generated rc 0
|
||||
```
|
||||
|
||||
**Include closure** — the brief's form names `clang++-20`, which does not exist on this host (`clang++` is
|
||||
22.1.6); both forms were run:
|
||||
|
||||
```
|
||||
python3 scripts/check_include_closure.py rc 0
|
||||
value-header OK 66 headers, 0 forbidden; artifacts-header OK 65; mutation-header OK 84; wire-header OK 2
|
||||
include-closure: 4 probes, 0 skipped, 0 problem(s)
|
||||
python3 scripts/check_include_closure.py --mode both --compiler clang++ --self-test --require-all rc 0
|
||||
include-closure: self-test: 6 negative-control trip(s), parser checks OK
|
||||
include-closure: 4 probes, 0 skipped, 0 problem(s)
|
||||
```
|
||||
|
||||
**Three builds** — `cmake --build <dir> -j 24`
|
||||
|
||||
| build | rc |
|
||||
|---|---|
|
||||
| `build-linux` (pull) | 0 (339/339) |
|
||||
| `build-push` | 0 (349/349) |
|
||||
| `build-verify` | 0 (349/349) |
|
||||
|
||||
**Three unit runs** — `ctest --test-dir <dir> -L unit -j 12 --no-tests=error`, rc 0 in all three:
|
||||
|
||||
```
|
||||
build-linux 100% tests passed, 0 tests failed out of 1571 (9.71 s)
|
||||
build-push 100% tests passed, 0 tests failed out of 1571 (9.76 s)
|
||||
build-verify 100% tests passed, 0 tests failed out of 1571 (9.72 s)
|
||||
```
|
||||
|
||||
**Name-set checks (G2's name half, G14)**
|
||||
|
||||
```
|
||||
ctest -N names: build-linux 2487, build-push 2487, build-verify 3315
|
||||
diff <build-linux names> <build-push names> -> empty
|
||||
comm -23 ~/w7/p3a-before-ctest-names.txt <build-linux names> -> empty (nothing removed)
|
||||
comm -13 ... -> 5 added:
|
||||
PipeCatalogue.ResourceRespecifyAcksOnlyImmutableStorage
|
||||
PipeCatalogue.VertexBufferSetCarriesAnExplicitBaseInstance
|
||||
PipeCatalogue.VertexWireViewsAreFlatAndCarryIsLongSeparately
|
||||
ResourceEmit.TheResourceOpTableIsUnregisteredUntilABackendInstallsOne
|
||||
VertexInputEmit.AResetApplierCarriesNoVertexInputStateOver
|
||||
ctest --test-dir build-push -N -R 'VertexInputEmit\.|ResourceEmit\.' -> Total Tests: 2
|
||||
```
|
||||
|
||||
(The baseline was 2482 names; 2487 = 2482 + 5.)
|
||||
|
||||
**G13's two greps**
|
||||
|
||||
```
|
||||
grep -c 'MG_State' MobileGL/MG_Pipe/PipeApply.h -> 0
|
||||
grep -rc 'pGLContext' MobileGL/MG_Backend | grep -v ':0$' -> empty
|
||||
```
|
||||
|
||||
**Not run here, and why**: G2's execution half, G3/G3b/G4's retrace, G5 (`p3a_untouched_regions.sh` is package
|
||||
D's and does not exist yet), G6-G12, G15. `c0` touches no `Managers.cpp` region and changes no behaviour, and
|
||||
those gates belong to the integrator's D.1 merges.
|
||||
|
||||
---
|
||||
|
||||
## 5. Left undone / handed on
|
||||
|
||||
1. **`p3a/wire`'s `c1`, `c2`, `c3`** — the fourteen bodies and `ResourceEmitTest`'s applier cases. Not started;
|
||||
this task was `c0` only.
|
||||
2. **`kMGPipeWiredSubsystems`** must gain `kMGPipeSubsystemResources | kMGPipeSubsystemVertexInput` in the
|
||||
commit that gives the emitters bodies (B2). Until then no vertex-input field is skipped by the residual
|
||||
fill — which is correct, but it also means the subsystem A/B (G12) cannot show a *fill-loop* difference yet.
|
||||
3. **`Tracker.h`'s three `MGPipeSubsystemForDirty` arms** (bits 5, 9, 10 → `kMGPipeSubsystemVertexInput`) are
|
||||
package B's; the three conditional pairing asserts in `PipeFill.cpp` become equalities the moment they land,
|
||||
with no edit needed.
|
||||
4. **`EmittedCallSuppliesTheWholeField(GetBoundVertexArray)`** — C4's note; B must decide it explicitly.
|
||||
5. **Doc corrections owed to the integrator**, beyond the ones the brief already lists: D-M's "all four in one
|
||||
commit" is not achievable under C.5's ownership split (B1/B2); D-A5's "a flag-word edit changes the
|
||||
generated tables" is not true in this tree (C1); C.0's "ten new `MGPipeApplierState` members" is eleven
|
||||
(A3); the brief's `VertexInputEmitTest.`/`ResourceEmitTest.` case names must lose the `Test` (D3);
|
||||
`check_include_closure.py --compiler clang++-20` does not exist on this host (§4).
|
||||
6. **Not pushed**, per the task. The tag is local to `/home/swung/w7/p3a-contract`; the other three trees must
|
||||
be created from it with `wsl_p3a_tree.sh <slug> p3a/contract`.
|
||||
|
||||
Intermediate logs this package created — `~/w7/p3a-contract-{sym,closure,closure2}.log` and
|
||||
`~/w7/p3a-contract-names-build-*.txt` — were deleted. `~/w7/p3a-contract-tree.log` is kept, as instructed.
|
||||
Six further files match the same glob and were **left alone because they are not this package's**: the tree
|
||||
script's own `p3a-contract-{submodule,build-linux-configure,build-linux-build,build-push-configure,
|
||||
build-push-build,build-verify-configure,build-verify-build}.log`. The integrator should delete them if the
|
||||
tree-creation transcript is no longer wanted.
|
||||
@@ -0,0 +1,514 @@
|
||||
# P3a package C — adversarial review of the Espryt switch-over (`espryt-review-v1`)
|
||||
|
||||
Reviewed `9ae4ec09 … 203120fa` on `p3a/espryt`, parent `39722687` (tag `p3a/contract`), worktree
|
||||
`/home/swung/w7/p3a-espryt` (**not modified**; no worktree was created — every finding below was reached by opening
|
||||
the file at `HEAD` and at `$BASE` through `git show 39722687:<path>`, and by reading the frontend code the arms call
|
||||
into). Line numbers are `HEAD`'s unless a `$BASE` reading is named.
|
||||
|
||||
## Verdict
|
||||
|
||||
**REWORK.** The shape of the package is right and most of it is very carefully done: the nine op bodies are
|
||||
recognisably their `Ops_*` counterparts, the readback ordering rule is implemented and written down where it belongs,
|
||||
the G5 nine are untouched by construction (the diff contains no hunk between `Managers.cpp`'s `IsPoolable` and
|
||||
`RingAllocate`), `AcquirePersistentMap`'s legacy body is byte-untouched, the pull arm is the pre-P3a text verbatim,
|
||||
and the commit hygiene is clean.
|
||||
|
||||
What forces a rework is four things:
|
||||
|
||||
1. **`IsBufferDrawCleanByHandle` drops the live-map test and replaces it with a field nothing ever sets**, so on the
|
||||
handle arm a persistently mapped (non-adopted) buffer reads *draw-clean* forever and its host writes stop reaching
|
||||
the GPU (**C-1**). The report calls this substitution "identical semantics"; it is the inverse.
|
||||
2. **`GLESBufferResource::hostBytes` is a cached raw base with no invalidation**, where every legacy path re-asked
|
||||
`MappedData()`. The two events that free or move the client's shadow — persistent-map adoption and a shadow
|
||||
resize — leave it dangling, and the fp64 narrowing and the pool reseed dereference it (**C-2**).
|
||||
3. **Contract-review `M2` is entirely unaddressed** — neither fixed in `SlotTables.h` (which `C.5` hands to C at the
|
||||
tag) nor guarded at the one call site — and the package report does not mention it at all (**M-1**).
|
||||
4. **Nothing in this package has ever executed.** Every lane C ran was either a legacy arm (`0` / `0x7f`) or the
|
||||
default mask where `EnsureBufferResource` returns `nullptr` for every buffer and `SyncToBackendFromApplier` returns
|
||||
at its first line. The 202 failures are correctly attributed to the stub applier (§8), and the corollary is that
|
||||
**no line of `Ops_H_*`, `EnsureBufferResourceForHandle`, `IsBufferDrawCleanByHandle` or the applier walk has been
|
||||
run once, in any build**. The package's own evidence cannot distinguish "correct" from "never reached".
|
||||
|
||||
None of the four needs a new design; C-1 and C-2 are a handful of lines each. The rework list is §"Rework" below.
|
||||
|
||||
---
|
||||
|
||||
## Critical
|
||||
|
||||
### C-1 — `IsBufferDrawCleanByHandle` answers **clean** for a buffer with live host writes, so `SyncPersistentMappedRange()` stops being called
|
||||
|
||||
`Managers.cpp:2385-2404` (the handle arm) against `:2405-2434` (the legacy arm, verbatim from `$BASE:1579-1600`),
|
||||
`MG_State/GLState/BufferState/BufferObject.cpp:291-303` (`SyncPersistentMappedRange`), `Managers.cpp:2530`
|
||||
(`EnsureBufferResourceForHandle`'s copy of the D-N call), `DirectGLES.cpp:611-620` / `:706-711` (the memo pass that
|
||||
consumes the probe).
|
||||
|
||||
The legacy probe has five questions; the fourth is
|
||||
|
||||
```cpp
|
||||
// A live non-zero-copy map may owe a per-draw SyncPersistentMappedRange push
|
||||
// (persistent maps mutate the shadow without bumping the change serial).
|
||||
if (frontend->IsMapped()) return false; // Managers.cpp:2428
|
||||
```
|
||||
|
||||
The handle arm substitutes
|
||||
|
||||
```cpp
|
||||
if (record->HasLiveHostWrites) return false; // Managers.cpp:2400
|
||||
```
|
||||
|
||||
and pins `HasLiveHostWrites` **false** with a `MOBILEGL_PIPE_VERIFY` assert two lines above it (`:2396-2399`), because
|
||||
D-A4/D-N say P3a has no producer for it. `false` means *clean*. So the two arms give opposite answers on exactly the
|
||||
state the legacy question exists for.
|
||||
|
||||
Failure scenario, and it is the common Minecraft/Flywheel/Sodium shape rather than a corner:
|
||||
|
||||
1. The app maps a buffer `GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT` and the store is **not** adopted — under 16 MiB,
|
||||
or `DisableLargeBufferAdoption`, or no `EXT_buffer_storage`. The frontend keeps the shadow; `m_isMapped` is true and
|
||||
`m_resource.IsGpuResident()` is false, which is precisely `SyncPersistentMappedRange`'s live case.
|
||||
2. The app writes through the mapped pointer. **No op is emitted, no change serial moves, no epoch is bumped** — that
|
||||
is the whole reason the legacy probe asks `IsMapped()` instead of asking a serial.
|
||||
3. On the handle arm the probe now finds: twin matches, context generation matches, `id != 0`, not
|
||||
`persistentMapped` (the *backend* store is an ordinary mutable one), `HasLiveHostWrites == false`, no
|
||||
`pendingRespecify`, no `pendingRanges`, `storageSize == Desc.Width`, `syncedChangeSerial == record.Serial`
|
||||
→ **clean**.
|
||||
4. `SyncVaoAttributeBuffersByHandle` (`DirectGLES.cpp:611-620`) therefore leaves `allClean == true` and stamps
|
||||
`memo->vboCleanEpoch = bufferEpoch`, so the probes are skipped entirely on later draws; and even when an epoch bump
|
||||
re-opens them, step 3 answers clean again. `EnsureBufferResource` is never called for that buffer again, and
|
||||
`EnsureBufferResourceForHandle`'s `bufferObject->SyncPersistentMappedRange()` (`:2530`) is the **only** per-draw push
|
||||
for a vertex/uniform/SSBO persistent map — D-N's other seven sites are the indirect (`DirectGLES.cpp:297, 4964,
|
||||
4965, 5066, 5067`) and index (`:4710`, `MultiDraw.cpp:511`) paths. The frame draws the last uploaded bytes, forever,
|
||||
with no diagnostic anywhere.
|
||||
|
||||
Refutations attempted, all failed:
|
||||
|
||||
- *"`persistentMapped` above it covers this."* It covers the **adopted** store only (`resource->persistentMapped` is
|
||||
the backend's own coherent donation). The case here is the emulated persistent map, which is exactly what
|
||||
`SyncPersistentMappedRange` exists for and what `MOBILEGL_COHERENT_AS_FLUSH` exercises.
|
||||
- *"The pending-range test catches it."* Circular: a range only appears once `SyncPersistentMappedRange` →
|
||||
`NotifySubData` runs, and that only runs from the ensure path the clean verdict skips.
|
||||
- *"`FLUSH_EXPLICIT` maps publish through `FlushMappedRange`, so the serial moves."* True, and irrelevant: `:297`'s
|
||||
guard is `if (m_mappingAccess & FlushExplicit) return;` — the **non**-explicit map is the one this push serves.
|
||||
- *"It only costs one stale frame."* No: nothing on either side ever moves back to dirty.
|
||||
|
||||
Fix: keep a live-host-write input on the handle arm. The cheapest honest one is to keep asking the frontend object
|
||||
that `EnsureBufferResourceForHandle` already takes (D-N keeps `SyncPersistentMappedRange` in Espryt for all of P3a, so
|
||||
the object is present at every call site of this probe: `DirectGLES.cpp:614`, `:786`, `Managers.cpp:2411`) — i.e.
|
||||
`IsBufferDrawCleanByHandle(res, resource, frontend)` with `if (frontend && frontend->IsMapped()) return false;` beside
|
||||
the `HasLiveHostWrites` test, and a comment saying the frontend read retires when P5 gives `HasLiveHostWrites` a
|
||||
producer. Do **not** delete the `HasLiveHostWrites` test or its assert; they are right.
|
||||
Gate to add: an itest that maps a sub-adoption-threshold buffer persistently, writes through the pointer with no GL
|
||||
call at all, draws, and reads the pixels back — nothing in the named must-not-break set does this today
|
||||
(`LargeArenaAdoption` and `StorageBufferRegrow` both drive the **adopted** path).
|
||||
|
||||
### C-2 — `hostBytes` is a cached raw base into the client's shadow, and two ordinary events free or move that shadow under it
|
||||
|
||||
`Managers.h:651-663` (the member and its own warning), written at `Managers.cpp:1837`, `:1885`, `:1933`; dereferenced
|
||||
at `:1901`, `:1966`, `:1974`, `:1997`, `:2498`, `:2533`, `:2538` and `:4186`. Against
|
||||
`MG_State/GLState/BufferState/PipeResource.h:100-118` (`ResizeShadow`, `AdoptPersistentMap`).
|
||||
|
||||
The comment is right about the rule — *"it may not be dereferenced except while the client's shadow is known to be
|
||||
live"* — and the code does not keep it. Every legacy path re-read `bufferObject.MappedData()` at the moment of use;
|
||||
the handle arm reads a pointer recorded by whichever content-carrying call came last. Two events invalidate it and
|
||||
neither clears it:
|
||||
|
||||
- **`PipeResource::AdoptPersistentMap` does `m_shadow->clear(); m_shadow->shrink_to_fit();`** (`PipeResource.h:116-118`),
|
||||
i.e. the allocation `hostBytes` points into is *freed*, and the live bytes move to the coherent map.
|
||||
- **`ResizeShadow` is `reserve(bit_ceil(size)); resize(size)`** (`:102-105`): a grow past the reserved capacity
|
||||
reallocates and frees the old block. An **orphaning** respecify (`glBufferData(size, NULL)`) carries
|
||||
`HasDefinedContent = 0` and therefore `initialBytes == nullptr` (D-A2), so `Ops_H_Respecify` (`:1836-1838`) does not
|
||||
refresh the base it just invalidated.
|
||||
|
||||
The reachable consequence is `SyncFloat64AttributeAsFloat32ByHandle`:
|
||||
|
||||
```cpp
|
||||
const Uint8* const sourceBase = resource->hostBytes; // Managers.cpp:4186
|
||||
...
|
||||
const Bool memoHit = stream.valid && convertedBufferId != 0 && !resource->persistentMapped && ... // :4218
|
||||
NarrowDoubleStreamToFloat32(sourceBase + attrib.Offset, sourceStride, componentCount, elementCount, converted); // :4235
|
||||
```
|
||||
|
||||
The memo is *deliberately* not trusted for a persistently mapped source (correct, and inherited), so for an adopted
|
||||
buffer the `!resource->persistentMapped` term makes `memoHit` false **on every draw** and the narrowing reads
|
||||
`elementCount * componentCount * 8` bytes from the freed shadow, every draw. The legacy arm at `:4056` reads
|
||||
`bufferObject->MappedData()`, which after adoption is `PipeResource::Bytes()` → the coherent map → the live bytes. So
|
||||
this is simultaneously a use-after-free and a wrong-data path, and it is not the gap D7 declares (D7 is the missing
|
||||
`SyncGpuWrites`, a different and lesser problem on the same function).
|
||||
|
||||
The second dereference is the pool reseed (`:2489-2498`): `glBufferSubData(TempBufferTarget, 0, poolSize,
|
||||
resource->hostBytes)` uploads `poolSize` bytes from the cached base, gated only on `hostBytes != nullptr` — a dangling
|
||||
pointer is not null. Reaching it needs `resource->id == 0` with a pooled entry of exactly `Desc.Width` (`IsPoolable`
|
||||
caps at 8 MiB), so it is narrower than the fp64 path, but it is the same defect and it is on the adopt→respecify→
|
||||
regrow path `StorageBufferRegrowScenario` drives.
|
||||
|
||||
Same finding, second half, **undeclared**: that `hostBytes != nullptr` term is a change to the **pool decision**, not
|
||||
to "the source of bytes" that D-F permits. `$BASE:1662-1663` is `(poolSize > 0 && !resource->persistentMapped)`; the
|
||||
handle arm adds a third condition, so a buffer whose base was never recorded silently stops recycling pool ids. It is
|
||||
not among the ten declared deviations and it moves `AcquireFromPool` call counts, which `StreamedArenaScenario`'s two
|
||||
recycle cases observe.
|
||||
|
||||
Refutation attempted: *"every content-carrying call refreshes the base, so it is never stale when read."* False for
|
||||
both events above — adoption is not a content-carrying call, and an orphaning respecify carries no bytes by design.
|
||||
*"An adopted buffer never reaches those reads."* False for `:4186`: the fp64 path has no `persistentMapped` early-out,
|
||||
only a memo exclusion that makes the read *more* frequent.
|
||||
|
||||
Fix: (a) in `Ops_H_MapPersistent`, set `resource->hostBytes = nullptr` when the map succeeds — the shadow is about to
|
||||
be released and the coherent pointer is `resource->persistentPtr`, which is what the fp64 narrowing should read for a
|
||||
`persistentMapped` resource; (b) in `Ops_H_Respecify`, `resource->hostBytes = nullptr` whenever `desc.HasDefinedContent
|
||||
== 0` (an orphan says the client has no bytes for this store); (c) gate the pool reseed on the applier's own
|
||||
`record->Desc.HasDefinedContent` as well, so a reseed can never move bytes the client did not just hand over. Each is
|
||||
one line, and (a) is also what makes `SyncFloat64AttributeAsFloat32ByHandle` read the right memory for an adopted
|
||||
source.
|
||||
|
||||
---
|
||||
|
||||
## Major
|
||||
|
||||
### M-1 — contract-review `M2` is unaddressed and unmentioned: `GetOrCreate(MGPipeHandle)` still adopts a stale generation, and `EntryAt` still resizes on an unbounded client slot
|
||||
|
||||
`SlotTables.h:272-286` is byte-identical to `39722687` (`git diff 39722687 HEAD -- SlotTables.h` adds
|
||||
**only** `ReleaseByHandle`, `:288-311`); `EntryAt` at `:453-456` still does `m_slots.resize(slot + 1)`;
|
||||
`GetOrCreateBufferResourceForHandle` (`Managers.cpp:2227-2238`) adds neither a slot bound nor a generation direction
|
||||
test.
|
||||
|
||||
`contract-review-v1` M2 and its must-know item 6 both name this as C's to fix or guard, in a file `C.5` hands to C at
|
||||
the tag; `INTEGRATOR-DECISIONS.md` ID-8 records it as going "to espryt's e1". `espryt-v1` does not mention M2 anywhere
|
||||
— not in §1's description of e1, not in §5's deviations, not in §6's post-rebase list. The consequence is unchanged
|
||||
from the contract review: a `handle.Gen` *behind* the entry's destroys the incumbent live twin
|
||||
(`entry.backend.reset()`), and because `GLESBufferResource::~GLESBufferResource` is `= default` (`Managers.h:~600`)
|
||||
that drops a driver buffer id with no `glDeleteBuffers` and no pool enrolment — a leak *and* a resource that loses its
|
||||
storage with no diagnostic. `FindByHandle` (`:294-301`) refuses the same input, so the two entry points still disagree.
|
||||
|
||||
e6's new case cannot go red for it: `EverySwitchedOverKindResolvesItsTwinThroughTheHandleArm`
|
||||
(`SanityTest.cpp:3896-3950`) only reaches `GetOrCreate(second)` **after** `ReleaseByHandle(first)` has set
|
||||
`entry.Live = false`, which is the one path where the `entry.Live && entry.Gen != handle.Gen` arm cannot run.
|
||||
|
||||
Fix, as the contract review specifies: refuse the backwards case in `GetOrCreate(MGPipeHandle)` (return `m_nullTwin`,
|
||||
or `Fatal{ProtocolCorruption}`), say in the comment which direction each arm covers, and bound `handle.Slot` before
|
||||
`EntryAt` — plus one `SanityTest` case that stamps a live twin at `{slot, gen=2}`, calls `GetOrCreate({slot, gen=1})`
|
||||
and asserts the incumbent survived. Note the applier's `RecordAt` has the identical unbounded-resize shape
|
||||
(`wire-review-v1` M-D); one of the two must bound it and both should say which.
|
||||
|
||||
### M-2 — the attribute walk is bounded by `AttributeCount`, so a shrinking configuration leaves arrays enabled that the legacy walk disabled
|
||||
|
||||
`Managers.cpp:3794-3796`:
|
||||
|
||||
```cpp
|
||||
const Uint32 attributeCount = std::min<Uint32>(rec->AttributeCount, MG_Pipe::kMGPipeMaxVertexAttribs);
|
||||
for (Uint attribIndex = 0; attribIndex < attributeCount && emitAttributes; ++attribIndex) {
|
||||
```
|
||||
|
||||
against `$BASE:2479` `for (Uint attribIndex = 0; attribIndex < allAttributes.size() && emitAttributes; …)`, i.e. all
|
||||
**32** slots, with `glDisableVertexAttribArray` reached for every disabled one.
|
||||
|
||||
D-G2 fixes only `AttributeCount <= 32`; nothing in the contract requires the client to emit 32. D-H3 sets the
|
||||
precedent in the other direction for the *buffer* set ("`Count` = MAX_VERTEX_ATTRIBS **truncated to the highest
|
||||
enabled attribute + 1**"), so a client that applies the same rule to `MGPVertexElements` is contract-legal and would
|
||||
make attribute 5 stop being disabled after the VAO disables it — leaving the driver VAO with an enabled array pointing
|
||||
at a stale buffer, which is the class D-J's first Adreno workaround exists to prevent.
|
||||
|
||||
This is free to close and the applier already did the work: `MGPipeApplyCreateVertexElements` zeroes both arrays
|
||||
before the unpack (`wire-v1` §2.2), so `rec->Attributes[i]` for `i >= AttributeCount` is all-zero, i.e. `Enabled == 0`.
|
||||
Walk `kMGPipeMaxVertexAttribs` and the disable arm is restored with no dependency on B at all. If the bound is kept
|
||||
deliberately, it has to be stated as a hard requirement on B (`AttributeCount == 32` always) in the report and pinned
|
||||
by a `VertexInputEmit` case — today it is neither.
|
||||
|
||||
### M-3 — the vertex-input subsystem cannot in fact "run alone", and the header says it can
|
||||
|
||||
`Managers.h:690-692` — *"Kept separate because the two bits are separately clearable and the A/B has to be able to run
|
||||
either one alone."*
|
||||
|
||||
With bit 8 set and bit 7 clear: `EnsureBufferResource` (`Managers.cpp:2556`) takes the **legacy** arm and puts the twin
|
||||
in `PipeResource::m_backend`, so `g_backendBufferResources` stays empty; `BindAttributeBufferByHandle`
|
||||
(`Managers.cpp:3421-3433`) and `SyncZeroStrideAttributeByHandle` (`:3437-3465`) resolve the driver id only through
|
||||
`FindBufferResourceForHandle`, get null, log `MGLOG_E_ONCE` and `continue` — **without disabling the array**, so the
|
||||
draw fetches through whatever pointer the driver VAO last held. Every attribute of every draw, in a configuration the
|
||||
comment advertises and that G12's A/B is entitled to run.
|
||||
|
||||
(The mirror combination, bit 7 set and bit 8 clear, is fine: the legacy VAO walk calls `BindAttributeBuffer` →
|
||||
`EnsureBufferResource`, which dispatches to the handle arm.)
|
||||
|
||||
Fix: either make bit 8 imply bit 7 in `ResolveVertexInputSubsystemArm()` (with a loud line saying so) and correct the
|
||||
comment, or have the two handle-arm binders fall back to `EnsureBufferResource(attrib.Buffer)` when the table has no
|
||||
twin. The first is the honest one; a silent fallback is what `EnsureBufferResource`'s own null-handle arm
|
||||
(`:2557-2566`) deliberately refuses to do.
|
||||
|
||||
### M-4 — the two new arms ignore `Features.PipeLegacyMemos`, so "no arm at all" is reachable and silent
|
||||
|
||||
`Managers.cpp:2215-2225` — both resolvers read only `MG_Config::Features.PipePush & kMGPipeSubsystem{Resources,
|
||||
VertexInput}`.
|
||||
|
||||
The tree's established rule for a re-keyed family is the three-way `EsprytSlotArmVerdict`
|
||||
(`SlotTables.h:89-99`): bit clear **and** `PipeLegacyMemos` false is `NoArm`, and `ResolveEsprytSlotTablesArm()`
|
||||
**stops**; Magma's equivalent raises `Fatal{PipeLegacyMemosDisabled}` (`MagmaPipeArms.h:112-115`). C adds two new
|
||||
legacy arms with no such classification, so `(bits 7/8 clear, MOBILEGL_PIPE_LEGACY_MEMOS=0)` runs the pre-handle
|
||||
buffer and VAO paths in silence. That pair is not hypothetical: it is what
|
||||
`MG_IntegrationTest/CMakeLists.txt:863` pins for every `.Handles` lane today
|
||||
(`MOBILEGL_PIPE_LEGACY_MEMOS=0;MOBILEGL_PIPE_PUSH=0x7f`), which is contract-review item 11's problem — but item 11 is
|
||||
about which lane exists, and this is about C's arms not answering the knob at all.
|
||||
|
||||
Fix: give bits 7 and 8 the same verdict shape as `ClassifyEsprytSlotArm`, or at minimum log at `MGLOG_E` and stop in
|
||||
`Resolve*SubsystemArm()` when the bit is clear and `Features.PipeLegacyMemos` is false. Package D's
|
||||
`ResourceSubsystemControlScenario` is then able to assert it.
|
||||
|
||||
### M-5 — the re-keyed memos are correct only if `wire`'s C2 rework lands, and the report never says so
|
||||
|
||||
`Managers.cpp:3766-3776` (the twin's gate), `DirectGLES.cpp:601-610` and `:640-648` (the `ResolvedDrawBuffers` key).
|
||||
|
||||
`MGPipeApplierReset()` runs at **every** change of the current `GLContext` (`Tracker.h:192-195`, established in
|
||||
`wire-review-v1` C1) and today sets `VertexBuffersSerial` and `IndexBufferSerial` back to **0**
|
||||
(`PipeApply.cpp:565`, `:567`), while the twin survives the excursion — `BackendVertexArrayObject` has no
|
||||
context-generation member and `OnBackendContextDestroyed` runs on destroy, not on make-current. So both counters walk
|
||||
back through values this twin has already stamped, and `m_syncedVertexBuffersSerial` / `m_syncedIndexSerial` can match
|
||||
over cleared state.
|
||||
|
||||
I checked whether C's gate survives that on its own, and it does **not**: `attributesDirty`
|
||||
(`Managers.cpp:3768-3772`) is an AND of `{elementsHandle, elementsSerial, buffersSerial}`, and after a reset the
|
||||
per-record `ContentSerial` also restarts at 1 for a re-created CSO at the **same** `{slot, gen}` (an applier reset is
|
||||
not a slot recycle, so `Gen` does not move — which is the half `wire-review-v1` waved through as "safe (a recycled slot
|
||||
moves Gen)"). With `wire`'s C2 fix applied — *advance* the two global serials at reset instead of zeroing them — the
|
||||
`m_syncedVertexBuffersSerial` term can never match again after a reset and the whole AND is forced dirty, which
|
||||
rescues the `ContentSerial` half as well. So: **C's design is correct conditional on C2, and unsafe without it**, and
|
||||
nothing in `espryt-v1` records the dependency.
|
||||
|
||||
Fix: state it in the report and at the gate (one comment naming `PipeApply.cpp`'s reset and why the
|
||||
`VertexBuffersSerial` term is load-bearing), and add it to §6 as a post-rebase precondition: if the integrator lands
|
||||
`wire` without C2, this package must not be merged.
|
||||
|
||||
Related, same area, smaller: after a reset and before the client's first re-emission, `BoundVertexElements` is null, so
|
||||
`SyncVaoAttributeBuffersByHandle` builds a memo whose key is `{null, 0, 0}` and marks it `valid`
|
||||
(`DirectGLES.cpp:640-648`). That key never changes, so the memo hits on every later draw for a VAO whose attributes
|
||||
have moved — the legacy arm's config version caught exactly this. Treat "no bound elements record" as a memo miss.
|
||||
|
||||
---
|
||||
|
||||
## Minor
|
||||
|
||||
- **m1 — the report's D-E evidence is incomplete.** §3.1's statement-level diff renders
|
||||
`GetBackendResource()/SetBackendResource()` → "the slot table's `GetOrCreate(res)`", but the substituted call is
|
||||
`GetOrCreateBufferResourceForHandle` (`Managers.cpp:2227-2238`), which additionally seeds `pendingRespecify = true`
|
||||
on a freshly minted twin — where `Ops_AcquirePersistentMap` (`$BASE:1146`) does not. The outcome is the same (a twin
|
||||
with no `storageInitialized` respecifies either way), but a claim of "byte-identical below the signature" must name it.
|
||||
- **m2 — `Ops_H_Readback` maps at `record.Offset` while clamping the size against `storageSize`**
|
||||
(`Managers.cpp:1993-2001`); `$BASE:1404` maps at literal 0. Equivalent under D-A2's whole-buffer contract, but a
|
||||
non-zero `Offset` that the applier's `BufferRangeFault` accepts against `Desc.Width` can still run off a smaller
|
||||
`storageSize`. Clamp `size` to `storageSize - Offset`.
|
||||
- **m3 — `Ops_H_FlushRange` lost the `ZoneScopedC` the legacy map arm carries** (`$BASE:1357-1359`). Profiling only.
|
||||
- **m4 — the shared `FlushPendingRangesFrom` adds `if (hostBase == nullptr) return;` after the queue is drained**
|
||||
(`Managers.cpp:1109-1111`), which is a text change the *legacy* arm also runs inside a push build. Unreachable there
|
||||
(`MappedData()` is non-null whenever ranges are queued) and defensively right, but it is the one place D1's "one
|
||||
body, so the arms cannot drift" is not literally true.
|
||||
- **m5 — the VAO index bind no longer ensures storage.** `$BASE:2622` calls `EnsureBufferResource(indexBufferBinding)`;
|
||||
`Managers.cpp:3862-3866` only `FindBufferResourceForHandle`. Covered in practice because `PrepareForDraw`
|
||||
(`DirectGLES.cpp:3193-3196`) runs `SyncNeccessaryBuffers` before `SyncCurrentVAO` — but `SyncNeccessaryBuffers`
|
||||
ensures the IBO only when `includeIBO`, so a non-indexed draw whose `IndexBufferSerial` moved logs
|
||||
`"No backend buffer found for index buffer binding"` and leaves the binding alone. Harmless (the serial is not
|
||||
stamped, so the next indexed draw repairs it), noisy, and worth one line of comment.
|
||||
- **m6 — new per-draw allocator probes, unmeasured and unmentioned.** `HandleOfBuffer` (`Managers.cpp:2220-2225`) goes
|
||||
straight to `MGPipeSlots().FindByLifetimeId`, which is a hash lookup (`MG_Impl/Pipe/SlotAllocator.cpp:97-105`), and
|
||||
it now runs inside `EnsureBufferResource` (every SSBO/UBO/atomic/XFB/PBO/IBO bind), inside `IsBufferDrawClean`, and
|
||||
once per SSBO per draw through `MarkBufferGpuWritten`. The legacy arm paid a pointer compare. `BackendSlotTable`'s
|
||||
own `m_memoLifetimeId`/`m_memoHandle` front memo is never populated on this arm (only the minting overload calls
|
||||
`RememberHandle`), so nothing absorbs it. ID-6 makes this recorded-not-gated, but D.4 has to be told to expect it,
|
||||
and memoising inside `HandleOfBuffer` is a two-line recovery.
|
||||
- **m7 — "no `MG_State` type in any new handle-arm signature" is stated more broadly than it holds.** D6's list omits
|
||||
`EnsureBufferResourceForHandle` (`Managers.h:733-734`) and `MarkBufferGpuWritten` (`:746`), both of which take
|
||||
`SharedPtr<BufferObject>`. G13 only greps `PipeApply.h`, so nothing is broken; the sentence should name its
|
||||
exceptions rather than list only the functions that satisfy it.
|
||||
- **m8 — a contract point the report owes B and does not state.** `MarkGpuWritten` sets **both** `m_hasDefinedContent`
|
||||
and `m_gpuWritePending` (`BufferObject.cpp:314-317`). The client's `OnGpuWritten` implementation must set both, or
|
||||
the next `ResourceRespecify` carries `HasDefinedContent = 0`, `Ops_H_Respecify` orphans instead of uploading
|
||||
(`Managers.cpp:1873-1877`), and the shader-written contents are dropped. D8 states the *range shape*; this is the
|
||||
other half.
|
||||
- **m9 — `MOBILEGL_PIPE_LEGACY_MEMOS=0` was checked with `-fsyntax-only`, which is not the claim.** §4.2's check
|
||||
proves the two translation units parse; it does not link, does not cover `MultiDraw.cpp` / `Utils.cpp` /
|
||||
`SanityTest.cpp`, and never runs. The greps do support the conclusion (no retired member is referenced outside a
|
||||
`MOBILEGL_PIPE_LEGACY_MEMOS` arm — I re-ran them across the whole backend directory), so the *conclusion* stands;
|
||||
the *evidence* should say "parses" rather than "compiles".
|
||||
|
||||
---
|
||||
|
||||
## Dimension-by-dimension
|
||||
|
||||
**(1) The nine op bodies vs their `Ops_*` counterparts.** Diffed side by side against `$BASE:1134-1447`.
|
||||
|
||||
| pair | verdict |
|
||||
|---|---|
|
||||
| `Ops_Respecify` (`$BASE:1213`) / `Ops_H_Respecify` (`:1832`) | Substitutions only: `ResourceOf` → `FindBufferResourceForHandle`, `GetSize()==0` → `desc.Width==0`, `RespecifyStorageNow` → `RespecifyStorageWith(desc.Width, desc.Usage, HasDefinedContent?initialBytes:null, ResourceSerialOf)`. Immutable-store retire, off-thread arm, all five field resets and the `return`s are structurally identical. ✔ (plus the `hostBytes` write — C-2) |
|
||||
| `Ops_SubData` (`:1266`) / `Ops_H_SubData` (`:1880`) | All four arms preserved in order: `pendingRespecify` early-out, off-thread/size-mismatch queue, adopted zero-copy stamp-and-return, `EsprytDisableUploadRing` immediate upload, queue-only default (the Mali WAR fix). `StorageMatches(obj)` → `StorageMatchesSize(ResourceWidthOf)`. ✔ |
|
||||
| `Ops_ResidentSubData` (`:1304`) / `Ops_H_ResidentSubData` (`:1911`) | Identical; one added `bytes == nullptr` guard. `hostBytes` deliberately not recorded (D10) — correct, and the reason given is the right one. ✔ |
|
||||
| `Ops_FlushMappedRange` (`:1314`) / `Ops_H_FlushRange` (`:1927`) | Same five arms; `AccessFlags` re-widened from the record and read unnormalised; the kill-switch map arm gains `&& resource->hostBytes != nullptr`, which only steers a null base into `UploadRangeFrom`'s own null early-out. ✔ (m3) |
|
||||
| `Ops_ReadbackFromGpu` (`:1382`) / `Ops_H_Readback` (`:1978`) | Both branches survive; `WritebackFromBackend` → `OnBufferWriteback`. ✔ (m2) |
|
||||
| `Ops_OnDestroy` (`:1417`) / `Ops_H_Destroy` (`:2037`) | The *same function* is called with the twin `ReleaseByHandle` hands out, so the three outcomes are byte-identical by construction. A `ResourceDestroy` for a slot the backend never twinned yields a null and returns — no leak. ✔ |
|
||||
| `Ops_AcquirePersistentMap` (`:1134`) / `Ops_H_MapPersistent` (`:2055`) | Statement-for-statement equal below the signature: four-way gate, stale-generation wipe **before** the stamp, idempotency hit, `++g_bufferBackendIdGeneration`, `immutableStorage = true` before the map, decline log, all six success stamps. The legacy body is untouched. ✔ (m1) |
|
||||
| — / `Ops_H_Create` (`:1824`) | No-op, as D-A2's row says. ✔ |
|
||||
| — / `Ops_H_UnmapPersistent` (`:2129`) | No-op with its reason. ✔ (D9 sound) |
|
||||
|
||||
No early-out, ring use, pool interaction or epoch bump differs **inside the nine**. The two behavioural drifts I found
|
||||
are outside them, in `IsBufferDrawCleanByHandle` (C-1) and `EnsureBufferResourceForHandle` (C-2's pool gate).
|
||||
|
||||
**(2) The seven wrappers and epoch discipline.** All seven `*Tracked` shapes are reproduced (`:2141-2176`), including
|
||||
`Ops_H_MapPersistentTracked`'s **bump on decline** (`:2169-2175`); `Ops_H_Create` and `Ops_H_UnmapPersistent`
|
||||
correctly bump nothing. `RegisterBufferBackendOps` / `UnregisterBufferBackendOps` keep their bumps and install/clear
|
||||
`MGPipeSetResourceOps` inside them (`:2291`, `:2306`). The readback order is **writeback → unmap → serial stamp →
|
||||
`BumpBufferMutationEpoch`** with the bump in the wrapper, i.e. strictly last (`:2010-2035`, `:2161-2164`) —
|
||||
`ARCHITECTURE.md:288` satisfied, and the rule is written into the function where the next reader will meet it. Serial
|
||||
stamping reads `record->Serial` inside the hook, which is consistent with the applier bumping before the hook
|
||||
(`wire-v1` §2.1); every arm that does not stamp leaves the twin dirty, which is the safe direction. ✔
|
||||
|
||||
**(3) The slot table.** `ReleaseByHandle` (`SlotTables.h:288-311`) hands the twin out with the entry already retired,
|
||||
forgets the front memo when the slot matches, frees no slot — matching `ReleaseTwinAt`'s established shape and D-L's
|
||||
order. No `ForEachLive` sweep over the buffer table exists (item 7 ✔ — and the handle overload writes no `stateRef`,
|
||||
so one would see nothing anyway). `EnsureProcessTeardownSentinel()` is armed by `GetOrCreate(MGPipeHandle)`
|
||||
(`SlotTables.h:277`), i.e. at first insertion, not from a destructor ✔. The destroy path frees ids and pool-enrols
|
||||
exactly as `Ops_OnDestroy` did ✔. **M2/M-1 is the one open hole.** One latent hazard worth recording: after
|
||||
`ReleaseByHandle` the twin is destroyed, so `ResolvedDrawBuffers::Entry::resource` and `iboResource` become dangling —
|
||||
where on the legacy arm the frontend's `SharedPtr` kept them alive. Both consumers check identity through
|
||||
`FindByHandle` before touching the pointer (`Managers.cpp:2386-2388`, `DirectGLES.cpp:784-790`), so nothing is
|
||||
dereferenced today; the invariant deserves a sentence at the member, because it is now the only thing standing between
|
||||
the memo and a use-after-free.
|
||||
|
||||
**(4) The VAO half.** Gate: `{m_syncedElementsHandle, m_syncedElementsSerial}` + `m_syncedVertexBuffersSerial` +
|
||||
`m_syncedIndexSerial` + the unchanged `m_syncedBufferIdGeneration` and `m_hasConvertedFloat64Attribute`, with
|
||||
`m_syncedFetchBaseInstance` kept as the *emitted* record — D-G4's table, plus D5's independent index serial. The walk
|
||||
is field-for-field the legacy one (enable/disable, fp64 narrowing with the Adreno disable and the explicit re-enable,
|
||||
zero-stride binding-API path, attribute bind, BGRA drain/probe/disable, `Pointer`/`IPointer` at the shifted offset,
|
||||
divisor); the per-attribute `needsSync*` skips are gone, which costs redundant GL calls but changes no state.
|
||||
`BaseInstanceByteShiftWire` (`:3435-3438`) reproduces `BaseInstanceByteShift` (`$BASE:2377-2382`) exactly, divisor
|
||||
term included, and is applied at the pointer call and inside the fp64 narrowing — the two places the legacy value
|
||||
reached; `DrawElementsIndirect` and the multi-draw tiering are untouched, as D-H2 requires, and the three former scope
|
||||
sites now compile to `((void)value)` under `MOBILEGL_PIPE_LEGACY_MEMOS=0` only (`DirectGLES.cpp:5272-5276`).
|
||||
`ResolvedDrawBuffers` re-keys with the same hit/miss/repair shape and the same `vboCleanEpoch`/`iboCleanEpoch`
|
||||
semantics ✔. **Stale-record risk: M-5 (reset) and M-2 (`AttributeCount`).** `IsBufferDrawClean`'s reads are equivalent
|
||||
except for the map state — **C-1**. One cross-package assumption the report does not record: `VertexFetchBaseInstance`
|
||||
is *sticky* in the applier, where the legacy global was scoped to the draw, so correctness depends on B emitting
|
||||
`set_vertex_buffers` with `BaseInstance = 0` for the next non-base-instanced draw — which D-H2.3's `ContentHash`
|
||||
requirement delivers, and which `DrawParametersScenario.APlainDrawAfterABaseInstancedOneSeesZeroAgain` is the gate for.
|
||||
|
||||
**(5) D-E / D-F / D-J.** `Ops_AcquirePersistentMap` is untouched (no hunk in the diff touches `$BASE:1134-1210`);
|
||||
`Ops_H_MapPersistent`'s two permitted changes are the only ones (m1 aside). `git diff 39722687 HEAD --
|
||||
MobileGL/MG_Backend/DirectGLES/Managers.cpp` places **no hunk** inside any of the nine G5 functions — the two hunks in
|
||||
that region are an insertion before `RespecifyStorageNow` and a lone `#endif` after the last of the pre-existing
|
||||
helpers, so G5 holds by construction, script or no script. Both Adreno workarounds are reproduced in the handle walk
|
||||
with their rationale (`Managers.cpp:3807-3826`, `:3852-3874`); the three rings are untouched;
|
||||
`InvalidateIndexedBufferBindingShadowsForId` on an extent move survives inside the shared `RespecifyStorageWith`
|
||||
(`:1006-1008`). ✔
|
||||
|
||||
**(6) G1 / D-K.** Every new member is push-only (`hostBytes` `Managers.h:651-663`; `ResolvedDrawBuffers::Entry::handle`
|
||||
and the four struct fields; the four new twin members) and every retired member is under
|
||||
`MOBILEGL_PIPE_LEGACY_MEMOS`, which `CMakeLists.txt:476-479` forces ON whenever `MOBILEGL_PIPE_PUSH` is OFF — so the
|
||||
pull build's `sizeof` and symbol set cannot move, and the reported `0 added / 0 removed / 0 resized / 0 renamed` at all
|
||||
six commits is consistent with the guards I read. `grep` over the whole backend confirms every remaining reference to
|
||||
the seven retired names sits inside a `MOBILEGL_PIPE_LEGACY_MEMOS` arm. No `pGLContext`; no `MG_State` type in any
|
||||
`MGPipeResourceOps` signature (m7 is about a looser claim). ✔ (m9 on the `LEGACY_MEMOS=0` evidence.)
|
||||
|
||||
**(7) Legacy-arm parity.** The `#else` copy of the five helpers is the pre-P3a text **unmodified** — the diff proves
|
||||
it, since neither hunk lands inside the block. In a *push* build the legacy arm runs the parameterised cores through
|
||||
thin forwarders (`RespecifyStorageNow`, `UploadRangeNow`, `FlushPendingRangesNow`, `StorageMatches`, the two-argument
|
||||
`DrainResidentWritesNow`), and I compared those statement by statement against `$BASE:895-1118`: the only difference
|
||||
is m4's added null test. The `0` and `0x7f` lanes being green at HEAD is consistent. ✔
|
||||
|
||||
**(8) The 202 default-arm failures.** Attributable to the stub applier, and I could not construct a counter-example.
|
||||
With no `ResourceCreate` emitted, `HandleOfBuffer` returns the null handle for every buffer, so `EnsureBufferResource`
|
||||
(`Managers.cpp:2556-2568`) returns `nullptr` before touching any of C's new code; with no
|
||||
`CreateVertexElements`/`BindVertexElements`, `BoundVertexElementsRecord` returns null and
|
||||
`SyncToBackendFromApplier` returns at `:3771` before `Bind()`. Those are the only two new failure sources reachable at
|
||||
`0x1ff` on this tree, they are exactly the two diagnostics quoted in §4.4, and the scenario histogram ("every scenario
|
||||
that draws or touches a buffer") matches. **But the same argument is the reason this package has no positive
|
||||
evidence at all**: the 202-failure run proves the two refusals fire and nothing else, and the two green lanes exercise
|
||||
only the legacy arm. Every finding above is therefore un-contradicted by any run C has done, and the post-rebase gate
|
||||
is the first execution of the code under review.
|
||||
|
||||
**(9) Tests.** No name added or removed (`ctest -N` 2487 == 2487, five additions all `contract`'s) — G14 ✔.
|
||||
`EveryReKeyedObjectClassAnnouncesItsOwnDeath`'s buffer arm asserts the **absence** of a notice, which is the
|
||||
falsifiable form of D-L (it goes red if anyone adds a seventh raiser, which is the mistake it guards). It does not go
|
||||
red if a *notice were dropped* — but that direction is covered for the six kinds by the existing membership assertion,
|
||||
and for the buffer the equivalent is `resource_destroy` reaching `Ops_H_Destroy`, which no unit test can see and which
|
||||
`HandleRecycleScenario`'s buffer arm (package D) is the gate for. `EverySwitchedOverKindResolvesItsTwinThroughTheHandleArm`
|
||||
drives the real walk and its five assertions are each falsifiable (drop `ReleaseByHandle`'s `Live = false` and
|
||||
`:3908` goes red; drop the `Gen` compare in `FindByHandle` and `:3922` does). Gap: neither case can go red for M-1,
|
||||
and nothing anywhere exercises an `Ops_H_*` body.
|
||||
|
||||
**(10) Commit hygiene.** Six commits, six single-line messages, empty bodies (`git log --format=%b` prints nothing for
|
||||
all six), author and committer `Swung0x48 <swung0x48@outlook.com>`, no `Co-Authored-By` and no generator line.
|
||||
`git diff --stat 39722687 HEAD` names exactly `SlotTables.h`, `Managers.h`, `Managers.cpp`, `DirectGLES.cpp`,
|
||||
`SanityTest.cpp` — five of C.2's seven, nothing outside. e1-e5's messages are byte-identical to C.2's; e6's is C's own
|
||||
(C.2 gives step 6 no message) and follows the house style. ✔
|
||||
|
||||
---
|
||||
|
||||
## Judgement on the ten declared deviations
|
||||
|
||||
| # | judgement |
|
||||
|---|---|
|
||||
| **D1** `#if PUSH / #else` instead of an in-place refactor | **Sound, and the right call.** The measurement behind it is real (five resized pull symbols), G1 admits an empty resize set, and the diff proves the `#else` copy is the original text untouched. The push arm's forwarders are behaviourally equivalent to it statement by statement; the single exception is m4's added null test, which is unreachable on the legacy arm. The claimed benefit — one three-tier ladder inside a push build — is delivered. |
|
||||
| **D2** `g_pendingFetchBaseInstance` retired, not deleted | **Sound.** Deleting two defined symbols from the pull build is a straight G1 break, and `ARCHITECTURE.md:367` requires the legacy arm to keep working. The re-reading of C.2's `# empty` grep as "every hit inside a `LEGACY_MEMOS` arm" is the same rule the twin-memo grep two lines below already states, and I verified the hits: `Managers.h:1160-1172`, `Managers.cpp:3320-3333`, `DirectGLES.cpp:5271-5276`, all guarded. |
|
||||
| **D3** `MGPipeSetResourceOps` from `RegisterBufferBackendOps()` | **Sound.** `BackendObject_DirectGLES.cpp` is not in C.2's file list and hard rule (4) forbids it; both named bring-up sites call `RegisterBufferBackendOps`, so one edit covers both, in the file that owns the table, paired with the unregister. Contract-review item 13's constraint (install at bring-up/teardown only) is met — and note it also re-installs on every make-current, which is idempotent because the pointer is the same object. |
|
||||
| **D4** e2 carries `OnBufferWriteback`, e3 carries `OnGpuWritten` + the ordering | **Sound and unavoidable.** A handle-shaped readback has no object to call `WritebackFromBackend` on; the split is the brief's own, one step over, and both commits are individually coherent. |
|
||||
| **D5** the new `m_syncedVertexBuffersSerial` | **Sound, and it is load-bearing beyond its stated reason.** D-G4's table drops `baseInstanceDirty` on the argument that a base-instance change moves `VertexBuffersSerial`; without a term for that serial the twin would never see the move. It is also the term that rescues the whole gate across an applier reset — see M-5. It should be described that way rather than as an addition to the census. |
|
||||
| **D6** `EnsureBufferResourceForHandle` keeps its `SharedPtr<BufferObject>` | **Sound.** D-N keeps `SyncPersistentMappedRange` in Espryt for all of P3a and the call is named at the site. The accompanying claim about "no `MG_State` type in any new handle-arm signature" is overstated (m7), and note that C-1's fix *uses* this parameter, so the argument for keeping it is stronger than the report makes it. |
|
||||
| **D7** the fp64 `SyncGpuWrites` gap | **The gap is real, correctly declared, and P8's to close — but it is not the only defect on that function.** `SyncFloat64AttributeAsFloat32ByHandle` also reads a cached shadow base that adoption has freed (C-2), which the declaration does not cover and which is worse than the declared gap: stale bytes are at least *valid* bytes. `DoublePrecisionScenario` will only see either of them if its source buffer is shader-written or adopted; as written it likely sees neither, so "`DoublePrecisionScenario` is the gate that would see it" is optimistic and should be checked against the scenario's actual body before it is relied on. |
|
||||
| **D8** whole-resource `OnGpuWritten` as one `kMGPipeWholeBuffer` range | **Sound, and the right distinction to draw for P8/P9.** Verified against the payload: `MGPRange{0, ~0ull}` matches `MGPipeTypes.h:63-67` and `:177`, and `MGPBlobRef{address, size, kMGHostSpanSegNone, 0}` matches `:55-61`'s field order exactly. The report should add the `HasDefinedContent` half of the same contract (m8). |
|
||||
| **D9** `Ops_H_UnmapPersistent` is a no-op | **Sound.** D-B4 forbids the alternative, nothing emits it in P3a, and the entry exists so the transport has both halves. |
|
||||
| **D10** `Ops_H_ResidentSubData` does not record `hostBytes` | **Sound, and it is the one place the lifetime question was asked and answered correctly** — which is what makes C-2 a slip rather than a design error. |
|
||||
|
||||
---
|
||||
|
||||
## Rework list
|
||||
|
||||
**Blocking (before the integrator merges `espryt` in D.1):**
|
||||
|
||||
1. **C-1** — restore a live-host-write input to `IsBufferDrawCleanByHandle` (`Managers.cpp:2385-2404`): keep the
|
||||
`HasLiveHostWrites` test and its assert, add the frontend `IsMapped()` test through the object the three call sites
|
||||
already hold, with a comment saying it retires when P5 gives the field a producer. Add a scenario that writes
|
||||
through a non-adopted persistent map with no GL call and draws.
|
||||
2. **C-2** — clear `hostBytes` at the two events that invalidate it: on a successful `Ops_H_MapPersistent`
|
||||
(`Managers.cpp:2055-2127`) and on a `HasDefinedContent == 0` respecify (`:1832-1878`); make
|
||||
`SyncFloat64AttributeAsFloat32ByHandle` (`:4186`) read `resource->persistentPtr` when the resource is
|
||||
`persistentMapped`; gate the pool reseed (`:2489-2498`) on `record->Desc.HasDefinedContent` as well as on the base
|
||||
being non-null, and declare the pool-decision change in the report.
|
||||
3. **M-1** — close contract-review M2 in `SlotTables.h:272-286` (refuse a backwards `Gen`, bound `handle.Slot` before
|
||||
`EntryAt`) and add the `SanityTest` case that goes red for it. Record it in the report.
|
||||
4. **M-2** — walk `kMGPipeMaxVertexAttribs` in `SyncToBackendFromApplier` (`Managers.cpp:3794-3796`), or state and pin
|
||||
`AttributeCount == 32` as a requirement on B.
|
||||
5. **M-3** — make bit 8 imply bit 7 (or give the two handle-arm binders an ensure fallback) and correct
|
||||
`Managers.h:690-692`.
|
||||
6. **M-4** — give bits 7 and 8 the `EsprytSlotArmVerdict` three-way treatment, or at minimum stop with a named line
|
||||
when the bit is clear and `Features.PipeLegacyMemos` is false.
|
||||
7. **M-5** — record the dependency on `wire`'s C2 in the report and at the gate, and treat "no bound elements record"
|
||||
as a memo miss in `SyncVaoAttributeBuffersByHandle` (`DirectGLES.cpp:640-648`).
|
||||
|
||||
**Declared minors, non-blocking (ID-4):** m1-m9.
|
||||
|
||||
## Post-rebase verification the integrator must insist on
|
||||
|
||||
`espryt-v1` §6 is a good list and stands; these are the additions and the ones to refuse to accept as green without
|
||||
seeing the output:
|
||||
|
||||
1. **§6's items 1-6 exactly as written**, and in particular item 5 — the default-mask lane green — is the *first* time
|
||||
any of this code executes. Treat a green there as bring-up, not as verification.
|
||||
2. **A named case for C-1**, run in both arms: a persistently mapped, non-adopted buffer written only through its
|
||||
pointer, drawn, read back. If package D cannot add one, `MOBILEGL_COHERENT_AS_FLUSH=1` over the two
|
||||
`coherent_as_flush: true` Create fixtures (G3b) is the nearest existing proxy and must be run under push **and**
|
||||
pull with a byte-for-byte path comparison, not only an SSIM pass.
|
||||
3. **A named case for C-2**: `DoublePrecisionScenario` with an **adopted** source buffer (≥ 16 MiB, adoption enabled),
|
||||
plus `StorageBufferRegrowScenario` under ASan or with `MOBILEGL_ESPRYT_*` pool tracing, since the pool reseed is
|
||||
the second dereference. A clean run of today's `DoublePrecisionScenario` does **not** discharge this.
|
||||
4. **`VertexArrayEnableDisableScenario` under the default mask** — it is the only gate that can see M-2, and it must be
|
||||
run with a configuration that actually shrinks the enabled set.
|
||||
5. **The three subsystem combinations, not two**: `0x1ff`, `0x7f` (both off) and `0x17f` (bit 8 on, bit 7 off). The
|
||||
third is M-3; if it is not made to work it must be made to refuse, and G12's scenario should assert whichever.
|
||||
6. **`MOBILEGL_PIPE_LEGACY_MEMOS=0` with `MOBILEGL_PIPE_PUSH=0x7f`** — the `.Handles` itest pin — must produce a named
|
||||
verdict rather than a silent legacy run (M-4).
|
||||
7. **Confirm `wire`'s C2 landed** (advance, not zero, at reset) before merging; if it did not, M-5 makes this package
|
||||
unsafe on any application that changes contexts.
|
||||
8. `bash scripts/p3a_untouched_regions.sh 44c2b5cf HEAD` once package D lands it — §3.2's sha stand-in is credible and
|
||||
I independently confirmed no hunk lands inside the nine, but the real script and its `--self-test` are the gate.
|
||||
9. A **real build** with `MOBILEGL_PIPE_LEGACY_MEMOS=0` (not `-fsyntax-only`), covering `MultiDraw.cpp`, `Utils.cpp`
|
||||
and the test targets, since the rebase brings in the client's headers (m9).
|
||||
10. Record the per-draw `FindByLifetimeId` cost in D.4 (m6) so it is a measured number rather than a surprise in the
|
||||
P3a-vs-pull A/B.
|
||||
|
||||
---
|
||||
|
||||
*No file in `/home/swung/w7/p3a-espryt` was modified and no worktree was created. Base readings were taken with
|
||||
`git show 39722687:<path>` into the scratchpad; those copies were the only artefacts and are the reviewer's to delete.*
|
||||
@@ -0,0 +1,474 @@
|
||||
# P3a package C — Espryt (`espryt-v1`)
|
||||
|
||||
Branch `p3a/espryt`, worktree `/home/swung/w7/p3a-espryt`, parent `39722687` (`p3a/contract`, tag). **Not pushed.**
|
||||
Six commits, oldest first:
|
||||
|
||||
| # | hash | message |
|
||||
|---|---|---|
|
||||
| e1 | `9ae4ec099dddaef0e6d6a1a4df9f551aa67f6f6e` | `[Refactor] (Espryt): give the buffer resource its own {slot, gen} table instead of hanging it off the frontend object` |
|
||||
| e2 | `de13c5886cd6d36287a26ecfd644561d2a6f77a7` | `[Refactor] (Espryt): take the buffer ops by handle and payload instead of by frontend object reference` |
|
||||
| e3 | `855272e5012d35126357297a2a3557bd4026a452` | `[Refactor] (Espryt): answer a readback through the reverse channel and bump the mutation epoch after it, never before` |
|
||||
| e4 | `469f78b85f8bd3a4bd6bbfe6af90c664c20c5bd9` | `[Refactor] (Espryt): drive the driver VAO from the pushed vertex-elements record and retire the wrapping index-slot version and its identity patch` |
|
||||
| e5 | `a9a1d0eb156b61cea8aff4847e44eb7d75c6bc8f` | `[Refactor] (Espryt): key the narrowed fp64 vertex stream on the buffer's handle instead of its lifetime id` |
|
||||
| e6 | `203120fa54a004023a79f05aba72947ee62c0bb2` | `[Test] (Espryt): extend the slot-table suite to the buffer kind and pin that its death crosses as resource_destroy` |
|
||||
|
||||
Files touched, all inside C.2's list: `MG_Backend/DirectGLES/{SlotTables.h, Managers.h, Managers.cpp, DirectGLES.cpp}`
|
||||
and `MG_Test/SanityTest.cpp`. **`MultiDraw.cpp` and `Utils.cpp` were not touched** — nothing in them needed to move
|
||||
(their element-array restores and the XFB/PBO writeback shapes are D-J's "must not change" rows, and their
|
||||
`EnsureBufferResource` call sites keep their behaviour through the dispatcher). Nothing outside the list was touched;
|
||||
in particular `BackendObject_DirectGLES.cpp` was NOT edited even though C.2 step e2 names `:849` as a bring-up site —
|
||||
see deviation **D3**.
|
||||
|
||||
---
|
||||
|
||||
## 1. Per-step summary
|
||||
|
||||
### e1 — the seventh slot table
|
||||
|
||||
* `Managers.h`, `namespace BufferImpl`, all inside `#if MOBILEGL_PIPE_PUSH`:
|
||||
* `using BackendBufferResourceTable = BackendSlotTable<BufferObject, GLESBufferResource, MGPipeKind::Buffer>` and
|
||||
`extern BackendBufferResourceTable g_backendBufferResources`. The `StateObject` parameter is `BufferObject` only
|
||||
because the template names one: **no member that touches it is instantiated** (`Find(StateObject*)`, `HandleOf`,
|
||||
`ForEachLive`, `OnFrontendObjectDestroyed` are never called on this table), which is what lets a handle-keyed kind
|
||||
live in the same class template. `EnsureProcessTeardownSentinel()` is armed by the table's own
|
||||
`GetOrCreate(MGPipeHandle)` — the contract's overload — i.e. at its first insertion, not from a destructor.
|
||||
* `ResolveResourceSubsystemArm()` / `ResolveVertexInputSubsystemArm()` plus the two **inline latched**
|
||||
`ResourceSubsystemEnabled()` / `VertexInputSubsystemEnabled()` (bit 7 / bit 8). Latched for the same reason
|
||||
`EsprytSlotTablesEnabled()` is: the two arms hold `GLESBufferResource` in **different containers** (the frontend
|
||||
object's `PipeResource::m_backend` vs this table), so a mid-run flip would strand every resource already built and
|
||||
leak the driver ids it owns. Inline for the same reason too — both are consulted per draw.
|
||||
* `GetOrCreateBufferResourceForHandle` / `FindBufferResourceForHandle` (neither touches `MGPipeSlots()`), and
|
||||
`HandleOfBuffer(const BufferObject*)`, named in place as **monolith glue** for the sites P3a deliberately does not
|
||||
migrate.
|
||||
* `GLESBufferResource` gains one push-only member, **`const Uint8* hostBytes`**: the client's shadow base as the last
|
||||
content-carrying resource call left it. It is what the three-tier flush, the pool reseed and the full re-upload read
|
||||
on the handle arm instead of asking a frontend object for `MappedData()`.
|
||||
* `SlotTables.h` gains **`BackendPtr ReleaseByHandle(MGPipeHandle)`** — the death half of the contract's
|
||||
`GetOrCreate(MGPipeHandle)`, for a kind whose announcement is its own destroy call. It hands the twin *out* rather
|
||||
than destroying it in place, because the caller still has to decide pool / delete / defer, and every one of those has
|
||||
to be reached with the entry already retired. It frees no slot: the client does that after the call returns (D-L).
|
||||
|
||||
### e2 — the nine ops by handle
|
||||
|
||||
* Nine `Ops_H_*` bodies + seven `*Tracked` wrappers duplicated for the new table, **including
|
||||
`Ops_H_MapPersistentTracked`'s bump-even-on-decline**. `Create` and `UnmapPersistent` get no wrapper (the legacy table
|
||||
had seven ops; `Create` defines nothing and `UnmapPersistent` is emitted by nothing).
|
||||
* `const MG_Pipe::MGPipeResourceOps g_glesResourceOps` registered from `RegisterBufferBackendOps()` and cleared in
|
||||
`UnregisterBufferBackendOps()`, **unconditionally**, exactly as `BufferBackendOps` is — the subsystem bit is the
|
||||
frontend's dispatch predicate, so bit 7 clear registers a table nobody calls and the A/B stays a configuration
|
||||
question rather than a bring-up-order one.
|
||||
* Applier reads, all through three file-local accessors: `ResourceRecordOf(res)` (Live + Gen checked),
|
||||
`ResourceSerialOf(res)`, `ResourceWidthOf(res)`.
|
||||
* **Shared bodies, one per helper, so the two arms cannot drift**: `RespecifyStorageWith(resource, size, usage,
|
||||
initialData, syncedSerial)`, `UploadRangeFrom(resource, hostBase, start, end)`,
|
||||
`FlushPendingRangesFrom(resource, hostBase, frontendSize)` (the whole three-tier ladder, unchanged),
|
||||
`DrainResidentWritesNow(resource)` and `StorageMatchesSize(resource, size)`. The object-shaped names
|
||||
(`RespecifyStorageNow`, `UploadRangeNow`, `FlushPendingRangesNow`, `StorageMatches`, the two-argument
|
||||
`DrainResidentWritesNow`) survive as thin forwarders. **The whole block is `#if MOBILEGL_PIPE_PUSH` / `#else`**: the
|
||||
pull build compiles the pre-P3a text verbatim — see deviation **D1**.
|
||||
* `EnsureBufferResourceForHandle(bufferObject, res)` beside the legacy `EnsureBufferResource`, dispatched from it.
|
||||
A **null handle on the handle arm is a loud `MGLOG_E_ONCE` and a null return, never a fall-back to the legacy arm**:
|
||||
quietly twinning off the frontend object would hide a missing emission behind a working picture, which is what the
|
||||
subsystem A/B exists to expose. (This is what makes the default-mask arm fail visibly on this tree — §4.)
|
||||
* `IsBufferDrawCleanByHandle(res, resource)` beside `IsBufferDrawClean`, dispatched from it. **The five reads become
|
||||
four applier reads with identical semantics**: identity → the slot table's twin at this handle (not
|
||||
`GetBackendResource()`); size → `record.Desc.Width` (not `GetSize()`); freshness → `record.Serial` vs
|
||||
`syncedChangeSerial` (not `GetChangeSerial()`); map state → `record.HasLiveHostWrites` (not `IsMapped()`).
|
||||
`HasLiveHostWrites` is pinned false by a `MOBILEGL_PIPE_VERIFY`-only `MOBILEGL_ASSERT`, so P5 cannot land a silent
|
||||
semantic change under it.
|
||||
|
||||
### e3 — the reverse channel
|
||||
|
||||
* `Ops_H_Readback` answers through `gMGPipeCallbacks.OnBufferWriteback(res, offset, {Offset=(address), Size,
|
||||
Seg=kMGHostSpanSegNone})` instead of `bufferObject.WritebackFromBackend`, in the fixed order **writeback → unmap →
|
||||
serial stamp → `BumpBufferMutationEpoch()`** (the bump is in `Ops_H_ReadbackTracked`, i.e. strictly after the other
|
||||
three; the ordering rule and why it must never move earlier are written into the function). A missing reverse channel
|
||||
is an `MGLOG_E_ONCE`, not a silent drop.
|
||||
* `BufferImpl::MarkBufferGpuWritten(bufferObject)` replaces the three `MarkGpuWritten` sites
|
||||
(`DirectGLES.cpp:500 / :544 / :2012`). On the handle arm it announces `OnGpuWritten(res, 1, &{0,
|
||||
kMGPipeWholeBuffer})`; on the legacy arm it calls `MarkGpuWritten` as before. Each call site is
|
||||
`#if MOBILEGL_PIPE_PUSH / #else` so the pull build's text is unchanged.
|
||||
**Integration point for package `client`:** the whole-resource announcement is spelled as **one range of
|
||||
`kMGPipeWholeBuffer`**, deliberately not as "zero ranges" — a zero count is the shape a fully *narrowed*
|
||||
announcement will legitimately have once P8/P9 build the client's conservative set, and the two must not be the same
|
||||
record. The client's `OnGpuWritten` must read it that way.
|
||||
|
||||
### e4 — the VAO half
|
||||
|
||||
* `BackendVertexArrayObject::SyncToBackendFromApplier()` beside the legacy `SyncToBackend` body, dispatched at the top
|
||||
of `SyncToBackend`. It takes **no argument** and reads no frontend type.
|
||||
* **Gate, re-keyed** (`Managers.h`, new members all `#if MOBILEGL_PIPE_PUSH`):
|
||||
|
||||
| retired (now `#if MOBILEGL_PIPE_LEGACY_MEMOS`) | replaced by |
|
||||
|---|---|
|
||||
| `m_hasSyncedConfigVersion` + `m_syncedConfigVersion` | `m_hasSyncedElements` + `m_syncedElementsHandle` + `m_syncedElementsSerial` vs `BoundVertexElements` + `rec.ContentSerial` |
|
||||
| `Array<VertexAttributeVersion,32> m_syncedAttributeVersions` | **deleted** — the applier's `Attributes[]` *is* what was last pushed, so the per-attribute compare has nothing left to prove; a moved `ContentSerial` re-emits the whole walk |
|
||||
| `m_syncedIndexBufferVersion` (wrapping `Uint16`) + `m_syncedIndexBufferObject` (raw identity patch) | `m_syncedIndexSerial` vs `IndexBufferSerial` — one monotone `Uint64`, no wrap, nothing to patch. **This is the Track H re-key.** |
|
||||
| `baseInstanceDirty` as a gate input | gone: a base-instance change is a `ContentHash` input, so it moves `VertexBuffersSerial`. `m_syncedFetchBaseInstance` **survives** as the record of what was last *emitted*. |
|
||||
| — | **`m_syncedVertexBuffersSerial` (new, beyond D-G4's table)** vs `VertexBuffersSerial`; see deviation **D5** |
|
||||
| `m_syncedBufferIdGeneration` | **unchanged**, server-local, still the only thing that catches a driver-id re-mint no counter on either side moves |
|
||||
| `m_hasConvertedFloat64Attribute` | **unchanged** — a narrowed stream is derived from buffer *content*, which no serial covers |
|
||||
|
||||
* Per-attribute walk from `rec->Attributes[i]` and `st.VertexBuffers[]`, with
|
||||
`VertexBufferForBindingIndex(st, bindingIndex)` (positional slot first, window scan behind it) and
|
||||
`BaseInstanceByteShiftWire(stride, divisor, baseInstance)` — the divisor comes from `MGPVertexBuffer::Divisor`,
|
||||
because the wire attribute deliberately does not carry it. **Every branch survives**: the enable/disable block, the
|
||||
fp64 narrowing with its Adreno disable, the zero-stride binding-API path
|
||||
(`SyncZeroStrideAttributeByHandle`), `BindAttributeBufferByHandle` (driver id from the slot table),
|
||||
the BGRA refusal probe, `glVertexAttribPointer`/`IPointer` at the shifted `fetchOffset`, `glVertexAttribDivisor`.
|
||||
* `VertexArrayImpl::BackendUsesNativeBaseInstance()` (reads `g_GLESCapabilities.SupportsBaseInstance`) is applied to
|
||||
`st.VertexFetchBaseInstance` in the applier arm. It is **idempotent** with whatever `wire` resolves, so the answer is
|
||||
the same whichever side resolves first.
|
||||
* `ResolvedDrawBuffers` **re-keyed** (all new fields push-only): `Entry` gains `MGPipeHandle handle`; the struct gains
|
||||
`elementsHandle`, `elementsSerial`, `buffersSerial` and `iboHandle`. `SyncNeccessaryBuffers` grows a push branch
|
||||
(`SyncVaoAttributeBuffersByHandle`) whose memo validity is `{BoundVertexElements, ContentSerial, VertexBuffersSerial}`
|
||||
instead of the frontend configuration version, and whose clean probe is `IsBufferDrawCleanByHandle(entry.handle, …)`.
|
||||
The IBO half re-keys `iboFrontend` → `iboHandle` the same way. `vboCleanEpoch`/`iboCleanEpoch` against
|
||||
`CurrentBufferMutationEpoch()` and the hit/miss/repair structure are unchanged.
|
||||
* `g_pendingFetchBaseInstance`, `SetPendingFetchBaseInstance`, `GetPendingFetchBaseInstance`, `ScopedFetchBaseInstance`
|
||||
and the three scopes at `DirectGLES.cpp:5150 / :5187 / :5239` are **removed from the handle arm** and kept compiled
|
||||
under `MOBILEGL_PIPE_LEGACY_MEMOS` — see deviation **D2**. `EmulatedFetchBaseInstance` / `UseNativeBaseInstance`
|
||||
survive; the applier arm's copy of the decision is `BackendUsesNativeBaseInstance()`.
|
||||
|
||||
### e5 — the fp64 stream key, and the D-L comment
|
||||
|
||||
* `ConvertedFloat64Stream::sourceLifetimeId` (**`ARCHITECTURE.md`'s "`ConvertedVertexStreamKey` 的 `sourcePin`"**) moves
|
||||
under `#if MOBILEGL_PIPE_LEGACY_MEMOS`; the push arm gains `MGPipeHandle sourceHandle`. `sourceChangeSerial` is the
|
||||
applier's server-owned `Serial` on the handle arm. `sourceOffset` / `sourceStride` / `componentCount` /
|
||||
`elementCount` are unchanged, and the memo is still **never trusted for a persistently mapped buffer**.
|
||||
* `SyncFloat64AttributeAsFloat32ByHandle` enables the memo on that key (e4 landed the function with the memo
|
||||
deliberately disabled so the key change is this commit's whole subject).
|
||||
* `Managers.cpp`'s `default:` arm comment now reads *"Buffer death crosses as ResourceDestroy (P3a)"*, with the fixed
|
||||
order (`resource_destroy` → `MGPipeSlots().Free`) and the reason written in place.
|
||||
|
||||
### e6 — SanityTest
|
||||
|
||||
No new test name (G2's name sets stay identical, G14 has nothing to compare against). Two existing cases grew arms:
|
||||
|
||||
* `DirectGLESSlotTable.EveryReKeyedObjectClassAnnouncesItsOwnDeath` now also builds a `BufferObject` and asserts it
|
||||
raises **no** `StateObjectDeathNotice` — the falsifiable form of D-L. Both firing would free the slot twice.
|
||||
* `DirectGLESSlotTable.EverySwitchedOverKindResolvesItsTwinThroughTheHandleArm` now drives the seventh table through
|
||||
the family's own walk: client mints → `GetOrCreate(handle)` → `FindByHandle` → `ReleaseByHandle` (resource_destroy)
|
||||
→ `MGPipeSlots().Free` → re-acquire, asserting the slot comes back, `Gen` moves, the stale handle resolves to
|
||||
nothing, and the successor does **not** inherit the predecessor's storage.
|
||||
* `PixelPackBindingCacheSkipsRedundantBindsAndRestsAtZero` untouched and passing.
|
||||
|
||||
---
|
||||
|
||||
## 2. Track H census — every deleted/retired member and re-keyed memo
|
||||
|
||||
Deleted from the handle arm (kept compiled under `MOBILEGL_PIPE_LEGACY_MEMOS`, which a pull build forces ON, so
|
||||
`sizeof` moves nowhere and G1 holds):
|
||||
|
||||
1. `BackendVertexArrayObject::m_hasSyncedConfigVersion`
|
||||
2. `BackendVertexArrayObject::m_syncedConfigVersion`
|
||||
3. `BackendVertexArrayObject::m_syncedAttributeVersions` (`Array<VertexAttributeVersion, 32>`) — **the largest single
|
||||
deletion of the phase**
|
||||
4. `BackendVertexArrayObject::m_syncedIndexBufferVersion` (wrapping `Uint16`)
|
||||
5. `BackendVertexArrayObject::m_syncedIndexBufferObject` (raw frontend pointer, the wrap-hole identity patch)
|
||||
6. `ConvertedFloat64Stream::sourceLifetimeId` — **`ConvertedVertexStreamKey`'s `sourcePin`**
|
||||
7. `VertexArrayImpl::g_pendingFetchBaseInstance` + `SetPendingFetchBaseInstance` + `GetPendingFetchBaseInstance` +
|
||||
`ScopedFetchBaseInstance` (the ambient process global and its three draw-site scopes)
|
||||
8. `GLESBufferResource`'s residence in `PipeResource::m_backend` — the resource moves into the seventh slot table.
|
||||
`SetBackendResource` / `m_backend` / `BackendBufferResource` are **not deleted** (D-K), they simply stop being
|
||||
written under push.
|
||||
|
||||
Re-keyed memos:
|
||||
|
||||
| memo | was | is |
|
||||
|---|---|---|
|
||||
| `BackendVertexArrayObject`'s sync gate | config version + 32 per-attribute version triples | `{elementsHandle, elementsSerial}` + `VertexBuffersSerial` |
|
||||
| the twin's index memo | wrapping `Uint16` + raw `BufferObject*` | `m_syncedIndexSerial` (`Uint64`) |
|
||||
| `ResolvedDrawBuffers::configVersion` | frontend VAO config version | `{elementsHandle, elementsSerial, buffersSerial}` |
|
||||
| `ResolvedDrawBuffers::Entry::frontend` | raw `BufferObject*` | `+ MGPipeHandle handle` (the probe's identity) |
|
||||
| `ResolvedDrawBuffers::iboFrontend` | raw `BufferObject*` | `+ MGPipeHandle iboHandle` |
|
||||
| `ConvertedFloat64Stream` | frontend lifetime id + frontend change serial | buffer `{slot, gen}` + applier `Serial` |
|
||||
| `GLESBufferResource::syncedChangeSerial` | mirrors `BufferObject::GetChangeSerial()` | mirrors `MGPipeResourceRecord::Serial` (server-owned `MGGen`) |
|
||||
|
||||
Unchanged on purpose (D-J / D-A4): `g_bufferBackendIdGeneration`, `m_hasConvertedFloat64Attribute`,
|
||||
`m_syncedFetchBaseInstance` (as the *emitted* record), the `BackendSlotTable` single-entry `m_memoLifetimeId` /
|
||||
`m_memoHandle` front memo, `TempBufferTarget` and its redundant-bind cache.
|
||||
|
||||
---
|
||||
|
||||
## 3. Evidence
|
||||
|
||||
### 3.1 `AcquirePersistentMap` — the two permitted changes only (D-E)
|
||||
|
||||
Statement-level diff of `Ops_AcquirePersistentMap@44c2b5cf` against `Ops_H_MapPersistent@HEAD` (comments and blank
|
||||
lines stripped; nothing else in the function differs):
|
||||
|
||||
```
|
||||
-void* Ops_AcquirePersistentMap(BufferObject& bufferObject) {
|
||||
+void* Ops_H_MapPersistent(MG_Pipe::MGPipeHandle res, Uint64 size, const void* seedBytes) {
|
||||
-const SizeT size = bufferObject.GetSize();
|
||||
-auto* resource = static_cast<GLESBufferResource*>(bufferObject.GetBackendResource().get());
|
||||
-if (!resource) { auto created = MakeShared<GLESBufferResource>(); resource = created.get();
|
||||
- bufferObject.SetBackendResource(std::move(created)); }
|
||||
+auto* resource = GetOrCreateBufferResourceForHandle(res);
|
||||
+if (!resource) return nullptr;
|
||||
-const void* initial = bufferObject.MappedData();
|
||||
+const void* initial = seedBytes;
|
||||
-MGLOG_E_ONCE("Ops_AcquirePersistentMap: ...")
|
||||
+MGLOG_E_ONCE("Ops_H_MapPersistent: ...")
|
||||
-resource->storageSize = size;
|
||||
+resource->storageSize = static_cast<SizeT>(size);
|
||||
-resource->syncedChangeSerial = bufferObject.GetChangeSerial();
|
||||
+resource->syncedChangeSerial = ResourceSerialOf(res);
|
||||
```
|
||||
|
||||
That is: **(1)** the signature, **(2)** the three reads through the object (`GetSize()` → `size`, `MappedData()` →
|
||||
`seedBytes`, `GetBackendResource()`/`SetBackendResource()` → the slot table's `GetOrCreate(res)`), plus the two
|
||||
consequences that follow from them mechanically — the `Uint64 → SizeT` narrowing of the parameter and the
|
||||
`GetChangeSerial()` → server-owned `Serial` substitution D-A2's table names for every hook. The four-way capability
|
||||
gate, the stale-generation wipe **before** the new stamp, the idempotency hit, the fresh-id sequence with
|
||||
`++g_bufferBackendIdGeneration`, the locally defined `0x0040/0x0080/0x0100` constants, `immutableStorage = true` set as
|
||||
soon as the store exists, the `MGLOG_E_ONCE` decline and every success stamp are byte-identical. The legacy
|
||||
`Ops_AcquirePersistentMap` itself is **untouched**.
|
||||
|
||||
### 3.2 G5 — the nine functions are byte-identical
|
||||
|
||||
Brace-extracted from `Managers.cpp` at `44c2b5cf` and at `HEAD`, sha256 (first 16 hex) of each body:
|
||||
|
||||
```
|
||||
OK IsPoolable 01200228771b2bb3 == 01200228771b2bb3
|
||||
OK EnrollIntoPool 7a55c6a95d1970db == 7a55c6a95d1970db
|
||||
OK AcquireFromPool f8dd2b3c22efe640 == f8dd2b3c22efe640
|
||||
OK TrimBufferPool cb607a511958cf8f == cb607a511958cf8f
|
||||
OK ClearBufferPool 068fff7ad1e01e8b == 068fff7ad1e01e8b
|
||||
OK ProcessDeferredBufferReleases 497b6b793b3451cd == 497b6b793b3451cd
|
||||
OK CreateRingStorage b648500e8fe072f0 == b648500e8fe072f0
|
||||
OK RingAvailable f62a79ad5ee22bc6 == f62a79ad5ee22bc6
|
||||
OK RingAllocate efc1c1b7dee277de == efc1c1b7dee277de
|
||||
```
|
||||
|
||||
`git diff 44c2b5cf -- MG_Backend/DirectGLES/Managers.cpp` contains no hunk inside any of the nine; the only lines
|
||||
mentioning them are new forward declarations inside the push arm and new *calls* (`AcquireFromPool` from
|
||||
`EnsureBufferResourceForHandle`, `RingAllocate`/`RingAvailable` from the shared flush/drain cores).
|
||||
`scripts/p3a_untouched_regions.sh` is package D's and does not exist yet; the check above is its stand-in and the
|
||||
integrator should re-run the real script after D lands.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verification transcript
|
||||
|
||||
`CCACHE_BASEDIR=/home/swung/w7`, all in `/home/swung/w7/p3a-espryt`.
|
||||
|
||||
### 4.1 Per-commit: pull symbol identity, push build, unit
|
||||
|
||||
`python3 scripts/symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so
|
||||
--threshold 0 --fail-on-symbol-set-change`
|
||||
|
||||
| commit | symbol report | build-push | `ctest -L unit` build-linux | `ctest -L unit` build-push |
|
||||
|---|---|---|---|---|
|
||||
| e1 | `0 added, 0 removed, 0 resized, 0 renamed` | rc 0 | run, green | run, green |
|
||||
| e2 | `0 added, 0 removed, 0 resized, 0 renamed` | rc 0 | `100% tests passed, 0 failed out of 1571` | `100% … 1571` |
|
||||
| e3 | `0 added, 0 removed, 0 resized, 0 renamed` | rc 0 | `100% … 1571` | `100% … 1571` |
|
||||
| e4 | `0 added, 0 removed, 0 resized, 0 renamed` | rc 0 | `100% … 1571` | `100% … 1571` |
|
||||
| e5 | `0 added, 0 removed, 0 resized, 0 renamed` | rc 0 | `100% … 1571` | `100% … 1571` |
|
||||
| e6 | `0 added, 0 removed, 0 resized, 0 renamed` | rc 0 | `100% … 1571` | `100% … 1571` |
|
||||
|
||||
`.text 10792739 -> 10792739 (+0, +0.000%)`, `Total 17209979 -> 17209979 (+0)` at every one of the six.
|
||||
**Honesty note:** at e1 the two unit runs were executed but their summary lines were cut off by a `tail` in the run
|
||||
script; every later commit prints the summary and e1's tree is a strict subset of e2's. Everything from e2 on is
|
||||
quoted verbatim.
|
||||
|
||||
**An intermediate e2 state resized five pull symbols and was fixed before the commit.** The first cut of the shared
|
||||
helper cores rewrote `RespecifyStorageNow`, `UploadRangeNow`, `FlushPendingRangesNow` and `DrainResidentWritesNow` in
|
||||
place, which is pull-visible: `1 added, 1 removed, 5 resized` (`RespecifyStorageNow +16`, `FlushPendingRangesNow +14`,
|
||||
`UploadRangeNow +14`, `Ops_SubDataTracked −13`, `Ops_FlushMappedRangeTracked −12`; the add/remove pair was
|
||||
`DrainResidentWritesNow` losing its unused parameter). The fix is deviation **D1**.
|
||||
|
||||
### 4.2 Purity and shape
|
||||
|
||||
```
|
||||
grep -rc 'pGLContext' MobileGL/MG_Backend | grep -v ':0$' -> empty
|
||||
grep -n 'MG_State' MobileGL/MG_Pipe/PipeApply.h -> no hit
|
||||
```
|
||||
|
||||
`grep -n 'g_pendingFetchBaseInstance\|ScopedFetchBaseInstance' MG_Backend/DirectGLES/*.{h,cpp}` is **not empty**, and
|
||||
every remaining hit is inside a `MOBILEGL_PIPE_LEGACY_MEMOS` arm (`Managers.h:1159-1172`, `Managers.cpp:3320-3333` and
|
||||
the legacy `SyncToBackend` body, `DirectGLES.cpp:5271-5276`'s macro). Same for
|
||||
`m_syncedConfigVersion|m_syncedAttributeVersions|m_syncedIndexBufferObject|m_hasSyncedConfigVersion|m_syncedIndexBufferVersion`
|
||||
(`Managers.h:1079-1100`, one `#if MOBILEGL_PIPE_LEGACY_MEMOS … #endif` block; the only other hits are the prose in the
|
||||
replacement block's comment). See deviation **D2**.
|
||||
|
||||
`MOBILEGL_PIPE_LEGACY_MEMOS=0` push build compiles: `clang++ -fsyntax-only` with build-push's own command line and the
|
||||
macro flipped, on both `Managers.cpp` and `DirectGLES.cpp` — **rc 0 for both**. (No standard build directory configures
|
||||
that combination, so this is the only place it is checked.)
|
||||
|
||||
`ctest -N` name sets: build-linux 2487, build-push 2487, `diff` empty. Against `~/w7/p3a-before-ctest-names.txt`:
|
||||
0 removed, 5 added — and all five are **the contract's** (`PipeCatalogue.*` ×3, `ResourceEmit.*`,
|
||||
`VertexInputEmit.*`). This package adds no test name and removes none (G14).
|
||||
|
||||
### 4.3 The two legacy integration arms (both green)
|
||||
|
||||
```
|
||||
MOBILEGL_PIPE_PUSH=0 ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES
|
||||
rc 0 100% tests passed, 0 tests failed out of 461
|
||||
MOBILEGL_PIPE_PUSH=0x7f ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES
|
||||
rc 0 100% tests passed, 0 tests failed out of 461
|
||||
```
|
||||
|
||||
**Both were re-run against a freshly built HEAD `build-push`.** An earlier pass of these lanes was taken against a
|
||||
`build-push` left over from a base-commit excursion; the numbers above replace it. (`ROADMAP.md:7`'s stale-binary rule,
|
||||
the hard way.)
|
||||
|
||||
Two entries — `UnlocatedIoBlockScenario.TheEmulationIsActuallyArmedWhenTheEnvironmentPinsItOn` and
|
||||
`PointSizeDemotionScenario.TheDemotionIsActuallyArmedWhenTheEnvironmentPinsItOn` — failed in one narrowly filtered
|
||||
`build-linux` run and pass in every full lane. `build-linux/libMobileGL.so` is **symbol- and byte-identical to
|
||||
`$BASE`**, so they cannot be this package's; they look filter- or concurrency-sensitive and are recorded here rather
|
||||
than chased.
|
||||
|
||||
### 4.4 The default-mask arm — expected red, and why
|
||||
|
||||
```
|
||||
MOBILEGL_PIPE_PUSH=0x1ff ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES
|
||||
rc 8 56% tests passed, 202 tests failed out of 461
|
||||
```
|
||||
|
||||
The same lane at `39722687` (base, `build-push` rebuilt at it) is `100% tests passed, 0 failed out of 461`, so the 202
|
||||
are this package's switch-over meeting an applier that is still a stub. **Every one of them is explained by a missing
|
||||
record**, and the two diagnostics this package emits say so by name. Running one failing case directly
|
||||
(`MOBILEGL_LOG_FILE_PATH=… MOBILEGL_PIPE_PUSH=0x1ff MobileGLIntegrationTest
|
||||
--gtest_filter='*OrientationScenario.OffscreenPassRendersUpright*'`, rc 1):
|
||||
|
||||
```
|
||||
[ERROR]: MGPipe: buffer 1 has no resource handle - the resource family is switched over but
|
||||
nothing emitted resource_create for it
|
||||
[ERROR]: MGPipe: no vertex-elements record is bound, so the driver VAO cannot be configured -
|
||||
nothing emitted create_vertex_elements/bind_vertex_elements
|
||||
```
|
||||
|
||||
i.e. `MGPipeSlots()` holds no `Buffer` slot (nothing calls the client's `ResourceCreate` emitter) and
|
||||
`MGPipeApplierState::{VertexElementsCsos, BoundVertexElements}` are empty (`MGPipeApplyCreateVertexElements` /
|
||||
`…BindVertexElements` are no-op stubs at `c0`). Failures by scenario, top of the list: `ImageTargetKind` 24,
|
||||
`VertexAttribBinding` 13, `Orientation` 11, `DoublePrecision` 8, `SsboDeclarationForm` 7, `TessellationXfbCapture` 6,
|
||||
`DrawParameters` 6, `XfbRepeatedCapture` 5, `XfbAfterClipDistance` 5, `ProgramPipeline` 5, `PointSizeDemotion` 5+3,
|
||||
`XfbCaptureBufferReuse` 4, `UnwrittenPositionOutput` 4, `UnboundImageDescriptor` 4, `PrimitiveRestart` 4, … — that is
|
||||
"every scenario that draws or touches a buffer", which is the expected blast radius of a VAO that cannot be configured
|
||||
and an `EnsureBufferResource` that returns null. **No failure was found that is not explained by a missing record**, so
|
||||
nothing here is treated as a defect. `MGB_CTX` was **not** re-read in the handle arm to paper over it.
|
||||
|
||||
---
|
||||
|
||||
## 5. Deviations, each with its reason
|
||||
|
||||
**D1 — the shared helper cores are `#if MOBILEGL_PIPE_PUSH` / `#else`, and the pull build compiles the pre-P3a text
|
||||
verbatim.** Refactoring `RespecifyStorageNow` / `UploadRangeNow` / `FlushPendingRangesNow` /
|
||||
`DrainResidentWritesNow` / `StorageMatches` in place is **pull-visible** and resized five symbols (§4.1). G1 admits an
|
||||
empty resize set, so the pull arm keeps the original text and the push arm carries the parameterised cores plus thin
|
||||
forwarders. Consequence, and it is the good half: **inside a push build there is exactly one three-tier flush, one
|
||||
respecify and one range upload**, shared by the legacy and the handle arm, so E's "the tier silently changes" risk has
|
||||
no second copy to drift into. The `#else` copy is frozen by G1 itself and retires with the pull path at P13.
|
||||
|
||||
**D2 — `g_pendingFetchBaseInstance` and friends are retired, not deleted.** C.2's verification line asks for
|
||||
`grep -n 'g_pendingFetchBaseInstance\|ScopedFetchBaseInstance' … # empty`. That is not achievable together with G1:
|
||||
`SetPendingFetchBaseInstance` and `GetPendingFetchBaseInstance` are declared in `Managers.h` and defined in
|
||||
`Managers.cpp`, so they are **real symbols in the pull build** and deleting them is `2 removed` — a straight G1 break.
|
||||
It would also leave the legacy arm (bit 8 clear) with no base-instance emulation at all, which `ARCHITECTURE.md:367`
|
||||
requires to keep working through P3a/P4a. They are therefore inside `#if MOBILEGL_PIPE_LEGACY_MEMOS`, exactly like the
|
||||
five retired twin memos, and the handle arm neither declares nor reads them. The grep's rule should read as it does for
|
||||
the twin memos two lines below it: *every remaining hit must be inside a `MOBILEGL_PIPE_LEGACY_MEMOS` arm.*
|
||||
|
||||
**D3 — `MGPipeSetResourceOps` is installed from `RegisterBufferBackendOps()`, not from the two bring-up call sites.**
|
||||
C.2 step e2 names `BackendObject_DirectGLES.cpp:849` and `DirectGLES.cpp:10402`, but `BackendObject_DirectGLES.cpp` is
|
||||
**not in C.2's file list** and hard rule (4) forbids touching it. Both named sites call
|
||||
`BufferImpl::RegisterBufferBackendOps()`, so installing there covers both with one edit, in the file that owns the
|
||||
table, and pairs it with `UnregisterBufferBackendOps()` exactly as `BufferBackendOps` is paired today.
|
||||
|
||||
**D4 — e2 necessarily carries the `OnBufferWriteback` substitution; e3 carries `OnGpuWritten` and the ordering.**
|
||||
A handle-shaped readback has no `BufferObject` to call `WritebackFromBackend` on, so the reverse-channel call cannot be
|
||||
deferred past the commit that introduces the handle-shaped op (D-A2's own table says the substitution is part of the
|
||||
hook conversion). e3 is therefore the three `MarkGpuWritten` sites, the written-down epoch-order rule and the
|
||||
missing-channel diagnostic. Both commits are individually coherent; the split is the brief's, one step over.
|
||||
|
||||
**D5 — the twin gained `m_syncedVertexBuffersSerial`, which D-G4's table does not list.** `set_index_buffer` and
|
||||
`set_vertex_buffers` are independent calls, and `set_vertex_buffers` carries the buffer identities, offsets and
|
||||
divisors this twin **bakes into the driver VAO**. A set that moved while the elements CSO did not (a rebind of the same
|
||||
format onto a different buffer, or a base-instance-only change — which is a `ContentHash` input precisely so it is not
|
||||
suppressed) has to re-emit them. Keying only on `ContentSerial` would drop exactly the case `baseInstanceDirty` used to
|
||||
catch. It is a third monotone server-owned `Uint64`, no wrap and no identity patch, so it costs the census nothing.
|
||||
|
||||
**D6 — `EnsureBufferResource` keeps its `SharedPtr<BufferObject>` parameter on the handle arm.** C.2's "must not
|
||||
break" list says the sixteen call sites keep their behaviour "taking a handle where they took a `SharedPtr`". Full
|
||||
handle shape is not reachable in P3a: `BufferObject::SyncPersistentMappedRange()` at the old `Managers.cpp:1700` is one
|
||||
of the eleven sites **D-N explicitly keeps where they are** (the per-site attribution table is P8's to execute). So
|
||||
`EnsureBufferResourceForHandle(bufferObject, res)` is handle-shaped in every respect except that one call, which is
|
||||
named in a comment at the call. The sixteen call sites are unchanged and dispatch inside `EnsureBufferResource`. No
|
||||
`MG_State` type appears in any *new* handle-arm signature (`MGPipeResourceOps`' nine, `SyncToBackendFromApplier`,
|
||||
`SyncFloat64AttributeAsFloat32ByHandle`, `IsBufferDrawCleanByHandle`, `Ops_H_*`, `BindAttributeBufferByHandle`,
|
||||
`SyncZeroStrideAttributeByHandle`, `ResourceWidthForHandle`, `ResourceSerialForHandle`,
|
||||
`GetOrCreateBufferResourceForHandle`, `FindBufferResourceForHandle`).
|
||||
|
||||
**D7 — one behavioural difference between the arms, and it is confined to fp64 vertex arrays.** The legacy
|
||||
`SyncFloat64AttributeAsFloat32` opens with `bufferObject->SyncGpuWrites()` (the other D-N-retained site,
|
||||
`Managers.cpp:2774`). A handle has no inverse map to a frontend object — by design, the server has none — so
|
||||
`SyncFloat64AttributeAsFloat32ByHandle` cannot make that call, and a `GL_DOUBLE` array whose **source buffer was
|
||||
written by a shader and not yet pulled back** narrows stale bytes on the handle arm. It is written into the function.
|
||||
P8 closes it by moving the pull to the client. `DoublePrecisionScenario` is the gate that would see it, and it must be
|
||||
re-run after the rebase (§6).
|
||||
|
||||
**D8 — the whole-resource `OnGpuWritten` announcement is one `kMGPipeWholeBuffer` range, not zero ranges.** See e3.
|
||||
This is a contract point the client half has to agree with and is called out for the integrator.
|
||||
|
||||
**D9 — `Ops_H_UnmapPersistent` is a no-op.** P3a emits it from nowhere; the donation is permanent for the life of the
|
||||
store and is ended by the respecify / destroy paths, which already retire the immutable id. Giving it a body that
|
||||
unmapped a live coherent store is the one thing D-B4 forbids. The entry exists so the transport has both halves.
|
||||
|
||||
**D10 — `Ops_H_ResidentSubData` does not record `hostBytes`.** Its `bytes` are the application's staging store, valid
|
||||
for the duration of the call only, which is exactly why they are copied. Recording them as the shadow base would leave
|
||||
a dangling pointer for the next drain. (The three content-carrying calls that *do* record it —
|
||||
respecify / sub-data / flush-range — all carry the client's own shadow.)
|
||||
|
||||
---
|
||||
|
||||
## 6. What the post-rebase verification must cover
|
||||
|
||||
After `git rebase feat/disaggregated` (contract + wire + client) in `/home/swung/w7/p3a-espryt`, in this order:
|
||||
|
||||
1. **Rebuild all three build dirs before judging anything.** A verdict from a stale `build-push` cost this package a
|
||||
round already (§4.3).
|
||||
2. `symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so --threshold 0
|
||||
--fail-on-symbol-set-change --fail-on-added-bytes 0` → `0/0/0/0`.
|
||||
3. `ctest -L unit` in build-linux, build-push and build-verify.
|
||||
4. `ctest -N` name sets: build-linux == build-push; nothing removed against `~/w7/p3a-before-ctest-names.txt`.
|
||||
5. **The default-mask arm, which is the whole point of the rebase**:
|
||||
`ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES` (no env pin, i.e. `0x1ff`)
|
||||
must be green. Any residual failure is now a real defect, not a missing record: the two diagnostics
|
||||
(`has no resource handle`, `no vertex-elements record is bound`) name which record is still missing, and
|
||||
`MOBILEGL_LOG_FILE_PATH=… ./build-push/MobileGL/MG_IntegrationTest/MobileGLIntegrationTest --gtest_filter=…` is how
|
||||
to read them.
|
||||
6. Both legacy arms again: `MOBILEGL_PIPE_PUSH=0` and `MOBILEGL_PIPE_PUSH=0x7f`, same lane, both green.
|
||||
7. **The buffer/VAO family by name** (C.2's last regex), under the default mask:
|
||||
`-R 'LargeArenaAdoption|StorageBufferRegrow|VertexAttribBinding|MultiDraw|PrimitiveRestart|CrossFrameBuffer|ResidentIndex|BufferTexture|AtomicCounter|XfbCaptureBufferReuse|PackedWordReadback|DoublePrecision|VertexArrayEnableDisable|DrawParameters'`.
|
||||
Specifically watch: **`DoublePrecisionScenario`** (D7's stale-narrowing gap),
|
||||
**`VertexAttribBindingScenario.BaseInstanceMovesTheInstancedArraysStartElement` / `…LeavesPerVertexArraysWhereTheyWere`**
|
||||
and all eight `DrawParametersScenario` cases (the retired ambient global, D2/D-H2),
|
||||
**`PrimitiveRestartScenario` + `ResidentIndexScenario` + `MultiDrawScenario`** (the two element-array restore scopes
|
||||
against `m_syncedIndexSerial`), **`CrossFrameBufferScenario` + `StreamedArenaScenario`** (the Mali WAR-stall
|
||||
queue-only `SubData` and `FlushPendingRangesFrom`'s tier ladder), **`LargeArenaAdoptionScenario` +
|
||||
`StorageBufferRegrowScenario`** (`Ops_H_MapPersistent`, `mpr`, and
|
||||
`InvalidateIndexedBufferBindingShadowsForId` on an extent move), **`AtomicCounterScenario` +
|
||||
`BufferTextureScenario` + `PackedWordReadbackScenario` + `XfbCaptureBufferReuseScenario`** (the reverse channel and
|
||||
the epoch order).
|
||||
8. `MOBILEGL_ESPRYT_DISABLE_INVALIDATE_FLUSH=1 ctest --test-dir build-push -L integration-gpu -j 8` — D.3's named
|
||||
step. This package rewrote that kill switch's caller.
|
||||
9. `ctest --test-dir build-verify -L integration-verify` and the verify retrace sweep: `grep -l 'Fatal{'` empty,
|
||||
`grep -L 'MGPipe verify:'` empty. A `Fatal{ProtocolCorruption}` here is a malformed `CreateVertexElements` blob or
|
||||
an out-of-range `MGPSubData` box.
|
||||
10. `ctest --test-dir build-verify -R HandleRecycle` (G8), including package D's new buffer arm.
|
||||
11. **The retrace sweep**: `python3 ~/w7/retrace_gate.py --tree ~/w7/p3a-espryt --lib build-push/libMobileGL.so --out
|
||||
~/w7/retrace-out/p3a-espryt -j 4`, and the named `--only` set of G3b. The two `coherent_as_flush: true` Create
|
||||
fixtures must take the same buffer path under push as under pull.
|
||||
12. `bash scripts/p3a_untouched_regions.sh 44c2b5cf HEAD` once package D lands it (§3.2 is the stand-in), and
|
||||
`--self-test`.
|
||||
13. Re-check `grep -rc 'pGLContext' MobileGL/MG_Backend | grep -v ':0$'` empty and the
|
||||
`MOBILEGL_PIPE_LEGACY_MEMOS=0` syntax check of `Managers.cpp` + `DirectGLES.cpp` (§4.2) — the rebase brings in the
|
||||
client's headers and can reopen it.
|
||||
14. Two contract points to confirm against the merged `client`: the `OnGpuWritten` whole-resource range shape (D8) and
|
||||
that `MGPVertexBuffer::BindingIndex` is the attribute index for every entry (D-H3), which
|
||||
`VertexBufferForBindingIndex` assumes on its fast path.
|
||||
|
||||
Intermediate logs this package created live in the WSL `/tmp` of the run shell and in
|
||||
`<scratchpad>/wsl/*.sh`; nothing was written under `~/w7/p3a-espryt-*.log`.
|
||||
@@ -0,0 +1,527 @@
|
||||
# P3a package C — Espryt rework (`espryt-v2`)
|
||||
|
||||
Branch `p3a/espryt`, worktree `/home/swung/w7/p3a-espryt`, **rebased onto `refs/heads/feat/disaggregated` (`5cb826b0`)**
|
||||
and then ten new commits. **Not pushed.** Every file touched is in C.2's list
|
||||
(`MG_Backend/DirectGLES/{SlotTables.h, Managers.h, Managers.cpp, DirectGLES.cpp}`, `MG_Test/SanityTest.cpp`);
|
||||
`MultiDraw.cpp` and `Utils.cpp` are still untouched, and nothing outside the list was edited.
|
||||
|
||||
---
|
||||
|
||||
## 1. The rebase (ID-9), and where `d7655247`'s fix sits in each arm
|
||||
|
||||
`git rebase refs/heads/feat/disaggregated` applied **cleanly, with no conflict** — the contract commit `39722687`
|
||||
dropped out as a duplicate of `e01c0ccc`, and the six package commits replayed with new hashes:
|
||||
|
||||
| # | before | after | message (unchanged) |
|
||||
|---|---|---|---|
|
||||
| e1 | `9ae4ec09` | `4db6bf1e` | give the buffer resource its own {slot, gen} table … |
|
||||
| e2 | `de13c588` | `4d157a44` | take the buffer ops by handle and payload … |
|
||||
| e3 | `855272e5` | `b4687922` | answer a readback through the reverse channel … |
|
||||
| e4 | `469f78b8` | `6926efb1` | drive the driver VAO from the pushed vertex-elements record … |
|
||||
| e5 | `a9a1d0eb` | `568005fb` | key the narrowed fp64 vertex stream on the buffer's handle … |
|
||||
| e6 | `203120fa` | `cdbd5535` | extend the slot-table suite to the buffer kind … |
|
||||
|
||||
**A clean rebase was the trap, not the relief.** `d7655247` adds `++g_bufferBackendIdGeneration` inside
|
||||
`Ops_Respecify`'s immediate immutable-store retire; e2 had *copied* that retire path into `Ops_H_Respecify` before the
|
||||
merge existed, so three-way merge put the new line into the original body and left the copy alone. There was no
|
||||
textual conflict and no diagnostic — the fix was simply absent from the arm the default mask runs.
|
||||
|
||||
After the rework the file has **six** `++g_bufferBackendIdGeneration` sites, three per arm, and the two arms are
|
||||
symmetric:
|
||||
|
||||
| what re-mints the driver id | legacy arm | handle arm |
|
||||
|---|---|---|
|
||||
| persistent-map adoption | `Managers.cpp:1484` (`Ops_AcquirePersistentMap`) | `:2134` (`Ops_H_MapPersistent`) |
|
||||
| **respecify's immediate immutable retire — `d7655247`** | **`:1548`** (`Ops_Respecify`) | **`:1881`** (`Ops_H_Respecify`, added by `8589bb5a`) |
|
||||
| the ensure path's deferred immutable retire | `:2798` (`EnsureBufferResource`) | `:2659` (`EnsureBufferResourceForHandle`) |
|
||||
|
||||
`LargeArenaAdoptionScenario.RespecifiedVertexArenaKeepsVaoBindings` and the two other cases `d7655247` added are the
|
||||
gate; they are among the 463 the two legacy lanes run green, and among the 204 the default mask still fails on the
|
||||
stub applier (§5.4).
|
||||
|
||||
`build-linux` / `build-push` were reconfigured against `5cb826b0` before anything was judged, and `~/w7/p3a-before-*`
|
||||
is ID-9's re-captured baseline (2502 ctest names, `p3a-before-head.txt` = `5cb826b0`).
|
||||
|
||||
---
|
||||
|
||||
## 2. The rework, finding by finding
|
||||
|
||||
Ten commits, oldest first. Every message is a single line, no body, no attribution.
|
||||
|
||||
| # | hash | finding | message |
|
||||
|---|---|---|---|
|
||||
| r1 | `8589bb5a` | ID-9 | `[Fix] (Espryt): carry the adopted-store respecify's buffer-id generation bump into the handle arm as well` |
|
||||
| r2 | `5f3f82c1` | ID-11 | `[Fix] (Espryt): leave FlushPendingRangesNow as this file's only definition and call the one shared range ladder from both arms` |
|
||||
| r3 | `7c8e2ba3` | m2, m3, m5, m6, m8 | `[Fix] (Espryt): clamp the handle readback to the backend store past its offset, memoise the buffer handle lookup, and write down the two contracts the ops owed their callers` |
|
||||
| r4 | `7b950575` | **C-1** | `[Fix] (Espryt): keep the live-map question in the handle arm's draw-clean probe instead of a record field P3a pins false` |
|
||||
| r5 | `b3bd5d27` | **C-2** | `[Fix] (Espryt): re-read the client's shadow base at every use and forget it at the two events that free the allocation it names` |
|
||||
| r6 | `329cbae5` | **M-1** | `[Fix] (Espryt): refuse a backwards generation and an out-of-range slot in the handle-keyed GetOrCreate instead of adopting them` |
|
||||
| r7 | `88ff762b` | **M-2** | `[Fix] (Espryt): walk all 32 attribute slots so a vertex-elements record that shrinks still disables the arrays it dropped` |
|
||||
| r8 | `ea5a6089` | **M-3, M-4** | `[Fix] (Espryt): make the vertex-input bit require the resource bit and give both new subsystems a named verdict when the knobs leave no arm` |
|
||||
| r9 | `cbd60fe9` | **M-5** | `[Fix] (Espryt): treat an unbound vertex-elements record as a memo miss and record the applier-reset serial rule the twin's gate depends on` |
|
||||
| r10 | `6a1a9bc7` | C-1 / M-1 gates | `[Fix, Test] (Espryt): pin that a live host map keeps the handle arm's draw probe dirty and that a backwards generation is refused` |
|
||||
|
||||
### C-1 — the live-map question is back, and it is asked of the only thing that can answer it
|
||||
|
||||
`Managers.cpp:2556` (the signature), `:2577` (the test), `:2588` / `DirectGLES.cpp:631` / `:810` (the three call
|
||||
sites), `Managers.h:748` (the declaration and its contract).
|
||||
|
||||
`IsBufferDrawCleanByHandle` now takes `const BufferObject* frontend` and asks `frontend->IsMapped()` **at exactly the
|
||||
point in the order the legacy probe asks it** — after the adopted-store early-out, beside the `HasLiveHostWrites`
|
||||
test, which is kept together with its `MOBILEGL_PIPE_VERIFY` assertion. The review's reasoning is reproduced in the
|
||||
function: `HasLiveHostWrites` is pinned false and written by nobody in P3a, so it *cannot* stand in for the frontend's
|
||||
map state; an emulated (non-adopted) persistent map mutates the client's shadow with no call, no serial and no epoch,
|
||||
which is the whole reason a map question exists in this probe at all. The comment says the frontend read retires the
|
||||
moment P5 gives the field a producer, and that it is the last frontend read in the function.
|
||||
|
||||
The three call sites all already held the object: the dispatcher has `frontend`; the VBO memo entry has
|
||||
`entry.frontend` (the same pointer the legacy arm probes, kept alive by the VAO attribute's `SharedPtr` for as long as
|
||||
the memo is valid); the IBO half is handed `possibleIBO.get()`, the live bound object, which is what the legacy
|
||||
comment there says the probe re-validates against. A null `frontend` means "no live map", stated at the declaration.
|
||||
|
||||
**The test that would have caught it** — `DirectGLESBufferDrawProbe.ALiveHostMapKeepsTheHandleArmProbeDirtyBetweenTwoDraws`
|
||||
(`SanityTest.cpp:4180`, push-only, skipping visibly in a pull build at `:4375`). It builds an applier record and a twin
|
||||
that answer **clean to every one of the probe's other questions** (asserted first, so the case cannot pass vacuously),
|
||||
takes a `GL_MAP_PERSISTENT_BIT | GL_MAP_WRITE_BIT` map that nothing adopts, writes one byte through the pointer,
|
||||
asserts the record's `Serial` did **not** move (the point of the whole finding), and requires the probe to answer
|
||||
dirty; then unmaps and requires it to answer clean again, so the case is about the map and not about the fixture.
|
||||
**Negative control run:** with the `IsMapped()` test disabled again the case fails at `SanityTest.cpp:4238`
|
||||
("the handle arm called a persistently mapped, non-adopted buffer draw-CLEAN…").
|
||||
|
||||
A unit-level case is what C.2's file list allows — the itest the review asks for lives in `MG_IntegrationTest`, which
|
||||
is package D's — so §6 carries it forward as an integrator item.
|
||||
|
||||
### C-2 — no cached host pointer survives the two events that free it
|
||||
|
||||
`Managers.h:656` (the member's lifetime rule), `Managers.cpp:2637` (`liveHostBase`), `:2676` / `:2689` (the pool
|
||||
reseed), `:2726` (the ensure path's base), `:1865` (the orphan clear), `:2164` (the adoption clear), `:4419` (the fp64
|
||||
source).
|
||||
|
||||
Four changes, and the first is the one that matters:
|
||||
|
||||
1. **`EnsureBufferResourceForHandle` re-reads `bufferObject->MappedData()` at every use**, through a `liveHostBase()`
|
||||
lambda declared at the top of the function with the reason beside it — exactly what the legacy arm did, and
|
||||
available because D-N/D6 keep the frontend object on this path for `SyncPersistentMappedRange` anyway. The pool
|
||||
reseed, the respecify's `initialData` and the pending-range flush all read it; none of them touches the cached
|
||||
member any more.
|
||||
2. **The pool decision is back to the legacy one** — `(poolSize > 0 && !resource->persistentMapped)`. The undeclared
|
||||
`&& resource->hostBytes != nullptr` term is gone, with a comment saying why it was wrong: it changed the *pool*
|
||||
behaviour D-F freezes rather than "the source of bytes" the conversion may move, and it moves `AcquireFromPool`
|
||||
call counts that `StreamedArenaScenario`'s two recycle cases observe.
|
||||
3. **`hostBytes` is cleared at the two events that invalidate it** — a `HasDefinedContent == 0` respecify
|
||||
(`Ops_H_Respecify`, which is also the call that resizes the client's shadow and brings no replacement base) and a
|
||||
successful `Ops_H_MapPersistent` (the client adopts the coherent pointer and does `clear() + shrink_to_fit()` on
|
||||
the shadow the instant we return). The member's comment now states the rule as three bullets and says that every
|
||||
path holding the frontend object must re-read instead of reading it.
|
||||
4. **`SyncFloat64AttributeAsFloat32ByHandle` reads `persistentPtr` for an adopted source.** This was the reachable
|
||||
use-after-free: the memo is deliberately never trusted for a persistently mapped source, so for an adopted buffer
|
||||
the narrowing re-read the freed shadow **on every draw**. With (3) in place the alternative branch is a null and a
|
||||
refusal rather than a stale read.
|
||||
|
||||
**Declared deviation (new, D11):** `Ops_H_MapPersistent` gains one statement that `Ops_AcquirePersistentMap` does not
|
||||
have (`resource->hostBytes = nullptr`). It is about a push-only member the legacy arm does not own, not about the map,
|
||||
and it is the statement that makes (4) read the right memory. D-E's "two permitted changes" is therefore three, and
|
||||
this is the third; the legacy `Ops_AcquirePersistentMap` is still byte-untouched.
|
||||
|
||||
### M-1 — `GetOrCreate(MGPipeHandle)` refuses what `FindByHandle` refuses
|
||||
|
||||
`SlotTables.h:148` (`kMaxHandleSlot`), `:283-296` (the bound), `:301-315` (the direction test), `:331` (`LiveGenAt`),
|
||||
`:502` (`EntryAt`'s contract), `Managers.cpp:2359-2372` (the release-build diagnostic).
|
||||
|
||||
The `!=` becomes a **direction** test: forward is a recycle and resets the twin, backward returns `m_nullTwin`. The
|
||||
comment says which arm covers which direction and why the minting overload's symmetric form is provably safe where
|
||||
this one's is not. `handle.Slot` is bounded by `kMaxHandleSlot` (2^20, documented as a sanity cap rather than a
|
||||
policy — the allocator is the client's and there is no constant to check against on this side) **before** `EntryAt`
|
||||
resizes on it, and `EntryAt` now carries the sentence that every caller bounds its slot first.
|
||||
|
||||
`MOBILEGL_ASSERT` is inert at INFO, so `GetOrCreateBufferResourceForHandle` asks the same two questions first and
|
||||
answers them with `MGLOG_E_ONCE` — a refused resource is loud in the builds that ship. `LiveGenAt(slot)` exists for
|
||||
that and for nothing else.
|
||||
|
||||
**Gate:** `DirectGLESSlotTable.AGenerationBehindTheLiveTwinIsRefusedRatherThanAdopted` (`SanityTest.cpp:4258`) stamps a
|
||||
live twin at `{7, 2}`, calls `GetOrCreate({7, 1})` and asserts the incumbent's twin survived **with its marker**, then
|
||||
checks that `{7, 3}` still resets it (the direction that was always right) and that a slot at `kMaxHandleSlot` is
|
||||
refused rather than resized to. **Negative control run:** with the direction test disabled the case fails at
|
||||
`SanityTest.cpp:4277`.
|
||||
|
||||
Note for the integrator: `wire-review-v1` M-D reports the identical unbounded-resize shape in the applier's
|
||||
`RecordAt`. This package bounds the **backend** side; the applier side is still A's.
|
||||
|
||||
### M-2 — the attribute walk covers all 32 slots
|
||||
|
||||
`Managers.cpp:4008-4021`. The loop bound is `MG_Pipe::kMGPipeMaxVertexAttribs`, not `rec->AttributeCount`, so the
|
||||
disable arm is restored for an attribute the configuration has dropped. The comment records why it costs nothing:
|
||||
`MGPipeApplyCreateVertexElements` zeroes both arrays before it unpacks, so an entry past `AttributeCount` reads
|
||||
`Enabled = 0`, `Type = 0` (`DataType::Int8`, **not** `Float64`, which is 8) and `IsLong = 0` — i.e. exactly "disable
|
||||
this array", with no requirement placed on B. `VertexArrayObject::MAX_VERTEX_ATTRIBS` is also 32, so the legacy walk
|
||||
issued the same `glDisableVertexAttribArray` calls and no new GL traffic appears on either arm.
|
||||
|
||||
### M-3 — bit 8 requires bit 7, and the header says so
|
||||
|
||||
`Managers.cpp:2316-2331`, `Managers.h:700-711`.
|
||||
|
||||
`ResolveVertexInputSubsystemArm()` refuses `bit 8 set, bit 7 clear` with an `MGLOG_E` that names both bits and the
|
||||
reason (the vertex-input handle arm resolves every attribute's driver buffer id out of the resource slot table, and
|
||||
only bit 7 puts twins there), and runs the legacy vertex-input arm instead. The header's claim that "the A/B has to be
|
||||
able to run either one alone" is corrected in place: `0x0ff` (bit 7 on, bit 8 off) **is** a supported A/B, because the
|
||||
legacy VAO walk reaches the handle arm through `EnsureBufferResource`'s own dispatch; `0x17f` is not, and is now
|
||||
refused loudly rather than half-run with every attribute binding through whatever pointer the driver VAO last held.
|
||||
|
||||
### M-4 — both new subsystems answer `PipeLegacyMemos`
|
||||
|
||||
`Managers.cpp:2283-2290` (`PipeSubsystemArmVerdict` + `ClassifyPipeSubsystemArm`), `:2292-2310` and `:2312-2354` (the
|
||||
two resolvers).
|
||||
|
||||
The three-way shape `ClassifyEsprytSlotArm` established for bit 5, with the third verdict's **reachability** as a
|
||||
parameter, because the two families genuinely differ:
|
||||
|
||||
* **bit 7** — the buffer family's legacy arm is the `Ops_*` table and `g_glesBufferBackendOps`, compiled
|
||||
*unconditionally* (only the VAO twin memos and the pre-handle VAO body sit under `MOBILEGL_PIPE_LEGACY_MEMOS`), so
|
||||
`NoArm` is unreachable for it. The knob is still answered: bit clear **and** `PipeLegacyMemos` false logs an
|
||||
`MGLOG_W` saying which arm actually ran.
|
||||
* **bit 8** — the legacy arm *is* conditional, so `NoArm` is real and is named with `MGLOG_E` at arm resolution, not
|
||||
only at the first draw (the pre-existing `SyncToBackend` guard still says it again there).
|
||||
|
||||
**It diagnoses and does not stop, deliberately, and this is a decision the integrator should confirm.**
|
||||
`ResolveEsprytSlotTablesArm`'s `Fatal{}` is safe because no shipped lane pins bit 5 clear. Bits 7 and 8 are clear in
|
||||
**every `.Handles` itest lane today** (`MG_IntegrationTest/CMakeLists.txt` pins `MOBILEGL_PIPE_PUSH=0x7f` beside
|
||||
`MOBILEGL_PIPE_LEGACY_MEMOS=0`), which is contract-review item 11 and package D's to re-pin: a stop here would turn
|
||||
that lane red for a mis-pinned control rather than for a defect. The reason is written at the classifier, and it says
|
||||
the stop can be promoted the moment those lanes carry an explicit `0x1ff` arm.
|
||||
|
||||
### M-5 — the reset dependency is declared, and an unbound record is a memo miss
|
||||
|
||||
`Managers.cpp:3974-3990` (the twin's gate), `DirectGLES.cpp:613-622` and `:677-679` (the memo key).
|
||||
|
||||
The gate carries a paragraph naming `MGPipeApplierReset()`, the fact that it runs on **every** change of the current
|
||||
`GLContext` (`Tracker.h`'s `if (m_context != &ctx) Reset();`), that the twin survives the excursion because
|
||||
`BackendVertexArrayObject` has no context-generation member, and that this design is correct **only if the reset
|
||||
ADVANCES `VertexBuffersSerial` / `IndexBufferSerial` instead of zeroing them** — wire's C2. It also records the second
|
||||
half the review derived: that the `m_syncedVertexBuffersSerial` term is what forces the whole AND dirty after a reset,
|
||||
which is what rescues the per-record `ContentSerial` half. `wire-v2` reports C2 fixed (`PipeApply.cpp:628-646`), so
|
||||
the precondition is expected to hold at merge; §6 item 12 keeps it as a hard gate anyway.
|
||||
|
||||
Separately, `SyncVaoAttributeBuffersByHandle` now treats "no live vertex-elements record" as a **miss**: the key
|
||||
`{null, 0, buffersSerial}` describes no configuration and never changes while the state persists, so a memo stamped
|
||||
with it would hit on every later draw of a VAO whose attributes have moved. The walk still runs and the buffers are
|
||||
still ensured; only `memo->valid` is withheld.
|
||||
|
||||
### The minors
|
||||
|
||||
| # | disposition |
|
||||
|---|---|
|
||||
| m1 | **Report fix.** §3.1 of `espryt-v1` rendered `GetBackendResource()/SetBackendResource()` → "the slot table's `GetOrCreate(res)`". The substituted call is `GetOrCreateBufferResourceForHandle` (`Managers.cpp:2357`), which additionally seeds `pendingRespecify = true` on a freshly minted twin where `Ops_AcquirePersistentMap` does not. Outcome identical (a twin with no `storageInitialized` respecifies either way); the claim is corrected here rather than in the code. |
|
||||
| m2 | **Fixed** (`Managers.cpp:2036-2043`). `Ops_H_Readback` maps at `record.Offset`, so the size is clamped against `storageSize - Offset` and a `readOffset >= storageSize` returns; the applier's `BufferRangeFault` checks the range against `Desc.Width`, which a not-yet-applied respecify can leave larger than the store. |
|
||||
| m3 | **Fixed** (`Managers.cpp:1997`). The `ZoneScopedC` the legacy map arm carries is back in `Ops_H_FlushRange`'s kill-switch map arm. |
|
||||
| m4 | **Declared, kept.** `FlushPendingRangesFrom`'s `if (hostBase == nullptr) return;` after the queue is drained is a text change the legacy arm also runs inside a push build. It is unreachable there (`MappedData()` is non-null whenever ranges are queued) and it is the honest answer on the handle arm (the queue is dropped, and the next full re-upload puts the store right, which the comment says in place). It is the one place D1's "one body, so the arms cannot drift" is not literally true, and it is recorded here rather than removed. |
|
||||
| m5 | **Fixed** (comment, `Managers.cpp:4123-4131`). The VAO index bind resolves without ensuring; the comment says why that is noisy rather than wrong (nothing is stamped on the miss, so the next indexed draw repairs it) and why ensuring here would need the object this arm does not hold. |
|
||||
| m6 | **Fixed** (`Managers.cpp:2400`). `HandleOfBuffer` goes through `BackendSlotTable::HandleOf`, which carries the table's single-entry front memo and populates it — previously only the minting overload wrote it, so nothing absorbed the per-draw `FindByLifetimeId` hash lookups. Same answer, same allocator probe on a miss. D.4 should still record the cost (§6). |
|
||||
| m7 | **Report fix.** D6's "no `MG_State` type in any new handle-arm signature" holds for the nine `MGPipeResourceOps` bodies, `SyncToBackendFromApplier`, `SyncFloat64AttributeAsFloat32ByHandle`, `BindAttributeBufferByHandle`, `SyncZeroStrideAttributeByHandle`, `ResourceWidthForHandle`, `ResourceSerialForHandle`, `GetOrCreateBufferResourceForHandle` and `FindBufferResourceForHandle`. It does **not** hold for `EnsureBufferResourceForHandle` (D-N's `SyncPersistentMappedRange`), `MarkBufferGpuWritten`, or — now — `IsBufferDrawCleanByHandle` (C-1). All three are named at their declarations; G13 greps `PipeApply.h`, which is unaffected. |
|
||||
| m8 | **Fixed** (comment, `Managers.cpp:2431-2437`) **and stated for B**: `BufferObject::MarkGpuWritten` sets **both** `m_hasDefinedContent` and `m_gpuWritePending`. The client's `OnGpuWritten` must set both, or the next `ResourceRespecify` carries `HasDefinedContent = 0`, `Ops_H_Respecify` orphans instead of uploading, and the shader-written contents are dropped. |
|
||||
| m9 | **Fixed by running the real thing.** §5.5: a full `MOBILEGL_PIPE_LEGACY_MEMOS=OFF` + `MOBILEGL_PIPE_PUSH=ON` configure and build of the library, the test targets and the integration test, not `-fsyntax-only`. |
|
||||
|
||||
### ID-11 — `FlushPendingRangesNow` is the file's only definition again, and it is byte-identical
|
||||
|
||||
`Managers.cpp:1127-1139` (where the forwarder was, and why it is not there), `:1316` (the one definition),
|
||||
`:1718-1723` and `:2869-2871` (the two legacy call sites).
|
||||
|
||||
The v1 tree had **two** definitions of the name — a two-line forwarder in the push arm and the untouched body in the
|
||||
`#else` — and package D's `scripts/p3a_untouched_regions.sh` exits **2 ("could not run")** on exactly that, because it
|
||||
requires each of the ten names to be defined exactly once. The forwarder is gone. The push arm's two legacy call
|
||||
sites (`Ops_ReadbackFromGpu` and `EnsureBufferResource`) call `FlushPendingRangesFrom(*resource,
|
||||
bufferObject.MappedData(), bufferObject.GetSize())` under `#if MOBILEGL_PIPE_PUSH`, with the untouched
|
||||
`FlushPendingRangesNow(*resource, bufferObject)` in the `#else`.
|
||||
|
||||
**What this delivers versus what ID-11 asked for, stated plainly.** ID-11 says "restore it byte-identical and make the
|
||||
handle arm CALL it". The first half is met exactly (the gate now runs and reports the sha equal — §5.3). The second
|
||||
half cannot be met literally: `FlushPendingRangesNow`'s signature is `(GLESBufferResource&, BufferObject&)`, and a
|
||||
byte-identical body must keep it; having no frontend object to offer is the whole point of the conversion, and
|
||||
`Ops_H_Readback` has none. What is delivered instead is the property the gate's own comment says the row exists for,
|
||||
in its strongest available form: **a push build contains exactly ONE three-tier ladder, `FlushPendingRangesFrom`, and
|
||||
BOTH arms call it**; a pull build contains exactly one, `FlushPendingRangesNow`, byte-identical to `5cb826b0`'s. There
|
||||
is no build in which two ladders are compiled, so there is nothing for a tier to drift into. The alternative reading —
|
||||
keep the byte-identical function compiled in both builds and let the handle arm carry `FlushPendingRangesFrom` beside
|
||||
it — would pass the same gate while putting two ladders in every push build, which is what the row forbids.
|
||||
|
||||
---
|
||||
|
||||
## 3. Track H census and re-keyed memos
|
||||
|
||||
Unchanged from `espryt-v1` §2, with two additions and one correction:
|
||||
|
||||
* `GLESBufferResource::hostBytes` keeps its place in the census as a push-only member, but its **lifetime rule** is now
|
||||
part of the contract (`Managers.h:656`): refreshed by a content-carrying call, cleared by an orphaning respecify and
|
||||
by a successful persistent-map adoption, and never read by a path that holds the frontend object.
|
||||
* `BackendSlotTable::kMaxHandleSlot` and `LiveGenAt` are new, push-only, and add no member to any object.
|
||||
* `IsBufferDrawCleanByHandle` reads **five** things again, not four: the four applier reads plus the frontend's
|
||||
`IsMapped()`, which retires at P5. The v1 report's "five reads become four applier reads with identical semantics"
|
||||
was the inverse of what the code did and is corrected here.
|
||||
|
||||
---
|
||||
|
||||
## 4. Deviations
|
||||
|
||||
D1-D10 stand as `espryt-v1` §5 records them, with the judgements `espryt-review-v1` gave them, plus:
|
||||
|
||||
* **D7 is narrower than it was.** The declared `SyncGpuWrites` gap is unchanged and is still P8's. The *second* defect
|
||||
on that function — the freed shadow — is fixed (C-2), so `DoublePrecisionScenario` with an adopted source now
|
||||
exercises correct memory rather than a use-after-free, and the remaining difference is only the declared one.
|
||||
* **D11 (new)** — `Ops_H_MapPersistent` clears `hostBytes` on success. See C-2 above.
|
||||
* **D12 (new)** — `MOBILEGL_PIPE_PUSH` builds contain no `FlushPendingRangesNow`. See ID-11 above.
|
||||
* **D13 (new)** — bit 8 without bit 7 is refused rather than supported. See M-3 above.
|
||||
* **D14 (new)** — the armless verdict for bits 7 and 8 diagnoses and does **not** stop. See M-4 above; this one wants
|
||||
an explicit integrator decision, because the alternative depends on package D re-pinning the `.Handles` lanes.
|
||||
|
||||
---
|
||||
|
||||
## 5. Verification transcript
|
||||
|
||||
All in `/home/swung/w7/p3a-espryt` at `6a1a9bc7`, `CCACHE_BASEDIR=/home/swung/w7`. Every build directory was
|
||||
rebuilt before anything was judged.
|
||||
|
||||
### 5.1 Builds and unit
|
||||
|
||||
```
|
||||
cmake --build build-push --parallel 28 rc 0
|
||||
cmake --build build-linux --parallel 28 rc 0
|
||||
|
||||
ctest --test-dir build-push -L unit --no-tests=error
|
||||
100% tests passed, 0 tests failed out of 1584
|
||||
ctest --test-dir build-linux -L unit --no-tests=error
|
||||
100% tests passed, 0 tests failed out of 1584
|
||||
```
|
||||
|
||||
`ctest -N`: **2504** in `build-push`, **2504** in `build-linux`, `diff` empty. Against
|
||||
`~/w7/p3a-before-ctest-names.txt` (2502): **0 removed, 2 added**, and both are this rework's gates —
|
||||
`DirectGLESBufferDrawProbe.ALiveHostMapKeepsTheHandleArmProbeDirtyBetweenTwoDraws` and
|
||||
`DirectGLESSlotTable.AGenerationBehindTheLiveTwinIsRefusedRatherThanAdopted`. Both **run** in `build-push` and both
|
||||
**skip visibly** in `build-linux` (G2/G14).
|
||||
|
||||
### 5.2 G1 — the pull build is still inert
|
||||
|
||||
```
|
||||
python3 scripts/symbol_report.py --before ~/w7/p3a-before-libMobileGL.so \
|
||||
--after build-linux/libMobileGL.so --threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0
|
||||
rc 0
|
||||
Removed (0) _none_ Added (0) _none_ Resized (0) _none_ Renamed only (0) _none_
|
||||
```
|
||||
|
||||
`~/w7/p3a-before-libMobileGL.so` is ID-9's re-captured baseline, i.e. the **pull build of `5cb826b0`**.
|
||||
|
||||
### 5.3 G5 — the ten, by the real script
|
||||
|
||||
`scripts/p3a_untouched_regions.sh` is package D's and is not in this tree; a copy of `p3a-gates`' current version
|
||||
(`/home/swung/w7/p3a-gates/scripts/p3a_untouched_regions.sh`, which already carries ID-11's tenth row) was placed in
|
||||
the tree for the run and **removed again** — the working tree is clean and nothing of D's was committed.
|
||||
|
||||
```
|
||||
bash scripts/p3a_untouched_regions.sh --self-test
|
||||
positive control: 10 bodies extracted from the working tree
|
||||
positive control: an untouched copy compares equal
|
||||
positive control: an edit outside the ten bodies is invisible
|
||||
negative control: a perturbed ClearBufferPool body is reported, and named
|
||||
negative control: a perturbed FlushPendingRangesNow body is reported, and named
|
||||
self-test passed rc 0
|
||||
|
||||
bash scripts/p3a_untouched_regions.sh 5cb826b0 HEAD rc 0
|
||||
the 10 pool / deferred-release / ring / flush-drain functions are
|
||||
byte-identical between 5cb826b0 and HEAD
|
||||
```
|
||||
|
||||
**Verdict: all TEN, including `FlushPendingRangesNow`.** Their shas at both refs:
|
||||
|
||||
```
|
||||
ba79b92dc6ebf2cb2af6aa79f23ba1941818d131812965e9f96a89caffc8e90a IsPoolable
|
||||
6563286e007650a5abb0a1bbdd7acddd901776f3e55d3c0087c8fee60aa6cc4c EnrollIntoPool
|
||||
dc9d3066b2429208e18adc27c639d16260e74b7f17f7c3f290d54f58534f089b AcquireFromPool
|
||||
12656cfd716dec50a4a4893459a7a6aaa0a635f79dda8fa51b88a819da27e5e0 TrimBufferPool
|
||||
c44a12746bcd82e55d8a635adf766e1fe2cf961ded5d9d745896fd65535bde16 ClearBufferPool
|
||||
15259e547fb514dcdcf087bbde1d048fc2d9e7901ea6c6c94a1109fb7987073a ProcessDeferredBufferReleases
|
||||
2daaa5254c38db63742ef8d6dacd25f8868c7fcd3d9745956862134cf76911d5 CreateRingStorage
|
||||
6221df2e4c0b185fbac061e956253dacd8f8d886bb3f3341cd76a26b5e1f84b1 RingAvailable
|
||||
709b6f4190c735517034b9c5d62967a9ae61f2198d2eb441dfe4e7af437cb784 RingAllocate
|
||||
c65570022a5856c1afccfd0cb42fefac707689f5bb3154c3a8e17d2495ccdf8e FlushPendingRangesNow
|
||||
```
|
||||
|
||||
At `203120fa` (before this rework) the same invocation **could not run**: two definitions of
|
||||
`FlushPendingRangesNow` is the script's exit 2.
|
||||
|
||||
### 5.4 The three integration lanes
|
||||
|
||||
```
|
||||
MOBILEGL_PIPE_PUSH=0 ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES
|
||||
rc 0 100% tests passed, 0 tests failed out of 463
|
||||
MOBILEGL_PIPE_PUSH=0x7f ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES
|
||||
rc 0 100% tests passed, 0 tests failed out of 463
|
||||
ctest --test-dir build-push -L integration-gpu --no-tests=error -j 8 -R DirectGLES (0x1ff)
|
||||
rc 8 56% tests passed, 204 tests failed out of 463
|
||||
```
|
||||
|
||||
463, not 461: `d7655247` added three `LargeArenaAdoptionScenario` cases and the rebase brought them in.
|
||||
|
||||
**Classification of the 204, and it is stronger than a classification.** The lane was run **twice against freshly
|
||||
built binaries**: once at `cdbd5535` (this package before the rework) and once at `6a1a9bc7`. Both fail **204 of 463**,
|
||||
and the failing **name sets are identical** — `comm` reports nothing on either side:
|
||||
|
||||
```
|
||||
--- failures ONLY at HEAD (new, would be mine) : (empty)
|
||||
--- failures ONLY before the rework (fixed by it) : (empty)
|
||||
```
|
||||
|
||||
So no failure in that lane is attributable to this rework. They remain the stub applier's, as `espryt-v1` §4.4
|
||||
established and as the review confirmed: with nothing emitting `resource_create` every buffer resolves to the null
|
||||
handle, and with nothing emitting `create_vertex_elements`/`bind_vertex_elements` there is no bound record. Running one
|
||||
of them directly under `MOBILEGL_LOG_FILE_PATH` confirms the two, and only the two, MGPipe diagnostics:
|
||||
|
||||
```
|
||||
MOBILEGL_LOG_FILE_PATH=… MOBILEGL_PIPE_PUSH=0x1ff MobileGLIntegrationTest \
|
||||
--gtest_filter='*OrientationScenario.OffscreenPassRendersUpright*' rc 1
|
||||
|
||||
[ERROR]: MGPipe: buffer 1 has no resource handle - the resource family is switched over but
|
||||
nothing emitted resource_create for it
|
||||
[ERROR]: MGPipe: no vertex-elements record is bound, so the driver VAO cannot be configured -
|
||||
nothing emitted create_vertex_elements/bind_vertex_elements
|
||||
```
|
||||
|
||||
No other `MGPipe` error line appears in that log. (The two `NormalizePixelFormat: unhandled internalFormat:
|
||||
GL_STENCIL_INDEX8` errors in the same log are pre-existing and unrelated to the pipe.)
|
||||
|
||||
Failures by scenario, whole list this time rather than a head:
|
||||
`ImageTargetKind` 24, `VertexAttribBinding` 13, `CrossFrameBuffer` 13, `Orientation` 11, `MultiDraw` 9, `GuiBatch` 9,
|
||||
`DrawParameters` 8, `DoublePrecision` 8, `SsboDeclarationForm` 7, `PrimitiveRestart` 7, `TessellationXfbCapture` 6,
|
||||
`XfbRepeatedCapture` 5, `XfbAfterClipDistance` 5, `ResidentIndex` 5, `ProgramPipeline` 5, `PointSizeDemotion` 5+3,
|
||||
`XfbCaptureBufferReuse` 4, `UnwrittenPositionOutput` 4, `UnboundImageDescriptor` 4, `LargeArenaAdoption` 4,
|
||||
`VertexArrayEnableDisable` 3, `UniformInitializer` 3, `SsboArrayLength` 3, `ClearThenReadPixels` 3, `AtomicCounter` 3,
|
||||
then 2s and 1s — "every scenario that draws or touches a buffer", unchanged in shape from v1.
|
||||
|
||||
### 5.5 `MOBILEGL_PIPE_LEGACY_MEMOS=0`, really built (m9)
|
||||
|
||||
A dedicated `build-nolegacy` was configured with `-DMOBILEGL_PIPE_PUSH=ON -DMOBILEGL_PIPE_LEGACY_MEMOS=OFF` and the
|
||||
rest of `build-push`'s options, and **built to completion** — the shared library, `MG_Test`'s targets and
|
||||
`MobileGLIntegrationTest`, so `MultiDraw.cpp`, `Utils.cpp` and `SanityTest.cpp` are compiled **and linked**, which
|
||||
`-fsyntax-only` never did:
|
||||
|
||||
```
|
||||
cmake -S . -B build-nolegacy -G Ninja -DMOBILEGL_PIPE_PUSH=ON -DMOBILEGL_PIPE_LEGACY_MEMOS=OFF …
|
||||
configure rc=0
|
||||
cmake --build build-nolegacy --parallel 28
|
||||
build rc=0
|
||||
MOBILEGL_PIPE_LEGACY_MEMOS:BOOL=OFF MOBILEGL_PIPE_PUSH:BOOL=ON (from CMakeCache.txt)
|
||||
build-nolegacy/libMobileGL.so
|
||||
build-nolegacy/MobileGL/MG_Test/SanityTest
|
||||
build-nolegacy/MobileGL/MG_IntegrationTest/MobileGLIntegrationTest
|
||||
ctest --test-dir build-nolegacy -L unit --no-tests=error
|
||||
100% tests passed, 0 tests failed out of 1584
|
||||
```
|
||||
|
||||
That path also exercises `ResolveVertexInputSubsystemArm`'s `kLegacyVaoArmCompiled == false` arm (M-4). The directory
|
||||
is deleted afterwards; it is not one of the three gate builds. Note that `MOBILEGL_BUILD_BENCHMARK` must be forced
|
||||
`OFF` for a fresh configure in a worktree — the vendored google-benchmark does not build with this tree's
|
||||
`-Werror` set, which is unrelated to the knob under test.
|
||||
|
||||
### 5.6 Falsifiability of the two new cases
|
||||
|
||||
Both were run with their fix reverted in the working tree, rebuilt, and observed to fail — then restored, rebuilt and
|
||||
observed to pass:
|
||||
|
||||
```
|
||||
C-1 disable the IsMapped() test -> FAILED at SanityTest.cpp:4238
|
||||
M-1 disable the Gen direction test -> FAILED at SanityTest.cpp:4277
|
||||
restore both -> [ PASSED ] 2 tests
|
||||
```
|
||||
|
||||
### 5.7 Purity and shape, re-checked after the rebase
|
||||
|
||||
```
|
||||
grep -rc 'pGLContext' MobileGL/MG_Backend | grep -v ':0$' -> empty
|
||||
grep -n 'MG_State' MobileGL/MG_Pipe/PipeApply.h -> no hit
|
||||
git status --porcelain -> clean
|
||||
git diff --stat 5cb826b0 HEAD -> SlotTables.h, Managers.h, Managers.cpp,
|
||||
DirectGLES.cpp, SanityTest.cpp only
|
||||
```
|
||||
|
||||
`g_pendingFetchBaseInstance` / `ScopedFetchBaseInstance` stay under `MOBILEGL_PIPE_LEGACY_MEMOS` as ID-10 directs, and
|
||||
the handle arm reads `MGPipeApplierState::VertexFetchBaseInstance`; nothing here changed that.
|
||||
|
||||
---
|
||||
|
||||
## 6. The exact post-rebase verification list for the integrator
|
||||
|
||||
This package has been rebased onto `feat/disaggregated` at `5cb826b0` — i.e. onto **contract only**. `wire` and
|
||||
`client` are not underneath it yet. After `git rebase refs/heads/feat/disaggregated` once those are merged, in this
|
||||
order:
|
||||
|
||||
1. **Rebuild `build-linux`, `build-push` and `build-verify` before judging anything.** A verdict from a stale
|
||||
`build-push` has already cost this package a round.
|
||||
2. `python3 scripts/symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so
|
||||
--threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0` → `0/0/0/0`.
|
||||
3. `ctest -L unit` in all three build directories; `ctest -N` name sets equal between `build-linux` and `build-push`,
|
||||
nothing removed against `~/w7/p3a-before-ctest-names.txt`, and **exactly the two additions named in §5.1**.
|
||||
4. **`bash scripts/p3a_untouched_regions.sh 5cb826b0 HEAD` and `--self-test`** — the real script, now that D has
|
||||
landed it. It must report **ten** functions, not nine. An exit **2** means a second definition of one of the ten
|
||||
has reappeared; that is a different failure from an exit 1 and must not be read as a pass.
|
||||
5. **The default-mask lane is the first execution of most of this code.** `ctest --test-dir build-push -L
|
||||
integration-gpu --no-tests=error -j 8 -R DirectGLES` with no env pin must be green. Treat a green there as
|
||||
bring-up, not as verification. The A/B in §5.4 says only that this rework introduces no failure the stub applier
|
||||
did not already produce.
|
||||
6. **Both legacy arms again**: `MOBILEGL_PIPE_PUSH=0` and `=0x7f`, same lane, both green.
|
||||
7. **The named case for C-1, in an integration lane.** `SanityTest`'s new case pins the probe's semantics but issues no
|
||||
GL. The itest the review asks for — map a sub-adoption-threshold buffer `PERSISTENT|WRITE`, write through the
|
||||
pointer with **no GL call at all**, draw, read the pixels back — is package D's to add
|
||||
(`MG_IntegrationTest` is not in C.2's list). Until it exists, `MOBILEGL_COHERENT_AS_FLUSH=1` over the two
|
||||
`coherent_as_flush: true` Create fixtures (G3b) is the nearest proxy and must be run under push **and** pull with a
|
||||
byte-for-byte path comparison, not only an SSIM pass.
|
||||
8. **The named cases for C-2**: `DoublePrecisionScenario` with an **adopted** source buffer (≥ 16 MiB, adoption
|
||||
enabled), and `StorageBufferRegrowScenario` under ASan or with pool tracing, since the reseed is the second
|
||||
dereference. A clean run of today's `DoublePrecisionScenario` does not discharge this.
|
||||
9. **`VertexArrayEnableDisableScenario` under the default mask, with a configuration that actually shrinks the enabled
|
||||
set** — the only gate that can see M-2.
|
||||
10. **Three subsystem combinations, and the third now has a defined answer**: `0x1ff`, `0x7f`, and `0x17f`. `0x17f`
|
||||
must **refuse** — an `MGLOG_E` naming bits 7 and 8 — and run the legacy vertex-input arm. G12's scenario should
|
||||
assert the refusal rather than a behaviour. `0x0ff` (bit 7 on, bit 8 off) is the supported one-family A/B.
|
||||
11. **`MOBILEGL_PIPE_LEGACY_MEMOS=0` with `MOBILEGL_PIPE_PUSH=0x7f`** — the `.Handles` itest pin — now produces a named
|
||||
verdict rather than a silent legacy run (M-4). **Integrator decision wanted (D14):** it diagnoses and does not
|
||||
stop, because a stop would turn every `.Handles` lane red before package D re-pins them (contract-review item 11).
|
||||
If D lands the `0x1ff` arm and re-pins those lanes, promote it to the `Fatal{}` that bit 5 raises.
|
||||
12. **Confirm wire's C2 is in the merged tree** — the applier reset must **advance** `VertexBuffersSerial` and
|
||||
`IndexBufferSerial`, not zero them. `Managers.cpp:3974` says so at the gate. `wire-v2` records the fix at
|
||||
`PipeApply.cpp:628-646` (`++` at every reset, with mutation M15 going red when it is reverted), so this
|
||||
precondition is expected to hold — but it is a **hard merge gate**: if a later rebase or a revert puts the `= 0`
|
||||
back, the twin's attribute gate can read clean over state the applier has just cleared, and this package must not
|
||||
be merged. (`wire`'s C1 — the records now survive a make-current — only narrows how often the state this gate
|
||||
guards against arises; the serial rule is what the gate depends on.)
|
||||
13. `MOBILEGL_ESPRYT_DISABLE_INVALIDATE_FLUSH=1 ctest --test-dir build-push -L integration-gpu -j 8` — D.3's named
|
||||
step; this package rewrote that kill switch's caller.
|
||||
14. `ctest --test-dir build-verify -L integration-verify` and the verify retrace sweep (`grep -l 'Fatal{'` empty,
|
||||
`grep -L 'MGPipe verify:'` empty), plus `ctest --test-dir build-verify -R HandleRecycle` (G8) including package D's
|
||||
buffer arm.
|
||||
15. **The retrace sweep**: `python3 ~/w7/retrace_gate.py --tree ~/w7/p3a-espryt --lib build-push/libMobileGL.so --out
|
||||
~/w7/retrace-out/p3a-espryt -j 4`, plus G3b's named `--only` set.
|
||||
16. **The buffer/VAO family by name** under the default mask (C.2's last regex), watching `DoublePrecisionScenario`
|
||||
(D7), the two `VertexAttribBindingScenario` base-instance cases and all eight `DrawParametersScenario` cases
|
||||
(D2/D-H2 — and ID-10's three client call sites, which must be present for them to go green),
|
||||
`PrimitiveRestart`/`ResidentIndex`/`MultiDraw` (the element-array restores against `m_syncedIndexSerial`),
|
||||
`CrossFrameBuffer`/`StreamedArena` (the Mali WAR queue-only `SubData` and the tier ladder),
|
||||
`LargeArenaAdoption`/`StorageBufferRegrow` (`Ops_H_MapPersistent`, `mpr`, `InvalidateIndexedBufferBindingShadowsForId`,
|
||||
**and `d7655247`'s three new cases** — the handle-arm half of that fix has never run), and
|
||||
`AtomicCounter`/`BufferTexture`/`PackedWordReadback`/`XfbCaptureBufferReuse` (the reverse channel and the epoch
|
||||
order).
|
||||
17. **Two contract points to confirm against the merged `client`**, both now written into this package's code:
|
||||
`OnGpuWritten`'s whole-resource range shape **and** that the client's implementation sets `m_hasDefinedContent`
|
||||
as well as `m_gpuWritePending` (m8); and that `MGPVertexBuffer::BindingIndex` is the attribute index for every
|
||||
entry (D-H3), which `VertexBufferForBindingIndex`'s fast path assumes.
|
||||
18. **Record the per-draw handle-resolution cost in D.4** (m6). It is now memoised through the slot table's front
|
||||
memo, so the number to publish is the memo's hit rate, not a raw `FindByLifetimeId` count.
|
||||
19. `bash scripts/p3a_vertex_input_negative_control.sh` and package D's `ResourceSubsystemControlScenario`, which are
|
||||
what turn M-3's refusal and M-4's verdict from log lines into assertions.
|
||||
|
||||
**Still open and NOT this package's to close**, recorded so it is not lost: `wire-review-v1` M-D (the applier's
|
||||
`RecordAt` resizes on an unbounded client slot — the backend half is bounded here, the applier half is A's); the
|
||||
dangling-`ResolvedDrawBuffers::Entry::resource` invariant after `ReleaseByHandle` (both consumers check identity
|
||||
through `FindByHandle` first, so nothing is dereferenced today, but the invariant is the only thing between that memo
|
||||
and a use-after-free and deserves a sentence at the member in a later pass).
|
||||
|
||||
---
|
||||
|
||||
*Intermediate logs (`~/w7/p3a-espryt2-{lanes,ab,nolegacy}.log`, `build-nolegacy/`, the scratchpad's WSL scripts and
|
||||
the copied `scripts/p3a_untouched_regions.sh`) are deleted; `git status` is clean.*
|
||||
@@ -0,0 +1,616 @@
|
||||
# P3a package C — Espryt verification round (`espryt-v3`)
|
||||
|
||||
Branch `p3a/espryt`, worktree `/home/swung/w7/p3a-espryt`, **rebased onto `refs/heads/feat/disaggregated`
|
||||
(`31e370be` = contract + dev merge + wire + client + the two version bumps)** and then **three new commits**.
|
||||
**Not pushed.** Every file touched is still in C.2's list; `MultiDraw.cpp` and `Utils.cpp` are untouched.
|
||||
|
||||
**This is the round in which the handle path executed for the first time against real emitters and real applier
|
||||
bodies.** It found three defects, all in C.2's files, all fixed and all with a measured before/after. It also
|
||||
found one red that is **not** this package's — 26 `BufferTest` unit cases — with a proof of ownership and the
|
||||
exact one-line fix for the owner (§7).
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| rebase | clean, **no conflict**, 16 commits replayed |
|
||||
| new commits | `13b380fe`, `75ea7ee2`, `3c55e027` |
|
||||
| HEAD | `3c55e027` |
|
||||
| default-mask integration lane | **920 / 920 green** (was 204/463 red on the stub base, 13 red on the first run of this tree) |
|
||||
| retrace | **79/79 push, 79/79 verify-armed, 0 Fatal** |
|
||||
| still red | 26 `BufferTest` unit cases — package-boundary, §7 |
|
||||
|
||||
---
|
||||
|
||||
## 1. The rebase
|
||||
|
||||
```
|
||||
git rebase refs/heads/feat/disaggregated Successfully rebased and updated refs/heads/p3a/espryt
|
||||
```
|
||||
|
||||
**No conflict, and this time no hidden trap either** (the ID-9 three-way-merge trap of the previous round was
|
||||
about `Managers.cpp` and dev's `d7655247`; `31e370be` adds nothing in `MG_Backend`). All sixteen commits
|
||||
replayed: `6a1a9bc7 → ed83424c` at the tip, `9ae4ec09/4db6bf1e → 9951961d` at the base. `git diff --stat`
|
||||
against the new base names exactly `SlotTables.h`, `Managers.h`, `Managers.cpp`, `DirectGLES.cpp`,
|
||||
`SanityTest.cpp`.
|
||||
|
||||
One environmental repair was needed before the retrace could run: **this worktree's
|
||||
`tools/trace_replay/fixtures` were LFS pointers** (7.7 MB of 131/133-byte stubs against 803 MB in `~/w7/pipe`),
|
||||
so the first retrace invocation reported `passed 2 / 79` with `rc=1 0s ssim=None` on every Minecraft case —
|
||||
a missing-fixture failure that reads exactly like a total regression. They were materialised by copying
|
||||
`~/w7/pipe/tools/trace_replay/fixtures/.` over them; the 92 `assume-unchanged` entries were already set, so
|
||||
`git status` stayed clean. **Recorded for the integrator: a package worktree's fixtures are not materialised by
|
||||
`wsl_tree.sh`, and a retrace run against pointer files is a false red.**
|
||||
|
||||
---
|
||||
|
||||
## 2. The two cross-package items
|
||||
|
||||
### B-M3 — the `hostBytes` convention (client passes shadow base + offset)
|
||||
|
||||
**Already conformant; no change was needed, and the report that said otherwise was wrong about the code.**
|
||||
|
||||
`client-v2.md` §5 item 1 asks espryt to move its latch because the client sends `base + at` on
|
||||
`resource_subdata` and `base + offset` on `resource_flush_range`. The handle arm has **always** subtracted:
|
||||
|
||||
```cpp
|
||||
Ops_H_SubData (Managers.cpp:1921): if (bytes != nullptr) resource->hostBytes = static_cast<const Uint8*>(bytes) - offset;
|
||||
Ops_H_FlushRange (Managers.cpp:1969): if (bytes != nullptr) resource->hostBytes = static_cast<const Uint8*>(bytes) - start;
|
||||
```
|
||||
|
||||
`git log -S` puts both lines in `e2` (`4e446501`, the original switch-over commit), not in any later one. The
|
||||
subtrahends are the right ones: `offset` is `MG_Pipe::MGPipeSubDataBufferOffset(record)`, which
|
||||
`MGPipeTypes.h:661` defines as the record's `UnionBox.X`, i.e. exactly the `at` the client adds
|
||||
(`PipeFill.cpp:650` `MGPipeApplyResourceSubData(record, base + at)` beside
|
||||
`MGPipeBuildSubDataRecord(handle, at, …)`); `start` is `record.Offset`, which the client adds at
|
||||
`PipeFill.cpp:701`. `Ops_H_Respecify` takes the pointer verbatim because the client sends the true base there
|
||||
(`PipeFill.cpp:640`), and `Ops_H_ResidentSubData` records nothing (D10), which matches the client's
|
||||
`base + (at - offset)` staging pointer.
|
||||
|
||||
So `espryt-v1.md` §1's phrase "latches the client's shadow base" described the *value after the subtraction*,
|
||||
which is what it is. **B does not change and C did not need to.** The behavioural half is now also observed
|
||||
rather than argued: `CrossFrameBufferScenario`'s non-zero-offset flush and `StreamedArenaScenario`'s two
|
||||
recycle cases — the shape `client-v2` named as the one that would catch it — are green in the default-mask
|
||||
lane (§4, L1/L4), and they were green with the same code before and after this round, so nothing here is a
|
||||
new claim.
|
||||
|
||||
### ID-13 — one `FlushPendingRangesNow`, and the handle arm's separate ladder
|
||||
|
||||
Confirmed, with the residual difference from ID-13's literal text stated rather than glossed:
|
||||
|
||||
* **Defined exactly once.** `grep -n FlushPendingRangesNow Managers.cpp` finds one definition
|
||||
(`:1316`) and two call sites (`:1723`, `:2872`), plus two comments. Package D's script exits **2** on a
|
||||
second definition, and it exited **0**.
|
||||
* **Byte-identical to `5cb826b0`.** Its extracted-body sha is
|
||||
`c65570022a5856c1afccfd0cb42fefac707689f5bb3154c3a8e17d2495ccdf8e` at both refs.
|
||||
* **`FlushPendingRangesFrom` is the separate ladder** (`:1051`, under `#if MOBILEGL_PIPE_PUSH`), with four
|
||||
call sites (`:1721`, `:2044`, `:2732`, `:2870`).
|
||||
* **No hunk lands inside any of the ten.** `git diff 5cb826b0 HEAD -- Managers.cpp` is 16 hunks (`-U0`), and
|
||||
the gate below proves none of them touches a protected body.
|
||||
|
||||
**The one deviation from ID-13's wording, and it is `espryt-v2`'s declared D12, not a regression:** ID-13 says
|
||||
"defined exactly once, **outside any `#if`**". The definition sits in the `#else` of
|
||||
`#if MOBILEGL_PIPE_PUSH` (verified by walking the preprocessor nesting: guard stack at `:1316` is
|
||||
`#else of #if MOBILEGL_PIPE_PUSH`), so a **push build contains no `FlushPendingRangesNow` at all** and its
|
||||
legacy arm calls `FlushPendingRangesFrom` instead. Consequences, stated plainly so the integrator can rule:
|
||||
|
||||
* both gates ID-13 names are satisfied — G1 (the pull build's text and symbol set are untouched) and G5 (the
|
||||
extractor finds one definition and it is byte-identical);
|
||||
* a push build contains **one** tier ladder, which is what ID-11's row exists for;
|
||||
* the price is that in a push build the `MOBILEGL_PIPE_PUSH=0` / `0x7f` arms run
|
||||
`FlushPendingRangesFrom` rather than the frozen body. The only textual difference between the two ladders is
|
||||
`espryt-v2` m4's added `if (hostBase == nullptr) return;`, unreachable on the legacy arm. Both legacy arms
|
||||
are 920/920 green (§4).
|
||||
|
||||
Taking ID-13 literally instead would compile **two** ladders in every push build. This round did not change
|
||||
the shape; it is recorded here because the task's wording ("defined exactly once, byte-identical … and the
|
||||
handle arm's `FlushPendingRangesFrom` is the separate ladder") is met exactly, while ID-13's "outside any
|
||||
`#if`" is not.
|
||||
|
||||
### Package D's G5 script, and whether it accepts a foreign cwd
|
||||
|
||||
**It does not, and an invocation that looks like it worked is a false pass.**
|
||||
`scripts/p3a_untouched_regions.sh` self-locates: `REPO_ROOT=$(cd "$(dirname "$0")/.." && pwd); cd "$REPO_ROOT"`.
|
||||
Running `bash /home/swung/w7/p3a-gates/scripts/p3a_untouched_regions.sh 5cb826b0 HEAD` from
|
||||
`/home/swung/w7/p3a-espryt` exits 0 and prints "byte-identical between 5cb826b0 and HEAD" — but it has `cd`-ed
|
||||
into `p3a-gates` first, so `HEAD` is **gates' HEAD**, not espryt's. The authoritative form, which needs no copy
|
||||
of D's file in this tree, is to run it from gates' worktree against espryt's ref (the worktrees share
|
||||
`/home/swung/w7/pipe/.git`, so `git show <ref>:<path>` reaches it):
|
||||
|
||||
```
|
||||
cd /home/swung/w7/p3a-gates && bash scripts/p3a_untouched_regions.sh 5cb826b0 p3a/espryt rc 0
|
||||
[p3a-untouched] the 10 pool / deferred-release / ring / flush-drain functions are
|
||||
[p3a-untouched] byte-identical between 5cb826b0 and p3a/espryt
|
||||
bash scripts/p3a_untouched_regions.sh --self-test rc 0
|
||||
positive control: 10 bodies extracted / an untouched copy compares equal / an edit outside the ten is invisible
|
||||
negative control: a perturbed ClearBufferPool body is reported, and named
|
||||
negative control: a perturbed FlushPendingRangesNow body is reported, and named
|
||||
```
|
||||
|
||||
The ten shas are unchanged from `espryt-v2` §5.3.
|
||||
|
||||
---
|
||||
|
||||
## 3. The three defects this round found, and the fixes
|
||||
|
||||
The first execution of the handle path under real traffic left **13 failures** in the default-mask
|
||||
integration lane (920 entries). Two of the thirteen (`DirectVulkan.PrimGenReroute.…ActuallyArmed…` and
|
||||
`DirectVulkan.PointSizeDemotion.…ActuallyArmed…`) are the shared-log-file race `client-v2` §6 item 6 names and
|
||||
appear only in a `-j 8` run; they are absent from every `-j 4` run and from the serial reruns, and neither
|
||||
touches a file this package edits. The other **eleven** were real, and a mask bisect split them cleanly:
|
||||
|
||||
| mask | failures |
|
||||
|---|---|
|
||||
| `0x7f` (both subsystems off) | 0 |
|
||||
| `0xff` (bit 7 resources only) | 5 — `XfbCaptureBufferReuse` ×4, `LargeArenaAdoption.RespecifiedIndexArenaKeepsVaoBinding` |
|
||||
| `0x1ff` (both) | 11 — the five above plus `VertexAttribBinding` ×6 |
|
||||
|
||||
i.e. one defect in the vertex-input family and one in the resource family, plus a third that only the third
|
||||
of them exposed.
|
||||
|
||||
### F1 — `13b380fe` — the vertex-buffer entry was resolved by the attribute's GL **binding point**, not by its **attribute index**
|
||||
|
||||
`Managers.cpp:3647` (the helper, renamed `VertexBufferForBindingIndex` → `VertexBufferForAttributeIndex`),
|
||||
`:4070` (the call site).
|
||||
|
||||
```cpp
|
||||
- VertexBufferForBindingIndex(st, attrib.BindingIndex);
|
||||
+ VertexBufferForAttributeIndex(st, attribIndex);
|
||||
```
|
||||
|
||||
`MGPVertexBuffer::BindingIndex` and `MGPVertexAttribWire::BindingIndex` are two different numbers.
|
||||
Espryt consumes **resolved** attributes, so the client emits `set_vertex_buffers` as one entry per attribute
|
||||
slot with `MGPVertexBuffer::BindingIndex == the attribute index` (`VertexInputEmit.h:190-193`, `:229` —
|
||||
"Espryt consumes RESOLVED attributes, so the set is one entry per attribute slot with BindingIndex == the
|
||||
attribute index"), each carrying that attribute's already-folded buffer, stride and divisor.
|
||||
`MGPVertexAttribWire::BindingIndex` is the GL **binding point** the attribute was attached to by
|
||||
`glVertexAttribBinding` (`VertexInputEmit.h:325`: `vao.GetAttributeBindingIndex(i)`) and is the key of the
|
||||
binding-point view — a view **this arm never reads**, because the resolution already happened on the client.
|
||||
The helper's own comment already said the entries are keyed by attribute index; only the call site disagreed.
|
||||
|
||||
The two numbers coincide for every attribute configured through `glVertexAttribPointer`, which is why every
|
||||
other scenario stayed green. They differ exactly in `KHR-GL43.vertex_attrib_binding`'s subject:
|
||||
`glVertexAttribBinding(2, 3)`, `glVertexAttribBinding(0, 5)`, `glVertexAttribBinding(1, 0)` — the six
|
||||
`VertexAttribBindingScenario` cases that failed, all of which read the disabled/zero default
|
||||
(`point 0 attribute 2 is (0, 0, 0, 0)`) because the lookup found the wrong entry or none.
|
||||
|
||||
**Measured:** the six went to three immediately after this fix alone (the three fp64 ones survived to F3).
|
||||
|
||||
### F2 — `75ea7ee2` — the ensure path asked a descriptor no content call refreshes whether the shadow held bytes
|
||||
|
||||
`Managers.cpp:2759-2761` (`EnsureBufferResourceForHandle`).
|
||||
|
||||
```cpp
|
||||
- const void* initialData = record->Desc.HasDefinedContent != 0 ? hostBase : nullptr;
|
||||
+ const Bool shadowHasContent =
|
||||
+ bufferObject ? bufferObject->HasDefinedContent() : (record->Desc.HasDefinedContent != 0);
|
||||
+ const void* initialData = shadowHasContent ? hostBase : nullptr;
|
||||
```
|
||||
|
||||
`MGPResourceDesc::HasDefinedContent` states what was true at the last `resource_respecify` and **nothing
|
||||
refreshes it afterwards**: `NotifySubData` (`BufferObject.cpp:85`), `NotifyFlushMappedRange` (`:101`),
|
||||
`NotifyContentWrite` (`:127`), `MarkGpuWritten` (`:365`) and `LandBytesIntoResidentStore` (`:441`, `:459`) all
|
||||
set the frontend's `m_hasDefinedContent` without re-emitting a descriptor, and re-emitting one per
|
||||
`glBufferSubData` would be new wire traffic D-J forbids. The legacy arm never had the problem because
|
||||
`RespecifyStorageNow` (`Managers.cpp:967-968`) reads `bufferObject.HasDefinedContent()` **and**
|
||||
`bufferObject.MappedData()` — the source of the bytes and the statement about them come from the same object.
|
||||
The handle arm paired the frontend's pointer with the applier's descriptor, and the two disagreed after the
|
||||
commonest idiom in the corpus:
|
||||
|
||||
```
|
||||
glBufferData(target, size, NULL, usage) -> Desc.HasDefinedContent = 0
|
||||
glBufferSubData(target, 0, size, data) -> record.Serial moves; the twin queues the range
|
||||
(or: the twin does not exist yet, and the call is dropped by design - "lazy: the ensure path full-uploads")
|
||||
draw -> EnsureBufferResourceForHandle: pendingRespecify -> RespecifyStorageWith(size, usage, NULL, serial)
|
||||
which CLEARS pendingRanges and STAMPS syncedChangeSerial
|
||||
```
|
||||
|
||||
— an empty store, declared current, with the application's bytes dropped and no diagnostic anywhere. It is a
|
||||
silent wrong-pixels defect, not a crash.
|
||||
|
||||
**Measured, with the instrumented build** (temporary `MGLOG_E` traces, removed before the commits):
|
||||
|
||||
```
|
||||
before TRACE respecifyWith id=1 size=16 data=(nil) serial=2 extentChanged=1
|
||||
after TRACE ensure {2,0} … pendRes=1 init=0 ranges=0 synced=5 serial=8 content=1 host=0x5b73c1bad3c0
|
||||
TRACE respecifyWith id=2 size=4096 data=0x5b73c1bad3c0 serial=8 extentChanged=1
|
||||
```
|
||||
|
||||
That first line is `XfbCaptureBufferReuseScenario`'s **vertex** buffer (`glBufferData(16, nullptr)` in the
|
||||
fixture, then `glBufferSubData` in `SetVertex`): its store was created empty, so the capture program captured
|
||||
zeros and every span read back `component 0 is 0, expected 10`. The second is
|
||||
`LargeArenaAdoptionScenario.RespecifiedIndexArenaKeepsVaoBinding`'s final `glBufferData(4096, nullptr)` +
|
||||
`glBufferSubData(elements)` after the 24 MiB adopted arena is retired — the element store came up empty and
|
||||
the draw was black ("VAO did not fetch the replacement index store").
|
||||
|
||||
**Closed by this commit alone:** all four `XfbCaptureBufferReuse` cases and the `LargeArenaAdoption` index
|
||||
case, i.e. every `0xff` failure.
|
||||
|
||||
The read is **declared**, exactly like C-1's `IsMapped()`: it is a frontend read this function keeps for P3a
|
||||
(the signature already carries the object for D-N's `SyncPersistentMappedRange`, and C-2 already re-reads
|
||||
`MappedData()` from it at every use) and it retires the moment the client publishes a live content flag beside
|
||||
the descriptor. With no frontend object — the handle-only drains — the descriptor is all there is, and that is
|
||||
what the `?:` says. **This is not the prohibited "re-read `MGB_CTX` to make a lane pass"**: no GL context is
|
||||
read, the object is the one this function is already given, and the alternative (a twin-side
|
||||
`hostContentDefined` mirroring six frontend setters, two of which — `NotifyContentWrite` on a resident store,
|
||||
and the write-map path at `BufferObject.cpp:209` — emit no wire call at all) could not be proven equivalent
|
||||
today. That alternative is the P5/P8 shape and is named in the comment.
|
||||
|
||||
### F3 — `3c55e027` — a lazily twinned store never published a shadow base, so the fp64 narrowing refused every draw
|
||||
|
||||
`Managers.cpp:2741` (`EnsureBufferResourceForHandle`).
|
||||
|
||||
```cpp
|
||||
+ if (hostBase != nullptr) resource->hostBytes = hostBase;
|
||||
```
|
||||
|
||||
`resource->hostBytes` is what the readers that hold **no** frontend object read, and there are three:
|
||||
`Ops_H_Readback`'s queue flush (`:2048`), `Ops_H_FlushRange`'s kill-switch map arm (`:2005`), and
|
||||
`SyncFloat64AttributeAsFloat32ByHandle` (`:4479-4482`, whose legacy counterpart reads
|
||||
`bufferObject->MappedData()`). It is written by the content-carrying ops — but a twin is created **lazily**,
|
||||
because D-A2's row makes `Ops_H_Create` a no-op, so the very first `resource_respecify` of a buffer finds
|
||||
`FindBufferResourceForHandle == nullptr` and drops its base on the floor:
|
||||
|
||||
```
|
||||
TRACE respecify {2,0} width=16 defined=1 bytes=0x5fdd854e5440 res=(nil) id=0 storeSize=0
|
||||
```
|
||||
|
||||
For the ordinary static vertex array — `glGenBuffers` + `glBufferData(size, data)` and no further content
|
||||
call — `hostBytes` then stayed **null for the object's whole life**. The full re-upload never noticed (it uses
|
||||
`liveHostBase()`), but the fp64 narrowing did: `sourceBase == nullptr` → `return false` → the Adreno
|
||||
workaround disables the array → the shader reads the disabled default `(0, 0, 0, 1)`. That is exactly what
|
||||
`DoubleArrayIsFetchedAtFloat32Precision`, `NormalizedIsIgnoredForDoubleArrays` and
|
||||
`LongDoubleArrayIsFetchedAtFloat32Precision` reported.
|
||||
|
||||
The refresh is placed where the base is already computed, which is the one place that both holds the object
|
||||
and runs before every draw that uses the store. It is reached **only for a non-adopted resource** (the adopted
|
||||
arm returns at `:2683`), so C-2's rule is intact: an adopted store's `hostBytes` stays null and its bytes are
|
||||
read through `persistentPtr`.
|
||||
|
||||
**Closed by this commit:** the last three `VertexAttribBinding` failures. After it the whole lane is
|
||||
920 / 920.
|
||||
|
||||
### Instrumentation hygiene
|
||||
|
||||
Five temporary `MGLOG_E("TRACE …")` lines (in `Ops_H_Respecify`, `Ops_H_Readback` ×2, `RespecifyStorageWith`
|
||||
and `EnsureBufferResourceForHandle`) were used to obtain the traces above. They were **removed before any
|
||||
commit**; the reconstruction of the three commits was diffed against the verified working tree and is
|
||||
code-identical (the only textual difference is one re-wrapped comment line). `grep -n "TRACE " Managers.cpp`
|
||||
is empty at HEAD.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verification transcript
|
||||
|
||||
All in `/home/swung/w7/p3a-espryt` at `3c55e027`, `CCACHE_BASEDIR=/home/swung/w7`. All three build directories
|
||||
were rebuilt before anything was judged. `build-verify` was configured with the COMMON flags of
|
||||
`~/w7/notes/tools/wsl_p3a_gate.sh` plus `-DMOBILEGL_PIPE_VERIFY=ON -DMOBILEGL_ITEST_REQUIRE_GPU=ON`.
|
||||
|
||||
### 4.1 Builds and unit
|
||||
|
||||
```
|
||||
cmake --build build-linux -j 24 rc 0
|
||||
cmake --build build-push -j 24 rc 0
|
||||
cmake --build build-verify -j 24 rc 0
|
||||
|
||||
ctest --test-dir build-linux -L unit -j 12 100% passed, 0 failed out of 1619
|
||||
ctest --test-dir build-push -L unit -j 12 98% passed, 26 failed out of 1619 <-- §7, NOT this package's
|
||||
ctest --test-dir build-verify -L unit -j 12 98% passed, 26 failed out of 1619 <-- the same 26
|
||||
```
|
||||
|
||||
The 26 are the whole and only red left on this tree. They are `BufferTest.*` and they are a test-fixture
|
||||
collision at the client×espryt seam; §7 proves the ownership and gives the fix, which was measured green.
|
||||
|
||||
### 4.2 G1 — the pull build is still inert
|
||||
|
||||
```
|
||||
python3 scripts/symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so \
|
||||
--threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0 rc 0
|
||||
symbol-report: .text 10806323 -> 10806323 (+0, +0.000%) .data +0 .bss +0 .rodata +0
|
||||
symbol-report: Total 17226471 -> 17226471 (+0)
|
||||
symbol-report: 27811 -> 27811 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
|
||||
```
|
||||
|
||||
**0 / 0 / 0 / 0.** `~/w7/p3a-before-head.txt` reads `b9eaa474…`, i.e. ID-8d's re-captured baseline (the pull
|
||||
build taken after the two version bumps), which is this branch's base.
|
||||
|
||||
### 4.3 Names — G2's name half, and G14
|
||||
|
||||
```
|
||||
ctest -N: build-linux 2539 build-push 2539 build-verify 3371
|
||||
diff <linux names> <push names> -> EMPTY (0 lines)
|
||||
comm -23 ~/w7/p3a-before-ctest-names.txt <linux names> -> 0 removed
|
||||
comm -13 ... -> 20 added
|
||||
```
|
||||
|
||||
**0 removed.** The 20 added are this package's **two** (`DirectGLESBufferDrawProbe.ALiveHostMapKeeps…`,
|
||||
`DirectGLESSlotTable.AGenerationBehindTheLiveTwinIsRefused…`, both running in `build-push` and **skipping
|
||||
visibly** in `build-linux`) plus **18** from the merged client/wire (`ResourceEmit.*` ×7,
|
||||
`VertexInputEmit.*` ×7, `TrackerWalk.*` ×3, `TrackerShippedEmitter.*` ×1). This round adds no test name.
|
||||
|
||||
### 4.4 G5 — the ten byte-identical functions
|
||||
|
||||
`rc 0`, see §2. Self-test `rc 0`, both negative controls tripped and named.
|
||||
|
||||
### 4.5 Purity
|
||||
|
||||
```
|
||||
grep -rc 'pGLContext' MobileGL/MG_Backend | grep -v ':0$' -> empty
|
||||
grep -c 'MG_State' MobileGL/MG_Pipe/PipeApply.h -> 0
|
||||
git status --porcelain -> clean
|
||||
```
|
||||
|
||||
`g_pendingFetchBaseInstance` / `ScopedFetchBaseInstance` still have hits and every one is inside a
|
||||
`MOBILEGL_PIPE_LEGACY_MEMOS` arm (`Managers.h:1191-1200`, `Managers.cpp:3523-3530`, `:3745`,
|
||||
`DirectGLES.cpp:5293`) — D2, unchanged.
|
||||
|
||||
### 4.6 The integration lanes — every arm green
|
||||
|
||||
Run **serially**, no competing load (the protocol `client-v1` established for the
|
||||
`…ActuallyArmedWhenTheEnvironmentPinsItOn` family).
|
||||
|
||||
| # | lane | result |
|
||||
|---|---|---|
|
||||
| L1 | `ctest --test-dir build-push -L integration-gpu -j 8` (**DEFAULT mask 0x1ff, both backends**) | rc 0 — **100%, 0 failed of 920** |
|
||||
| L2 | the same with `MOBILEGL_PIPE_PUSH=0` | rc 0 — 100%, 0 of 920 |
|
||||
| L3 | the same with `MOBILEGL_PIPE_PUSH=0x7f` | rc 0 — 100%, 0 of 920 |
|
||||
| L4 | the buffer/VAO family, `-j 4 -R 'LargeArenaAdoption\|StorageBufferRegrow\|VertexAttribBinding\|MultiDraw\|PrimitiveRestart\|CrossFrameBuffer\|ResidentIndex\|BufferTexture\|AtomicCounter\|XfbCaptureBufferReuse\|PackedWordReadback\|DoublePrecision\|VertexArrayEnableDisable\|DrawParameters'` | rc 0 — **100%, 0 failed of 184** |
|
||||
| L5 | `MOBILEGL_ESPRYT_DISABLE_INVALIDATE_FLUSH=1 … -j 8` (D.3's named kill-switch arm) | rc 0 — 100%, 0 of 920 |
|
||||
| L6 | `ctest --test-dir build-verify -L integration-verify -j 4` | rc 0 — **100%, 0 failed of 832**, **`Fatal{` lines: 0** |
|
||||
| L7 | `MOBILEGL_PIPE_PUSH=0xff` (bit 7 alone, the supported one-family A/B) | rc 0 — 100%, 0 of 920 |
|
||||
| L8 | `MOBILEGL_PIPE_PUSH=0x17f` (bit 8 without bit 7) | rc 0 — 100%, 0 of 920, and the refusal fires (below) |
|
||||
|
||||
**`DoublePrecisionScenario` — the declared watch item — is green** in L1 and L4 and needed no fix. D7's
|
||||
`SyncGpuWrites` gap on `SyncFloat64AttributeAsFloat32ByHandle` is still real and still declared; it is only
|
||||
observable when the fp64 **source buffer** is shader-written and not yet pulled back, which no scenario in the
|
||||
corpus does. What `DoublePrecisionScenario` and the three `VertexAttribBinding` fp64 cases *did* expose is F3,
|
||||
which was a different defect on the same function (a null source base, not a stale one) and is fixed.
|
||||
|
||||
**L8 / espryt-v2 §6 item 10** — `0x17f` refuses, by name, and runs the legacy vertex-input arm:
|
||||
|
||||
```
|
||||
[ERROR]: MGPipe: kMGPipeSubsystemVertexInput (bit 8) is set but kMGPipeSubsystemResources (bit 7) is clear;
|
||||
the vertex-input handle arm resolves attribute buffer ids through the resource slot table, which only
|
||||
bit 7 populates - REFUSING bit 8 and running the legacy vertex-input arm. Set bit 7 as well, or clear both
|
||||
```
|
||||
|
||||
### 4.7 ID-10 — the base-instance control, both directions
|
||||
|
||||
The brief asks for the base-instance scenarios green on this tree and red with the three
|
||||
`MG_Impl/GLImpl/Drawing/GL_Drawing.cpp` call sites stubbed out. **The plain form of that control is not
|
||||
falsifiable on this host, and the reason is a capability, not a defect:**
|
||||
|
||||
```
|
||||
[INFO]: base instance (EXT_base_instance; emulated by attribute offsets when absent): yes
|
||||
```
|
||||
|
||||
llvmpipe exposes `GL_EXT_base_instance` and all three entry points, so
|
||||
`BackendUsesNativeBaseInstance()` (`Managers.cpp:3569` = `g_GLESCapabilities.SupportsBaseInstance`) is **true**
|
||||
and `Managers.cpp:4044` forces `fetchBaseInstance` to `0` — the attribute-offset emulation, which is the
|
||||
**only** consumer of `MGPipeApplierState::VertexFetchBaseInstance` anywhere in the backend, never runs. First
|
||||
experiment, measured: with the three call sites stubbed out, the base-instance scenarios were **10/10 green**
|
||||
and the whole lane was **920/920 green**.
|
||||
|
||||
So the control was run in the configuration where the pushed value is observable — the emulation — by forcing
|
||||
**both** native-base-instance gates false (`Managers.cpp:3569` and `DirectGLES.cpp:5276`'s
|
||||
`UseNativeBaseInstance()`; forcing only the first double-applies the shift, which is itself a positive proof
|
||||
that the pushed value reaches the fetch, and was measured: 2/10 red with the call sites **present**, 10/10
|
||||
green with them stubbed — the inverse, exactly as a double shift predicts).
|
||||
|
||||
| experiment (temporary, in place, never committed) | base-instance scenarios | whole lane |
|
||||
|---|---|---|
|
||||
| **F1** both native gates forced false (emulation live), the three call sites **present** | **10 / 10 PASS** | 920 / 920 |
|
||||
| **F2** both native gates forced false, the three call sites **STUBBED OUT** | **8 / 10 — 2 FAILED** | — |
|
||||
| restored (`git checkout --` on all three files) | 10 / 10 PASS | 920 / 920 |
|
||||
|
||||
The two that go red are `VertexAttribBindingScenario.BaseInstanceMovesTheInstancedArraysStartElement` and
|
||||
`BaseInstanceLeavesPerVertexArraysWhereTheyWere`. **`DrawParametersScenario`'s eight cases stay green in both
|
||||
directions**, and that is correct rather than a hole: they observe `gl_BaseInstance` / `gl_DrawID`, which come
|
||||
from `SetCurrentBaseInstance` — "orthogonal and runs either way — it feeds the shader's `gl_BaseInstance`, not
|
||||
the fetch" (`DirectGLES.cpp:5272-5274`). **The ID-10 gate is the two `VertexAttribBinding` base-instance
|
||||
cases, not the `DrawParameters` eight**, and the integrator should record that correction.
|
||||
|
||||
`git status` was verified clean and the tree rebuilt after every experiment; `grep -rc 'ID-10 CONTROL,
|
||||
TEMPORARY'` is 0 in all three files.
|
||||
|
||||
### 4.8 The retrace, both sweeps
|
||||
|
||||
```
|
||||
python3 ~/w7/retrace_gate.py --tree ~/w7/p3a-espryt --lib ~/w7/p3a-espryt/build-push/libMobileGL.so \
|
||||
--out ~/w7/retrace-out/p3a-espryt -j 4 rc 0
|
||||
passed 79 / 79; failed: []
|
||||
logs 79, with Fatal{: 0
|
||||
|
||||
MOBILEGL_PIPE_VERIFY=1 python3 ~/w7/retrace_gate.py --tree ~/w7/p3a-espryt \
|
||||
--lib ~/w7/p3a-espryt/build-verify/libMobileGL.so \
|
||||
--out ~/w7/retrace-out/p3a-espryt-verify -j 4 rc 0
|
||||
passed 79 / 79; failed: []
|
||||
logs 79; armed (MGPipe verify: present) 79; NOT armed 0; with Fatal{: 0
|
||||
```
|
||||
|
||||
Every case at or above its own SSIM threshold on both backends (`rd12-odinlite` 1.0 / 0.999991,
|
||||
`1.21.4-in-world` 0.999976, `1.21.4-main-menu` 0.997009, `OpenRA` 1.0/1.0, `startup` 1.0/1.0). **This is the
|
||||
first verify-armed retrace of the whole corpus with the backend switched over**: the compare-at-read re-reads
|
||||
every migrated field from the live context at every backend read and found zero divergence and zero
|
||||
unmigrated reads. No `Fatal{UnmigratedPipeInput}`, so no `FillPoints.def` row is owed. Both output trees were
|
||||
deleted afterwards (`retrace-out/p3a-espryt*` → 0 left).
|
||||
|
||||
### 4.9 D.4.6 — peak RSS
|
||||
|
||||
**Not available, so skipped.** `~/w7/retrace_gate.py` has five arguments (`--tree --lib --out -j --only`) and
|
||||
contains no `rss` / `maxrss` / `getrusage` reference at all (`grep -ci` → 0). A push-vs-pull peak-RSS reading
|
||||
over the retrace would need the gate to grow the measurement; it is not something this round can report
|
||||
without changing package D's tool.
|
||||
|
||||
### 4.10 Cross-package confirmations owed by `espryt-v2` §6
|
||||
|
||||
| item | result |
|
||||
|---|---|
|
||||
| 12 — wire's C2: the applier reset must **advance** the two serials | **holds.** `PipeApply.cpp:645-646` (`MGPipeApplierReset`) and `:658-659` (`MGPipeApplierReleaseObjectRecords`) are `++`; `grep` finds no `= 0` on either serial. |
|
||||
| 17a — `OnGpuWritten` sets **both** `m_hasDefinedContent` and `m_gpuWritePending` (m8) | **holds.** `ResourceTracker.h:614` calls `buffer->MarkGpuWritten()`, which sets both (`BufferObject.cpp:364-367`). |
|
||||
| 17b — `MGPVertexBuffer::BindingIndex` is the attribute index (D-H3) | **holds** (`VertexInputEmit.h:229`) — and F1 is the fix for the arm that assumed the opposite. |
|
||||
| B-DEV-7 — `kMGPipeResourceTargetBuffer == 0` | **confirmed** (`ResourceTracker.h:160`). |
|
||||
| 13 — D.3's `MOBILEGL_ESPRYT_DISABLE_INVALIDATE_FLUSH=1` arm | green, §4.6 L5. |
|
||||
| 10 — `0x1ff` / `0x7f` / `0x17f` | all three run; `0x17f` refuses by name, §4.6 L8. |
|
||||
|
||||
---
|
||||
|
||||
## 5. Track H census inputs
|
||||
|
||||
Unchanged from `espryt-v1` §2 as amended by `espryt-v2` §3, plus this round's three:
|
||||
|
||||
**Members deleted from the handle arm and kept compiled under `MOBILEGL_PIPE_LEGACY_MEMOS`** (a pull build
|
||||
forces that ON, so no `sizeof` moves — G1 is 0/0/0/0 at HEAD, which is the measurement):
|
||||
|
||||
1. `BackendVertexArrayObject::m_hasSyncedConfigVersion`
|
||||
2. `BackendVertexArrayObject::m_syncedConfigVersion`
|
||||
3. `BackendVertexArrayObject::m_syncedAttributeVersions` (`Array<VertexAttributeVersion, 32>`) — the largest single deletion of the phase
|
||||
4. `BackendVertexArrayObject::m_syncedIndexBufferVersion` (wrapping `Uint16`)
|
||||
5. `BackendVertexArrayObject::m_syncedIndexBufferObject` (raw frontend pointer — the wrap-hole identity patch)
|
||||
6. `ConvertedFloat64Stream::sourceLifetimeId` (`ConvertedVertexStreamKey`'s `sourcePin`)
|
||||
7. `VertexArrayImpl::g_pendingFetchBaseInstance` + `SetPendingFetchBaseInstance` + `GetPendingFetchBaseInstance` + `ScopedFetchBaseInstance` and its three scopes
|
||||
|
||||
**Kept, NOT deleted (D-K):** `PipeResource::m_backend`, `SetBackendResource`, `ReleaseBackend`,
|
||||
`BackendBufferResource` — under push they simply stop being written. Deleting them moves `sizeof(BufferObject)`
|
||||
in the **pull** build, which is a straight G1 break; they retire with the pull path at P13.
|
||||
|
||||
**Re-keyed memos:**
|
||||
|
||||
| memo | was | is |
|
||||
|---|---|---|
|
||||
| `BackendVertexArrayObject`'s sync gate | config version + 32 per-attribute version triples | `{elementsHandle, elementsSerial}` + `VertexBuffersSerial` |
|
||||
| the twin's index memo | wrapping `Uint16` + raw `BufferObject*` | `m_syncedIndexSerial` (`Uint64`) |
|
||||
| `ResolvedDrawBuffers::configVersion` | frontend VAO config version | `{elementsHandle, elementsSerial, buffersSerial}` |
|
||||
| `ResolvedDrawBuffers::Entry` | raw `BufferObject*` | `+ MGPipeHandle handle` (the probe's identity); `iboFrontend` likewise `+ iboHandle` |
|
||||
| `ConvertedFloat64Stream` | frontend lifetime id + frontend change serial | buffer `{slot, gen}` + applier `Serial` |
|
||||
| `GLESBufferResource::syncedChangeSerial` | mirrors `BufferObject::GetChangeSerial()` | mirrors `MGPipeResourceRecord::Serial` |
|
||||
|
||||
**Push-only members added** (none of them in a pull build): `GLESBufferResource::hostBytes`,
|
||||
`BackendVertexArrayObject::m_syncedVertexBuffersSerial` / `m_syncedElementsHandle` / `m_syncedElementsSerial` /
|
||||
`m_hasSyncedElements`, `ResolvedDrawBuffers::{elementsHandle, elementsSerial, buffersSerial, Entry::handle,
|
||||
iboHandle}`, `BackendSlotTable::kMaxHandleSlot` + `LiveGenAt` (no member).
|
||||
|
||||
**Unchanged on purpose (D-J / D-A4):** `g_bufferBackendIdGeneration`, `m_hasConvertedFloat64Attribute`,
|
||||
`m_syncedFetchBaseInstance` (as the *emitted* record), `BackendSlotTable`'s single-entry
|
||||
`m_memoLifetimeId`/`m_memoHandle` front memo, `TempBufferTarget` and its redundant-bind cache.
|
||||
|
||||
**This round's additions to the census:**
|
||||
|
||||
* `GLESBufferResource::hostBytes` gains a **publisher**: `EnsureBufferResourceForHandle` republishes the live
|
||||
shadow base at every ensure (F3). Its lifetime rule is otherwise unchanged (refreshed by a content-carrying
|
||||
call, cleared by an orphaning respecify and by a successful persistent-map adoption, never read by a path
|
||||
that holds the frontend object).
|
||||
* `IsBufferDrawCleanByHandle` reads five things (four applier reads + the frontend's `IsMapped()`, C-1) and
|
||||
`EnsureBufferResourceForHandle` now reads **two** frontend things beyond `SyncPersistentMappedRange`:
|
||||
`MappedData()` (C-2) and `HasDefinedContent()` (F2). All three retire at P5/P8 and are named at their sites.
|
||||
D6's "no `MG_State` type in any new handle-arm signature" is unchanged: it holds for the nine op bodies and
|
||||
the object-free helpers, and its three named exceptions are `EnsureBufferResourceForHandle`,
|
||||
`MarkBufferGpuWritten` and `IsBufferDrawCleanByHandle`.
|
||||
* No memo was retired or re-keyed by this round; `VertexBufferForBindingIndex` → `VertexBufferForAttributeIndex`
|
||||
is a rename of a lookup helper, not of a memo.
|
||||
|
||||
---
|
||||
|
||||
## 6. Deviations
|
||||
|
||||
D1-D14 stand as `espryt-v1` §5 / `espryt-v2` §4 record them, with two notes:
|
||||
|
||||
* **D7 narrows again.** The fp64 function had three problems, not one: the declared `SyncGpuWrites` gap
|
||||
(still open, still P8's), the freed shadow base (C-2, fixed last round), and the base that was **never
|
||||
published at all** (F3, fixed here). Only the declared one is left.
|
||||
* **D12 is the live divergence from ID-13's letter** — a push build contains no `FlushPendingRangesNow`. §2.
|
||||
It wants an explicit integrator ruling; it costs nothing today (both legacy arms are 920/920).
|
||||
|
||||
No new deviation is declared by this round.
|
||||
|
||||
---
|
||||
|
||||
## 7. Still red, and it is NOT this package's: 26 `BufferTest` unit cases
|
||||
|
||||
**Symptom.** In `build-push` and `build-verify` under the default mask, 26 of the 86 `BufferTest` cases fail;
|
||||
they pass in `build-linux`, and under `MOBILEGL_PIPE_PUSH=0` and `=0x7f` in `build-push`. The failures are all
|
||||
`EnsureGpuResidentStorage()` returning `false` and `mock.gpu.data()` staying `NULL` — the mock backend is
|
||||
never called.
|
||||
|
||||
**Mechanism, with the evidence.** `MG_Test/Buffer/BufferTest.cpp:1650-1655`'s `ScopedBackendOps` installs a
|
||||
mock through `MG_State::GLState::SetBufferBackendOps(&kZeroCopyMockOps)`. The `BufferTest` binary **brings up
|
||||
the real DirectGLES backend** (its log: `Initializing MobileGL… Renderer Name: Espryt`), so
|
||||
`BufferImpl::RegisterBufferBackendOps()` runs and, per this package's D3, also installs the handle-shaped table
|
||||
(`Managers.cpp:2454` `MG_Pipe::MGPipeSetResourceOps(&g_glesResourceOps)`). `MGPipeResourceSubsystemEnabled()`
|
||||
(`PipeFill.cpp:593`) is therefore true, and the frontend's push arms
|
||||
(`BufferObject.cpp:602-608`, `:655-661`, and six more) route the call to `MGPipeEmitMapPersistent` and
|
||||
**never reach `g_bufferBackendOps`** — the mock the fixture installed. The fixture scopes one table and not
|
||||
the other.
|
||||
|
||||
**Whose it is.** Not espryt's implementation choice: C.2's step `e2` prescribes installing the table "at
|
||||
bring-up … beside `RegisterBufferBackendOps`", so any conformant espryt produces this. Not the client's
|
||||
either: the eight `BufferObject.cpp` dispatch branches are exactly what D-K specifies. It is the
|
||||
**merge-seam** case C.5 warns about in as many words — *"Green on two branches separately is not green on the
|
||||
merge"*: at `espryt-v2` these 86 were green because nothing emitted through the pipe; at `client-v2` they were
|
||||
green because nothing registered a table; together they are red. `MG_Test/Buffer/BufferTest.cpp` is
|
||||
**"nobody"** in C.5's ownership table, i.e. the integrator's (or D's) to land, and it is not in C.2's file
|
||||
list, so this package may not commit the fix.
|
||||
|
||||
**The fix, and it is measured, not proposed.** `ScopedBackendOps` must scope the pipe table too, exactly as
|
||||
`MG_Test/Pipe/ResourceEmitTest.cpp:139-153`'s `ApplierGuard` already does for the applier:
|
||||
|
||||
```cpp
|
||||
struct ScopedBackendOps {
|
||||
explicit ScopedBackendOps(const MG_State::GLState::BufferBackendOps* ops) {
|
||||
MG_State::GLState::SetBufferBackendOps(ops);
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
m_savedResourceOps = MG_Pipe::MGPipeGetResourceOps();
|
||||
MG_Pipe::MGPipeSetResourceOps(nullptr); // these 86 cases are BufferBackendOps tests;
|
||||
#endif // the pipe-side dispatch is ResourceEmitTest's
|
||||
}
|
||||
~ScopedBackendOps() {
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
MG_Pipe::MGPipeSetResourceOps(m_savedResourceOps);
|
||||
#endif
|
||||
MG_State::GLState::SetBufferBackendOps(nullptr);
|
||||
}
|
||||
#if MOBILEGL_PIPE_PUSH
|
||||
const MG_Pipe::MGPipeResourceOps* m_savedResourceOps = nullptr;
|
||||
#endif
|
||||
};
|
||||
```
|
||||
|
||||
plus `#include <MG_Pipe/PipeApply.h>`. **Applied temporarily in this worktree and measured:**
|
||||
|
||||
```
|
||||
B: BufferTest (default mask) : 100% tests passed, 0 tests failed out of 86
|
||||
B: whole unit suite : 100% tests passed, 0 tests failed out of 1619
|
||||
(reverted; back to the committed tree: 70% passed, 26 failed of 86)
|
||||
```
|
||||
|
||||
It weakens nothing: those 86 cases are `BufferBackendOps` dispatch tests, the pipe-side dispatch is covered by
|
||||
`ResourceEmitTest`'s 25, and the fix restores exactly the arm they were written against. A larger alternative
|
||||
— giving the fixture a pipe-shaped mock so the same assertions run over the handle path — is worth doing, but
|
||||
it is a rewrite of 86 cases and belongs to whoever owns that file.
|
||||
|
||||
**Also recorded, and not fixed here:** the two `DirectVulkan.…ActuallyArmedWhenTheEnvironmentPinsItOn` cases
|
||||
that failed only in the very first `-j 8` run of this tree and in no `-j 4` run, no serial rerun and no later
|
||||
`-j 8` run. `client-v2` §6 item 6 already names this as the shared-log-file race at
|
||||
`MG_IntegrationTest/CMakeLists.txt:1040`; this package touches no `DirectVulkan` file and no
|
||||
`MG_IntegrationTest` file.
|
||||
|
||||
---
|
||||
|
||||
## 8. Open items carried forward (not this round's to close)
|
||||
|
||||
* `wire-review-v1` M-D's applier half is closed (`PipeApply.h:112-113`, bounded); the backend half was bounded
|
||||
by M-1 last round. Nothing left here.
|
||||
* The dangling-`ResolvedDrawBuffers::Entry::resource` invariant after `ReleaseByHandle`: both consumers still
|
||||
check identity through `FindByHandle` first, so nothing is dereferenced, and the invariant still deserves a
|
||||
sentence at the member in a later pass.
|
||||
* D7's `SyncGpuWrites` gap on the fp64 narrowing — P8's, unchanged.
|
||||
* The three `GL_Buffer.cpp` `NoteBoundAs` sites (`client-v2` §6 item 2) and `delete_vertex_elements` / the VAO
|
||||
CSO slot free (`client-v2` §6 item 3, which C.5 gives to this package but which C.2's ordered steps do not
|
||||
contain) — both still open, both invisible in monolith.
|
||||
* Package D's itest for C-1 (a persistently mapped, non-adopted buffer written only through its pointer, then
|
||||
drawn and read back) is still owed; `SanityTest`'s unit case pins the probe's semantics but issues no GL.
|
||||
|
||||
---
|
||||
|
||||
*Intermediate logs (`~/w7/espryt3-*.log`, `~/w7/espryt3-*.sh`, `~/w7/espryt3-fixes*.patch`) and the
|
||||
scratchpad's `espryt3-*` scripts are deleted; `~/w7/retrace-out/p3a-espryt` and `-verify` are deleted;
|
||||
`git status` in `/home/swung/w7/p3a-espryt` is clean at `3c55e027`. The trace fixtures are left materialised
|
||||
(803 MB, `assume-unchanged` intact), which is the state the next retrace run needs.*
|
||||
@@ -0,0 +1,338 @@
|
||||
# P3a — closing the exit-order class: no MobileGL destructor may run from `__run_exit_handlers`
|
||||
|
||||
Investigator: exit-order round, 2026-09-08. Private worktree `~/w7/p3a-exit`, branch **`p3a/exit`** from
|
||||
`d54ec57a` (the fix ID-18 landed). Two commits, not pushed. `~/w7/pipe` untouched.
|
||||
|
||||
## VERDICT
|
||||
|
||||
`d54ec57a` closed **two of the three** things the class needs and left the third wide open.
|
||||
|
||||
* Its three never-destroyed singletons (`MGPipeSlots`, `MGPipeResourceTrackerInstance`, `g_applier`) are
|
||||
correct and stay.
|
||||
* It did **not** cover `MGPipeVertexInputEmitterInstance()` — the singleton the C-1 rework put *directly* on
|
||||
`~VertexArrayObject`'s own death path one commit earlier. Every teardown of a bound-and-deleted vertex
|
||||
array reads and then **writes** its `Vector<Latch>` after that vector has been freed. Under ASan this
|
||||
fires on **6/6** representative cases across both backends; natively it is what the `tcache_count=0` knob
|
||||
turns into 10 SegFaults in the verify lane and 12 in the push lane at `d54ec57a`.
|
||||
* And it left the **class** open, because it fixed destinations rather than the source. The destination set
|
||||
is not closable from the pipe: `~BufferObject` reaches, through `MGPipeApplyResourceDestroy` →
|
||||
`g_resourceOps->Destroy` → `Ops_H_Destroy`, Espryt's `g_backendBufferResources`, `g_deferredBufferReleases`,
|
||||
the buffer pool and `g_GLESFuncs` — namespace-scope globals in `Managers.cpp` that the pipe does not own
|
||||
and that G5 protects functions inside.
|
||||
|
||||
**The fix is therefore at the source, and it is the repository's own already-written rule.** `Init.cpp:160-172`
|
||||
and `GlobalObjects.cpp:17-23` state it: *"the global singletons use leak-at-exit storage … so a process that
|
||||
exits without eglTerminate simply leaks them to the OS instead of running backend destructors during static
|
||||
teardown"*. `pGLContext`, `pEGLContext`, `pActiveBackendObject`, `pVulkanRenderer`, `pProxyTextureManager`,
|
||||
`pDefaultFramebufferInfo` and the shader-compile pool all obey it. **The four `PipeInputs` blocks did not**,
|
||||
and a `PipeInputs` is the one static in the tree that holds `SharedPtr`s to *frontend* GL objects. They obey
|
||||
it now.
|
||||
|
||||
With the fix, on the knob that made the class visible: **integration-verify 844/844**, **integration-gpu
|
||||
966/966**, unit 1622 × 3 on all three builds, G1 0/0/0/0, G5 rc 0, G2 0, G14 0 removed / +69.
|
||||
|
||||
---
|
||||
|
||||
## 1. Path inventory
|
||||
|
||||
### 1a. Chain starters — every static that can run a frontend destructor at `exit()`
|
||||
|
||||
A chain starts wherever a static-storage object holds the **last** `SharedPtr` to a frontend GL object. The
|
||||
only frontend destructors that reach the pipe are `~BufferObject` (`BufferObject.cpp:60`) and
|
||||
`~VertexArrayObject` (`VertexArrayObject.cpp:60`); a VAO owns its buffers through
|
||||
`VertexAttribute::Buffer` / `VertexBufferBindingPoint::Buffer` (`MGPipeValueTypes.h:516`, `:533`), so one VAO
|
||||
release is also a buffer release. The other five death-notice raisers (`ProgramObject`, `SamplerObject`,
|
||||
`FramebufferObject`, `TextureObject`, `RenderbufferObject`) reach only
|
||||
`NotifyStateObjectDestroyed` → the backend.
|
||||
|
||||
| # | static | what it holds | destroyed at exit before? | after? |
|
||||
|---|---|---|---|---|
|
||||
| 1 | `MG_Pipe::gPipeInputs` (`MG_Backend/MGPipe/PipeInputs.h:691`) | `SharedPtr<VertexArrayObject> m_boundVertexArray`, three `SharedPtr<ProgramObject>` | **YES — this is the one the ASan trace names** | no (leak-at-exit) |
|
||||
| 2 | `g_snapshot` (`MG_Impl/Pipe/PipeFill.cpp:366`) | a whole `PipeInputs`, filled from the live context (verify builds) | **YES** | no |
|
||||
| 3 | `g_readScratch` (`PipeFill.cpp:367`) | same | **YES** | no |
|
||||
| 4 | `probe` (`PipeFill.cpp:1166`, function-local in `ApplierDerivesRenderStateFields`) | a `PipeInputs`; today render state only | **YES** | no |
|
||||
| 5 | `MG_State::pGLContext` — owns *every* GL object of a live context | `UniquePtr<GLContext>` | no: `Core.cpp:1534` is already `*new` (leak-at-exit, `b8a8a660`) | no |
|
||||
| 6 | `MG_Backend::pActiveBackendObject`, `pVulkanRenderer`, `pEGLContext`, `pProxyTextureManager`, `pDefaultFramebufferInfo` | backend/EGL/impl singletons | no: all already leak-at-exit | no |
|
||||
| 7 | DirectGLES twin tables (`g_backendTextureObjects`, `g_backendBufferResources`, `g_backendProgramObjects`, `TwinRegistry`) | `Entry::stateRef` is a **`WeakPtr`** (`SlotTables.h:67-70`, `DirectGLES.cpp:113`) | destroyed, but **non-owning**: cannot start a chain | unchanged |
|
||||
| 8 | `g_liveSyncObjects` / `g_liveQueryObjects` (`GL_Sync.cpp:30`, `GL_Query.cpp:52`) | raw `SyncObject*` / `QueryObject*` | destroyed, **non-owning** | unchanged |
|
||||
| 9 | `nullBufferObject`, `nullProgramObject`, `nullTextureObject`, `nullSamplerObject`, `nullFramebufferObject`, `nullRenderbufferObject`, `nullShaderObject` (the `*State.cpp` files) | `SharedPtr<...> = nullptr`, never assigned | destroyed, **always empty** | unchanged |
|
||||
| 10 | `MG_Test/Pipe/PipeInputsTest.cpp:362` `static PipeInputs snapshot{}` | a unit-test-local `PipeInputs` | destroyed | still destroyed — but now harmless, see §3 |
|
||||
|
||||
The itest harness starts no chain and never tears anything down: `HeadlessGL::Get()` is a Meyers singleton
|
||||
(`HeadlessGL.cpp:545`) **with no destructor**, so `HeadlessGL::ShutDown()` — the only thing that would call
|
||||
`eglTerminate` → `MobileGL::Destroy()` → `pGLContext.reset()` — is never reached at exit, and the pre-flight
|
||||
child leaves through `_exit` on purpose (`HeadlessGL.cpp:365`). So at exit the context and everything in it
|
||||
simply leak; the *only* frontend objects whose last reference is elsewhere are the ones rows 1-4 hold, i.e.
|
||||
objects the application deleted (or rebound away from) while the pipe block still named them.
|
||||
|
||||
### 1b. Destinations — every destroyed object those chains reach
|
||||
|
||||
Starting from row 1-4 and walking `~VertexArrayObject` / `~BufferObject`:
|
||||
|
||||
| destination | reached from | state at `d54ec57a` |
|
||||
|---|---|---|
|
||||
| `MGPipeSlots()` (`SlotAllocator.cpp:170`) | both emitters | never destroyed ✔ (ID-18) |
|
||||
| `MGPipeResourceTrackerInstance()` (`ResourceTracker.h:554`) | `MGPipeEmitResourceDestroyAndFree` | never destroyed ✔ (ID-18) |
|
||||
| `g_applier` (`PipeApply.cpp:384`) | `MGPipeApplyResourceDestroy`, `MGPipeApplyDeleteVertexElements` | never destroyed ✔ (ID-18) |
|
||||
| **`MGPipeVertexInputEmitterInstance()` (`VertexInputEmit.h:434`)** | **`MGPipeEmitVertexElementsDestroyAndFree` (`PipeFill.cpp:818`, `:823`) — C-1's own path** | **DESTROYED — the open hole** |
|
||||
| Espryt `g_backendBufferResources` (`Managers.cpp:2316`), `g_deferredBufferReleases` (`:700`), the buffer pool, `g_GLESFuncs` | `MGPipeApplyResourceDestroy` → `g_resourceOps->Destroy` → `Ops_H_Destroy` (`Managers.cpp:2268`) → `Ops_OnDestroy` | **DESTROYED, and not fixable from the pipe** — `Ops_H_Destroy` carries no `InProcessTeardown()` guard |
|
||||
| Espryt twin tables via `NotifyStateObjectDestroyed` | `MGPipeEmitVertexElementsDestroyAndFree` (`PipeFill.cpp:841`) | already guarded: `OnFrontendStateObjectDestroyed` returns on `InProcessTeardown()` (`Managers.cpp:200`) |
|
||||
| `MGPipeTrackerInstance`, `MGPipeSetHashSuppressorInstance`, `MGPipeCsoCacheInstance` | not on today's death paths | DESTROYED (latent) |
|
||||
|
||||
The fourth row is the defect this round found. `MGPipeEmitVertexElementsDestroyAndFree` asks
|
||||
`emitter.RecordIsPublished(handle)` — a read of `m_latch.size()` and `m_latch[slot]` — and, when the record
|
||||
is live, `emitter.NoteRecordDestroyed(handle)`, which **writes** `m_latch[slot] = Latch{}`. On a destroyed
|
||||
emitter that is a read of a freed `Vector` buffer followed by a write into it: exactly the shape ID-18
|
||||
described for the slot allocator, one level further along.
|
||||
|
||||
The fifth row is why the class cannot be closed by enumerating destinations. It is closed here because
|
||||
after the fix **no such chain runs at all**.
|
||||
|
||||
---
|
||||
|
||||
## 2. The fix
|
||||
|
||||
Branch `p3a/exit`, two commits on `d54ec57a`, six files, +56/-12.
|
||||
|
||||
**`6515c8e6` — the source half (this is what kills the class).** Every static `PipeInputs` becomes
|
||||
leak-at-exit storage, the same `*new` idiom `GlobalObjects.cpp` documents:
|
||||
|
||||
```cpp
|
||||
// MG_Backend/MGPipe/PipeInputs.h
|
||||
- inline PipeInputs gPipeInputs{};
|
||||
+ inline PipeInputs& gPipeInputs = *new PipeInputs();
|
||||
|
||||
// MG_Impl/Pipe/PipeFill.cpp
|
||||
- PipeInputs g_snapshot{}; PipeInputs g_readScratch{};
|
||||
+ PipeInputs& g_snapshot = *new PipeInputs(); PipeInputs& g_readScratch = *new PipeInputs();
|
||||
- static PipeInputs probe;
|
||||
+ static PipeInputs& probe = *new PipeInputs();
|
||||
```
|
||||
|
||||
References, not pointers, so none of the ~50 use sites (including `MGB_CTX`) changes. Each carries a comment
|
||||
naming the hazard and pointing at `Init.cpp`'s statement of the rule.
|
||||
|
||||
**`fde5fda3` — the destination half (defence in depth).** The four MGPipe process singletons `d54ec57a` did
|
||||
not reach become never-destroyed, in `MGPipeSlots()`' exact shape:
|
||||
`MGPipeVertexInputEmitterInstance` (the live defect), `MGPipeTrackerInstance`,
|
||||
`MGPipeSetHashSuppressorInstance`, `MGPipeCsoCacheInstance`. None of the four types declares a destructor, so
|
||||
nothing is lost; each costs one allocation for the life of the process.
|
||||
|
||||
### The completeness argument
|
||||
|
||||
1. **A chain can only start at a static that owns the last reference to a frontend GL object.** §1a is that
|
||||
list, derived by sweeping the tree for static-storage objects whose type can hold a frontend `SharedPtr`.
|
||||
Rows 5-6 were already leak-at-exit before this round; rows 7-8 hold weak/raw references and own nothing;
|
||||
row 9 is always empty. Rows 1-4 were the only owners, and all four are now never destroyed.
|
||||
2. **Therefore no `~VertexArrayObject` / `~BufferObject` — and no `NotifyStateObjectDestroyed` raiser —
|
||||
runs from `__run_exit_handlers` at all.** That is stronger than making the destinations survive: it also
|
||||
covers the destinations the pipe cannot fix (Espryt's twin tables, the deferred-release queue, the buffer
|
||||
pool, and the driver itself, which may already be unloaded), and it is the same guarantee `Init.cpp`
|
||||
already claims for the backend.
|
||||
3. **A holder outside this list is still safe on the client side**, because of half two: every MGPipe
|
||||
process singleton now outlives `exit()`, so a destructor reached from an application's own static, a test
|
||||
fixture's static (row 10 is a real instance of this), or a future holder finds live client state rather
|
||||
than freed storage. What such a holder could still reach is the *backend* half, which is the backend's
|
||||
own `InProcessTeardown()` business — armed at the first twin creation (`SlotTables.h:229`, `:299`), i.e.
|
||||
before any pre-`main` global's destructor, and honoured by the death-notice consumer.
|
||||
4. **The ordering is not relied on anywhere.** "Never destroyed" is order-independent by construction, which
|
||||
is the reason a latch was rejected: a latch armed by `std::atexit` is only correct if its registration is
|
||||
later than the construction of *every* singleton it protects, and those are constructed lazily at
|
||||
different moments (`MGPipeSlots` at the first `glGenBuffers`, the emitter at the first validated draw).
|
||||
No single `call_once` registration can guarantee that.
|
||||
5. **Empirically:** the whole verify lane under ASan and under the layout knob is clean (§4), where before
|
||||
the fix ASan fired on 6/6 representatives and the knob produced 22 crashes across the two lanes.
|
||||
|
||||
### G1 (the pull build must not move)
|
||||
|
||||
Every file touched is compiled only into push builds: `MG_Backend/MGPipe/PipeInputs.h` is included solely
|
||||
through `PipeInputsSwitch.h`'s `#if MOBILEGL_PIPE_PUSH` arm, and the four `MG_Impl/Pipe/*.h` plus
|
||||
`PipeFill.cpp` are wholly inside `#if MOBILEGL_PIPE_PUSH`. The pull link is therefore untouched by
|
||||
construction — `cmake --build build-linux` after the two commits reported **`ninja: no work to do`** — and
|
||||
`symbol_report.py --threshold 0` is 0 added / 0 removed / 0 resized / 0 renamed with `.text` identical to
|
||||
the byte.
|
||||
|
||||
---
|
||||
|
||||
## 3. Backtraces
|
||||
|
||||
ASan build of the **pristine** `d54ec57a` (`build-asan`, RelWithDebInfo + `-fsanitize=address`,
|
||||
`ASAN_OPTIONS=detect_leaks=0`). Trimmed; file:line verbatim.
|
||||
|
||||
```
|
||||
==2117599==ERROR: AddressSanitizer: heap-use-after-free on address 0x7135e0697270
|
||||
READ of size 1 at 0x7135e0697270 thread T0
|
||||
#0 MGPipeVertexInputEmitter::RecordIsPublished(MGPipeHandle) const MG_Impl/Pipe/VertexInputEmit.h:312:26
|
||||
#1 MGPipeEmitVertexElementsDestroyAndFree(unsigned long) MG_Impl/Pipe/PipeFill.cpp:818:40
|
||||
#2 MG_State::GLState::VertexArrayObject::~VertexArrayObject() MG_State/.../VertexArrayObject.cpp:60:9
|
||||
#3..#5 _Sp_counted_base::_M_release / ~__shared_ptr<VertexArrayObject>
|
||||
#6 MG_Pipe::PipeInputs::~PipeInputs() MG_Backend/MGPipe/PipeInputs.h:158:12
|
||||
#7/#8 __run_exit_handlers / exit (libc)
|
||||
#9/#10 __libc_start_main / _start
|
||||
|
||||
0x7135e0697270 is located 32 bytes inside of 40-byte region [0x7135e0697250,0x7135e0697278)
|
||||
freed by thread T0 here:
|
||||
#0 operator delete(void*, unsigned long)
|
||||
#1/#2 __run_exit_handlers / exit (libc)
|
||||
(the Meyers static MGPipeVertexInputEmitter's ~Vector<Latch>)
|
||||
|
||||
previously allocated by thread T0 here:
|
||||
#0 operator new(unsigned long)
|
||||
#1..#6 std::vector<MGPipeVertexInputEmitter::Latch>::resize
|
||||
#7 MGPipeVertexInputEmitter::EmitVertexElements(GLContext&) MG_Impl/Pipe/VertexInputEmit.h:173:49
|
||||
#8 (anonymous namespace)::EmitVertexElements(GLContext&) MG_Impl/Pipe/PipeFill.cpp:1477:55
|
||||
#9 MGPipeValidateForVerb(MGPipeVerb) MG_Impl/Pipe/PipeFill.cpp:1597:29
|
||||
#10 MG_Impl::GLImpl::Clear_Backend / Clear MG_Impl/GLImpl/Drawing/GL_Drawing.cpp:531 / :1219
|
||||
#11.. the scenario body
|
||||
|
||||
SUMMARY: AddressSanitizer: heap-use-after-free MG_Impl/Pipe/VertexInputEmit.h:312:26 in
|
||||
MobileGL::MG_Pipe::MGPipeVertexInputEmitter::RecordIsPublished(MGPipeHandle) const
|
||||
```
|
||||
|
||||
Every run printed `[ PASSED ] 1 test.` first, exactly as CI does. The **same** report, byte for byte in its
|
||||
first six frames, came out of all six representative runs:
|
||||
|
||||
| backend | `DrawParametersScenario.MultiDrawElementsIndirect…` | `VertexArrayEnableDisableScenario.EitherHalf…` | `ProgramPipelineScenario.UniformsGoToTheActive…` |
|
||||
|---|---|---|---|
|
||||
| DirectVulkan | UAF `VertexInputEmit.h:312` | UAF `VertexInputEmit.h:312` | UAF `VertexInputEmit.h:312` |
|
||||
| DirectGLES | UAF `VertexInputEmit.h:312` | UAF `VertexInputEmit.h:312` | UAF `VertexInputEmit.h:312` |
|
||||
|
||||
The allocator-level UAF ID-18 documented (`SlotAllocator.cpp:100`) no longer appears: `d54ec57a` closed it,
|
||||
and the emitter is the frame that now gets there first.
|
||||
|
||||
**gdb note for whoever repeats this.** A native backtrace of the SegFault could not be obtained and should
|
||||
not be attempted: the crash is decided by heap layout, and gdb's own environment block shifts it — the exact
|
||||
ctest command and `ENVIRONMENT` of a failing entry, replayed under `gdb -batch -ex run` *or* replayed bare
|
||||
from a script, both **pass** (`rc=0`, verified on
|
||||
`DirectVulkan.Verify.DrawParametersScenario.MultiDrawElementsIndirectCarriesEveryCommandsParameters`). ASan
|
||||
is layout-independent and is the only tool that names this defect; use it.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verification transcript
|
||||
|
||||
All on `~/w7/p3a-exit` at `fde5fda3`, `GLIBC_TUNABLES=glibc.malloc.tcache_count=0` where stated.
|
||||
|
||||
### Before (pristine `d54ec57a`, knob on) — the population the fix has to move
|
||||
|
||||
```
|
||||
build-verify ctest -L integration-verify -j 8 -> 99% passed, 10 failed out of 844
|
||||
build-push ctest -L integration-gpu -j 8 -> 99% passed, 12 failed out of 966
|
||||
```
|
||||
|
||||
verify lane (all crash **after** `[ PASSED ]`):
|
||||
|
||||
```
|
||||
DirectGLES.Verify.ProgramPipelineScenario.UniformsGoToTheActiveShaderProgram (Subprocess aborted)
|
||||
DirectGLES.Verify.PointSizeDemotionScenario.AGeometryOnlyChainCarriesTheVertexValue (Subprocess aborted)
|
||||
DirectGLES.Verify.VertexArrayEnableDisableScenario.EitherHalfOfTheAttributesInTurn (SEGFAULT)
|
||||
DirectGLES.Verify.VertexArrayEnableDisableScenario.TheEvenHalfAlone (SEGFAULT)
|
||||
DirectVulkan.Verify.DrawParametersScenario.MultiDrawElementsIndirectCarriesEveryCommandsParameters (SEGFAULT)
|
||||
DirectVulkan.Verify.PrimitiveRestartScenario.AnAllOnesVertexIndexSurvivesTheSubstitution (SEGFAULT)
|
||||
DirectVulkan.Verify.Glsl420DeclarationScenario.AnExplicitDefaultColorIndexStillDraws (SEGFAULT)
|
||||
DirectVulkan.Verify.XfbCaptureBufferReuseScenario.EverySpanIntoOneImmutableStorageBuffer (SEGFAULT)
|
||||
DirectVulkan.Verify.TessellationXfbCaptureScenario.TheEvaluationStageSeesTheUserPerVertexBlockOfItsPatch (SEGFAULT)
|
||||
DirectVulkan.Verify.LayeredAttachmentShapeScenario.LayeredOneDArrayClearMaterialisedBySamplingReachesEveryLayer (SEGFAULT)
|
||||
```
|
||||
|
||||
push lane:
|
||||
|
||||
```
|
||||
DirectGLES.XfbAfterClipDistanceScenario.SkipComponentsCaptureAlone (SEGFAULT)
|
||||
DirectGLES.ViewportArrayScenario.AnIndexedScissorEnableClipsOnlyThatIndex (SEGFAULT)
|
||||
DirectGLES.ProgramPipelineScenario.UniformsGoToTheActiveShaderProgram (Subprocess aborted)
|
||||
DirectVulkan.PrimitiveRestartScenario.AnArbitraryRestartIndexDrawsInsteadOfKillingTheProcess (Subprocess aborted)
|
||||
DirectVulkan.PrimitiveRestartScenario.ChangingTheRestartIndexBetweenDrawsIsHonoured (Subprocess aborted)
|
||||
DirectVulkan.DoublePrecisionScenario.AnEnabledLongArrayDoesNotBreakADrawThatIgnoresIt (SEGFAULT)
|
||||
DirectVulkan.TessellationDrawModeScenario.TessellationProgramRejectsNonPatchModes (SEGFAULT)
|
||||
DirectVulkan.VertexAttribBindingScenario.BindingDivisorAppliesToEveryAttributeOnThePoint (Subprocess aborted)
|
||||
DirectVulkan.PointSizeDemotion.PointSizeDemotionScenario.AGeometryOnlyChainCarriesTheVertexValue (SEGFAULT)
|
||||
DirectVulkan.CsoContentAddressing.On.CsoContentAddressingScenario.TheBlendToggleMintsBoundedly… (SEGFAULT)
|
||||
DirectGLES.MapPersistentRoundtrips.LargeArenaAdoptionScenario.AnAdoptionCostsExactlyOneMapPersistentRoundtrip (SEGFAULT)
|
||||
DirectGLES.ResourceSubsystemOn.LargeArenaAdoptionScenario.SubDataAfterAnInFlightDrawReachesTheNextDraw (SEGFAULT)
|
||||
```
|
||||
|
||||
This is **not** the same 21 names the brief listed from the earlier `LastTestsFailed.log`, and that is the
|
||||
point: the selection is pure allocator layout, the defect is in every one of them, and only the fatality
|
||||
moves. The two `VerifyCorrupted.PipeVerifyArmingScenario` controls were `Skipped` in this run, not failing.
|
||||
|
||||
### After (`fde5fda3`, same knob, same commands)
|
||||
|
||||
```
|
||||
build-verify GLIBC_TUNABLES=glibc.malloc.tcache_count=0 ctest -L integration-verify -j 8
|
||||
-> 100% tests passed, 0 tests failed out of 844 rc=0
|
||||
build-push GLIBC_TUNABLES=glibc.malloc.tcache_count=0 ctest -L integration-gpu -j 8
|
||||
-> 100% tests passed, 0 tests failed out of 966 rc=0
|
||||
```
|
||||
|
||||
### The rest of the gate
|
||||
|
||||
| gate | result |
|
||||
|---|---|
|
||||
| G1 `symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so --threshold 0` | **0 added, 0 removed, 0 resized, 0 renamed**; 27811 → 27811 defined symbols; `.text` 10806323 → 10806323 (+0.000%). `build-linux` itself reported `ninja: no work to do` |
|
||||
| G5 `scripts/p3a_untouched_regions.sh 3e298c9a HEAD` | **rc 0** — `[p3a-untouched] byte-identical between 3e298c9a and HEAD` |
|
||||
| G2 pull-vs-push ctest names | **0 differing lines** |
|
||||
| G14 vs `~/w7/p3a-before-ctest-names.txt` | **0 removed**, +69 (unchanged from the P3a landing) |
|
||||
| unit × 3, `build-linux` | 100%, 0 failed of **1622**, three times |
|
||||
| unit × 3, `build-push` | 100%, 0 failed of **1622**, three times |
|
||||
| unit × 3, `build-verify` | 100%, 0 failed of **1622**, three times |
|
||||
| ASan, 10 representative runs (5 scenarios × 2 backends), fix in | **10/10 rc 0, zero ASan reports** (incl. `CrossFrameBufferScenario.VertexCopyBufferSubData` — the two original CI cases — and `HandleRecycleScenario.DestroyedVertexArraysReturnTheirVertexElementsSlots`) |
|
||||
| ASan, whole `integration-verify` lane, fix in | 838/844; **zero teardown reports** — the six are one pre-existing test-side bug, see below |
|
||||
|
||||
`ASAN_OPTIONS=detect_leaks=0 ctest -L integration-verify -j 8` on `build-asan`: `99% tests passed, 6 tests
|
||||
failed out of 844`. Every AddressSanitizer report in the whole lane — `grep -o "ERROR: AddressSanitizer:
|
||||
[a-z-]*" | sort | uniq -c` over `Testing/Temporary/LastTest.log` — is **`6 stack-buffer-overflow`** and
|
||||
nothing else: **no `heap-use-after-free`, and no report from an exit handler anywhere in 844 processes.**
|
||||
|
||||
The six are `IntegerBorderColorScenario.{ASignedIntegerBorderIsClampedToTheFormatsRepresentableRange,
|
||||
ANegativeBorderOnAnUnsignedFormatClampsToTheFormatsMaximum, AnOversizedUnsignedBorderIsClampedToTheFormatsMaximum}`
|
||||
× both backends, and they are **not this round's and not P3a's**: the scenario passes a 4-byte
|
||||
`std::int8_t texels[4]` to a `glTexSubImage2D(…, 2, 2, GL_RED_INTEGER, GL_BYTE, …)` whose default
|
||||
`GL_UNPACK_ALIGNMENT` of 4 pads row 0 to four bytes, so a correct unpack needs **six** source bytes and
|
||||
`PixelStoreProcessor::ProcessTexturePixelsDataUnpack` reads two past the array
|
||||
(`IntegerBorderColorScenario.cpp:206`, from `:336-338`). The file is unchanged since `01d20e5c`
|
||||
(2026-08-27) and neither of this round's commits touches it. It fires in the test body, never at teardown.
|
||||
Recorded as follow-up 6.
|
||||
|
||||
---
|
||||
|
||||
## 5. Hashes
|
||||
|
||||
```
|
||||
base d54ec57a (ID-18's fix; feat/disaggregated head is c20e2f2b + d54ec57a)
|
||||
p3a/exit 6515c8e6ae… [Fix] (MG_Backend, MG_Impl): give the MGPipe input blocks leak-at-exit storage …
|
||||
p3a/exit fde5fda3b5… [Fix] (MG_Impl): never destroy the four remaining MGPipe singletons …
|
||||
worktree /home/swung/w7/p3a-exit (build-linux, build-push, build-verify, build-asan)
|
||||
```
|
||||
|
||||
Files: `MobileGL/MG_Backend/MGPipe/PipeInputs.h`, `MobileGL/MG_Impl/Pipe/{PipeFill.cpp, VertexInputEmit.h,
|
||||
Tracker.h, SetHashSuppressor.h, CsoCache.h}`.
|
||||
|
||||
---
|
||||
|
||||
## 6. Follow-ups for the integrator
|
||||
|
||||
1. **Arm the knob in CI.** ID-18's follow-up 3 is still the cheapest guard there is: one arm of the
|
||||
integration lane with `GLIBC_TUNABLES=glibc.malloc.tcache_count=0`. It costs nothing and turns this whole
|
||||
class from "CI-only, two cases, once" into a hard deterministic red. Without it the next holder of a
|
||||
frontend `SharedPtr` at namespace scope reopens the class silently.
|
||||
2. **`Ops_H_Destroy` has no `InProcessTeardown()` guard** (`Managers.cpp:2268`), where its five siblings and
|
||||
`OnFrontendStateObjectDestroyed` do. It is unreachable at exit *after this fix*, and only because of it.
|
||||
A one-line guard there would make Espryt's half independently safe, and belongs to the backend owner.
|
||||
3. **`VerifyState::~VerifyState` logs from a static destructor** (`PipeFill.cpp:379-386`, `MGLOG_E` when a
|
||||
divergence survived `MOBILEGL_PIPE_VERIFY_FATAL=0`). It runs at exit into `MG_Util::Debug`, whose file
|
||||
stream is not leak-at-exit. Only on an already-failing verify run, so not touched here; recorded because
|
||||
it is the same class one file over.
|
||||
4. **The leak is real and intended.** `gPipeInputs` never releases its `SharedPtr`s, so a VAO the
|
||||
application deleted while it was bound, its buffers and (on Espryt) their twins live to process exit —
|
||||
ID-18's follow-up 2, now deliberate rather than accidental. Releasing them at context teardown
|
||||
(`MGPipeApplierReleaseObjectRecords`' moment) is the right long-term shape and is a `MG_Backend/MGPipe`
|
||||
edit, i.e. contract-frozen territory; it stays a follow-up row.
|
||||
5. **Nothing is pushed.** `p3a/exit` sits on `d54ec57a` and rebases onto `feat/disaggregated` cleanly (the
|
||||
six hunks touch nothing else in flight).
|
||||
6. **A real, pre-existing, test-side stack overflow in `IntegerBorderColorScenario`** (`01d20e5c`, 2026-08-27):
|
||||
four bytes of source for a 2×2 `GL_RED_INTEGER`/`GL_BYTE` upload that `GL_UNPACK_ALIGNMENT=4` makes six
|
||||
bytes long. Invisible in every non-sanitizer build (it reads two bytes of adjacent stack and the pixels
|
||||
happen to come out right), and the only thing standing between the whole verify lane and a clean ASan
|
||||
run. Fix is one line in the scenario (`std::int8_t texels[6]`, or `glPixelStorei(GL_UNPACK_ALIGNMENT, 1)`
|
||||
before the upload); it belongs to the scenario's owner, not to this round.
|
||||
@@ -0,0 +1,401 @@
|
||||
# P3a final adversarial review — the integrated tree `5cb826b0..3e298c9a` on `feat/disaggregated`
|
||||
|
||||
Reviewer: final integrator-side review, 2026-09-08. Scope: the whole integrated diff, cross-package seams only —
|
||||
each package's own review already ran. Read-only against `//wsl.localhost/Arch/home/swung/w7/pipe` (a gate is
|
||||
running there; nothing was built or run in it) and the Windows worktree
|
||||
`C:/Users/geekerwan/AndroidStudioProjects/FoldCraftLauncher/MobileGL-disagg` at the same commit `3e298c9a`.
|
||||
Diff extraction: `<scratchpad>/wsl/review-final.sh` → `<scratchpad>/wsl/diff/` (37 files, +9273 / -230).
|
||||
|
||||
## VERDICT: **REWORK**
|
||||
|
||||
Two criticals, both of them exactly the class this review exists to find — one is a defect no per-package
|
||||
reviewer could see because it only exists at the client × *non-Espryt backend* seam, and the other is a gate
|
||||
that is green while protecting code the shipping build does not compile. Neither is expensive to fix (C-1 is
|
||||
one line plus an integrator ruling; C-2 is a script/ID amendment plus one line of `-R`). Everything else on the
|
||||
tree is in very good shape: the handle lifecycle, the base-instance path, the epoch ordering and the
|
||||
serial/version coherence all hold under the adversarial sequences I could construct (§6), G13 purity is clean,
|
||||
the contract payload is in the base, and CI was not narrowed.
|
||||
|
||||
---
|
||||
|
||||
## 1. Critical
|
||||
|
||||
### C-1 — Under any backend that does not install `StateObjectDeathOps`, every VAO leaks a `VertexElementsCso` slot **and** a ~1.3 KB applier record, for the life of the process, on the shipped default mask
|
||||
|
||||
**Where.**
|
||||
- mint: `MobileGL/MG_Impl/Pipe/VertexInputEmit.h:171` — `MGPipeSlots().Acquire(MGPipeKind::VertexElementsCso, lifetimeId)`, called from `EmitVertexElements` at every validate point.
|
||||
- record: `MobileGL/MG_Pipe/PipeApply.cpp:1202-1203` `RecordAt(g_applier.VertexElementsCsos, desc.Cso.Slot, kMGPipeMaxVertexElementsSlots)`; the record is `MobileGL/MG_Pipe/PipeApply.h:141-152` — `Array<MGPVertexAttribWire,32>` (24 B each) + `Array<MGPVertexBindingPointWire,32>` (16 B each) = **1280 B + header per slot**.
|
||||
- the only free: `MobileGL/MG_Backend/DirectGLES/SlotTables.h:416-429` `OnFrontendObjectDestroyed` → `MGPipeSlots().Free(kKind, handle)`, reached from `MG_State/GLState/VertexArrayState/VertexArrayObject.cpp:53`'s `NotifyStateObjectDestroyed` **only when `g_stateObjectDeathOps` is installed**.
|
||||
- the only installer: `MobileGL/MG_Backend/DirectGLES/Managers.cpp:314` `SetStateObjectDeathOps(&g_glesStateObjectDeathOps)`, inside Espryt's `EsprytSlotTablesEnabled()`. `grep -rn "SetStateObjectDeathOps" MobileGL/` returns that one call site and the declaration.
|
||||
- no global escape hatch: `grep -rn "MGPipeSlots()\.Reset"` outside `MG_Test/` is **empty**.
|
||||
|
||||
**Failure scenario.** DirectVulkan/Magma with the new default `MOBILEGL_PIPE_PUSH = kMGPipeSubsystemsMigratedAtP3a = 0x1ff` (`MobileGL/ConfigLoader.cpp:257`, `MobileGL/MG_Pipe/MGPipe.h:95`). The client's vertex-input emission gate is backend-agnostic — `wants()` is `MGPipeSubsystemForDirty(bit) & pushMask` (`MG_Impl/Pipe/PipeFill.cpp:1462-1466`) and bits 5/9/10 now map to `kMGPipeSubsystemVertexInput` (`MG_Impl/Pipe/Tracker.h:145-148`) — so `EmitVertexElements` runs on every draw under Magma too. Each new `VertexArrayObject` takes a slot; `~VertexArrayObject` raises the death notice into a null `g_stateObjectDeathOps` and returns; the slot is never freed and `g_applier.VertexElementsCsos` never shrinks and never goes `Live = false` (there is **no** `delete_vertex_elements` producer anywhere in the library — `grep` finds only `PipeApply.cpp`'s definition and `MG_Test`). Sodium/Create churn VAOs per chunk section: 10 k VAOs ≈ 13 MB of applier records plus 10 k `SlotState` + 10 k `UnorderedMap` nodes, monotonically, on a platform with an LMK. Past 65536 slots (`kMGPipeMaxVertexElementsSlots`, `PipeApply.h:113`) `RecordAt` returns null and **every** `create_vertex_elements` trips `Fatal{ProtocolCorruption}` permanently — fatal on a verify build.
|
||||
|
||||
`MG_Backend/DirectVulkan/Renderer/MagmaPipeArms.h:243-250` documents this exact anti-pattern as the reason Magma built its own age-reclaimed `MagmaPipeIdentityTable` instead of using `MGPipeSlots`: *"an allocator here would grow by one `SlotState` plus one map node per object EVER created, for the life of the process, on a platform with an LMK."* P3a re-introduces precisely that, from the client side, for a kind Magma deliberately kept out of the allocator.
|
||||
|
||||
**Refutation attempted, three ways, all failed.**
|
||||
1. *"Espryt frees it, so this is Espryt's business."* Espryt does free it, and unconditionally — `OnFrontendObjectDestroyed` returns the slot *"whether or not any holder still had a twin at it"* (`SlotTables.h:407-410`). So the client's and espryt's own note that "on this tree VAO CSO slots are never freed" (`client-v2.md:308-309`, `espryt-v3.md:605-607`) is **wrong for Espryt and right for Magma** — both packages assigned the item to package C, and package C is the one backend where it already works. Nobody looked at the backend where it does not.
|
||||
2. *"Magma is untouched in P3a, so this cannot be P3a's."* The mint is not in `MG_Backend/DirectVulkan/**`; it is in the client, which runs under every backend. Before this diff `MGPipeSlots()` held **zero** `VertexElementsCso` slots under Magma.
|
||||
3. *"It is bounded by a shipped A/B."* No: `0x1ff` is the push default for both backends, and `MG_IntegrationTest/CMakeLists.txt:954, :1055, :1060` now pin `0x1ff` on three DirectVulkan lane families as well (raised from `0x7f` by gates' M1).
|
||||
|
||||
**Fix (one of):** (a) install the death notice for the `VertexElementsCso` kind from a backend-neutral place — a `MGPipeSlots().Free` in the client, driven by a `delete_vertex_elements` the client emits from `~VertexArrayObject` (this is `client-v2.md` §6.3 / `espryt-v3.md` §8's open item, and it is also the missing producer for the applier record); or (b) gate the client's vertex-input emission on the backend actually consuming it. (a) is the right one and closes three open rows at once.
|
||||
|
||||
### C-2 — G5's tenth row is green while the **push build compiles no `FlushPendingRangesNow` at all**; the ladder the shipping build runs is outside the gate
|
||||
|
||||
**Where.** `MobileGL/MG_Backend/DirectGLES/Managers.cpp`: `#if MOBILEGL_PIPE_PUSH` at `:902`, `#else` at `:1197`, `#endif` at `:1433`.
|
||||
- `FlushPendingRangesFrom(GLESBufferResource&, const Uint8* hostBase, SizeT frontendSize)` — `:1051-1125`, **push arm**, the only three-tier ladder a push build has. Both call sites in a push build reach it: `:1717-1724` (the legacy call site, `#if PUSH → FlushPendingRangesFrom`) and `:2044` (`Ops_H_Readback`).
|
||||
- `FlushPendingRangesNow(GLESBufferResource&, BufferObject&)` — `:1316-1385`, **inside the `#else`**, byte-identical to `5cb826b0:1004-1073`. A push build never compiles it.
|
||||
- `scripts/p3a_untouched_regions.sh:76` lists the ten names including `FlushPendingRangesNow`; the extractor is preprocessor-blind (`:180-223`) and hashes the pull-arm text.
|
||||
|
||||
**Why this is "green for the wrong reason", not a nit.** `BRIEF-P3A.md`'s own risk row for this function is *"`FlushPendingRangesNow`'s three-tier drain silently changes tier because its caller now supplies bytes differently … The function is in G5's byte-identical set"*, and `scripts/p3a_untouched_regions.sh:39-41` states the threat model verbatim: *"A push arm that re-spells the three tiers beside an untouched pull arm satisfies G1 and defeats this gate's reason to exist — two ladders drift."* That is exactly the shape on the tree; the defence is keyed on the **name**, so a copy that was *renamed* walks past it. A future tier-threshold or map-access-bit edit made in `FlushPendingRangesFrom` — the only ladder the shipping build runs — regresses MC 26.3's p99 with G5 still green, and ID-6 makes the perf number recorded rather than gated, so nothing catches it.
|
||||
|
||||
It also **violates ID-13 as written**: *"`FlushPendingRangesNow` is defined exactly once, outside any `#if`, byte-identical to 5cb826b0."* It is defined once, but inside the `#else`. `espryt-v3.md:75-106, :519-520` (D12) raised precisely this and said *"It wants an explicit integrator ruling"* — **no ruling was recorded** (confirmed against `INTEGRATOR-DECISIONS.md`, which stops at ID-13's original text).
|
||||
|
||||
**Refutation attempted.** The author's argument at `Managers.cpp:1127-1138` — that a push build then contains exactly one ladder and both arms call it, where a forwarder would leave two definitions and make the extractor exit 2 — is sound *as far as it goes*, and I verified the ladders are behaviourally equivalent **today**: the three textual differences are the `hostBase == nullptr` early return (`:1066`, unreachable from the legacy call site, which passes `MappedData()`), `frontendSize` vs `bufferObject.GetSize()` (`:1070` vs `:1330`, the same value at that call site), and `UploadRangeFrom(resource, hostBase, …)` vs `UploadRangeNow(resource, bufferObject, …)` — and in the push arm `UploadRangeNow` is itself a one-line forwarder onto `UploadRangeFrom` (`:993-995`). So **there is no behavioural defect on this tree.** What is broken is the gate's coverage from here on, which is what G5 exists for.
|
||||
|
||||
**Fix (both halves).** (1) Amend `scripts/p3a_untouched_regions.sh` so the tenth row hashes the ladder the **push** build compiles: add `FlushPendingRangesFrom` to the list and capture its baseline sha at this commit, keeping `FlushPendingRangesNow` for the pull build. (2) Record the amendment as an ID (ID-14) superseding ID-13's "outside any `#if`" sentence, since the tree deliberately chose the two-arm shape. Both are minutes of work; without them the row is decorative for every build that ships.
|
||||
|
||||
---
|
||||
|
||||
## 2. Major
|
||||
|
||||
### M-1 — A `BufferObject` constructed while the resource op table is unregistered never gets an applier record, and unlike the legacy arm the handle arm has no repair
|
||||
|
||||
`MG_State/GLState/BufferState/BufferObject.cpp:44-45`: the handle is minted unconditionally but the create is
|
||||
gated on `MGPipeResourceSubsystemEnabled()` = *bit 7 **and** `MGPipeGetResourceOps() != nullptr`*
|
||||
(`MG_Impl/Pipe/PipeFill.cpp:593-596`). Espryt's consumer gate is bit-7-only
|
||||
(`MG_Backend/DirectGLES/Managers.h:715-718`). The two disagree across a register/unregister boundary:
|
||||
`UnregisterBufferBackendOps` nulls the table (`Managers.cpp:2466-2468`), called from `OnBackendContextDestroyed`
|
||||
← `DirectGLES.cpp:11104 DestroyEGLContext()`; the re-register is at `MakeCurrent` (`DirectGLES.cpp:10568`).
|
||||
|
||||
A buffer born in that window latches `Published = false` (`ResourceTracker.h:342-350`), so no record exists;
|
||||
every later `resource_respecify` is refused (`PipeApply.cpp:967-968`, counted into `RefusedResourceCalls`), and
|
||||
`EnsureBufferResourceForHandle` reads `ResourceRecordOf(res) == nullptr → size = 0 → return resource`
|
||||
(`Managers.cpp:2717-2721`) with **no diagnostic** — the store stays empty for the object's whole life and the
|
||||
draw fetches through `id == 0`. The legacy arm recovers from the same window: `EnsureBufferResource` twins
|
||||
lazily off the frontend object and full-uploads from the shadow.
|
||||
|
||||
*Refutation attempted:* "no GL call happens without a current context" — `CanTouchGLNow()` exists precisely
|
||||
because frontend calls reach this code with no current backend context, and D-A2 explicitly preserves
|
||||
`NotifySubData` as reachable off the render thread. The window is narrow, not empty.
|
||||
|
||||
**Fix:** in `MGPipeEmitResourceRespecify` (`PipeFill.cpp:629`), if `!tracker.WasPublished(handle)` emit the
|
||||
create first (the descriptor is already built two lines below). Three lines, and it makes the create/destroy
|
||||
latch self-healing in both directions.
|
||||
|
||||
### M-2 — `GLESBufferResource::hostBytes` is a raw pointer written off the render thread with no synchronisation
|
||||
|
||||
`Managers.h:673` `const Uint8* hostBytes = nullptr;` — a plain pointer. It is written at
|
||||
`Managers.cpp:1921` (`Ops_H_SubData`) and `:1969` (`Ops_H_FlushRange`) **before** the `CanTouchGLNow()` test,
|
||||
i.e. on the arm D-A2 keeps reachable off the render thread, and read on the render thread at `:2005`, `:2013`,
|
||||
`:2044` (`Ops_H_Readback`), `:2639`/`:2741` (the ensure path) and `:4476` (the fp64 narrowing).
|
||||
|
||||
Everything else on that same struct and that same path is synchronised on purpose: `pendingRanges` /
|
||||
`pendingResidentWrites` under `resource->pendingMutex`, `syncedChangeSerial` an `std::atomic` read with
|
||||
`memory_order_acquire` (`:2581`, `:2610`). `hostBytes` is the one member the off-thread path touches with
|
||||
neither. It is new in P3a — the legacy arm never cached a base, it re-read `bufferObject->MappedData()` on the
|
||||
render thread at every use. espryt-review's C-2 fixed the *lifetime* of this pointer; nobody looked at its
|
||||
*visibility*.
|
||||
|
||||
**Fix:** write it inside the `pendingMutex` scope, or only on the `CanTouchGLNow()` arm — the ensure path
|
||||
republishes it on the render thread anyway (`:2741`, the `3c55e027` fix), so the off-thread store buys nothing.
|
||||
|
||||
### M-3 — the handle arm **drops** one of D-N's eleven `SyncGpuWrites` sites rather than keeping it, and the deviation was never ratified
|
||||
|
||||
`Managers.cpp:4456-4464`, in `SyncFloat64AttributeAsFloat32ByHandle`: *"the legacy arm opens with
|
||||
`bufferObject->SyncGpuWrites()` … on this arm a 64-bit array whose SOURCE buffer was written by a shader and
|
||||
not yet pulled back narrows stale bytes."* D-N's wording is *"**No move** of `SyncPersistentMappedRange` /
|
||||
`SyncGpuWrites` off their 8 + 3 Espryt sites"* — a site deleted on the arm that ships is not a site kept. This
|
||||
is a behavioural difference between the two arms **under the default mask**, and G2 requires the push and pull
|
||||
integration lanes to be green name-for-name, so it survives only because no scenario covers the shape.
|
||||
|
||||
The closure table confirms nothing closed it: `espryt-review-v1.md:493-495` asked package D for
|
||||
`DoublePrecisionScenario` **with an adopted source** and `StorageBufferRegrow` under ASan, and said in as many
|
||||
words that *"a clean run of today's `DoublePrecisionScenario` does not discharge this"* — **NO CLAIM FOUND**.
|
||||
`espryt-v3.md:362-366` reports `DoublePrecisionScenario` green, which is the run the review pre-emptively
|
||||
refused as evidence.
|
||||
|
||||
**Fix:** an explicit integrator ruling (D7 → P8, recorded in `INTEGRATOR-DECISIONS.md` and in
|
||||
`MEASUREMENTS.md`'s P3a section as a known behavioural delta), plus the named case package D still owes, or a
|
||||
statement that the shape is unreachable in the corpus.
|
||||
|
||||
### M-4 — the stale-comment promotion condition at `Managers.cpp:2276-2282` is now met and the promotion did not happen
|
||||
|
||||
The comment says `NoArm` stays a warning rather than a stop because *"bits 7 and 8 are clear in every `.Handles`
|
||||
itest lane today (`MG_IntegrationTest/CMakeLists.txt` pins `MOBILEGL_PIPE_PUSH=0x7f` …), which is
|
||||
contract-review item 11 and package D's to re-pin … the stop can be promoted the moment those lanes carry an
|
||||
explicit `0x1ff` arm."* Gates' M1 did exactly that: `MG_IntegrationTest/CMakeLists.txt:930` now pins `0x1ff`
|
||||
beside `MOBILEGL_PIPE_LEGACY_MEMOS=0` for the Handles-arm knobs, and the four CSO lanes went to `0x1ff` /
|
||||
`0x8000000000000 1ff`. So the sentence is false and the safety promotion it gated is unmade: a build with bit 8
|
||||
clear and `LEGACY_MEMOS=0` still runs with **no vertex-input arm at all**, logging once
|
||||
(`Managers.cpp:2343-2350`) and drawing through an unconfigured driver VAO.
|
||||
|
||||
**Fix:** correct the comment and promote `PipeSubsystemArmVerdict::NoArm` to the same `std::abort()` that
|
||||
`ResolveEsprytSlotTablesArm` uses for bit 5 (`Managers.cpp:294-298`) — this is also `espryt-v2` D14's
|
||||
"wants an explicit integrator ruling", still unruled.
|
||||
|
||||
### M-5 — four cross-package rows closed by nobody, carried into the phase exit
|
||||
|
||||
Not defects on this tree, but they are the "left for X that nobody closed" the review was asked to name; see
|
||||
§5 for the full table. In severity order:
|
||||
|
||||
| row | declared | owner as assigned | reality |
|
||||
|---|---|---|---|
|
||||
| `delete_vertex_elements` producer + VAO CSO slot free | `client-v2.md:308-309`, `espryt-v3.md:605-607` | package C | **is C-1 above**; both packages misattributed it to the one backend where it already works |
|
||||
| contract-review **m4** — the three pairing `static_assert`s use inconsistent right-hand sides | `contract-review-v1.md:136-142`, re-assigned to B by `wire-v2.md:194-201` | package B | B never mentions it; I confirmed the asymmetry survives at `PipeFill.cpp:933-947` (two of the three compare against `kMGPipeSubsystemVertexInput` directly rather than against `SubsystemForEmitter(...)`). Cosmetic, but it is the trap C.5 exists to prevent |
|
||||
| gates **m10** — the DirectGLES buffer ABA has no positive control | `gates-v2.md:244, :369-371` | package C | never mentioned by C. Compounded: there **is no DirectGLES `.AbaControl` lane** (`MG_IntegrationTest/CMakeLists.txt:959-1011` registers six lanes; the buffer kind's corruption evidence is Magma-only) |
|
||||
| wire **n6** — which counter G10 asserts against | `wire-v2.md:383-386` | package D | no document closes it, but **the code does**: `StorageBufferRegrowScenario` reads `PipeStats`' `mpr` out of the lane log (`Harness/PipeStatsWindow.h:26-28, :62-73`), not the applier's per-context member. Close it on the record |
|
||||
|
||||
---
|
||||
|
||||
## 3. Minor
|
||||
|
||||
| # | finding | file:line |
|
||||
|---|---|---|
|
||||
| m1 | Comment says the three vertex emitters *"still resolve to false today — their dirty bits map to no subsystem"*; they are mapped. | `MG_Impl/Pipe/PipeFill.cpp:1509-1512` vs `MG_Impl/Pipe/Tracker.h:145-148` |
|
||||
| m2 | G5 doc drift after the tenth function landed: *"Extract the nine bodies"*, and `test.yml`'s *"nine named bodies" / "nine bodies extracted" / "three canned controls"*. | `scripts/p3a_untouched_regions.sh:266`; `.github/workflows/test.yml` (G5 step comments) |
|
||||
| m3 | G7 attributes the trip with `grep -q IsBgra` over the **whole** ctest log rather than over the failing assertion, and traps only `EXIT` (no `INT`/`TERM`), so a Ctrl-C during the rebuild re-enters `repair`'s own build. Exact today (`IsBgra` appears once, at `MG_Test/Pipe/VertexInputEmitTest.cpp:266`); brittle to a future case name. | `scripts/p3a_vertex_input_negative_control.sh:174, :219` |
|
||||
| m4 | `p3a_untouched_regions.sh` exits 1 under Git Bash on Windows: Python text-mode stdout emits CRLF and the `awk -v n="$name"` lookup then misses every row. Linux CI unaffected; `newline='\n'` fixes it. | `scripts/p3a_untouched_regions.sh` (python emit block) |
|
||||
| m5 | G8's DirectGLES `.Handles` arm degrades to a **SKIP**, not a red, if `MGPipeResourceOps` is renamed — the arming marker is a CMake content grep. Honest (visible skip with a reason) but not a gate. | `MG_IntegrationTest/CMakeLists.txt:459-467`; `Scenarios/HandleRecycleScenario.cpp:390-407` |
|
||||
| m6 | `MGPipeApplierReset` zeroes `MapPersistentRoundtrips` at every make-current while `PipeStats`' `mpr` is process-wide; the two observables disagree across a context switch. Latent (G10/G12 read `PipeStats`'), but this is what wire n6 asked to have written down. | `MG_Pipe/PipeApply.cpp:631` vs `MG_Impl/Pipe/PipeFill.cpp:735-737` |
|
||||
| m7 | `MGPipeSlots()` is now mutated from `BufferObject`'s constructor and destructor, i.e. from whatever thread issues `glGenBuffers`/`glDeleteBuffers`. The "GL thread by construction" justification is stated but not enforced; two contexts of one share group on two threads is a torn free list. New for the `Buffer` kind. | `MG_Impl/Pipe/PipeFill.cpp:603-611, :741-763`; `ResourceTracker.h:287-299` |
|
||||
| m8 | `ResolvedDrawBuffers::Entry::resource` is still a raw twin pointer that can dangle after `ReleaseByHandle`; both consumers check identity through `FindByHandle` first, so nothing is dereferenced, but the invariant is not written at the member (espryt-v3 §8's own carry-forward). | `MG_Backend/DirectGLES/Managers.h:979-1019` |
|
||||
|
||||
---
|
||||
|
||||
## 4. What I attacked and found sound (so the next reviewer does not repeat it)
|
||||
|
||||
**Handle lifecycle, end to end.** `BufferObject` ctor mints unconditionally and latches `Published`
|
||||
(`BufferObject.cpp:44-45`, `ResourceTracker.h:342-350`) → `MGPipeApplyResourceCreate` starts the record over
|
||||
rather than editing it, so a recycled slot cannot inherit a field (`PipeApply.cpp:938-956`) → espryt's
|
||||
`GetOrCreate(handle)` refuses a **backwards** generation and resets the twin on a **forward** one
|
||||
(`SlotTables.h:315-325`), with a release-build voice at `Managers.cpp:2368-2374` because `MOBILEGL_ASSERT`
|
||||
compiles out at INFO → `~BufferObject` → `MGPipeEmitResourceDestroyAndFree` emits then frees, in that order
|
||||
(`PipeFill.cpp:741-763`) → `Ops_H_Destroy` takes the twin **out** of the table before deciding pool/delete/defer
|
||||
(`Managers.cpp:2084-2093`, `SlotTables.h:350-361`). I walked: (a) a handle whose twin was never created —
|
||||
`ReleaseByHandle` returns an empty `BackendPtr` and `Ops_OnDestroy` fast-outs on `!resource`
|
||||
(`Managers.cpp:1741`); (b) destroy while the ops table is unregistered — the applier clears the record, the
|
||||
backend is not called, the slot is recycled, and the next `GetOrCreate` resets the orphaned twin whose
|
||||
destructor skips the driver because `g_backendContextGeneration` moved; (c) the create/destroy latch
|
||||
asymmetry — that is M-1, the only hole; (d) the process-teardown sentinel — armed on the handle overload too
|
||||
(`SlotTables.h:299`), and the buffer's death path is byte-for-byte the legacy `Ops_OnDestroy`, so no new
|
||||
teardown hazard. **The old twin is gone before the new create lands** in every ordering I could build.
|
||||
|
||||
**Base instance.** Three sites, all after `ConditionalRenderDiscardsCommand()` and immediately before `MGP_FILL`
|
||||
(`GL_Drawing.cpp:662, :685, :715`); `Reset()` deliberately does **not** clear the pending value
|
||||
(`Tracker.h:368-392`, B-C1 fixed); the value is mixed into bit 9's shutter so a base-instance-only change still
|
||||
reaches the emitter (`Tracker.h:285-286`); it is a `ContentHash` input so the suppressor cannot eat it
|
||||
(`VertexInputEmit.h:123-130, :233`); and it is cleared on **both** validate-point exits — the no-live-context
|
||||
early return (`PipeFill.cpp:1443`) and the end of step 3 (`:1527`), the latter unconditionally, outside every
|
||||
`wants()` gate. `DrawElementsIndirect` and the multi-draw tiering never set it, so they see 0; a plain draw
|
||||
after a base-instanced one sees 0 and re-fires the shutter. The server resolves the shift
|
||||
(`Managers.cpp:4043-4045`, `BaseInstanceByteShiftWire` at `:3666-3669`) and the client never learns the answer.
|
||||
|
||||
**Persistent map / readback / epoch.** The five-step order is implemented and named in place
|
||||
(`Managers.cpp:2058-2081`): writeback → unmap → `syncedChangeSerial` stamp → epoch bump in
|
||||
`Ops_H_ReadbackTracked`, and `MGPipeApplyResourceReadback` moves **no** serial (`PipeApply.cpp:1051-1053`).
|
||||
The `hostBytes` base-vs-base+offset mismatch (client-review B-M3, ID-12 "espryt must change") **is closed by
|
||||
reading both ends**: the client sends `base + offset` (`PipeFill.cpp:651-659`, `:701`) and espryt subtracts it
|
||||
back — `hostBytes = bytes - offset` at `Managers.cpp:1921` and `bytes - start` at `:1969`. `OnBufferWriteback`'s
|
||||
shape agrees on both sides: espryt passes `record.Offset` as the destination and `mapped` as the address
|
||||
(`:2069-2072`), the client writes `WritebackFromBackend({addr, size}, offset)` (`ResourceTracker.h:582-585`).
|
||||
`OnGpuWritten` is one whole-buffer range on both sides, asserted rather than assumed (`Managers.cpp:2436-2437`,
|
||||
`ResourceTracker.h:599-602`), and the client's handler sets **both** `m_hasDefinedContent` and
|
||||
`m_gpuWritePending` via `MarkGpuWritten()` (espryt-review m8's contract point — holds).
|
||||
`Ops_H_MapPersistent` (`Managers.cpp:2102-2181`) is D-E-conformant: the two permitted substitutions plus one
|
||||
**declared** third statement (`hostBytes = nullptr` at `:2170`, because `AdoptPersistentMap` frees the shadow) —
|
||||
that third change is sound and is the C-2 fix, but it is a third change against D-E's "exactly two", so it
|
||||
belongs in the phase-exit record against `ARCHITECTURE.md:466`.
|
||||
|
||||
**Serial / version coherence — one adversarial sequence per memo, all held.**
|
||||
- `m_syncedVertexBuffersSerial`: A→B→A make-current with a stable per-activation call count would land on a
|
||||
stamped value if the reset zeroed the serial. `MGPipeApplierReset` does `++` (`PipeApply.cpp:645-646`). ✔
|
||||
- `m_syncedElementsSerial` + `m_syncedElementsHandle`: after `MGPipeApplierReleaseObjectRecords` a re-created CSO
|
||||
at the same `{slot, gen}` restarts `ContentSerial` at 1, which would match a twin that had only ever seen one
|
||||
configuration. Rescued because that function **also** advances both global serials (`:658-659`), forcing
|
||||
`attributesDirty`. ✔ (The rescue is stated at `Managers.cpp:4020-4034`, which correctly names the rule as
|
||||
living in another package.)
|
||||
- `m_syncedIndexSerial`: the two element-array restore scopes put the driver id back without touching the
|
||||
serial, which is right — the serial records what the *applier* said (`Managers.cpp:4188-4194`). ✔
|
||||
- The fp64 stream memo: re-keyed on `{sourceHandle, applier Serial}` and never trusted for a persistently
|
||||
mapped source (`Managers.cpp:4508-4513`); a destroy drops the record whole and keeps `Gen`, and the successor
|
||||
gets `Gen+1`, so the handle compare covers slot recycling. ✔
|
||||
- Suppressor reserved 0: a computed 0 is remapped to 1 (`SetHashSuppressor.h:62`), `Invalidate` writes 0, and
|
||||
`InvalidateAll()` is called in the `FreshlyPrimed` block **beside** `MGPipeApplierReset()` and the emitter's
|
||||
own `Reset()` (`PipeFill.cpp:1479-1494`) — without that trio a make-current would suppress the re-bind and
|
||||
the server would draw with no vertex elements bound. ✔
|
||||
- The client's per-handle create/bind latch is keyed on `{slot, Gen, ConfigVersion}` (`VertexInputEmit.h:174-186,
|
||||
:304-308`), so ping-ponging two VAOs re-binds but never re-creates. ✔
|
||||
- Records survive a make-current, per-draw state does not: `MGPipeApplierReset` clears the working half and
|
||||
keeps `Resources`/`VertexElementsCsos` (`PipeApply.cpp:607-631`), and the rule is stated in three places that
|
||||
agree (`PipeApply.h:196-219`, `ResourceTracker.h:465-492`, `Managers.cpp:4020-4034`). ✔
|
||||
|
||||
**Applier window bounds.** `MGPipeApplySetVertexBuffers` polices `Start + Count` (`PipeApply.cpp:1289-1303`);
|
||||
the applier deliberately does not clear entries outside the window, and espryt bounds every read by
|
||||
`VertexBufferStart/Count` **and** re-checks `BindingIndex == attributeIndex`
|
||||
(`Managers.cpp:3647-3661` — the `13b380fe` fix; `glVertexAttribBinding(2,3)` was fetching the wrong entry).
|
||||
The 32-slot walk (not `rec->AttributeCount`) is what keeps the disable arm alive after a shrinking
|
||||
configuration, and it is independent of the client because `MGPipeApplyCreateVertexElements` zeroes both arrays
|
||||
before unpacking (`:1225-1226`). ✔
|
||||
|
||||
**Subsystem masks.** Default `0x1ff` (`ConfigLoader.cpp:257`); bit 8 requires bit 7 and is refused **by name**
|
||||
with a released `MGLOG_E` at `Managers.cpp:2326-2332`; `MOBILEGL_PIPE_LEGACY_MEMOS=0` compiles and the
|
||||
`SyncToBackend` armless path says so (`Managers.cpp:3746-3750`). G13 is clean: `pGLContext` appears zero times
|
||||
under `MG_Backend/`, and no `MG_State` type appears in the `MGPipeResourceOps` block. The contract payload
|
||||
(`MGPVertexBuffers` 24 B, `F(BaseInstance)` in `PipeFields.def:99-100`) is already in the `5cb826b0` base, so
|
||||
`git diff --stat -- MG_Pipe/generated PipeCalls.def PipeFields.def` over this range is legitimately empty.
|
||||
|
||||
**The gates, on the finished tree** (read; the cheap ones traced, none run in the shared tree):
|
||||
G5 green and *correctly* green against `44c2b5cf` for the nine original functions, with a real `--self-test`
|
||||
whose negative control for the tenth entry is non-vacuous — but see **C-2** for what the tenth entry protects.
|
||||
G7 patches `IsBgra` at the one site that exists, restores + rebuilds on every exit path (trap armed *before* the
|
||||
patcher), keeps its logs out of the repo, and its exit codes match the brief; it must be green-before and
|
||||
compile-after, so an exit 0 for a different reason is well fenced (see m3 for the residue).
|
||||
G8 has five `TEST_F`s and six registered lanes, the `.AbaControl` arm asserts the corruption with an explicit
|
||||
"if this ever goes green-by-being-correct the reproducer has stopped reproducing" (`:287-297`), the new buffer
|
||||
case at `:767` uses different colours at the same size/layout so a broken re-key reads red, and an unknown arm
|
||||
`FAIL()`s instead of falling through — the two soft spots are m5 and M-5's missing DirectGLES `.AbaControl`.
|
||||
G10 asserts 3 roundtrips for 3 storage definitions against 12 for per-draw, over a real `EndFrame`-delimited
|
||||
`PipeStats` window, with `found` / `>= 0` guards that separate "no stats channel" from "counter read zero", and
|
||||
its sibling `LargeArenaAdoption` pins `== 1` in a different window, so a stuck-at-3 counter cannot pass both.
|
||||
G12 tests both directions in one case (`on` → 2, `off` → 0) **and** asserts identical pixels on both arms —
|
||||
"the counters moved and the picture did not" — with `FAIL()` on an unknown lane.
|
||||
G9's scan root, the `DirtySurface.def` regeneration and the `MG_State` widening are in the diff and clean.
|
||||
|
||||
**CI.** The TEMPORARY `feat/disaggregated` push trigger is present and untouched (`test.yml:9-12`). Nothing was
|
||||
narrowed: the only `-R` change **broadens** `'HandleRecycle|CsoContentAddressing'` to
|
||||
`'HandleRecycle|CsoContentAddressing|ResourceSubsystem|MapPersistentRoundtrip'` in `build-verify` (`:614-615`),
|
||||
the only job that unpacks a push build; the singular `MapPersistentRoundtrip` deliberately catches both the
|
||||
lane prefix and `…AnAdoptionCostsExactlyOneMapPersistentRoundtrip`. `VertexInputEmit` is a `unit` suite and runs
|
||||
via `test.yml:570` in `build-verify`, which is the only configuration where its emission cases compile. Two new
|
||||
G5 steps, branch-scoped to `feat/disaggregated` or `workflow_dispatch`, so they retire with the trigger. No
|
||||
`LABELS`, `add_test`, `gtest_discover` or matrix entry was removed anywhere in the diff.
|
||||
|
||||
**Ownership-table "nobody" files that were touched.** `MG_Impl/GLImpl/Drawing/GL_Drawing.cpp` — exactly the three
|
||||
one-line `MGP_SET_BASE_INSTANCE` calls ID-10 granted and nothing else; the macro is pull-safe
|
||||
(`PipeFill.h:117-123`) so the three sites compile in a pull build too. `MG_Test/Buffer/BufferTest.cpp` — the
|
||||
integrator landed espryt-v3 §7's measured fix verbatim (`83302ca2`; `ScopedBackendOps` at `:1658-1675` now
|
||||
scopes the pipe table alongside `BufferBackendOps`), which closes the 26 red cases; correct and minimal, and it
|
||||
is itself evidence that the `Published` latch (client m12) was necessary. `MG_Test/Pipe/TrackerTest.cpp` —
|
||||
touched by B with B-DEV-5's justification.
|
||||
|
||||
---
|
||||
|
||||
## 5. Closure table — every "left for X" across the ten result/review files
|
||||
|
||||
Legend: **CLOSED** = a later file claims it with a `file:line` I could check; **DECLINED** = declined with a
|
||||
reason on the record; **DEFERRED** = explicitly a later phase's; **OPEN** = no claim found anywhere.
|
||||
Rows marked ⚑ are the ones I verified against the code myself.
|
||||
|
||||
### 5.1 Closed, and verified where marked
|
||||
|
||||
| id | declared | closed at |
|
||||
|---|---|---|
|
||||
| contract-review **M1** (Coverage.def omits DispatchIndirect/Query) | `contract-review-v1.md:23-58` | `wire-v2.md:35, :103-111` — `Coverage.def:40-58` |
|
||||
| contract-review **M2** ⚑ (`GetOrCreate(handle)` adopts a stale generation) | `:60-108` | `espryt-v2.md:126-145` → verified live at `SlotTables.h:315-325`, `Managers.cpp:2368-2374` |
|
||||
| contract-review m1/m2/m3(A)/m6 | `:112-154` | `wire-v2.md:40-42`; `client-v2.md:200` |
|
||||
| contract-review must-know 9 ⚑ (`Start+Count` policing) | `:337-340` | `PipeApply.cpp:1289-1303` |
|
||||
| contract-review must-know 10/11 | `:341-347` | `client-v2.md:200`; `gates-v2.md:54-97` ⚑ (`CMakeLists.txt:930, 1045-1060`) |
|
||||
| wire-review **C1b** ⚑ (refusals countable) | `wire-review-v1.md:496-497` | `PipeApply.h:220-229`, `PipeApply.cpp:476-490` |
|
||||
| wire-review **C2** ⚑ (serials advance, never zero) | `:499-502` | `PipeApply.cpp:645-646`, `:658-659` |
|
||||
| wire-review M-B/M-C/M-D/M-E, n1, n7 | `:505-514, :284-288, :304-310` | `wire-v2.md:36-44`; `client-v2.md:283-285` ⚑ (`BufferObject.cpp:435`) |
|
||||
| client-review **B-C1** ⚑ (Reset ate the pending base instance) | `client-review-v1.md:22-56` | `Tracker.h:368-392`; the substitute clear at `PipeFill.cpp:1443` |
|
||||
| client-review **B-C2** ⚑ (record re-publication) | `:58-97` | resolved per ID-12; rule at `ResourceTracker.h:465-492`, `PipeApply.h:196-219` |
|
||||
| client-review **B-M1** ⚑ (the three ID-10 sites) | `:103-119` | `GL_Drawing.cpp:662, :685, :715` |
|
||||
| client-review **B-M2** ⚑ (Acquire on content paths) | `:134-159` | `PipeFill.cpp:581-596` — content paths use `Find` |
|
||||
| client-review **B-M3** ⚑ (hostBytes base vs base+offset) | `:161-178` | espryt was already conformant: `Managers.cpp:1921`, `:1969` subtract |
|
||||
| client-review B-M4(a)/(b-NoteBoundAs)/secondary, m1-m6, m8-m12 | `:187-256` | `client-v2.md:151-210` |
|
||||
| espryt-review **C-1** ⚑ (draw-clean vs a live host map) | `espryt-review-v1.md:38-101` | `Managers.cpp:2577` — the probe asks `frontend->IsMapped()` again |
|
||||
| espryt-review **C-2** ⚑ (dangling hostBytes) | `:103-160` | `Managers.cpp:2170`, `:2637-2641`, `:2741` — **but see M-2 for the visibility half** |
|
||||
| espryt-review **M-2** ⚑ (walk bounded by AttributeCount) | `:191-213` | `Managers.cpp:4054-4067` — all 32 slots |
|
||||
| espryt-review **M-3** ⚑ (bit 8 without bit 7) | `:215-233` | `Managers.cpp:2326-2332` |
|
||||
| espryt-review **M-5** ⚑ (memo depends on wire's C2) | `:254-281` | `Managers.cpp:4020-4034` |
|
||||
| espryt-review m2 ⚑ (readback clamp past the offset) | `:291-294` | `Managers.cpp:2036-2040` |
|
||||
| gates-review M1-M4, m1-m6 ⚑ | `gates-review-v1.md:25-210` | `gates-v2.md:54-210`; ID-11's ten at `scripts/p3a_untouched_regions.sh:76-77` |
|
||||
| espryt-v3 §7 ⚑ (26 red `BufferTest` cases) | `espryt-v3.md:526-587` | **integrator landed it** as `83302ca2` — `MG_Test/Buffer/BufferTest.cpp:1658-1675` |
|
||||
| wire **n6** (which counter G10 asserts) ⚑ | `wire-v2.md:383-386` | no document, but the code answers: `Harness/PipeStatsWindow.h:26-28` reads `PipeStats`' `mpr`. **Close it on the record** |
|
||||
|
||||
### 5.2 Declined with a reason (accepted)
|
||||
|
||||
wire n2/n3/n4/n5/n8/n9 (`wire-v2.md:393-401`); espryt-review m4 — `FlushPendingRangesFrom`'s extra null check
|
||||
(`espryt-v2.md:216`, restated `espryt-v3.md:99-101`) — **note this is now one of C-2's three divergences**;
|
||||
client-review B-M4(b)'s `RefreshBindMask` half and client m7 (`client-v2.md:173-181, :297-303`); gates m7/m9
|
||||
(`gates-v2.md:241, :243`); contract-review m5.
|
||||
|
||||
### 5.3 Deferred to a later phase (accepted)
|
||||
|
||||
wire R1 → P5 (`MGPipeApplierReleaseObjectRecords` has no production caller); client B-M5 → the phase that gives
|
||||
the backend an unmap hook (`PipeFill.cpp:718-726`) ⚑ — recorded correctly; espryt D7 → P8 (**but see M-3**);
|
||||
espryt §5's three frontend reads → P5/P8; the vertex-elements CSO content-addressing → P7;
|
||||
`PipeResource::m_backend` deletion → P13.
|
||||
|
||||
### 5.4 OPEN — no claim found anywhere in the ten
|
||||
|
||||
| # | row | declared | owner as assigned | my verdict |
|
||||
|---|---|---|---|---|
|
||||
| 1 | `delete_vertex_elements` producer + VAO CSO slot free | `client-v2.md:308-309`, `espryt-v3.md:605-607` | package C | ⚑ **This is C-1.** Misattributed: Espryt already frees; Magma does not. **Must fix** |
|
||||
| 2 | espryt D12 / ID-13 — a push build has no `FlushPendingRangesNow` | `espryt-v3.md:75-106, :519-520` | integrator | ⚑ **This is C-2.** **Must rule + amend the script** |
|
||||
| 3 | espryt-review post-rebase 3 — named C-2 cases (adopted `DoublePrecision`, ASan `StorageBufferRegrow`) | `espryt-review-v1.md:493-495` | package D | ⚑ still owed; the run espryt-v3 reports is the one the review pre-refused. Feeds M-3 |
|
||||
| 4 | espryt-review post-rebase 2 — package D's itest for C-1 | `:489-492` | package D | still owed |
|
||||
| 5 | espryt-review post-rebase 4 — `VertexArrayEnableDisableScenario` with a **shrinking** enabled set | `:496-497` | package D | the only gate that can see M-2's fix; in the lane regex but no shrinking-config claim |
|
||||
| 6 | espryt-review post-rebase 6 — `LEGACY_MEMOS=0` + `PUSH=0x7f` must name a verdict | `:500-501` | integrator/D | ⚑ related to **M-4** |
|
||||
| 7 | espryt D14 — the armless verdict diagnoses and does not stop | `espryt-v2.md:272-273` | integrator | ⚑ **M-4**; the promotion condition is now met |
|
||||
| 8 | contract-review **m4** — the three pairing `static_assert`s | `contract-review-v1.md:136-142` → B | package B | ⚑ **M-5**; asymmetry survives at `PipeFill.cpp:933-947` |
|
||||
| 9 | gates **m10** — the DirectGLES buffer ABA positive control | `gates-v2.md:244, :369-371` | package C | ⚑ **M-5**; and there is no DirectGLES `.AbaControl` lane at all |
|
||||
| 10 | client §6.2 — the three `GL_Buffer.cpp` `NoteBoundAs` binder hooks | `client-v2.md:304-307` | **nobody** | ⚑ real but bounded: the two bits anything keys on are covered by `NoteBoundAs` at `VertexInputEmit.h:219, :267`. Carry to P4a |
|
||||
| 11 | espryt m6 / post-rebase 10 — record the per-draw `FindByLifetimeId` cost in D.4 | `espryt-review-v1.md:306-312, :508-509` | package D | measurement, not a defect |
|
||||
| 12 | espryt §4.9 — D.4.6's peak-RSS reading needs `retrace_gate.py` to grow | `espryt-v3.md:436-441` | package D | ⚑ **this is the measurement that would have caught C-1**; do it before the device runs |
|
||||
| 13 | gates §5.2/§5.3/§5.4/§5.6/§5.7, gates m8, §6.10, §6.11 — re-capture `p3a-before-untouched.sha` with the ten-line listing; run G7 on a tree carrying B; the four counting entries must stop skipping; `build-bench`; `gh workflow run test.yml` | `gates-v2.md:353-371`; `gates-review-v1.md:214-216, :363-365` | integrator | ⚑ **all still owed**; G7 in particular has never been run on a tree carrying B |
|
||||
| 14 | client-review §7.3 — the `Blob.Size` off-by-one control in a verify build | `client-review-v1.md:408-410` | integrator | still owed |
|
||||
| 15 | client-review §7.7 — G10 non-zero and G12 behavioural on the merged tree | `:423-425` | integrator | ⚑ now provable: the lanes exist and are CI-reachable (`test.yml:614-615`). Run once and record |
|
||||
| 16 | client-review §7.8 / espryt §7 — the `…ActuallyArmedWhenTheEnvironmentPinsItOn` shared-log race | `MG_IntegrationTest/CMakeLists.txt:1040` | integrator/D | still open; pre-existing, `-j 8` only |
|
||||
| 17 | contract-review m3 (Magma half), m7; contract §5.5; wire §6.9; espryt §1, §2, §4.7 | various | integrator (docs/tooling) | doc + tooling corrections, none load-bearing; espryt §2's "the G5 script self-`cd`s, so a foreign-cwd run is a false pass" is worth taking |
|
||||
| 18 | espryt §8 — the `ResolvedDrawBuffers::Entry::resource` invariant sentence | `espryt-v3.md:601-603` | a later pass | **m8** |
|
||||
| 19 | client §6.5 — the `MOBILEGL_PIPE_POISON_OMIT` caselist sweep | `client-v2.md:311-312` | G15 | off the critical path, as declared |
|
||||
| 20 | client-review §7.2 residue — `EveryAttributeFieldSurvivesTheWireConversion` as a full round trip | `:402-407` | integrator | declined with a reason by B (a second oracle would make G7's field-drop fail twice); accept |
|
||||
| 21 | gates §1 — gates' own G1/G14 are measured against `5cb826b0`, not the final tree | `gates-v2.md:44-48` | integrator | ⚑ **must re-measure before the verdict**: G1 is a hard gate and the number on record predates espryt and gates |
|
||||
|
||||
---
|
||||
|
||||
## 6. The exact fix list
|
||||
|
||||
**Blocking (REWORK):**
|
||||
|
||||
1. **C-1.** Give `VertexElementsCso` a backend-neutral death path. Preferred shape: the client emits
|
||||
`delete_vertex_elements` and calls `MGPipeSlots().Free(MGPipeKind::VertexElementsCso, handle)` from
|
||||
`~VertexArrayObject` under `#if MOBILEGL_PIPE_PUSH`, mirroring `MGPipeEmitResourceDestroyAndFree`
|
||||
(`PipeFill.cpp:741-763`) — emit first, free second, latch "was it published" the same way. That closes
|
||||
`client-v2` §6.3, `espryt-v3` §8's carry-forward and the applier's missing `delete_vertex_elements` producer
|
||||
in one edit, and it makes Espryt's existing death notice a redundant second path rather than the only one.
|
||||
Add a case: create N VAOs, destroy them, assert `MGPipeSlots().HighWater(VertexElementsCso)` /
|
||||
`LiveCount` does not grow — and run it on the DirectVulkan lane, which is where it fails today.
|
||||
2. **C-2.** Add `FlushPendingRangesFrom` to `scripts/p3a_untouched_regions.sh:76`
|
||||
(`EXPECTED_FUNCTION_COUNT=11`), capture its baseline sha at `3e298c9a`, and add it to
|
||||
`SELF_TEST_FUNCTIONS`. Record an **ID-14** that supersedes ID-13's "outside any `#if`" sentence with the
|
||||
two-arm shape the tree actually chose and the reason (`Managers.cpp:1127-1138`). Fix the "nine" wording in
|
||||
the script and `test.yml` while there (m2).
|
||||
3. **M-1.** In `MGPipeEmitResourceRespecify` (`PipeFill.cpp:629`), emit the create first when
|
||||
`!tracker.WasPublished(handle)`.
|
||||
4. **M-2.** Move the `hostBytes` store in `Ops_H_SubData` (`Managers.cpp:1921`) and `Ops_H_FlushRange`
|
||||
(`:1969`) inside the `pendingMutex` scope, or restrict it to the `CanTouchGLNow()` arm.
|
||||
5. **M-4.** Correct `Managers.cpp:2276-2282` and promote `NoArm` to a stop for both P3a families, now that the
|
||||
lanes carry an explicit `0x1ff` arm.
|
||||
6. **Re-measure G1 and G14 on `3e298c9a`** before the phase verdict (closure row 21). The numbers on record
|
||||
are gates' at `5cb826b0`; G1 is a hard gate with an empty admitted-resize set and it has not been read on
|
||||
the finished tree.
|
||||
7. **Run G7 once on this tree** (`bash scripts/p3a_vertex_input_negative_control.sh build-push`) — closure row
|
||||
13. It has never been executed on a tree carrying package B, and it is the negative control for G6.
|
||||
|
||||
**Non-blocking, but before the `dev` merge:**
|
||||
|
||||
8. **M-3.** Record the fp64 `SyncGpuWrites` arm-divergence as a ruled deviation in
|
||||
`INTEGRATOR-DECISIONS.md` and `MEASUREMENTS.md`'s P3a section, or land package D's adopted-source
|
||||
`DoublePrecisionScenario` case (closure rows 3-5).
|
||||
9. **M-5.** Close contract-review m4 (`PipeFill.cpp:933-947`), record wire n6 as answered by the code, and
|
||||
either add a DirectGLES `.AbaControl` lane or write down that the buffer ABA's corruption evidence is
|
||||
Magma-only.
|
||||
10. Minors m1, m3, m4, m5, m6, m7, m8 as written above; and grow `retrace_gate.py`'s peak-RSS reading
|
||||
(closure row 12) — it is the measurement that would have caught C-1 on its own.
|
||||
11. Remove the TEMPORARY `feat/disaggregated` trigger (`test.yml:9-12`) **at** the `dev` merge, not before —
|
||||
the two G5 steps are branch-scoped to it and retire together, which is intentional
|
||||
(`test.yml`, G5 step `if:`).
|
||||
@@ -0,0 +1,376 @@
|
||||
# P3a final rework — `final-review-v1.md` §6 answered on `p3a/final` (`3e298c9a..680ea633`)
|
||||
|
||||
Worktree `/home/swung/w7/p3a-final`, branch `p3a/final` from `3e298c9a`, head **`c20e2f2b`**.
|
||||
Twelve commits, one per finding, plus three corrections the verification itself forced (two test
|
||||
registrations and G7's own attribution — see §6 and §8). Nothing pushed.
|
||||
|
||||
**Everything the brief asked to be green is green**, including the two things that were not:
|
||||
C-1's leak case is **red before the fix and green after it, on the DirectVulkan lane**, and G5 now
|
||||
has **eleven rows** with a non-vacuous control on each of the two flush ladders.
|
||||
|
||||
---
|
||||
|
||||
## 1. Per-finding disposition
|
||||
|
||||
| # | finding | verdict | commit | where |
|
||||
|---|---|---|---|---|
|
||||
| C-1 | VAO CSO slot + applier record leak under any backend with no `StateObjectDeathOps` | **FIXED** | `78ff0145` (fix), `f0beefa8` + `680ea633` (tests) | see §2 |
|
||||
| C-2 | G5's tenth row protects text no push build compiles | **FIXED per ID-15** | `9ba5d7ba` | see §3 |
|
||||
| M-1 | a `BufferObject` born with the op table unregistered never gets a record | **FIXED + test** | `433f51a0`, `959ca308` | `MG_Impl/Pipe/PipeFill.cpp:637-661`; test `MG_Test/Pipe/ResourceEmitTest.cpp:1807` |
|
||||
| M-2 | `hostBytes` written off the render thread with no synchronisation | **FIXED** | `afda613b` | `MG_Backend/DirectGLES/Managers.cpp:1949-1966`, `:2014-2019` |
|
||||
| M-3 | the fp64 stream's dropped `SyncGpuWrites` site | **RULED DEVIATION, recorded at the site** | `83c8101a` | `MG_Backend/DirectGLES/Managers.cpp:4546-4570`; §5 has the text for the docs |
|
||||
| M-4 | the stale promotion comment, and the promotion not made | **FIXED (now a stop)** | `2a5e0195` | `MG_Backend/DirectGLES/Managers.cpp:2325-2356`, `:2374-2380`, `:2424-2436`, `:3831-3843` |
|
||||
| M-5 | four cross-package rows closed by nobody | **ALL FOUR CLOSED** | `707bced4` (+ C-1 for row 1) | see §4 |
|
||||
| §6.6 | re-measure G1/G14 on `3e298c9a` | **not redone** (integrator's, per the brief); **G1 re-run on the final tree**, 0/0/0/0 | — | §6 |
|
||||
| §6.7 | run G7 once on this tree | **not redone**; re-run anyway because m3 changed its trip detection | — | §6 |
|
||||
| minors | m1, m3, m4, m6, m8 taken; m2 folded into C-2 | **TAKEN** | `0bff6875`, `9ba5d7ba` | §7 |
|
||||
| minors | m5, m7 and closure row 12 (`retrace_gate.py` RSS) | **NOT TAKEN**, with reasons | — | §7 |
|
||||
|
||||
### The commits, oldest first
|
||||
|
||||
```
|
||||
78ff0145 [Fix] (MG_Impl, MG_State, DirectGLES): give the vertex-elements CSO a backend-neutral death path ...
|
||||
f0beefa8 [Test] (MG_Test, MG_IntegrationTest): assert a destroyed vertex array returns its CSO slot ...
|
||||
9ba5d7ba [CI] (scripts, test.yml, DirectGLES): hash FlushPendingRangesFrom as G5's eleventh row ...
|
||||
433f51a0 [Fix] (MG_Impl, MG_Test): publish the create a respecify's handle never got ...
|
||||
afda613b [Fix] (DirectGLES): publish GLESBufferResource::hostBytes under pendingMutex ...
|
||||
2a5e0195 [Fix] (DirectGLES): stop on an armless P3a subsystem verdict ...
|
||||
83c8101a [Fix] (DirectGLES): record the fp64 narrowing's dropped SyncGpuWrites as a ruled P3a deviation ...
|
||||
707bced4 [Fix] (MG_Impl, MG_Pipe, MG_IntegrationTest): close the four cross-package rows nobody claimed ...
|
||||
0bff6875 [Fix] (MG_Impl, DirectGLES, scripts): take the cheap review minors ...
|
||||
959ca308 [Test] (MG_Test): declare the new respecify-repair case in ResourceEmitTest pull-skip list (G2)
|
||||
680ea633 [Test] (MG_IntegrationTest): baseline the CSO slot leak case after two warm-up rounds
|
||||
c20e2f2b [Fix] (scripts): attribute G7 trip over the failing assertion BLOCKS ...
|
||||
```
|
||||
|
||||
The `ctest -L unit` / `-N` / G1 / G2 / G14 / G5 / integration numbers in §6 were measured at
|
||||
`680ea633`; `c20e2f2b` touches only `scripts/p3a_vertex_input_negative_control.sh`, which no build
|
||||
or ctest entry reads, and G7's own end-to-end run at that commit (§8) rebuilt and re-greened
|
||||
`build-push` as part of its repair step.
|
||||
|
||||
---
|
||||
|
||||
## 2. C-1 — the backend-neutral death path, and its red/green evidence
|
||||
|
||||
### The shape
|
||||
|
||||
`~VertexArrayObject` (`MG_State/GLState/VertexArrayState/VertexArrayObject.cpp:44-60`, still inside
|
||||
`#if MOBILEGL_PIPE_PUSH`) no longer raises the death notice itself. It calls one client helper,
|
||||
declared at `MG_Pipe/PipeMutation.h:127-141` and defined at `MG_Impl/Pipe/PipeFill.cpp:795-853`,
|
||||
which performs the whole death in a fixed order:
|
||||
|
||||
1. resolve the handle from the lifetime id;
|
||||
2. **if the applier holds a record** for it, `MGPipeApplyDeleteVertexElements` and forget it;
|
||||
3. `NotifyStateObjectDestroyed(VertexElementsCso, lifetimeId)` — **unconditional**, exactly as the
|
||||
destructor raised it before, so Espryt still drops the driver VAO and the P2 e2 gate
|
||||
(`SanityTest.DirectGLESSlotTable.EveryReKeyedObjectClassAnnouncesItsOwnDeath`) still sees this
|
||||
class announce itself;
|
||||
4. `MGPipeSlots().Free(VertexElementsCso, handle)`.
|
||||
|
||||
**Espryt's notice is now the redundant second path and the double release is harmless.** Its
|
||||
`OnFrontendObjectDestroyed` frees the same slot at step 3, so step 4 is a no-op: `MGPipeSlotAllocator::Free`
|
||||
refuses a slot that is not live at that generation and the `Gen` bump rides the *next handout*, not
|
||||
the free (`MG_Impl/Pipe/SlotAllocator.cpp:113-130`). That is asserted, not assumed —
|
||||
`VertexInputEmit.ADoubleReleaseOfAVertexElementsSlotIsHarmless`
|
||||
(`MG_Test/Pipe/VertexInputEmitTest.cpp:584`) frees by hand first, then runs the client path, and
|
||||
checks that the successor still gets `{same slot, moved gen}`.
|
||||
|
||||
### The one thing the review's shape needed that it did not name
|
||||
|
||||
**A slot is not evidence of a record.** DirectGLES mints a `VertexElementsCso` slot from
|
||||
`BackendSlotTable::GetOrCreate` at every VAO sync, whether or not bit 8 ever asked the client to
|
||||
emit a create — which is exactly what the shipped `MOBILEGL_PIPE_PUSH=0x7f` A/B control arm runs.
|
||||
`delete_vertex_elements` on such a handle is a refused call, and the refusal **asserts**
|
||||
(`PipeApply.cpp`'s `ResolveVertexElements` → `MOBILEGL_ASSERT` → `TRAP`), i.e. it stops a verify
|
||||
build. So the emitter carries a client-side record latch — `Latch::RecordLive` / `RecordGen`,
|
||||
`RecordIsPublished` / `NoteRecordDestroyed` at `MG_Impl/Pipe/VertexInputEmit.h:307-345`, set at
|
||||
`:406` where the create actually reaches the applier. It is deliberately **not** cleared by
|
||||
`Reset()`: `Reset()` clears the per-context half because a fresh context is a fresh server, and
|
||||
object records are precisely what `MGPipeApplierReset` does *not* drop.
|
||||
|
||||
`Managers.cpp:216-234` now says at the `VertexElementsCso` case that this arm is the second path
|
||||
and what it is still uniquely for (dropping the driver VAO).
|
||||
|
||||
### RED BEFORE / GREEN AFTER
|
||||
|
||||
The control restores **only** `VertexArrayObject.cpp` to `3e298c9a` — the pre-C-1 destructor, which
|
||||
raises the notice and nothing else. The helper stays compiled, so the tests still build and the run
|
||||
is real rather than stale. (A plain `git revert` of `78ff0145` does *not* work: it breaks the build
|
||||
and ctest then runs the previous binary and passes — that trap was hit once and is recorded here so
|
||||
the next person does not repeat it.)
|
||||
|
||||
**Unit (`build-verify`, a binary that installs no `StateObjectDeathOps` at all — the Magma shape):**
|
||||
|
||||
```
|
||||
RED-BEFORE VertexInputEmit.DestroyedVertexArraysReturnTheirCsoSlotsAndRecords ... FAILED
|
||||
Expected: (slots.HighWater(VertexElementsCso) - highWaterBefore) <= (3u), actual: 65 vs 3
|
||||
Expected: (peakLive) <= (liveBefore + 2u), actual: 64 vs 2
|
||||
GREEN-AFTER 100% tests passed, 0 tests failed out of 2
|
||||
```
|
||||
|
||||
**Integration (`build-push`, both `HandleRecycle.Handles` lanes) — the decisive one:**
|
||||
|
||||
```
|
||||
RED-BEFORE
|
||||
DirectGLES.HandleRecycle.Handles....DestroyedVertexArraysReturnTheirVertexElementsSlots Passed
|
||||
DirectVulkan.HandleRecycle.Handles..DestroyedVertexArraysReturnTheirVertexElementsSlots ***Failed
|
||||
[ HandleRecycle ] backend=DirectVulkan VertexElementsCso live 2 -> 50 (peak 50),
|
||||
high water 3 -> 51 over 48 create/draw/destroy rounds
|
||||
"48 vertex arrays were created, drawn with and destroyed and 48 VertexElementsCso slots
|
||||
never came back."
|
||||
GREEN-AFTER
|
||||
100% tests passed, 0 tests failed out of 2
|
||||
```
|
||||
|
||||
That is the review's claim reproduced exactly: **green on DirectGLES before the fix** (Espryt
|
||||
already freed) and **red on DirectVulkan** (nobody did) — 48 slots leaked over 48 rounds, the leak
|
||||
growing 1:1 with the churn — and both green after.
|
||||
|
||||
### The cases and their registration
|
||||
|
||||
- `MG_Test/Pipe/VertexInputEmitTest.cpp:527` `DestroyedVertexArraysReturnTheirCsoSlotsAndRecords`
|
||||
and `:584` `ADoubleReleaseOfAVertexElementsSlotIsHarmless`, both in the pull-skip list at `:134-135`.
|
||||
- `MG_IntegrationTest/Scenarios/HandleRecycleScenario.cpp:1015`
|
||||
`DestroyedVertexArraysReturnTheirVertexElementsSlots`. `TEST_FILTER "HandleRecycleScenario.*"`
|
||||
registers it on **all six** HandleRecycle lanes for free, so it runs on the DirectVulkan Handles
|
||||
lane where it failed, and `test.yml:614`'s `-R HandleRecycle|...` picks it up in `build-verify`
|
||||
too. It skips on the Legacy/AbaControl lanes (`MOBILEGL_PIPE_PUSH=0`, no allocator to leak from)
|
||||
and on a pull build.
|
||||
- The observable needed a new harness TU, `MG_IntegrationTest/Harness/PipeSlotPeek.{h,cpp}`
|
||||
(registered at `MG_IntegrationTest/CMakeLists.txt:54`), for `BackendCapsPeek.h`'s stated reason:
|
||||
the scenario sources include the GL headers with prototypes and MobileGL's umbrella header must
|
||||
not meet them in one file. It returns `false` where the allocator is out of reach (pull build,
|
||||
Android's hidden-visibility link) and the case **skips** there — "could not look" is never
|
||||
reported as "did not leak".
|
||||
- `680ea633` baselines after **two** warm-up rounds. The first draws in a process mint slots that
|
||||
legitimately never come back inside one case (the default vertex array's above all); the second
|
||||
round proves the steady state has been reached, since a per-round leak would still be growing.
|
||||
The assertions are then exact — `liveAfter == liveBefore` and `highWaterAfter == highWaterBefore`,
|
||||
no slack.
|
||||
|
||||
---
|
||||
|
||||
## 3. C-2 — the eleven-row G5 verdict (ID-15)
|
||||
|
||||
`scripts/p3a_untouched_regions.sh`:
|
||||
|
||||
- `EXPECTED_FUNCTION_COUNT=11` (`:98`);
|
||||
- `FUNCTIONS` keeps the pre-P3a ten; `PINNED_FUNCTIONS="FlushPendingRangesFrom"` with
|
||||
`PINNED_BASELINE_REF=3e298c9a` and
|
||||
`PINNED_SHA_FlushPendingRangesFrom=37fc94ffc5991923d222d585daa3af6511d2352d255623026ce35a3b6963c4a6`
|
||||
(`:88-96`), captured at `3e298c9a` as ID-15 directs;
|
||||
- `SELF_TEST_FUNCTIONS="ClearBufferPool FlushPendingRangesNow FlushPendingRangesFrom"` (`:107`) —
|
||||
**both** ladders get a negative control, because the whole point of the eleventh row is that
|
||||
there are two bodies and either can drift;
|
||||
- a new `extract_baseline()` beside `extract_ref()`: the `<ref-b>` side must define all eleven
|
||||
exactly once, while the `<ref-a>` side falls back to the pinned sha **only** for a
|
||||
`PINNED_FUNCTIONS` name that is absent there — and it re-extracts the pre-P3a ten strictly first,
|
||||
so a genuine rename of one of *those* is still exit 2 and never a silently short list. CI passes
|
||||
`${BASELINE}` (the P3a base ref) as `<ref-a>`, where `FlushPendingRangesFrom` does not exist, so
|
||||
this is the path CI takes.
|
||||
|
||||
`FlushPendingRangesNow` is **untouched** and still lives inside the `#else`. The comment at
|
||||
`Managers.cpp:1139-1166` now states the two-arm shape and that both ladders are hashed from here on
|
||||
(see §5 for the sentence the docs should carry). `test.yml:1636-1660` says "ELEVEN named bodies",
|
||||
"six canned controls" and why the eleventh's baseline is pinned rather than read from `BASELINE` —
|
||||
m2's "nine" wording is gone from both files.
|
||||
|
||||
**Verdict, on the final tree:**
|
||||
|
||||
```
|
||||
scripts/p3a_untouched_regions.sh 3e298c9a HEAD -> rc 0, 11 rows, "byte-identical"
|
||||
scripts/p3a_untouched_regions.sh 5cb826b0 HEAD -> rc 0 (the eleventh row takes its PINNED baseline,
|
||||
and says so on stderr)
|
||||
scripts/p3a_untouched_regions.sh --self-test -> rc 0, six controls:
|
||||
positive: 11 bodies extracted / an untouched copy compares equal / an edit outside is invisible
|
||||
negative: ClearBufferPool, FlushPendingRangesNow, FlushPendingRangesFrom each reported BY NAME
|
||||
```
|
||||
|
||||
The eleven shas at HEAD are identical to those at `3e298c9a`:
|
||||
|
||||
```
|
||||
ba79b92d… IsPoolable 15259e54… ProcessDeferredBufferReleases
|
||||
6563286e… EnrollIntoPool 2daaa525… CreateRingStorage
|
||||
dc9d3066… AcquireFromPool 6221df2e… RingAvailable
|
||||
12656cfd… TrimBufferPool 709b6f41… RingAllocate
|
||||
c44a1274… ClearBufferPool c6557002… FlushPendingRangesNow
|
||||
37fc94ff… FlushPendingRangesFrom
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. M-5 — the four open rows
|
||||
|
||||
| row | disposition |
|
||||
|---|---|
|
||||
| `delete_vertex_elements` producer + VAO CSO slot free (package C) | **This was C-1.** Closed by `78ff0145`; the producer now exists and is the client's. |
|
||||
| contract-review **m4** — the three pairing `static_assert`s (package B) | **Closed in code**, `MG_Impl/Pipe/PipeFill.cpp:1010-1040`. All three now compare against `SubsystemForEmitter(MGPipeFieldEmitter::BindVertexElements)` rather than two of them against the constant, and the `== 0 \|\|` escape hatch is **removed** — it was explicitly conditional on the dirty half being unmapped, and the dirty half is now mapped (`Tracker.h:145-148`). Leaving it would have let a later edit *unmap* one of these bits silently. |
|
||||
| gates **m10** — no DirectGLES `.AbaControl` positive control (package C) | **NOT registration-only, so written down instead**, `MG_IntegrationTest/CMakeLists.txt:895-914`. `Features.PipeHandleAbaControl` has exactly one consumer in the tree (`DirectVulkan/Renderer/MagmaPipeArms.h:198`), so a DirectGLES `.AbaControl` lane would run with the knob inert, fail to reproduce the corruption it asserts, and go **red in an always-on `integration-gpu` lane** — the exact failure mode this file's own header records having had once. The note states what that costs (on DirectGLES the buffer case proves the re-key does not alias, and nothing proves the reproducer could still see an aliasing reintroduced there) and what would close it (one `if` in Espryt's slot table, the way `MagmaPipeClaimSlotMemos` is Magma's). |
|
||||
| wire **n6** — which counter G10 asserts against (package D) | **Closed on the record, in code**, `MG_Pipe/PipeApply.cpp:631-645`. G10/G12 read `PipeStats`' process-wide `mpr` out of the lane log through `Harness/PipeStatsWindow.h` — they cannot link the applier symbol at all — so the per-applier `MapPersistentRoundtrips` being zeroed at every make-current cannot silently reset what they measure. This also closes minor **m6**, which asked for exactly that sentence. |
|
||||
|
||||
---
|
||||
|
||||
## 5. For the integrator's documents
|
||||
|
||||
Two things need to leave this file and land in `INTEGRATOR-DECISIONS.md` / `MEASUREMENTS.md`.
|
||||
|
||||
### (a) M-3 — the ruled deviation (`docs`, and `MEASUREMENTS.md`'s P3a section)
|
||||
|
||||
> **The fp64 vertex-array narrowing drops one of D-N's eleven `SyncGpuWrites` sites on the handle
|
||||
> arm, and that is RULED for P3a rather than an oversight.** D-N's wording is "no *move* of those
|
||||
> sites off the frontend"; this arm does not move it, it **cannot make it at all** —
|
||||
> `SyncFloat64AttributeAsFloat32ByHandle` holds a handle and the call needs a frontend
|
||||
> `BufferObject`, and the server having no inverse map back to a frontend object is the design
|
||||
> (ARCHITECTURE.md 4.2), not a gap in it. The two ways to keep the site would each break something
|
||||
> D-N or D-J protects: a handle→object map is the very thing the split removes, and pulling the
|
||||
> bytes eagerly on the client at every draw is new behaviour and new cost.
|
||||
>
|
||||
> **Blast radius, stated so it can be checked later:** under the default mask, a 64-bit vertex array
|
||||
> whose *source* buffer was written by a shader and not yet pulled back narrows stale bytes on the
|
||||
> handle arm and fresh bytes on the legacy arm. That is the whole of it — fp64 vertex arrays, fed by
|
||||
> a shader-written buffer, read with no intervening explicit readback. No other attribute type reads
|
||||
> through this path, and a persistently mapped source is excluded separately (the memo never trusts
|
||||
> one). **P8 closes it** by moving the pull to the client where the object lives. Until then this is
|
||||
> the one behavioural difference between the two arms under the default mask.
|
||||
|
||||
The same text is at the site, `MG_Backend/DirectGLES/Managers.cpp:4546-4570`.
|
||||
|
||||
**Package D's `DoublePrecisionScenario` with an adopted source was NOT added.** It is not cheap
|
||||
under an hour: the scenario would have to drive a compute/XFB write into the fp64 source buffer and
|
||||
then read the narrowed attribute back, on a lane where an adopted (`≥16 MiB`, persistently mapped)
|
||||
store is actually taken — and the persistently mapped case is exactly the one the memo excludes, so
|
||||
the case has to force the *non*-adopted shader-written shape instead, which is a new workload rather
|
||||
than a parameter on the existing one. It stays package D's, and closure rows 3/4/5 stay open with
|
||||
that reason. The deviation is now recorded in code, which is what makes it auditable in the
|
||||
meantime.
|
||||
|
||||
### (b) C-2 — the two-arm statement (supersedes ID-13's "outside any `#if`" sentence)
|
||||
|
||||
> **ID-15.** `Managers.cpp` carries the three-tier flush drain twice, once per preprocessor arm, and
|
||||
> exactly one is compiled into any build: `FlushPendingRangesFrom` under `#if MOBILEGL_PIPE_PUSH` is
|
||||
> what a **push** build runs — both call sites, the legacy one and `Ops_H_Readback`, reach it — and
|
||||
> `FlushPendingRangesNow` inside the `#else`, byte-identical to `5cb826b0`, is what a **pull** build
|
||||
> runs. A push build compiles no `FlushPendingRangesNow` at all. No forwarder is possible: G5's
|
||||
> extractor is preprocessor-blind, so a forwarding `FlushPendingRangesNow` would leave two
|
||||
> definitions of one name and the gate would exit 2 — a gate that cannot run — rather than compare
|
||||
> anything. Therefore **both** names are G5 rows: eleven functions, the pull ladder compared against
|
||||
> the P3a base ref and the push ladder against a sha pinned at `3e298c9a`. Neither ladder may drift,
|
||||
> and neither may drift away from the other without the gate saying so.
|
||||
|
||||
### (c) One more line worth a doc row
|
||||
|
||||
`MG_IntegrationTest/Harness/PipeSlotPeek.{h,cpp}` is new and is the first thing in the integration
|
||||
module that reads the **client slot allocator** directly. It belongs beside `BackendCapsPeek` in any
|
||||
list of the module's "looks past the GL API" seams.
|
||||
|
||||
---
|
||||
|
||||
## 6. Verification transcript (all on `p3a/final` at `680ea633`)
|
||||
|
||||
```
|
||||
### builds x3 ###
|
||||
BUILD_build-linux=0 BUILD_build-push=0 BUILD_build-verify=0
|
||||
|
||||
### ctest -L unit x3 ###
|
||||
UNIT_build-linux=0 100% tests passed, 0 tests failed out of 1622
|
||||
UNIT_build-push=0 100% tests passed, 0 tests failed out of 1622
|
||||
UNIT_build-verify=0 100% tests passed, 0 tests failed out of 1622
|
||||
(1619 at 3e298c9a; +3 = 2 VertexInputEmit + 1 ResourceEmit)
|
||||
|
||||
### G1 pull symbols, --threshold 0, vs ~/w7/p3a-before-libMobileGL.so (the b9eaa474 pull build) ###
|
||||
G1=0 Removed (0) Added (0) Resized (0) Renamed only (same size) (0)
|
||||
-> the ~VertexArrayObject edit is push-guarded; the pull build is byte-identical.
|
||||
|
||||
### G2 pull vs push ctest names ###
|
||||
pull=2588 push=2588 G2_DIFF=0
|
||||
|
||||
### G14 vs ~/w7/p3a-before-ctest-names.txt ###
|
||||
REMOVED=0 ADDED=69
|
||||
|
||||
### G5 ###
|
||||
G5_3E=0 (3e298c9a..HEAD) G5_BASE=0 (5cb826b0..HEAD) 11 rows G5_SELFTEST=0 (6 controls)
|
||||
|
||||
### generators + closure ###
|
||||
GENPIPE=0 DIRTY=0 DIRTY_SELFTEST=0 CLOSURE=0 (--mode text, 4 probes, 0 forbidden)
|
||||
|
||||
### integration-gpu, default mask, build-push, -j 8 ###
|
||||
IGPU=0 100% tests passed, 0 tests failed out of 966
|
||||
|
||||
### integration-gpu, MOBILEGL_PIPE_PUSH=0x7f, build-push, -j 8 ###
|
||||
IGPU_7F=0 100% tests passed, 0 tests failed out of 966
|
||||
|
||||
### build-verify -R 'HandleRecycle|VertexElements|Leak' --no-tests=error ###
|
||||
VERIFY_R=0 100% tests passed, 0 tests failed out of 76
|
||||
|
||||
### integration-verify, build-verify, -j 4 ###
|
||||
IVERIFY=0 100% tests passed, 0 tests failed out of 844
|
||||
FATAL_IN_VERIFY=0
|
||||
```
|
||||
|
||||
Notes on the transcript:
|
||||
|
||||
- **`ctest -L unit` is 1622 in all three builds and `ctest -N` is 2588 in both**, which is what
|
||||
forced `959ca308`: `ResourceEmitTest` keeps an explicit pull-skip list for G2, and a new push-only
|
||||
case has to be declared in it or the pull build is one name short. A first pass had `G2_DIFF=1`.
|
||||
- **One flake seen and not reproduced.** The very first `integration-gpu -j 8` run reported
|
||||
`DirectGLES.SnormAttachmentScenario.SignedNormalizedAttachmentsRoundTripTheirChannelValues
|
||||
(Subprocess aborted)`. It passed in the `0x7f` run of the same batch, in every later run, and in
|
||||
the integrator's own gate on `3e298c9a` (958/958). Unrelated to this diff; llvmpipe under `-j 8`.
|
||||
- **§6 items 6 and 7 were not redone**, per the brief. G1 *was* re-run here on the final tree
|
||||
(above). G7 was re-run anyway, because minor m3 changes its trip detection and a gate whose
|
||||
detector I edited has to be shown still tripping — result in §7.
|
||||
|
||||
---
|
||||
|
||||
## 7. Minors
|
||||
|
||||
### Taken
|
||||
|
||||
| # | what was done | where |
|
||||
|---|---|---|
|
||||
| m1 | the stale "all three still resolve to false today — their dirty bits map to no subsystem" sentence replaced with what is true now (bits 5/9/10 are mapped, all three emitters have bodies, `wants()` answers true under the 0x1ff default on every backend) | `MG_Impl/Pipe/PipeFill.cpp:1588-1595` |
|
||||
| m2 | the "nine" wording in the G5 script and `test.yml` corrected to eleven, and the control count corrected from "three canned controls" to six | `scripts/p3a_untouched_regions.sh` (header, usage, exit codes, self-test messages), `.github/workflows/test.yml:1636-1660` |
|
||||
| m3 | G7's trip attribution matched against the **failing assertion's own lines** instead of `grep -q IsBgra` over the whole ctest log; `INT` and `TERM` traps added beside `EXIT`, each repairing and then re-raising with the default disposition so the exit status still reports the signal | `scripts/p3a_vertex_input_negative_control.sh:174-179`, `:230-241` |
|
||||
| m4 | the extractor reconfigures stdout to `newline='\n'`, so the sha list stays LF under Git Bash / MSYS python and the `awk -v n=` lookup stops missing every row | `scripts/p3a_untouched_regions.sh:269-276` |
|
||||
| m6 | closed together with wire n6 — see §4 | `MG_Pipe/PipeApply.cpp:631-645` |
|
||||
| m8 | the `ResolvedDrawBuffers::Entry::resource` invariant written **at the member**: the pointer may dangle, and the rule is that it is only ever dereferenced after the entry's identity has been re-resolved in the same pass (`FindByHandle` on the handle arm, the frontend identity compare on the legacy one); a third consumer that read it straight out of a "valid" memo would be reading freed memory and no compare in the struct would catch it; and why it stays raw | `MG_Backend/DirectGLES/Managers.h:980-999` |
|
||||
|
||||
### Not taken, with reasons
|
||||
|
||||
| # | why not |
|
||||
|---|---|
|
||||
| m5 | G8's DirectGLES `.Handles` arm degrading to a SKIP when `MGPipeResourceOps` is renamed is a **property of the marker mechanism**, not of this lane: all six `mgl_itest_probe_for_symbol` markers behave that way, by design, and the review itself calls it "honest (visible skip with a reason)". Fixing it for one marker only would leave five behaving differently; fixing it for all six is a gates-package change to the probe contract (a probe that must find its symbol, or configure-time red), which is out of scope for a rework round and would go red on any tree where a package has not landed yet — the exact thing the SKIP exists to avoid. |
|
||||
| m7 | `MGPipeSlots()` being mutated from `BufferObject`'s constructor and destructor is already stated at length where it matters (`MG_Impl/Pipe/PipeFill.cpp:566-580`: the mint happens once, on the GL thread, and the content paths therefore only ever *look up*). Turning "GL thread by construction" into something enforced means a thread assertion on the allocator or a lock inside it — a design change to the allocator, on the hot path, that P3a's brief does not authorise. Carry to the phase that gives the allocator a per-client-context instance (the header already says "under split there is one per client context"), which removes the sharing rather than guarding it. |
|
||||
| closure row 12 | growing `retrace_gate.py`'s peak-RSS reading is a **tools** change (`~/w7/notes/tools/`, ID-3: the integrator's, not a package's) and it is a device-run prerequisite, not a tree fix. It remains the measurement that would have caught C-1 on its own, and it should be done before the D.4 device runs — but C-1 now has a deterministic gate that does not need it. |
|
||||
|
||||
---
|
||||
|
||||
## 8. G7 on this tree — and the one thing minor m3 got wrong first
|
||||
|
||||
`bash scripts/p3a_vertex_input_negative_control.sh build-push`, run because m3 edited G7's trip
|
||||
detector and a gate whose attribution logic changed has to be shown still tripping.
|
||||
|
||||
**First run: rc 1, `INCONCLUSIVE`.** m3's first attempt matched the field name against single
|
||||
*lines* carrying `Failure` / `error:` / `Expected`. gtest does not print it there — it prints
|
||||
`<file>:<line>: Failure`, then the compared **expressions** on their own lines
|
||||
(` wire.IsBgra`, ` attrib.IsBgra ? 1 : 0`), then the values. So a real trip was reported as "went
|
||||
red but never named the field". The gate caught my own edit, which is what it is for.
|
||||
|
||||
**Fixed in `c20e2f2b`**: the unit is the failure **block**, not the line — awk prints from a
|
||||
`: Failure` / `: error:` line until the next blank line, and the field is grepped in that. Validated
|
||||
against the recorded failing log (16 hits inside the blocks, the same 16 the whole file has, i.e.
|
||||
the tightening loses nothing real) and then re-run end to end:
|
||||
|
||||
```
|
||||
[p3a-g7] VertexInputEmit\. is green before the patch
|
||||
[p3a-g7] neutralised 1 assignment(s) to .IsBgra
|
||||
[p3a-g7] the patched header still compiles, so the record still has the field and still asserts its size
|
||||
[p3a-g7] restored MobileGL/MG_Impl/Pipe/VertexInputEmit.h; rebuilding build-push from it
|
||||
[p3a-g7] the tree is restored, rebuilt and green again
|
||||
[p3a-g7] negative control tripped, naming IsBgra, and the tree is green again
|
||||
G7_RC=0
|
||||
```
|
||||
|
||||
Same verdict the integrator recorded on `3e298c9a` ("tripped, naming IsBgra"), now on a tree whose
|
||||
detector is no longer a whole-log substring search. The final commit list is the eleven in §1 plus
|
||||
`c20e2f2b`; `git status` is clean.
|
||||
@@ -0,0 +1,365 @@
|
||||
# P3a package D (`gates`) — adversarial review v1
|
||||
|
||||
Reviewed `1ef91dec` / `588d25e9` / `80f6bf1b` on `p3a/gates` (worktree `/home/swung/w7/p3a-gates`, parent
|
||||
`39722687`), against `BRIEF-P3A.md` A/B/C.3/D.2/D.3/E, `INTEGRATOR-DECISIONS.md` ID-1/ID-2/ID-8 **and the
|
||||
newly added ID-9**, `contract-v1.md` + `contract-review-v1.md` (item 11), `wire-v1.md`, `espryt-v1.md`, and
|
||||
the package's own `gates-v1.md` + `handlerecycle-before.log`.
|
||||
|
||||
Nothing in `p3a-gates` was modified. A private worktree `/home/swung/w7/p3a-review-gates` was created at
|
||||
`80f6bf1b`, used to run both scripts, and removed (`git worktree list` clean; `p3a-gates` `git status` empty).
|
||||
|
||||
## Verdict: **REWORK** — four majors, all mechanical (three edits and one integrator decision)
|
||||
|
||||
The package is well built and the two scripts are genuinely honest instruments: I ran them and they answer
|
||||
correctly on every path I could reach, including against the real P3a-rewritten `Managers.cpp`. Nothing here
|
||||
passes on a broken tree and no test name was removed or renamed. What blocks acceptance is narrower: an
|
||||
explicitly assigned open review item is two-thirds undone while the report says it is done (M1), eight new
|
||||
CI entries whose whole purpose is the P3a A/B are never selected by any push-build CI run (M2), a script
|
||||
that breaks its own written exit contract on the one path that matters (M3), and a G5 set that omits the
|
||||
function the brief's risk table names as G5-protected (M4).
|
||||
|
||||
---
|
||||
|
||||
## 1. Majors
|
||||
|
||||
### M1 — contract-review item 11 is one-third addressed; the four CSO stats lanes still pin `0x7f`, and the report claims the item closed
|
||||
|
||||
**Evidence.** `contract-review-v1.md:344-347` reads: *"The `.Handles` **and stats** itest lanes still pin
|
||||
`MOBILEGL_PIPE_PUSH=0x7f` (`MG_IntegrationTest/CMakeLists.txt:863, 965, 975`) … Package D owns that file:
|
||||
G12's A/B needs an explicit `0x1ff` arm (or the pins re-read as the control they now are)."*
|
||||
|
||||
At the contract commit those three line numbers are:
|
||||
- `:863` → `MGL_ITEST_HANDLES_ARM_KNOBS` — **fixed**, now `0x1ff` at `MG_IntegrationTest/CMakeLists.txt:930`.
|
||||
- `:965` → `MGL_ITEST_GLES_CSO_ON_ENVIRONMENT` — **unchanged**, still `0x7f` at HEAD `:1032`.
|
||||
- `:975` → `MGL_ITEST_VULKAN_CSO_ON_ENVIRONMENT` — **unchanged**, still `0x7f` at HEAD `:1042`.
|
||||
- and their Off twins at `:1037`, `:1047` still `0x800000000000007f`.
|
||||
|
||||
`gates-v1.md` §1 and D4 describe the change as the `MGL_ITEST_HANDLES_ARM_KNOBS` pin only and never mention
|
||||
the CSO lanes; the report presents item 11 as handled.
|
||||
|
||||
**Failure scenario.** After P3a lands, `DirectGLES/DirectVulkan.CsoContentAddressing.{On,Off}` — the P2
|
||||
control that proves CSO content addressing is real — runs with bits 7 and 8 **cleared**, i.e. on a
|
||||
configuration nothing ships. It keeps passing. This is verbatim the objection the package itself writes at
|
||||
`CMakeLists.txt:934-941`: *"Pinning it at 0x7f after P3a would leave the Handles arm asserting the P2 shape
|
||||
while the … handles it is supposed to be about stayed switched off — a lane that still passes and no longer
|
||||
measures the key that ships."* The rule was applied to one lane family and not to the two the review named.
|
||||
|
||||
**Refutation attempted.** Could the CSO lanes need `0x7f` deliberately? The counters they read (`csom`,
|
||||
`csob`) are render-state, untouched by bits 7|8, so raising the mask is behaviour-preserving for what they
|
||||
assert — and D's own stated principle ("the mask is the PHASE default, not a hand-picked bit") points the
|
||||
other way. I found no comment anywhere in the file or the report defending `0x7f` for these lanes. If there
|
||||
is a reason, it is unwritten, which is itself the finding.
|
||||
|
||||
**Fix.** `0x7f`→`0x1ff` at `:1032, 1042` and `0x800000000000007f`→`0x80000000000001ff` at `:1037, 1047`,
|
||||
re-run the four CSO lanes; **or** write the decision down in the file and in `gates-v1.md` §D4 and say item
|
||||
11 is closed by argument rather than by change.
|
||||
|
||||
---
|
||||
|
||||
### M2 — the `ResourceSubsystemOn.` / `ResourceSubsystemOff.` lanes (8 entries) never execute in a push build in CI, so the G12/D-A3 A/B cannot go red where it was installed
|
||||
|
||||
**Evidence.** `.github/workflows/test.yml:600-602` (as edited by this package):
|
||||
|
||||
```
|
||||
ctest --output-on-failure -L integration-gpu \
|
||||
-R 'HandleRecycle|CsoContentAddressing|ResourceSubsystemControl|MapPersistentRoundtrips' \
|
||||
--no-tests=error -j 4
|
||||
```
|
||||
|
||||
None of the four alternatives matches the new lanes:
|
||||
`DirectGLES.ResourceSubsystemOn.LargeArenaAdoptionScenario.SubDataAfterAnInFlightDrawReachesTheNextDraw`
|
||||
does not contain `ResourceSubsystemControl`, and
|
||||
`…ResourceSubsystemOn.LargeArenaAdoptionScenario.AnAdoptionCostsExactlyOneMapPersistentRoundtrip` does not
|
||||
contain `MapPersistentRoundtrip**s**` (the case name is singular). The only place the full label runs is the
|
||||
**pull** `build-linux` job (`test.yml:293-298`, `ctest -L integration-gpu`), where `MOBILEGL_PIPE_PUSH`
|
||||
steers nothing at all (`Config.h` declares the field inside the push guard) — so both arms are the same
|
||||
legacy path there. `integration-verify` is the only job that unpacks a push build (`test.yml:573`), and it
|
||||
runs only the filtered step above.
|
||||
|
||||
Net: the eight entries D added — the four `ResourceSubsystemOn.` and four `ResourceSubsystemOff.`
|
||||
`LargeArenaAdoptionScenario` entries, whose stated purpose (`CMakeLists.txt:1176-1182`) is *"if the handle
|
||||
path and the legacy BufferBackendOps path disagree about any of it, one of these two lanes goes red and
|
||||
names which"* — are, in CI, either a duplicate legacy run or not run.
|
||||
|
||||
**Failure scenario.** Espryt's handle arm and its legacy `BufferBackendOps` arm disagree about an adopted
|
||||
store's in-flight SubData / readback / GPU-write; the lane that exists to name that disagreement never runs
|
||||
with the bits set; CI is green; the divergence ships and is found on device.
|
||||
|
||||
**Refutation attempted.** `gates-v1.md` §8 item 5 does say the label-wide A/B is the integrator's. That is
|
||||
true of `MOBILEGL_PIPE_PUSH=0x7f ctest -L integration-gpu`, but D also chose to add these eight entries to
|
||||
CI's push build and then did not select them there; ROADMAP.md:7 asks a gate to be able to go red where it
|
||||
is installed. The pull job does run the entries — but with the mask inert, which is the "green that asserts
|
||||
nothing" the package's own comments reject elsewhere.
|
||||
|
||||
**Fix.** One string: `-R 'HandleRecycle|CsoContentAddressing|ResourceSubsystem|MapPersistentRoundtrip'`
|
||||
(drop `Control`, drop the plural). Confirm afterwards that all 16 new push-build entries appear in the
|
||||
step's `ctest` listing.
|
||||
|
||||
---
|
||||
|
||||
### M3 — `p3a_vertex_input_negative_control.sh` breaks its documented exit-1 contract: the "did not trip" path leaves the build directory holding the library built from the patched header
|
||||
|
||||
**Evidence.** Header contract, `scripts/p3a_vertex_input_negative_control.sh:40-44`: *"1 the control did
|
||||
not answer: either the suite stayed green with the field dropped, or it went red without ever naming
|
||||
IsBgra … **and both leave the tree restored AND rebuilt**"*. The second of those two branches honours it
|
||||
(`:186-197` restore → rebuild → re-ctest → `exit 1` at `:204`). The first does not:
|
||||
|
||||
```
|
||||
161 if ctest --test-dir "$BUILD_DIR" -R "$TEST_NAME" … ; then
|
||||
163 say "NEGATIVE CONTROL DID NOT TRIP: …"
|
||||
166 cp -f "$LOG_DIR/ctest-after.log" ./p3a-vertex-input-control-failure.log
|
||||
168 exit 1
|
||||
169 fi
|
||||
```
|
||||
|
||||
`exit 1` runs only the `trap 'restore' EXIT` installed at `:126`, which copies the header back and does
|
||||
nothing else. The script's own comment at `:171-174` states the rule it is violating: *"leaving a build
|
||||
directory holding the broken header is worse than any exit status."*
|
||||
|
||||
Separately, both exit-1 branches `cp` a log into `$REPO_ROOT` (`:166`, `:200`). `.gitignore` carries no rule
|
||||
matching `p3a-*.log`, so a run leaves untracked files in the working tree.
|
||||
|
||||
**Failure scenario.** G6 has stopped checking (exactly the condition this control exists to detect). An
|
||||
engineer sees "NEGATIVE CONTROL DID NOT TRIP", opens the suite, and re-runs
|
||||
`ctest --test-dir build-push` — against a `libMobileGL.so` in which `IsBgra` is hard-zeroed. Every
|
||||
downstream reading from that build directory until someone happens to rebuild is taken from a deliberately
|
||||
corrupted library.
|
||||
|
||||
**Refutation attempted.** `restore()` uses `cp -f`, which refreshes the header's mtime, so the *next*
|
||||
`cmake --build` does repair it. But nothing in the script, its message, or its exit code tells the caller to
|
||||
build, and `ctest` alone will not. The sibling branch proves the author considered the requirement; this
|
||||
branch simply misses it.
|
||||
|
||||
**Fix.** Hoist the restore → rebuild → re-ctest block (`:186-197`) above the verdict so all three outcomes
|
||||
share it, and keep the failure logs in `$LOG_DIR` (or a gitignored path) rather than the repo root.
|
||||
|
||||
---
|
||||
|
||||
### M4 — G5's set omits `FlushPendingRangesNow`, which the brief twice calls G5-protected and names as a named risk's only mitigation
|
||||
|
||||
**Evidence.** `scripts/p3a_untouched_regions.sh:58` implements D-F's nine-function table verbatim. But
|
||||
`BRIEF-P3A.md:420` says *"`FlushPendingRangesNow`'s three-tier drain (`:1004-1072`) is a G5-protected
|
||||
function"*, and E's risk row at `BRIEF-P3A.md:1708` makes it the whole mitigation: *"`FlushPendingRangesNow`'s
|
||||
three-tier drain silently changes tier … → **The function is in G5's byte-identical set** and its kill switch
|
||||
… gets its own integration pass in D.3."* It is not in the set. `Managers.cpp:1004` has exactly one
|
||||
definition (calls at `:1401`, `:1710`), so the extractor would take it as a tenth entry unchanged.
|
||||
|
||||
**Failure scenario.** During the P3a rewrite the tier-1 threshold or the whole-buffer test in
|
||||
`FlushPendingRangesNow` drifts and drops the hot path into tier 3. No gate sees it — G5 does not cover the
|
||||
function, and the brief's risk table records the risk as mitigated by a gate that does not exist. The
|
||||
symptom is the Mali WAR stall and MC 26.3's p99, i.e. exactly `ROADMAP.md:19`'s headline number, and under
|
||||
ID-6 performance is recorded rather than gated, so nothing else stops it either.
|
||||
|
||||
**Refutation attempted.** D-F's authoritative "**Decision**: nine functions" list omits it, and package D
|
||||
implemented that list exactly — so this is first a contradiction inside the brief. But D owns G5, the
|
||||
contradiction is in the same document D was implementing from, and `gates-v1.md` does not note it. Note also
|
||||
that P3a may legitimately need to edit the function (D-C reshapes `resource_flush_range`), in which case
|
||||
adding it would force a red — which is precisely why this needs a written decision rather than silence.
|
||||
|
||||
**Fix (integrator decision).** Either add `FlushPendingRangesNow` to `FUNCTIONS` (ten bodies; re-capture the
|
||||
D.0 baseline) and update the script's header table, or record in `gates-v1.md`/D.5 that E's risk row's
|
||||
mitigation is withdrawn and name what replaces it.
|
||||
|
||||
---
|
||||
|
||||
## 2. Minors
|
||||
|
||||
- **m1 — the kept D.2 artefact does not contain the verdict lines the report quotes.**
|
||||
`handlerecycle-before.log` is 153 lines of `--output-on-failure` (the brief's D.2 command) and contains
|
||||
**zero** `arm=` lines: gtest's `std::cout` verdict from `HandleRecycleScenario.cpp:288-291` surfaces only
|
||||
for failing tests. `gates-v1.md` §5 prints a block of `[ HandleRecycle ] arm=AbaControl expected=STALE
|
||||
observed=STALE …` lines under *"That is the artefact ROADMAP.md's 重键前红 asks for"*, annotated
|
||||
"(`ctest -V`)", and that `-V` log was not kept. The artefact that goes into `MEASUREMENTS.md` therefore
|
||||
proves the AbaControl arm only by its "Passed" — the inference-from-exit-code the design says it wants to
|
||||
avoid. Fix: keep the `ctest -V` log beside it and cite it in §5.
|
||||
|
||||
- **m2 — `gates-v1.md` D6 says "**Both** counting workloads were rewritten to define a SECOND arena".**
|
||||
`StorageBufferRegrowScenario.cpp:266-272` re-specifies SetUp's `m_buffer` three times (it is an SSBO with
|
||||
no VAO attributes, so d7655247's crash does not apply). Only `LargeArenaAdoptionScenario.cpp:150-158` and
|
||||
`ResourceSubsystemControlScenario.cpp:222-225` use a second arena. Report text only.
|
||||
|
||||
- **m3 — the D6 workaround is now stale, and it costs the coverage ID-9 asks for.**
|
||||
ID-9 (added since `gates-v1.md` was written) merged `dev@9eae9858` — `d7655247` included — into
|
||||
`feat/disaggregated` as `5cb826b0`, and requires the fix to be present in **both** the legacy and the
|
||||
handle arm of the respecify/retire path. After gates rebases, the two workloads that route around the
|
||||
crash stop exercising respecify-of-an-adopted-store-under-a-live-VAO, which is now the path that most
|
||||
needs arm-parity coverage. I verified the merge does not disturb G5:
|
||||
`p3a_untouched_regions.sh 44c2b5cf 5cb826b0` → **rc 0** (d7655247's edit is at `Managers.cpp:1081-1084`,
|
||||
inside `Ops_Respecify`, outside the nine). Fix after the rebase: restore a re-specify window in at least
|
||||
one of the two counting cases; `d7655247`'s own four `Respecified*Arena*` cases arrive by union anyway.
|
||||
|
||||
- **m4 — the report's G14 numbers are against the superseded baseline.** Measured now:
|
||||
`build-linux`/`build-push` = 2521; `~/w7/p3a-before-ctest-names.txt` = 2502 (re-captured at `5cb826b0`).
|
||||
D's own contribution is exactly the claimed **+34** and every one is a new name — no rename, no removal.
|
||||
The 15 names that `comm -23` now reports as "removed" are the un-rebased dev additions
|
||||
(`{DirectGLES,DirectVulkan}.LargeArenaAdoptionScenario.Respecified{Vertex,Index}Arena*` and 11
|
||||
`PersistentBufferOrderingProbeTest.*`). G14 must be re-measured after the rebase, and the union must keep
|
||||
all 15.
|
||||
|
||||
- **m5 — `p3a_untouched_regions.sh`'s masker mishandles an odd number of `'` in code.** A C++ digit
|
||||
separator (`16'777'216`) opens a char literal at `:115` and blanks to the next `'`, which can hide a brace
|
||||
and shift a body's extent silently. There is none in `Managers.cpp` today (verified: no `[0-9]'[0-9]`;
|
||||
every one of its 272 apostrophes is inside a comment or a balanced literal, and comments/strings are
|
||||
masked first), and the extractor survives the real P3a rewrite (below). Cheap fix: skip `'` when the
|
||||
preceding character is a digit.
|
||||
|
||||
- **m6 — `perturb()` locates the body brace in the ORIGINAL text** (`:192`, `text.index('{', begin)`) rather
|
||||
than the masked text, so a brace in a comment or a default argument on the signature line would perturb
|
||||
the wrong place. `SELF_TEST_FUNCTION=ClearBufferPool` is chosen to avoid this and it works; the failure
|
||||
mode would be a loud self-test failure, not a silent pass.
|
||||
|
||||
- **m7 — the hash starts at the line containing `name(`** (`:164`), so a return type on its own preceding
|
||||
line falls outside the hashed body. None of the nine is written that way today.
|
||||
|
||||
- **m8 — C.3's `cmake --build build-bench && ctest -L benchmark` was not run** (D11: no `build-bench` in the
|
||||
worktree). No benchmark source changed, but it is a brief-mandated verification step; the integrator
|
||||
should run it once on the finished tree.
|
||||
|
||||
- **m9 — commit `588d25e9`'s message says nothing about the `RESOURCE_LOCK` fix (D5)** it carries for four
|
||||
pre-existing lanes. A future bisect for that flake will not find the fix by message. The brief prescribed
|
||||
the three messages verbatim, so this is a note rather than a rule break.
|
||||
|
||||
- **m10 — the buffer ABA has no positive control on the backend P3a actually re-keys.** The `.AbaControl`
|
||||
arm is DirectVulkan-only (the knob has no DirectGLES consumer), so on Espryt — the buffer path P3a lands —
|
||||
the corruption is never demonstrated reproducible; only the `.Handles` arm asserting FRESH stands between
|
||||
a broken re-key and green. The gate can still go red for its reason (a broken re-key reads STALE), and
|
||||
`HandleRecycleScenario.cpp:319-321` names exactly where a `Features.PipeHandleAbaControl` consumer over
|
||||
the resource slot table would go. Worth carrying into package C's scope rather than losing.
|
||||
|
||||
---
|
||||
|
||||
## 3. What I checked and found correct
|
||||
|
||||
Recorded because several of these were the likeliest places for this package to be wrong.
|
||||
|
||||
- **The G8 "red before" is genuine, and the report's D.2 claims match the log exactly.**
|
||||
`ExpectPixelsFor` (`HandleRecycleScenario.cpp:287-299`) sets `expectsStale` only on `Arm::AbaControl` and
|
||||
then asserts the whole viewport is the **stale** colour, so a tree on which the corruption stopped
|
||||
reproducing turns the control **red**, not green. In `handlerecycle-before.log`: `.Legacy` Passed on both
|
||||
backends (#2479, #2485), `.AbaControl` and `.AbaControlHandles` Passed (#2491, #2497), `.Handles` Skipped
|
||||
(#2467 DirectGLES, #2473 DirectVulkan) — exactly as `gates-v1.md` §2 states.
|
||||
- **The two-buffer window is a real D-H probe.** Shared POSITION buffer, differing COLOUR buffer, elements
|
||||
blob byte-identical by construction, so an inherited `set_vertex_buffers` shows as own-geometry-in-the-
|
||||
dead-VAO's-colour. It cannot distinguish *which* binding was inherited, and does not claim to. Correctly
|
||||
gated on the arm marker only (P2's vertex-input key), **not** on the new resource marker. D1's split into
|
||||
its own case is justified by a measurement recorded at the site and adds a name without removing one.
|
||||
- **`mgl_itest_join_environment` usage is right on all six new lanes** — it is a `function` with
|
||||
`PARENT_SCOPE` joining on `\\;` (`CMakeLists.txt:312-322`), and every new lane appends
|
||||
`${MGL_ITEST_CAPABILITY_ENV} ${MGL_ITEST_COMMON_ENV}` (or `${MGL_ITEST_VULKAN_ENV}`), so the EGL/ICD
|
||||
pinning survives the property's REPLACE semantics.
|
||||
- **`mgl_itest_probe_for_symbol` clears its output variable** (`:396`, `set(mglItestProbeHit "")`), so the
|
||||
new `foreach(DirectGLES DirectVulkan)` at `:461` cannot leak the first iteration's hit into the second.
|
||||
Both new probes answer correctly here (no `MGPipeResourceOps` under `MG_Backend/`, no
|
||||
`MapPersistentRoundtrips` under `MG_Impl/Pipe/`) **and will fire on the real trees**:
|
||||
`p3a-espryt/MobileGL/MG_Backend/DirectGLES/Managers.cpp:2177` declares
|
||||
`const MG_Pipe::MGPipeResourceOps g_glesResourceOps`, and
|
||||
`p3a-client/MobileGL/MG_Impl/Pipe/PipeFill.cpp` names `MapPersistentRoundtrips`.
|
||||
- **No `PipeStatsWindow` timing flake.** `Log.cpp:84` `fflush`es every line, and
|
||||
`MOBILEGL_PIPE_STATS_PERIOD` is frames-per-line with a floor of 1 (`ConfigLoader.cpp:279`), so the summary
|
||||
line is on disk before the assertion reads it. `Last()` takes the last `MGPipe stats:` marker, so trailing
|
||||
log traffic is harmless.
|
||||
- **`mpr=` cannot be "absent" on a push build**, so the Off arm's `mpr == 0` is a reading and not a
|
||||
missing-field failure: `PipeStats.cpp:431` appends `" mpr=" + to_string(...)` unconditionally inside the
|
||||
`#if MOBILEGL_PIPE_PUSH` `cso[` bracket, and `CounterOrAbsent`'s `" "` prefix matches it. This was my main
|
||||
suspected false-red on G12 and it is refuted.
|
||||
- **Private-log discipline is complete.** Every new log-reading entry owns a `MOBILEGL_LOG_FILE_PATH`
|
||||
nothing else writes and selects exactly one case (`ResourceSubsystemControlScenario.cpp` has exactly one
|
||||
`TEST_F`; the two `MapPersistentRoundtrips.` registrations each name one case). The `ResourceSubsystemOn/
|
||||
Off.` lanes configure no log and the counting case skips saying so. `MGL_ITEST_COMMON_ENV` (`:279-287`)
|
||||
carries no log path. I enumerated all 20 log-owning registrations: the four D5 locked
|
||||
(`UnlocatedIoBlocks`, `PrimGenReroute`, both `PointSizeDemotion`) are exactly the ones that give a whole
|
||||
scenario one log **and** read it back; the CSO, verify-arming, verify-corrupt and poison lanes each filter
|
||||
a single case, and the `Verify.` lanes have no reader. **D5 is correct and complete.**
|
||||
- **G12's direction is sound in both dead-switch modes**: bits stuck ON → the Off arm reads 2 and goes red;
|
||||
bits stuck OFF → the On arm reads 0 and goes red; and both arms additionally assert the same green
|
||||
viewport, so a switch that changed what is drawn also fails.
|
||||
- **G10's numbers are far enough apart to be unambiguous**: 3 definitions vs 12 dispatches, 1 adoption vs 5
|
||||
draws, with 0 separately named in both messages.
|
||||
- **The G7 script's hard-coded assumptions hold against package B's real header.**
|
||||
`p3a-client/MobileGL/MG_Impl/Pipe/VertexInputEmit.h:88` is `wire.IsBgra = attrib.IsBgra ? 1 : 0;`; the
|
||||
script's regex matches it **exactly once** (dry-run confirmed) and rewrites it to
|
||||
`wire.IsBgra = 0 /* … */;`; `VertexInputEmitTest` is registered at `MG_Test/Pipe/CMakeLists.txt:147,171`.
|
||||
Missing header → 2, header without the field → 2, bad build dir → 2 (I ran the last one).
|
||||
- **Exit codes verified by running** (in the private worktree): `--self-test` → 0 with all three controls
|
||||
printing; `44c2b5cf HEAD` → 0; single-ref → 0 with 9 lines; nonexistent ref → 2; three arguments → 2.
|
||||
Worktree `git status` clean afterwards — **neither script leaves the tree modified**.
|
||||
- **G5 survives the real P3a rewrite.** Run against `p3a-espryt@203120fa` — which rewrites `Managers.cpp`
|
||||
for the whole handle conversion and adds the resource op table at `:2177` — the extractor finds all nine
|
||||
and reports **byte-identical vs `44c2b5cf`**. This is the strongest available evidence that the
|
||||
brace-matching extractor neither false-reds nor fails to extract after the file is rewritten. Extraction
|
||||
is also correct in the tricky cases: `RingAllocate`'s forward declaration (`:958`) and its call sites are
|
||||
rejected on the `)`-followed-by-`{` test, and `RingAllocateSlow` / `UboRingAllocate` /
|
||||
`UnpackRingAllocate` are excluded by the `\b` anchor.
|
||||
- **G5 will not false-red after the ID-9 merge**: `44c2b5cf → 5cb826b0` → rc 0.
|
||||
- **test.yml.** `fetch-depth: 0` and job-level `BASELINE: "44c2b5cf"` are both required and correctly scoped
|
||||
(and correctly *not* the workflow's `baseline_sha` symbol input). The workflow has no `pull_request`
|
||||
trigger, so the two G5 steps' `if:` runs them on every `feat/disaggregated` push and skips them on `dev` —
|
||||
as intended. `include-graph-check` untouched, the TEMPORARY trigger lines untouched, no other job changed
|
||||
(the whole 61-line test.yml diff is confined to the two regions).
|
||||
- **Commit hygiene.** Three commits, three single-line messages verbatim from C.3, no bodies, no trailers;
|
||||
files strictly inside C.5's package-D set; `wsl_p3a_gate.sh` / `p3a_ab.sh` correctly not written (ID-3
|
||||
supersedes C.3's table). Both scripts are mode 644, matching `scripts/g7_negative_control.sh`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Judgement on the deviations and the two carried findings
|
||||
|
||||
| # | judgement |
|
||||
|---|---|
|
||||
| D1 (new case, not a second window) | **Accept.** The reason is measured, recorded at the site, and adds a name rather than removing one (G14). The alternative genuinely does not work: one ABA memo entry per process carries the resolved layout as well as the bindings. |
|
||||
| D2 (a new resource marker, not P2's) | **Accept, and it is the right call.** Reading `MGITEST_HANDLE_REKEY_<backend>` would have armed the buffer arm on a tree where no buffer is keyed on a handle. Verified the new probe is absent here and present in `p3a-espryt`. |
|
||||
| D3 (AbaControl expectation follows the measurement) | **Accept.** The reasoning is at the assertion, and the log backs it (#2491, #2497 Passed). |
|
||||
| D4 (`0x7f`→`0x1ff`) | **Accept as far as it goes — see M1.** The Handles pin is right; the two CSO pins the same review item named were not touched and the report does not say so. |
|
||||
| D5 (`RESOURCE_LOCK` on four flaky lanes) | **Accept — this is a good fix.** The diagnosis (whole-scenario log + `fopen(path,"w")` + `ctest -j`) matches the file's own documented rule, `RESOURCE_LOCK` avoids the rename G14 forbids, the four locked lanes are exactly the ones with that shape (I enumerated all 20 log-owning registrations), and three consecutive 950/950 runs is adequate evidence. Only m9 (message) against it. |
|
||||
| D6 (`dev@d7655247` routed around) | **Superseded, and now a small liability.** ID-9 merged the fix as `5cb826b0` before gates rebases, so item 8 of §8 is already discharged. The workaround is not wrong (same number of storage definitions), but it now removes the only coverage of respecify-under-a-live-VAO at exactly the moment ID-9 requires that path to work in **both** arms. See m3. |
|
||||
| D7 (branch-scoped G5 rows, `BASELINE`, `fetch-depth: 0`) | **Accept.** Correct, necessary, and correctly distinguished from `baseline_sha`. |
|
||||
| D8 (single-ref listing mode) | **Accept.** Makes D.0's capture a plain redirect; verified rc 0 / 9 lines. |
|
||||
| D9 (new `PipeStatsWindow.h`) | **Accept.** Shared reader, `CsoContentAddressingScenario`'s copy left alone — right call for a package with no other reason to touch that file. |
|
||||
| D10 (mode 644) | **Accept.** Matches the nearest precedent. |
|
||||
| D11 (`build-bench` not built) | **Accept with m8.** No benchmark source changed; the integrator should run it once. |
|
||||
|
||||
**The two "findings the integrator must carry":**
|
||||
- *the d7655247 SIGSEGV* — real, correctly diagnosed, correctly not fixed in flight per ROADMAP.md:88, and
|
||||
**already resolved** by ID-9's merge. What must now be carried is the inverse: undo the detour so the path
|
||||
is covered again (m3).
|
||||
- *the RESOURCE_LOCK fix for four flaky pinned lanes* — real, correctly fixed here rather than carried, and
|
||||
verified as the only lanes with that shape. Nothing left for the integrator except to notice it is in
|
||||
`588d25e9` (m9).
|
||||
|
||||
---
|
||||
|
||||
## 5. Rework list (exact)
|
||||
|
||||
1. **M1** — `MG_IntegrationTest/CMakeLists.txt:1032, 1042`: `0x7f` → `0x1ff`; `:1037, 1047`:
|
||||
`0x800000000000007f` → `0x80000000000001ff`. Re-run the four `CsoContentAddressing.{On,Off}` lanes.
|
||||
**Or** write the reason they stay at the P2 mask into the file and into `gates-v1.md` D4, and say item 11
|
||||
is closed by argument. Either way, `gates-v1.md` must stop implying item 11 was a one-line change.
|
||||
2. **M2** — `.github/workflows/test.yml:601`: `-R 'HandleRecycle|CsoContentAddressing|ResourceSubsystem|MapPersistentRoundtrip'`.
|
||||
Verify the step now lists all 16 new push-build entries.
|
||||
3. **M3** — `scripts/p3a_vertex_input_negative_control.sh`: move the restore → rebuild → re-ctest block
|
||||
(`:186-197`) above the verdict so the `:161-169` branch shares it; write the two failure logs into
|
||||
`$LOG_DIR` instead of the repo root, or add a `.gitignore` rule.
|
||||
4. **M4** — integrator decision on `FlushPendingRangesNow`: add it to `FUNCTIONS` (`:58`) and to the header
|
||||
table, re-capture the D.0 baseline; or record the withdrawal of E's risk-row mitigation in D.5.
|
||||
5. **m1** — keep the `ctest -V` HandleRecycle log beside `handlerecycle-before.log` and cite it in
|
||||
`gates-v1.md` §5; **m2**, **m4** — correct the D6 and G14 wording.
|
||||
6. Optional (**m5**, **m6**): digit-separator guard in `mask()`; brace lookup in `perturb()` over the masked
|
||||
text.
|
||||
|
||||
## 6. What the integrator must re-run on the finished tree
|
||||
|
||||
`gates-v1.md` §8's list is correct and I have nothing to remove from it. Add:
|
||||
|
||||
7. **Re-measure G14 against the current baseline.** `~/w7/p3a-before-ctest-names.txt` is now `5cb826b0`'s
|
||||
(2502). After the rebase, `comm -23` must be empty and the union must contain all 15 dev-side names
|
||||
(`LargeArenaAdoptionScenario.Respecified{Vertex,Index}Arena*` × 2 backends, 11
|
||||
`PersistentBufferOrderingProbeTest.*`) **plus** D's 34. ID-9's union resolution in
|
||||
`LargeArenaAdoptionScenario.cpp` is where a name can be lost.
|
||||
8. **Re-run `p3a_untouched_regions.sh 44c2b5cf HEAD` after the espryt merge specifically.** I already
|
||||
verified it is rc 0 against `p3a-espryt@203120fa` and against `5cb826b0`; the merge resolution is the
|
||||
place a pool or ring body can still move.
|
||||
9. **After M2's fix, confirm the `ResourceSubsystemOn/Off` lanes actually assert** — i.e. that they do not
|
||||
all skip — in the `integration-verify` job's controls step.
|
||||
10. **`cmake --build build-bench && ctest --test-dir build-bench -L benchmark`** once (C.3's block, m8).
|
||||
11. Re-check that the `ResourceSubsystemControl.Off` arm reads `mpr == 0` **and** that the `On` arm reads a
|
||||
non-zero `mpr` on a tree carrying B **and** C. A green Off arm with a skipping On arm is not the A/B.
|
||||
@@ -0,0 +1,344 @@
|
||||
# P3a package D — the gates (`gates-v1`)
|
||||
|
||||
Branch `p3a/gates`, worktree `/home/swung/w7/p3a-gates`, parent `39722687` (tag `p3a/contract`, package A's `c0`).
|
||||
Three commits, the brief's messages verbatim, single line, no body. **Not pushed.**
|
||||
|
||||
| # | sha | message |
|
||||
|---|---|---|
|
||||
| 1 | `1ef91dec` | `[Test] (Pipe): reproduce the buffer handle ABA through public GL and prove the pre-rekey guards are what stops it` |
|
||||
| 2 | `588d25e9` | `[Test] (Pipe): assert a regrown adopted store costs one map-persistent round trip per storage definition, not one per draw` |
|
||||
| 3 | `80f6bf1b` | `[CI] (Pipe): gate that the buffer pool, the deferred-release drain and the three rings did not move` |
|
||||
|
||||
Files touched are C.5's package-D set and nothing else: `MobileGL/MG_IntegrationTest/**`,
|
||||
`scripts/p3a_*.sh`, `.github/workflows/test.yml`. `tools/**`, `android-plugin/**` and
|
||||
`MobileGL/MG_Benchmark/**` needed no change. `wsl_p3a_gate.sh` / `p3a_ab.sh` are the integrator's
|
||||
(ID-3) and were not written.
|
||||
|
||||
---
|
||||
|
||||
## 1. Per-file summary
|
||||
|
||||
| file | commit | what changed |
|
||||
|---|---|---|
|
||||
| `MG_IntegrationTest/Scenarios/HandleRecycleScenario.cpp` | 1 | **+`ABufferAtARecycledAddressDoesNotInheritItsPredecessorsContents`** (the buffer ABA, all three arms) and **+`AVertexArrayAtARecycledAddressDoesNotInheritItsPredecessorsVertexBufferSet`** (the recycled VAO must not inherit a predecessor's `set_vertex_buffers`; see deviation D1 for why it is a case rather than a second window in the existing one). New helper `ThisBackendsResourceRekeyHasLanded()` + the fixture's `SkipUnlessTheResourceHandlePathIsAssertableHere()`; `MakePositionBuffer` / `MakeColorBuffer` / `ConfigureSplitQuadVao`. Header block extended with what P3a adds. Existing cases untouched. |
|
||||
| `MG_IntegrationTest/CMakeLists.txt` | 1 | Two new build-time capability probes inside the existing `if (MOBILEGL_PIPE_PUSH)` block: `MGITEST_HANDLE_REKEY_RESOURCES_<backend>` (content probe for `MGPipeResourceOps` under each backend directory) and `MGITEST_PIPE_RESOURCE_EMITTER_PRESENT` (content probe for `MapPersistentRoundtrips` under `MG_Impl/Pipe`). `MGL_ITEST_HANDLES_ARM_KNOBS`'s pin **`MOBILEGL_PIPE_PUSH=0x7f` → `0x1ff`**, with the comment rewritten to name the phase constant rather than P2's. |
|
||||
| `MG_IntegrationTest/CMakeLists.txt` | 2 | `ResourceSubsystemControlScenario.cpp` added to the sources; six new registrations (§3); `RESOURCE_LOCK` on the four pinned lanes that share one log path between several cases (deviation D5). |
|
||||
| `MG_IntegrationTest/Harness/PipeStatsWindow.h` | 2 | **new**, header-only. Reads the library's last `MGPipe stats:` window out of the lane's private log and pulls one counter out of it by short name, with the separator included so `draws` cannot match `draws/f=`. The three counting cases share it instead of triplicating `CsoContentAddressingScenario`'s parser. |
|
||||
| `MG_IntegrationTest/Scenarios/StorageBufferRegrowScenario.cpp` | 2 | **G10** — `+NStorageDefinitionsCostNMapPersistentRoundtripsNotOnePerDraw`: three definitions of an adopted (≥16 MiB) SSBO store with four dispatches against each must publish `mpr=3`, never 12 and never 0. `AGrownStoreIsVisibleThroughItsExistingIndexedBinding` is untouched. |
|
||||
| `MG_IntegrationTest/Scenarios/LargeArenaAdoptionScenario.cpp` | 2 | **G10** — `+AnAdoptionCostsExactlyOneMapPersistentRoundtrip`: one storage definition plus five draws must publish `mpr=1`. The three existing cases are unchanged and now also run under both arms of the P3a A/B (§3). |
|
||||
| `MG_IntegrationTest/Scenarios/ResourceSubsystemControlScenario.cpp` | 2 | **new, G12** — one case, two lanes: with bits 7\|8 set the window's `mpr` equals the number of storage definitions; with them cleared it must be **0**; the pixels are the same green in both. A dead switch reads non-zero in the Off lane. |
|
||||
| `scripts/p3a_untouched_regions.sh` | 3 | **new, G5** — the nine named bodies out of `Managers.cpp` at two refs, sha256'd and diffed. |
|
||||
| `scripts/p3a_vertex_input_negative_control.sh` | 3 | **new, G7** — drops the `IsBgra` copy from `MG_Impl/Pipe/VertexInputEmit.h`, rebuilds, requires `ctest -R 'VertexInputEmit\.'` to go red **naming the field**, restores and rebuilds. |
|
||||
| `.github/workflows/test.yml` | 3 | `pipe-gates` gains `BASELINE: "44c2b5cf"`, `fetch-depth: 0` on its checkout, and two steps: the G5 comparison and its `--self-test`. The `integration-verify` job's always-on controls step gains `ResourceSubsystemControl` and `MapPersistentRoundtrips` beside `HandleRecycle|CsoContentAddressing`. `include-graph-check` untouched; the TEMPORARY `feat/disaggregated` trigger lines untouched. |
|
||||
|
||||
**34 ctest names added, none removed, pull and push name-identical** (2521 in both; the baseline at
|
||||
`44c2b5cf` was 2482, the contract commit added 5).
|
||||
|
||||
---
|
||||
|
||||
## 2. What each scenario asserts, and how it skips on an unimplemented tree
|
||||
|
||||
Every skip is decided by the BUILD (a `file(GLOB ... CONFIGURE_DEPENDS)` content probe over the
|
||||
directory the owning package owns), never by a hand-maintained list, and every skip names what is
|
||||
missing. Nothing vanishes from `ctest -N` in any build (G2/G14).
|
||||
|
||||
| entry | on the finished tree | on this tree (contract only) |
|
||||
|---|---|---|
|
||||
| `HandleRecycle.*.ABufferAtARecycledAddressDoesNotInheritItsPredecessorsContents` | `.Handles`: the replacement buffer's own bytes are drawn although the GL name and the `{slot, gen}` were recycled inside one frame. `.Legacy`: the same, through today's `SharedPtr`/lifetime-id guards. `.AbaControl`: **the corruption is the assertion** — with the identity half of Magma's vertex-input key defeated the dead store's bytes come back. | `.Legacy` **passes**, `.AbaControl` **passes asserting the corruption**, `.Handles` **SKIPs**: *"subsystem not implemented on this tree: … no source under `MG_Backend/<backend>` naming `MGPipeResourceOps`"*. |
|
||||
| `HandleRecycle.*.…VertexBufferSet` | The replacement VAO shares its predecessor's POSITION buffer and differs only in the COLOUR buffer, so an inherited `set_vertex_buffers` shows as its own geometry in the dead VAO's colour. `.AbaControl` asserts that inheritance. | Runs in all three arms already (the vertex-input key it rides is P2's): Handles/Legacy FRESH, AbaControl STALE. |
|
||||
| `StorageBufferRegrow.…NotOnePerDraw` | `mpr == 3` for three definitions × four dispatches. | **SKIPs**: no `MG_Impl/Pipe` source names `MapPersistentRoundtrips`, so `mpr=` is structurally zero (package B). Also skips outside its lane, in a pull build, and with no private log path — each with its own message. |
|
||||
| `LargeArenaAdoption.AnAdoptionCostsExactlyOneMapPersistentRoundtrip` | `mpr == 1` for one definition and five draws. | **SKIPs**, same probe. Skips in the two arm lanes too, saying they configure no private log. |
|
||||
| `LargeArenaAdoption.{SubDataAfterAnInFlightDraw…, ReadbackSeesTheLatestCpuWrite, GpuWriteIntoTheArenaIsReadBack}` | run under `MOBILEGL_PIPE_PUSH=0x1ff` **and** `0x7f`: the handle path and the legacy `BufferBackendOps` path must agree about an adopted store's whole life. | **run and pass in both arms today** (both arms are the legacy path until C lands). |
|
||||
| `ResourceSubsystemControl.{On,Off}` | On: `mpr == 2`. Off: `mpr == 0`. Both: the same green quad. | **SKIPs**, same probe, in both lanes. |
|
||||
|
||||
Verified skip texts (from `ctest -V`), one per family:
|
||||
|
||||
```
|
||||
subsystem not implemented on this tree: the buffer's Handles arm needs this backend's resource_*
|
||||
op table, and the build's capability probe found no source under MobileGL/MG_Backend/DirectGLES
|
||||
naming MGPipeResourceOps. … (P3a package C for DirectGLES; Magma's buffer path is P7)
|
||||
subsystem not implemented on this tree: no source under MobileGL/MG_Impl/Pipe/ names
|
||||
MapPersistentRoundtrips, so nothing emits map_persistent and mpr= is structurally zero. …
|
||||
```
|
||||
|
||||
### 3. The new ctest lanes
|
||||
|
||||
| prefix | filter | mask / knobs | why |
|
||||
|---|---|---|---|
|
||||
| `DirectGLES.ResourceSubsystemControl.On.` | `ResourceSubsystemControlScenario.*` | `0x1ff`, stats, private log | G12's armed arm |
|
||||
| `DirectGLES.ResourceSubsystemControl.Off.` | same | `0x7f`, stats, private log | G12's control arm |
|
||||
| `DirectGLES.MapPersistentRoundtrips.` | `StorageBufferRegrowScenario.NStorage…` | `0x1ff`, stats, private log | G10, one case per lane |
|
||||
| `DirectGLES.MapPersistentRoundtrips.` | `LargeArenaAdoptionScenario.AnAdoption…` | `0x1ff`, stats, private log | G10, one case per lane |
|
||||
| `DirectGLES.ResourceSubsystemOn.` | `LargeArenaAdoptionScenario.*` | `0x1ff` | the three behavioural cases, bits set |
|
||||
| `DirectGLES.ResourceSubsystemOff.` | `LargeArenaAdoptionScenario.*` | `0x7f` | the same three, bits cleared |
|
||||
|
||||
Every environment list is joined through `mgl_itest_join_environment(... ${MGL_ITEST_COMMON_ENV})`
|
||||
so the EGL-vendor pinning survives (a ctest `ENVIRONMENT` property REPLACES the job environment);
|
||||
every log-reading entry names ONE case and owns its log path. DirectGLES only — Magma's buffer path
|
||||
is P7 and registers no ops, so a DirectVulkan arm would measure the client emitter against a
|
||||
backend nobody asked to change.
|
||||
|
||||
---
|
||||
|
||||
## 4. The two scripts
|
||||
|
||||
### 4.1 `scripts/p3a_untouched_regions.sh` (G5)
|
||||
|
||||
```
|
||||
p3a_untouched_regions.sh <ref-a> <ref-b> compare the nine bodies at two refs
|
||||
p3a_untouched_regions.sh <ref> list the nine shas (D.0's baseline capture is a redirect)
|
||||
p3a_untouched_regions.sh --self-test prove the comparison can go red
|
||||
```
|
||||
|
||||
stdout is always the `<sha256> <function>` list in the fixed order; diagnostics go to stderr.
|
||||
Exit **0** identical · **1** at least one moved, the first named on stderr · **2** could not run
|
||||
(bad ref, missing file, a name not defined exactly once, a self-test control that did not answer).
|
||||
|
||||
Extraction masks comments and string/char/**raw**-string literals to spaces first (a shader source
|
||||
in this file is full of braces), then takes the ONE occurrence of `<name> (` whose closing
|
||||
parenthesis is followed — past `const`/`noexcept` — by `{`; that is what separates the definition
|
||||
from the forward declarations and from the call sites. Zero or two matches is exit 2, never a
|
||||
silent pass. The body is hashed from the ORIGINAL text, so a comment change inside one of the nine
|
||||
counts as a move: "byte-identical" is the claim.
|
||||
|
||||
Self-test output on this tree (rc 0):
|
||||
|
||||
```
|
||||
[p3a-untouched] positive control: 9 bodies extracted from the working tree
|
||||
[p3a-untouched] positive control: an untouched copy compares equal
|
||||
[p3a-untouched] positive control: an edit outside the nine bodies is invisible
|
||||
[p3a-untouched] negative control: a perturbed ClearBufferPool body is reported, and named
|
||||
[p3a-untouched] self-test passed
|
||||
```
|
||||
|
||||
The third control is the one P3a needs: the rest of `Managers.cpp` is going to be rewritten, so a
|
||||
gate that fired on any edit to the file would be switched off in the week it landed.
|
||||
|
||||
The gate itself, `44c2b5cf` → `HEAD`, rc 0, with the nine shas (this is also the D.0 baseline):
|
||||
|
||||
```
|
||||
ba79b92dc6ebf2cb2af6aa79f23ba1941818d131812965e9f96a89caffc8e90a IsPoolable
|
||||
6563286e007650a5abb0a1bbdd7acddd901776f3e55d3c0087c8fee60aa6cc4c EnrollIntoPool
|
||||
dc9d3066b2429208e18adc27c639d16260e74b7f17f7c3f290d54f58534f089b AcquireFromPool
|
||||
12656cfd716dec50a4a4893459a7a6aaa0a635f79dda8fa51b88a819da27e5e0 TrimBufferPool
|
||||
c44a12746bcd82e55d8a635adf766e1fe2cf961ded5d9d745896fd65535bde16 ClearBufferPool
|
||||
15259e547fb514dcdcf087bbde1d048fc2d9e7901ea6c6c94a1109fb7987073a ProcessDeferredBufferReleases
|
||||
2daaa5254c38db63742ef8d6dacd25f8868c7fcd3d9745956862134cf76911d5 CreateRingStorage
|
||||
6221df2e4c0b185fbac061e956253dacd8f8d886bb3f3341cd76a26b5e1f84b1 RingAvailable
|
||||
709b6f4190c735517034b9c5d62967a9ae61f2198d2eb441dfe4e7af437cb784 RingAllocate
|
||||
```
|
||||
|
||||
A nonexistent ref exits 2 (verified) rather than reporting a difference.
|
||||
|
||||
### 4.2 `scripts/p3a_vertex_input_negative_control.sh` (G7)
|
||||
|
||||
`p3a_vertex_input_negative_control.sh <build-dir>`. Exit **0** tripped and named `IsBgra` ·
|
||||
**1** did not answer (green on the dropped field, or red without naming it — both leave the tree
|
||||
restored AND rebuilt) · **2** could not run.
|
||||
|
||||
The break is chosen to be invisible to the compiler: the record keeps the member, keeps its 24-byte
|
||||
`static_assert`, keeps its `PipeFields.def` row and its generated comparator — only the VALUE stops
|
||||
being copied, and `Size` stays 4 for `GL_BGRA` (D-G2) so nothing else moves either. It is applied by
|
||||
regex (`.IsBgra = <expr>[;,]` → `0`) because `VertexInputEmit.h` is package B's file and its
|
||||
spelling is B's to choose.
|
||||
|
||||
**On this tree it returns 2, and that is the honest answer**: `MG_Impl/Pipe/VertexInputEmit.h` does
|
||||
not exist yet.
|
||||
|
||||
```
|
||||
[p3a-g7] MobileGL/MG_Impl/Pipe/VertexInputEmit.h does not exist on this tree.
|
||||
[p3a-g7] It is P3a package B's file (BRIEF-P3A.md C.5) … Until it lands there is no field copy to
|
||||
[p3a-g7] drop, so this control cannot run and MUST NOT report a pass.
|
||||
rc=2
|
||||
```
|
||||
|
||||
Three exit paths were exercised: the missing header (above); a header present that assigns no
|
||||
`.IsBgra` (a temporary probe file, removed straight after — also 2, with the message that this
|
||||
would mean G6 is already broken); and the patcher itself, on a scratch copy carrying both
|
||||
spellings, which neutralised 2 of 2 assignments:
|
||||
|
||||
```
|
||||
wire.IsBgra = 0 /* G7 NEGATIVE CONTROL: was attrib.IsBgra ? 1 : 0 */;
|
||||
.IsBgra = 0 /* G7 NEGATIVE CONTROL: was static_cast<Uint8>(a.IsBgra) */,
|
||||
```
|
||||
|
||||
The "suite must exist and be green first", "must still compile", "must name the field" and
|
||||
"restore then rebuild then re-run" steps are `g7_negative_control.sh`'s, kept verbatim in shape.
|
||||
|
||||
---
|
||||
|
||||
## 5. D.2 — the "red before" record
|
||||
|
||||
`cmake --build build-verify` then
|
||||
`ctest --test-dir build-verify -R HandleRecycle --no-tests=error --output-on-failure`, on the
|
||||
contract-based tree, rc **0**, 60 entries. Kept at `~/w7/p3a-handlerecycle-before.log` and copied to
|
||||
`~/w7/notes/p3a/p3a-results/handlerecycle-before.log`.
|
||||
|
||||
```
|
||||
28/60 Test #2479: DirectGLES.HandleRecycle.Legacy…ABufferAtARecycledAddress…Contents ...... Passed
|
||||
34/60 Test #2485: DirectVulkan.HandleRecycle.Legacy…ABufferAtARecycledAddress…Contents .... Passed
|
||||
40/60 Test #2491: DirectVulkan.HandleRecycle.AbaControl…ABufferAtARecycledAddress…Contents Passed
|
||||
46/60 Test #2497: DirectVulkan.HandleRecycle.AbaControlHandles…ABufferAtARecycledAddress… Passed
|
||||
2467 - DirectGLES.HandleRecycle.Handles…ABufferAtARecycledAddress…Contents (Skipped)
|
||||
2473 - DirectVulkan.HandleRecycle.Handles…ABufferAtARecycledAddress…Contents (Skipped)
|
||||
```
|
||||
|
||||
The per-arm verdict line is printed on EVERY arm whether or not the case passes, so the AbaControl
|
||||
green is readable as "the corruption is still reproducible" rather than inferred from an exit code
|
||||
(`ctest -V`):
|
||||
|
||||
```
|
||||
[ HandleRecycle ] arm=AbaControl expected=STALE observed=STALE - the draw after the buffer was recycled inside one frame (x2 lanes)
|
||||
[ HandleRecycle ] arm=AbaControl expected=STALE observed=STALE - the draw after a VAO reading a two-buffer vertex set … (x2 lanes)
|
||||
[ HandleRecycle ] arm=Legacy expected=FRESH observed=FRESH - the draw after the buffer was recycled inside one frame (x2 lanes)
|
||||
[ HandleRecycle ] arm=Handles expected=FRESH observed=FRESH - the draw after a VAO reading a two-buffer vertex set … (x2 lanes)
|
||||
```
|
||||
|
||||
That is the artefact `ROADMAP.md`'s "重键前红" asks for, for the buffer kind: **the corruption is
|
||||
reproducible today with the identity guards defeated, and the pre-re-key guards are what stop it.**
|
||||
|
||||
---
|
||||
|
||||
## 6. Deviations, each with its reason
|
||||
|
||||
**D1 — the vertex-buffer-set window is a NEW case, not a second window inside the existing VAO
|
||||
case.** C.3 says "the VAO case extended to the vertex-input path". Written as a second phase it
|
||||
turned the AbaControl arms red for a reason that is not about identity, and the measurement is in
|
||||
the file: gtest_discover_tests gives each case its own PROCESS, the ABA knob collapses every VAO in
|
||||
a process onto one memo entry, and that entry carries the resolved vertex-input LAYOUT as well as
|
||||
the bindings. The split VAOs deliberately do not share the first window's layout (interleaved
|
||||
stride 20 vs two tight arrays), so in one process the AbaControl arm read the split VAOs' vertices
|
||||
through the interleaved layout and every draw in the phase — priming and warm-ups included — came
|
||||
back as garbage (`"should be all green … first offender is blue"`). In its own process, where every
|
||||
VAO carries the same layout and only the buffer identity differs, the window asserts exactly what it
|
||||
claims. A name was added, none removed (G14).
|
||||
|
||||
**D2 — the buffer case's `.Handles` arm reads a NEW marker, not P2's.** `MGITEST_HANDLE_REKEY_<backend>`
|
||||
answers "is this backend's VERTEX-INPUT memo keyed on {slot, gen}", which P2 landed and which is set
|
||||
on this tree; a buffer only travels as a handle once `resource_*` does. Reading P2's marker would
|
||||
have armed the buffer arm on a tree where nothing about a buffer is keyed on a handle — a green
|
||||
asserting nothing. The new probe looks for `MGPipeResourceOps` under each backend's own directory
|
||||
(content, not filename, so package C keeps its file layout).
|
||||
|
||||
**D3 — the buffer case's AbaControl expectation is a measurement.** It was written expecting FRESH
|
||||
(the guards the knob leaves standing include VkBufferManager's slice epoch, which MOVES when the
|
||||
replacement buffer is created inside the window by construction) and the tree answered STALE over
|
||||
100% of the viewport on both AbaControl lanes. The expectation follows the measurement, and the
|
||||
reasoning is recorded at the assertion.
|
||||
|
||||
**D4 — `MGL_ITEST_HANDLES_ARM_KNOBS` moves `0x7f` → `0x1ff`.** As instructed. The comment now names
|
||||
the PHASE constant (`kMGPipeSubsystemsMigratedAtP3a`) rather than P2's, and says why: pinned at
|
||||
`0x7f` after P3a, the Handles arm would assert the P2 shape while the handles it is about stayed
|
||||
switched off. `0x7f` survives as `ResourceSubsystemControl`'s Off lane.
|
||||
|
||||
**D5 — [finding, fixed here] four pre-existing lanes needed a `RESOURCE_LOCK`.** Three runs of the
|
||||
full `integration-gpu` label at `-j 8` produced 4, 0 and 2 failures, always one of the
|
||||
`…IsActuallyArmedWhenTheEnvironmentPinsItOn` cases, never the same set twice; each passes alone. The
|
||||
mechanism is the one this file already documents: those lanes give a WHOLE scenario one
|
||||
`MOBILEGL_LOG_FILE_PATH`, the library opens it `fopen(path, "w")`, and a sibling case truncates it
|
||||
while the arming case reads. P2's gate run was green (916 entries); this package's +34 entries
|
||||
changed the scheduling odds. Re-filtering — the rule the file states — would RENAME the arming
|
||||
entries, which G14 forbids, so the fix is a ctest `RESOURCE_LOCK` named after each log on
|
||||
`UnlocatedIoBlocks`, `PrimGenReroute` and the two `PointSizeDemotion` lanes. Three consecutive
|
||||
full-label runs afterwards: 950/950, 950/950, 950/950, with the name list unchanged.
|
||||
|
||||
**D6 — [finding, NOT fixed] `dev@d7655247` is not in `feat/disaggregated`, and it bites here.**
|
||||
"rebind VAOs when an adopted buffer is respecified — the immediate retire path forgot the buffer-id
|
||||
generation, so cached vertex and element bindings kept the deleted store" is on `dev` and is **not**
|
||||
an ancestor of this branch. Re-specifying an adopted (≥16 MiB) store that a VAO's attributes still
|
||||
read is a hard SIGSEGV inside the vertex fetch on the first draw after it (reproduced twice on
|
||||
llvmpipe, backtrace in JIT code). Both counting workloads were rewritten to define a SECOND arena
|
||||
instead of re-specifying the first — the same number of STORAGE DEFINITIONS, which is what
|
||||
`ARCHITECTURE.md:474` prices — with the reason written at both sites. `ROADMAP.md:88` says unrelated
|
||||
fixes do not ride the split work, so **this is recorded for the integrator, not fixed**: it is a
|
||||
`dev` crash that the branch will inherit at the next merge, and a P3a scenario that carried it would
|
||||
be red for a reason that is not P3a's.
|
||||
|
||||
**D7 — `pipe-gates` gains `fetch-depth: 0` and a `BASELINE` env, and the two G5 steps are branch
|
||||
scoped.** The script reads `Managers.cpp` at `BASELINE` with `git show`, which a depth-1 checkout
|
||||
does not have. `BASELINE` is `44c2b5cf` (ID-1) and deliberately NOT the workflow's `baseline_sha`
|
||||
input, which is the SYMBOL baseline (`087685d1`) and is empty on a push. The two steps carry
|
||||
`if: github.ref == 'refs/heads/feat/disaggregated' || github.event_name == 'workflow_dispatch'`,
|
||||
because on `dev` — where unrelated buffer fixes land on their own schedule — the comparison asks a
|
||||
question nobody posed. They belong with the TEMPORARY trigger lines and retire with them.
|
||||
|
||||
**D8 — the G5 script also accepts ONE ref.** D.0's baseline capture is
|
||||
`p3a_untouched_regions.sh $BASE $BASE > ~/w7/p3a-before-untouched.sha`; a single-ref listing mode
|
||||
makes that a plain redirect and is what the two-ref mode prints anyway.
|
||||
|
||||
**D9 — a new harness header.** `MG_IntegrationTest/Harness/PipeStatsWindow.h` (package D's tree)
|
||||
holds the summary-line reader the three counting cases share.
|
||||
`CsoContentAddressingScenario`'s own copy was left alone: churn in a file this package has no other
|
||||
reason to touch.
|
||||
|
||||
**D10 — script file modes are 644**, matching `scripts/g7_negative_control.sh`; both are invoked as
|
||||
`bash scripts/...`.
|
||||
|
||||
**D11 — `MG_Benchmark`, `tools/**`, `android-plugin/**` unchanged.** C.3 lists them as D's to own,
|
||||
not as work: nothing in P3a's gate needs a benchmark or a device-side change.
|
||||
`cmake --build build-bench` from C.3's verification block was not run — there is no `build-bench`
|
||||
directory in this worktree (the tree script builds `build-linux`, `build-push`, `build-verify`) and
|
||||
no benchmark source changed.
|
||||
|
||||
---
|
||||
|
||||
## 7. Verification transcript
|
||||
|
||||
All commands in `/home/swung/w7/p3a-gates`, `CCACHE_BASEDIR=/home/swung/w7`, at `80f6bf1b`.
|
||||
|
||||
| check | result |
|
||||
|---|---|
|
||||
| `cmake --build {build-linux,build-push,build-verify} -j 28` | rc 0, rc 0, rc 0 |
|
||||
| **G1** `symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so --threshold 0` | rc 0 — `27799 -> 27799 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed`, total `17209979 -> 17209979 (+0)`. **0/0/0/0**, as expected: none of this package's files reaches the library. |
|
||||
| **G2 names** `ctest -N` (ID-4 extractor) pull vs push | identical, 2521 each |
|
||||
| **G14** `comm -23 ~/w7/p3a-before-ctest-names.txt <build-linux names>` | empty — nothing removed; +39 over the 2482 baseline (5 are the contract's, 34 are this package's) |
|
||||
| `ctest -L integration-gpu --no-tests=error -j 8` on **build-push** | rc 0 — 950/950 (three consecutive runs after the D5 fix: 950, 950, 950) |
|
||||
| `ctest -L integration-gpu --no-tests=error -j 8` on **build-linux** | rc 0 — 950/950 |
|
||||
| `ctest -L integration-verify --no-tests=error -j 4` on build-verify | rc 0 — 838/838 |
|
||||
| **hard rule 4** `ctest --test-dir build-verify -R HandleRecycle --no-tests=error` | rc 0 — 60 entries, only visible skips |
|
||||
| **hard rule 4** `ctest --test-dir build-push -R 'StorageBufferRegrow\|LargeArenaAdoption\|ResourceSubsystemControl' --no-tests=error` | rc 0 — 26 entries, only visible skips |
|
||||
| `ctest -L unit -j 12 --no-tests=error` on all three builds | rc 0 — 1571/1571 each |
|
||||
| **G5** `bash scripts/p3a_untouched_regions.sh 44c2b5cf HEAD` | rc 0 |
|
||||
| **G5** `bash scripts/p3a_untouched_regions.sh --self-test` | rc 0 (three controls, above) |
|
||||
| **G7** `bash scripts/p3a_vertex_input_negative_control.sh build-push` | rc **2** — package B's header is absent; the message says so |
|
||||
| `test.yml` parses; `pipe-gates` carries the two new steps with their `if:`, `env.BASELINE`, `fetch-depth: 0`; the controls step's `-R` carries the four families | verified by parsing the workflow |
|
||||
| `git status` | clean; three commits; nothing pushed |
|
||||
|
||||
**Plumbing evidence for the three counting cases** (they skip on this tree, so the workload, the
|
||||
window parser and the pixel assertion were exercised with `MGITEST_PIPE_RESOURCE_EMITTER_PRESENT=1`
|
||||
forced by hand, outside ctest): in every one the summary line was found and parsed, the draws
|
||||
landed, and the ONLY failure was the count itself reading 0 — `ResourceSubsystemControl`'s **Off**
|
||||
lane passed outright, which is the arm whose expectation is `mpr == 0`.
|
||||
|
||||
---
|
||||
|
||||
## 8. What the integrator must re-run once B, C and the rest have landed
|
||||
|
||||
1. `bash scripts/p3a_untouched_regions.sh 44c2b5cf HEAD` **after every merge** (D.1) — this is the
|
||||
gate that catches a pool or ring body that moved while `Managers.cpp` was being rewritten, and
|
||||
it is the one check in the five-part gate that no test can stand in for. Plus `--self-test`.
|
||||
2. `bash scripts/p3a_vertex_input_negative_control.sh build-push` on the tree that carries package
|
||||
B: it must report **"negative control tripped, naming IsBgra"** (rc 0). Anything else is a
|
||||
finding about G6, and rc 2 now means something different from what it means here.
|
||||
3. `ctest --test-dir build-verify -R HandleRecycle --no-tests=error --output-on-failure` — the
|
||||
buffer arm's `.Handles` entries must **stop skipping** and pass once package C registers
|
||||
`MGPipeResourceOps`. If they still skip, the probe's answer is a real statement: no backend
|
||||
source names the op table.
|
||||
4. `ctest --test-dir build-push -R 'StorageBufferRegrow|LargeArenaAdoption|ResourceSubsystemControl'`
|
||||
— the four counting entries must **stop skipping** once package B emits
|
||||
`MapPersistentRoundtrips`, and then: `mpr == 3`, `mpr == 1`, `mpr == 2` (On) and `mpr == 0`
|
||||
(Off). A non-zero Off is the dead-switch reading and blocks the phase's G12 claim.
|
||||
5. `MOBILEGL_PIPE_PUSH=0x7f ctest --test-dir build-push -L integration-gpu -j 8` beside the default
|
||||
`0x1ff` (D.3's third arm) — the two `ResourceSubsystemOn/Off.LargeArenaAdoption.` lanes already
|
||||
cover the adopted store's own life in both arms, but the label-wide A/B is still the integrator's.
|
||||
6. The full `integration-gpu` label on **both** builds, name-diffed first (G2), and
|
||||
`integration-verify` on the verify build.
|
||||
7. `gh workflow run test.yml --ref feat/disaggregated` — `pipe-gates` now runs the G5 rows; they are
|
||||
scoped to that branch and to `workflow_dispatch`, so a dev-branch run will not execute them.
|
||||
8. Carry **D6** (`dev@d7655247` absent from this branch: respecifying an adopted store under a live
|
||||
VAO is a SIGSEGV) into the phase's findings. Two P3a scenarios route around it; the next
|
||||
`dev` → `feat/disaggregated` merge is what actually fixes it.
|
||||
|
||||
Intermediate logs this package created under `~/w7/p3a-gates-*` were deleted. Kept:
|
||||
`~/w7/p3a-handlerecycle-before.log` (D.2's artefact, for `MEASUREMENTS.md`) and its copy at
|
||||
`~/w7/notes/p3a/p3a-results/handlerecycle-before.log`.
|
||||
@@ -0,0 +1,371 @@
|
||||
# P3a package D — the gates, rework round 1 (`gates-v2`)
|
||||
|
||||
Branch `p3a/gates`, worktree `/home/swung/w7/p3a-gates`, **rebased onto `refs/heads/feat/disaggregated`
|
||||
(`5cb826b0`)** per ID-9. HEAD **`2bafb316`**. Not pushed.
|
||||
|
||||
Answering `gates-review-v1.md`'s REWORK (four majors) plus the integrator's ID-9 / ID-10 / **ID-11**.
|
||||
Everything in the review's §5 rework list is addressed; the optional minors (m5, m6) are done too.
|
||||
|
||||
| # | sha | message |
|
||||
|---|---|---|
|
||||
| — | `5cb826b0` | (base: contract `e01c0ccc` + the `dev@9eae9858` merge) |
|
||||
| 1 | `9e08c563` | `[Test] (Pipe): reproduce the buffer handle ABA through public GL and prove the pre-rekey guards are what stops it` |
|
||||
| 2 | `ecbddcea` | `[Test] (Pipe): assert a regrown adopted store costs one map-persistent round trip per storage definition, not one per draw` |
|
||||
| 3 | `20dfb64c` | `[CI] (Pipe): gate that the buffer pool, the deferred-release drain and the three rings did not move` |
|
||||
| 4 | `331bb425` | `[Test] (Pipe): count the map-persistent round trips over a re-specified adopted arena in both arms, now that the VAO rebind fix is in the branch` |
|
||||
| 5 | `2dfac81a` | `[Fix] (Pipe): raise the four CSO stats lanes to the P3a subsystem mask so they stop asserting on a configuration nothing ships` |
|
||||
| 6 | `854b1be3` | `[CI] (Pipe): select the P3a subsystem and map-persistent lanes in the only job that unpacks a push build` |
|
||||
| 7 | `a9d4011a` | `[Fix] (Pipe): restore and rebuild on every exit path of the vertex-input negative control, and keep its logs out of the repository` |
|
||||
| 8 | `2bafb316` | `[CI] (Pipe): add FlushPendingRangesNow's three-tier drain to G5's byte-identical set` |
|
||||
|
||||
Commits 1–3 are the original three, rebased (the duplicate contract patch dropped out automatically).
|
||||
Commits 4–8 are the rework. Diffstat `20dfb64c..HEAD`: 6 files, +294 / −156.
|
||||
|
||||
---
|
||||
|
||||
## 1. The rebase (ID-9)
|
||||
|
||||
`git rebase refs/heads/feat/disaggregated` — **rc 0, no conflict**. Git merged
|
||||
`LargeArenaAdoptionScenario.cpp` cleanly: `dev`'s two cases were appended in one hunk and gates' case in
|
||||
another, far enough apart that the union is what git produced. It was verified by name rather than
|
||||
assumed, because ID-9 names this file as where a name can be lost:
|
||||
|
||||
| side | `TEST_F(LargeArenaAdoptionScenario, …)` |
|
||||
|---|---|
|
||||
| gates pre-rebase `80f6bf1b` | `SubDataAfterAnInFlightDrawReachesTheNextDraw`, `ReadbackSeesTheLatestCpuWrite`, `GpuWriteIntoTheArenaIsReadBack`, `AnAdoptionCostsExactlyOneMapPersistentRoundtrip` (4) |
|
||||
| dev side `5cb826b0` | `SubDataAfterAnInFlightDrawReachesTheNextDraw`, **`RespecifiedVertexArenaKeepsVaoBindings`**, **`RespecifiedIndexArenaKeepsVaoBinding`**, `ReadbackSeesTheLatestCpuWrite`, `GpuWriteIntoTheArenaIsReadBack` (5) |
|
||||
| **HEAD** | all **6** — the union, nothing renamed, nothing dropped |
|
||||
|
||||
The 11 `PersistentBufferOrderingProbeTest.*` names from `9eae9858` are in a file this package does not
|
||||
touch and arrived untouched. G14 below confirms both sets at the ctest level.
|
||||
|
||||
**`feat/disaggregated` has moved on since this rebase.** It was `5cb826b0` when this package rebased and
|
||||
when every number below was taken; by the end of this round `~/w7/pipe` reads **`12e6bfcf`** (package A's
|
||||
`wire` landed; `p3a/client` has also moved to `b6706362`). Under ID-2 gates integrates **last**, so one
|
||||
more rebase is expected and is the integrator's; nothing in this package touches `MG_Pipe/**`,
|
||||
`MG_Impl/**` or `MG_Backend/**`, so the only file with any chance of conflicting again is
|
||||
`MG_IntegrationTest/CMakeLists.txt`. G1 and G14 must be re-measured against whatever pull baseline the
|
||||
integrator holds at that point — the `~/w7/p3a-before-*` captures used here are `5cb826b0`'s.
|
||||
|
||||
---
|
||||
|
||||
## 2. Per-finding disposition
|
||||
|
||||
### M1 — the four CSO stats lanes still pinned `0x7f` — **FIXED** (`2dfac81a`)
|
||||
|
||||
`MG_IntegrationTest/CMakeLists.txt`, at the review's line numbers, now at HEAD's:
|
||||
|
||||
| lane | was | now | line at HEAD |
|
||||
|---|---|---|---|
|
||||
| `MGL_ITEST_GLES_CSO_ON_ENVIRONMENT` (`:1044`) | `0x7f` | `0x1ff` | `:1046` |
|
||||
| `MGL_ITEST_GLES_CSO_OFF_ENVIRONMENT` | `0x800000000000007f` | `0x80000000000001ff` | `:1051` |
|
||||
| `MGL_ITEST_VULKAN_CSO_ON_ENVIRONMENT` | `0x7f` | `0x1ff` | `:1056` |
|
||||
| `MGL_ITEST_VULKAN_CSO_OFF_ENVIRONMENT` | `0x800000000000007f` | `0x80000000000001ff` | `:1061` |
|
||||
|
||||
The control semantics are unchanged: the only bit that separates the two arms is **63**
|
||||
(`kMGPipeBehaviourNoCsoContentAddressing`, `MG_Pipe/MGPipe.h:90`); every other bit is the shipping mask
|
||||
and now moves with the phase (`kMGPipeSubsystemsMigratedAtP3a = 0x1ff`, `MGPipe.h:95`). A comment block at
|
||||
`:1031-1043` states that rule at the site, so the next phase's author does not have to rediscover it, and
|
||||
closes contract-review item 11 explicitly for all three lane families.
|
||||
|
||||
**Re-run (M1's own requirement).** `ctest --test-dir build-push -R CsoContentAddressing` → **rc 0, 6
|
||||
entries** (the 4 lanes pass; the 2 ambient entries skip by design). The arms are still distinguishable at
|
||||
the new mask — the lane logs read `csom=3 csob=17` (content-addressed) against `csom=17 csob=17`
|
||||
(no content addressing), i.e. 3 mints for 17 binds versus one mint per bind. The generated ctest
|
||||
environment was checked directly: the CSO On lanes now carry `MOBILEGL_PIPE_PUSH=0x1ff` and no
|
||||
`0x800000000000007f` string survives anywhere in the build tree.
|
||||
|
||||
**Every remaining pin in the file re-read** (`grep -n 'MOBILEGL_PIPE_PUSH=0' MG_IntegrationTest/CMakeLists.txt`),
|
||||
which is the second half of the instruction. Thirteen value-carrying pins remain:
|
||||
|
||||
| line | value | verdict |
|
||||
|---|---|---|
|
||||
| `:930` `MGL_ITEST_HANDLES_ARM_KNOBS` | `0x1ff` | phase default |
|
||||
| `:944`, `:947` `HandleRecycle.Legacy` (both backends) | `0` | **named control** — the pre-handle arm, documented at `:895-900` |
|
||||
| `:950` `HandleRecycle.AbaControl` | `0` | **named control** — D18's lane verbatim |
|
||||
| `:1046`, `:1056` CSO **On** | `0x1ff` | fixed here |
|
||||
| `:1051`, `:1061` CSO **Off** | `0x80000000000001ff` | fixed here; bit 63 is the control |
|
||||
| `:1130` `ResourceSubsystemControl.On` | `0x1ff` | phase default |
|
||||
| `:1135` `ResourceSubsystemControl.Off` | `0x7f` | **named control** — G12's armed/cleared A/B |
|
||||
| `:1164`, `:1169` `MapPersistentRoundtrips.` ×2 | `0x1ff` | phase default |
|
||||
| `:1200` `ResourceSubsystemOn.` | `0x1ff` | phase default |
|
||||
| `:1203` `ResourceSubsystemOff.` | `0x7f` | **named control** |
|
||||
|
||||
`HandleRecycle.AbaControlHandles` (`:953-956`) pins nothing of its own — it composes
|
||||
`MGL_ITEST_HANDLES_ARM_KNOBS`, so it followed `0x1ff` automatically. **No lane runs with P3a's subsystems
|
||||
off unless it is a named control.**
|
||||
|
||||
### M2 — the eight `ResourceSubsystemOn./Off.` entries never ran in a push build in CI — **FIXED** (`854b1be3`)
|
||||
|
||||
`.github/workflows/test.yml:615`, the `integration-verify` job's controls step:
|
||||
|
||||
```
|
||||
-R 'HandleRecycle|CsoContentAddressing|ResourceSubsystem|MapPersistentRoundtrip'
|
||||
```
|
||||
|
||||
`ResourceSubsystemControl` → `ResourceSubsystem` and the plural `MapPersistentRoundtrips` → singular, for
|
||||
exactly the reasons the review gives. A 14-line comment above the step records that these alternatives are
|
||||
test-name PREFIXES, that each is the shortest string that still selects only what it means to, and that
|
||||
this is the only CI job unpacking a push build — so an entry the filter misses either never runs under the
|
||||
P3a bits or runs only in the pull `integration` job where the mask steers nothing.
|
||||
|
||||
**Measured, in the job's own build directory (`build-verify`, `-L integration-gpu -R …`):**
|
||||
|
||||
| filter | entries selected |
|
||||
|---|---|
|
||||
| old (as reviewed) | **80** |
|
||||
| new | **96** |
|
||||
| of which P3a lane entries (`ResourceSubsystem{On,Off,Control}.` / `MapPersistentRoundtrips.`) | **16** |
|
||||
|
||||
The step run for real: **rc 0, 96/96 pass**. Of the 12 `ResourceSubsystemOn./Off.` entries, **10 assert and
|
||||
2 skip** — the two skips are `AnAdoptionCostsExactlyOneMapPersistentRoundtrip` in each lane, which needs
|
||||
package B's counter and says so; the other five cases per lane (including `dev`'s two
|
||||
`Respecified*Arena*`) run on both arms today. That is review item 9 ("confirm the lanes actually assert")
|
||||
discharged, at least for the pre-B tree.
|
||||
|
||||
**Every other new lane checked the same way.** All 38 names D adds are present in `ctest -N` on
|
||||
`build-linux`, `build-push` and `build-verify`; the 22 that carry `ResourceSubsystem` or
|
||||
`MapPersistentRoundtrip` in their names (16 lane entries + 6 ambient) are all inside the new filter. The
|
||||
`HandleRecycle` families were already reachable and remain so.
|
||||
|
||||
### M3 — the G7 script's exit contract — **FIXED** (`a9d4011a`)
|
||||
|
||||
`scripts/p3a_vertex_input_negative_control.sh` restructured:
|
||||
|
||||
- **A single `repair()`** (`:103-123`): restore the header from the pre-patch byte copy, `cmake --build`,
|
||||
then re-run the suite to prove the tree went back. Idempotent, a no-op until the patch is applied.
|
||||
- `PATCH_APPLIED=1` is set **before** the patcher runs (`:178`), not after, so a python that died mid-write
|
||||
is repaired too. `trap 'repair' EXIT` (`:174`) replaces `trap 'restore' EXIT`, so **mid-way failures
|
||||
repair**: the "patched header did not compile" branch (`:203`) and any interrupt now go through it.
|
||||
- Step 4 (from `:212`) only **records** a verdict (`tripped` / `did-not-trip` / `wrong-reason`); step 5
|
||||
(from `:227`) calls `repair` and clears the trap **before** anything is printed or exited, and a failed
|
||||
repair downgrades the verdict to **2** ("a build directory that could not be put back is 'could not
|
||||
run'"). All three outcomes share one block.
|
||||
- **No file is written into the repository.** `LOG_DIR` is `<build-dir>/p3a-g7-logs` (absolute, created
|
||||
with `mkdir -p`, falling back to `mktemp -d` if the build dir is unwritable); the header backup lives
|
||||
there too, and both former `cp … ./p3a-vertex-input-control-*.log` lines are gone. Every verdict prints
|
||||
the log path.
|
||||
- The header's exit-code block (`:39-63`) now states the rebuild as part of the contract and explains why
|
||||
the "did not trip" path is the one that needs it most.
|
||||
|
||||
**Proved by forcing each path once.** A rehearsal ran a **byte-identical copy** of the shipped script
|
||||
(`cmp` clean) inside a throwaway repo at `/tmp/g7rehearsal`, whose
|
||||
`MobileGL/MG_Impl/Pipe/VertexInputEmit.h` and `VertexInputEmit.Roundtrip` ctest entry are tiny stand-ins —
|
||||
so the control flow exercised is the real one, and only the two constants' *contents* differ:
|
||||
|
||||
| forced condition | rc | header after | binary after | repo root |
|
||||
|---|---|---|---|---|
|
||||
| the walk names `IsBgra` when it is zeroed | **0** | original | built from the restored header | clean |
|
||||
| the walk stopped comparing (stays green) | **1** | original | **built from the restored header** | clean |
|
||||
| the walk fails without naming the field | **1** | original | built from the restored header | clean |
|
||||
| the patched header does not compile (`Bgra` enum class) | **2** | original | built from the restored header | clean |
|
||||
|
||||
In every case the transcript shows `restored …; rebuilding … / the tree is restored, rebuilt and green
|
||||
again` **before** the verdict line (or, for the exit-2 case, from the trap), and `ls` of the fake repo root
|
||||
shows nothing new. The rehearsal tree was deleted.
|
||||
|
||||
On the real tree the script still answers **rc 2** — `MG_Impl/Pipe/VertexInputEmit.h` is package B's and
|
||||
does not exist yet — and leaves `git status` clean.
|
||||
|
||||
### M4 / ID-11 — `FlushPendingRangesNow` in G5 — **DONE** (`2bafb316`)
|
||||
|
||||
`scripts/p3a_untouched_regions.sh`: `FUNCTIONS` is now **ten** names, appended last so the first nine lines
|
||||
of the D.0 baseline keep their positions. `EXPECTED_FUNCTION_COUNT=10` replaces the hard-coded `9`. The
|
||||
header table gains the row and a paragraph recording *why* the tenth is there (ID-11 resolving
|
||||
`BRIEF-P3A.md:420` / `:1708` against D-F's nine-function table) and *what byte-identical means for it*:
|
||||
**the handle arm must CALL it, not carry a copy — a push arm that re-spells the ladder beside an untouched
|
||||
`#else` copy satisfies G1 and defeats G5, because two ladders drift.**
|
||||
|
||||
**The self-test grew a control for it.** `SELF_TEST_FUNCTIONS="ClearBufferPool FlushPendingRangesNow"`, one
|
||||
negative control each, each run from the pristine copy and each required to be *named* in the message.
|
||||
`ClearBufferPool` is the easy shape (small, no forward declaration); `FlushPendingRangesNow` is the
|
||||
opposite on purpose — 70 lines, three nested tiers, its own early returns — so an entry that silently
|
||||
extracted the wrong extent cannot pass. Both trip:
|
||||
|
||||
```
|
||||
[p3a-untouched] positive control: 10 bodies extracted from the working tree
|
||||
[p3a-untouched] positive control: an untouched copy compares equal
|
||||
[p3a-untouched] positive control: an edit outside the ten bodies is invisible
|
||||
[p3a-untouched] negative control: a perturbed ClearBufferPool body is reported, and named
|
||||
[p3a-untouched] negative control: a perturbed FlushPendingRangesNow body is reported, and named
|
||||
[p3a-untouched] self-test passed
|
||||
```
|
||||
|
||||
**The new D.0 baseline (`p3a_untouched_regions.sh HEAD`, rc 0):**
|
||||
|
||||
```
|
||||
ba79b92dc6ebf2cb2af6aa79f23ba1941818d131812965e9f96a89caffc8e90a IsPoolable
|
||||
6563286e007650a5abb0a1bbdd7acddd901776f3e55d3c0087c8fee60aa6cc4c EnrollIntoPool
|
||||
dc9d3066b2429208e18adc27c639d16260e74b7f17f7c3f290d54f58534f089b AcquireFromPool
|
||||
12656cfd716dec50a4a4893459a7a6aaa0a635f79dda8fa51b88a819da27e5e0 TrimBufferPool
|
||||
c44a12746bcd82e55d8a635adf766e1fe2cf961ded5d9d745896fd65535bde16 ClearBufferPool
|
||||
15259e547fb514dcdcf087bbde1d048fc2d9e7901ea6c6c94a1109fb7987073a ProcessDeferredBufferReleases
|
||||
2daaa5254c38db63742ef8d6dacd25f8868c7fcd3d9745956862134cf76911d5 CreateRingStorage
|
||||
6221df2e4c0b185fbac061e956253dacd8f8d886bb3f3341cd76a26b5e1f84b1 RingAvailable
|
||||
709b6f4190c735517034b9c5d62967a9ae61f2198d2eb441dfe4e7af437cb784 RingAllocate
|
||||
c65570022a5856c1afccfd0cb42fefac707689f5bb3154c3a8e17d2495ccdf8e FlushPendingRangesNow
|
||||
```
|
||||
|
||||
The integrator should replace `~/w7/p3a-before-untouched.sha` with this list (it is `44c2b5cf`'s too — the
|
||||
gate is rc 0 between them).
|
||||
|
||||
### D6 — the second-arena workaround undone (`331bb425`)
|
||||
|
||||
ID-9 makes `d7655247` an ancestor of this branch, so both counting workloads now **re-specify** an adopted
|
||||
store under a live VAO instead of routing around it:
|
||||
|
||||
- `LargeArenaAdoptionScenario.cpp:457-474` — `glBindBuffer(m_arena); glBufferData(kArenaBytes, nullptr, …)`
|
||||
inside the counted window, and the attribute pointers are **deliberately not re-declared** afterwards, so
|
||||
the draws below can only land if the backend VAO followed the new store on its own. `m_secondArena` and
|
||||
its TearDown lines are gone.
|
||||
- `ResourceSubsystemControlScenario.cpp` — `DefineAnArenaAndDrawFromIt` → `DefineTheArenaAndDrawFromIt`
|
||||
(`:225`): index 0 creates the store and declares the attributes, every later index re-specifies the same
|
||||
buffer and declares nothing. `std::vector<GLuint> m_arenas` → a single `GLuint m_arena` (`:250`). Two
|
||||
storage definitions either way, so the counter's expectations (`mpr == 2` on, `0` off) are unchanged.
|
||||
|
||||
Both comments now say why the shape is the hard one and cite ID-9 rather than the old detour. Because the
|
||||
first of these runs under `ResourceSubsystemOn.`/`Off.`, the respecify path is now exercised **on both arms
|
||||
of the P3a A/B**, which is what ID-9 asks for; a handle arm that re-implemented the retire without the
|
||||
rebind is a dead draw or a fault there rather than a divergence found on device.
|
||||
|
||||
### The minors
|
||||
|
||||
| # | disposition |
|
||||
|---|---|
|
||||
| **m1** (the `-V` artefact) | **Done.** Both logs regenerated post-rebase and kept: `~/w7/p3a-handlerecycle-before.log` (the D.2 command) **and** `~/w7/p3a-handlerecycle-before-verbose.log` (`ctest -V`, 158 KB, 22 `[ HandleRecycle ]` verdict lines), both copied to `~/w7/notes/p3a/p3a-results/`. The AbaControl green is now readable as a verdict line, not inferred from an exit code. |
|
||||
| **m2** (D6 wording) | Moot — the workaround is gone. For the record the review was right: `StorageBufferRegrowScenario` never used a second arena (it re-specifies an SSBO with no VAO attributes). |
|
||||
| **m3** (the stale workaround) | Fixed — see D6 above. |
|
||||
| **m4** (G14 numbers) | Re-measured against `5cb826b0`'s baseline; see §3. D's contribution is **+38** (34 + the 4 new `ResourceSubsystem{On,Off}.…Respecified*Arena*` lane entries the union produced). |
|
||||
| **m5** (digit separator) | **Done.** `mask()` skips a `'` preceded by a digit or a hex digit that itself follows a hex digit — a C++14 separator (`16'777'216`, `0xff'ff`) no longer opens a char literal that could blank a brace a function away. |
|
||||
| **m6** (`perturb()` brace) | **Done.** The opening brace is located in the **masked** text and used as an offset into the original (`mask()` preserves length), so a brace in a comment or a default argument on the signature line cannot misdirect the perturbation. |
|
||||
| **m7** (return type on its own line) | Not changed. Still true that none of the ten is written that way, `FlushPendingRangesNow` included (`void FlushPendingRangesNow(` is one line). |
|
||||
| **m8** (`build-bench`) | Still not run — there is no `build-bench` in this worktree and no benchmark source changed. Integrator item, unchanged. |
|
||||
| **m9** (`588d25e9`'s message) | Unchanged: the messages are C.3's verbatim and the rebase preserved them (`ecbddcea`). The D5 `RESOURCE_LOCK` fix is still carried by that commit; this report is the place it is written down. |
|
||||
| **m10** (no DirectGLES ABA positive control) | Unchanged; carried to package C's scope as the review suggests. |
|
||||
|
||||
---
|
||||
|
||||
## 3. The G5 verdict against espryt's tree
|
||||
|
||||
**`git -C /home/swung/w7/p3a-espryt rev-parse HEAD` has moved: it is now `cdbd5535`**
|
||||
(`[Test] (Espryt): extend the slot-table suite to the buffer kind and pin that its death crosses as
|
||||
resource_destroy`), not the `203120fa` the brief names. **The gate was run against both, and answers
|
||||
identically.**
|
||||
|
||||
```
|
||||
$ bash scripts/p3a_untouched_regions.sh 44c2b5cf 203120fa -> rc 2
|
||||
$ bash scripts/p3a_untouched_regions.sh 44c2b5cf cdbd5535 -> rc 2
|
||||
[p3a-untouched] FlushPendingRangesNow: expected exactly one definition, found 2
|
||||
[p3a-untouched] ...definition at line 1127, 3 lines
|
||||
[p3a-untouched] ...definition at line 1307, 70 lines
|
||||
[p3a-untouched] the handle arm must CALL the untouched FlushPendingRangesNow, not carry a copy of
|
||||
[p3a-untouched] it: two ladders drift (BRIEF-P3A.md:1708, ID-11)
|
||||
```
|
||||
|
||||
**The gate was not weakened.** Instead the `len(hits) > 1` diagnostic was made to print the two extents and
|
||||
the rule, because this is now the *expected shape* of the failure rather than a limitation of the
|
||||
extractor.
|
||||
|
||||
**The exact hunk, for espryt's rework** (`MG_Backend/DirectGLES/Managers.cpp` at both refs; the whole region
|
||||
is `#if MOBILEGL_PIPE_PUSH` at `:902` … `#else` at `:1188` … `#endif` at `:1424`):
|
||||
|
||||
| what | where | lines | sha256 (16) |
|
||||
|---|---|---|---|
|
||||
| **push arm** — `FlushPendingRangesFrom(GLESBufferResource&, const Uint8* hostBase, SizeT frontendSize)`, a **re-spelled copy of the whole three-tier ladder** | `:1051-1125` | 75 | `37fc94ffc5991923` |
|
||||
| **push arm** — `FlushPendingRangesNow(GLESBufferResource&, BufferObject&)`, a thin forwarder to it | `:1127-1129` | 3 | `7ac74243aec7b6f8` |
|
||||
| **`#else` (pull) arm** — `FlushPendingRangesNow(GLESBufferResource&, BufferObject&)` | `:1307-1376` | 70 | **`c65570022a5856c1`** = **byte-identical to `$BASE:1004`** |
|
||||
|
||||
New callers of the re-spelled core are at `:2000` and `:2541` (the handle arm); `:1708` and `:2677` still
|
||||
call `FlushPendingRangesNow`.
|
||||
|
||||
**Read this precisely, because it is not "a body moved":**
|
||||
|
||||
1. **All nine original G5 functions are byte-identical at espryt's HEAD** — verified by extracting them
|
||||
from espryt's file directly; every sha matches `44c2b5cf`. The review's earlier rc 0 still holds for the
|
||||
nine.
|
||||
2. **The pull arm's `FlushPendingRangesNow` is byte-identical too.** Nothing was edited in place.
|
||||
3. What the gate objects to is that **inside a push build the ladder exists twice** — once as
|
||||
`FlushPendingRangesFrom` (75 lines, re-parameterised) and once as the `#else` copy that G1 freezes — and
|
||||
the gate cannot say which is "the" body, so it refuses (rc 2) rather than picking one.
|
||||
|
||||
**This is a real conflict between G1 and G5-with-the-tenth, and it is the integrator's to settle.** Espryt's
|
||||
deviation D1 exists because refactoring these helpers in place resized five pull symbols
|
||||
(`FlushPendingRangesNow +14` among them), which G1's empty admitted-resize set forbids; the `#if/#else`
|
||||
split is what bought G1 back. The two obvious resolutions both cost something:
|
||||
|
||||
- **Espryt restores it byte-identical and the handle arm calls it.** This is what ID-11 asks for and it is
|
||||
what makes the risk row at `BRIEF-P3A.md:1708` true. It needs the handle arm to reach the same body
|
||||
without a `BufferObject&`, which is the constraint D1 was written around — so it is not a one-line
|
||||
change, and whether it is achievable without resizing a pull symbol is espryt's call, not this
|
||||
package's.
|
||||
- **The tenth entry stays and the phase records a written, argued exception for it** — naming the two
|
||||
copies, stating that the `#else` copy is frozen by G1 and the push copy is covered by
|
||||
`CrossFrameBufferScenario`'s thirteen cases plus `StreamedArenaScenario`'s two, and that the exception
|
||||
retires with the pull path at P13. That is a decision, not a silence, and it is what D.5 would record.
|
||||
|
||||
What this package will **not** do is drop the tenth entry or teach the extractor to prefer one of two
|
||||
definitions: either would turn `ROADMAP.md:19`'s headline p99 number back into a risk with a mitigation
|
||||
that does not exist. The finding is recorded here so espryt's rework and the integrator can choose.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verification transcript
|
||||
|
||||
All in `/home/swung/w7/p3a-gates`, `CCACHE_BASEDIR=/home/swung/w7`, at **`2bafb316`**.
|
||||
|
||||
| check | result |
|
||||
|---|---|
|
||||
| `cmake --build {build-push,build-linux,build-verify} -j 28` | rc 0, rc 0, rc 0 |
|
||||
| **G1** `symbol_report.py --before ~/w7/p3a-before-libMobileGL.so --after build-linux/libMobileGL.so --threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0` | **rc 0 — Removed 0, Added 0, Resized 0, Renamed 0**. `0/0/0/0` against ID-9's re-captured `5cb826b0` baseline |
|
||||
| **G2** `ctest -N` (ID-4 extractor), pull vs push | **identical**, 2540 each (`build-verify` 3382) |
|
||||
| **G14** `comm -23 ~/w7/p3a-before-ctest-names.txt <build-linux names>` | **empty — 0 removed**. `comm -13` = **+38 added**, all new names; the union kept `dev`'s `LargeArenaAdoptionScenario.Respecified{Vertex,Index}Arena*` on both backends **and** in both new subsystem lanes |
|
||||
| `ctest -L unit -j 12` on all three builds | rc 0 — **1582/1582** each |
|
||||
| `ctest -L integration-gpu -j 8` on **build-push** | rc 0 — **958/958** |
|
||||
| `ctest -L integration-gpu -j 8` on **build-linux** | rc 0 — **958/958** |
|
||||
| `ctest -L integration-verify -j 4` on **build-verify** | rc 0 — **842/842** |
|
||||
| **hard rule 4** `ctest --test-dir build-verify -R HandleRecycle --no-tests=error` | rc 0; only visible skips (the `.Handles` buffer arm and the `Verify.` prefixed copies, each naming what is missing) |
|
||||
| **hard rule 4** `ctest --test-dir build-push -R 'StorageBufferRegrow\|LargeArenaAdoption\|ResourceSubsystem'` | rc 0; the only skips are the four counting entries + the two lane copies, all saying `no source under MobileGL/MG_Impl/Pipe/ names MapPersistentRoundtrips` |
|
||||
| **M1 re-run** `ctest --test-dir build-push -R CsoContentAddressing` | rc 0 — 6 entries, 4 lanes assert, arms distinguishable (`csom=3` vs `csom=17` at 17 binds) |
|
||||
| **M2 re-run** the CI step as CI runs it, on build-verify | rc 0 — **96/96**; 80 → 96 entries, the 16 P3a lane entries now included; 10 of the 12 On/Off entries assert, 2 skip naming package B |
|
||||
| **G5** `p3a_untouched_regions.sh 44c2b5cf HEAD` | **rc 0** — ten bodies byte-identical |
|
||||
| **G5** `p3a_untouched_regions.sh --self-test` | **rc 0** — 3 positive controls + **2** negative controls (both named) |
|
||||
| **G5** vs `p3a/espryt` (`203120fa` **and** `cdbd5535`) | **rc 2**, naming the two definitions — §3 |
|
||||
| **G7** `p3a_vertex_input_negative_control.sh build-push` on this tree | **rc 2** — package B's header absent, message says so |
|
||||
| **G7** all four exit paths, forced on a byte-identical copy | **0 / 1 / 1 / 2**, tree restored **and rebuilt** on every one, nothing written to the repo root |
|
||||
| `git status` | clean |
|
||||
|
||||
Two D.2 artefacts kept (`~/w7/` and copied to `~/w7/notes/p3a/p3a-results/`):
|
||||
`handlerecycle-before.log` and `handlerecycle-before-verbose.log`. Every other log this round created —
|
||||
`~/w7/p3a-gates-build.log`, the `/tmp` build and label logs, the `/tmp/g7rehearsal` tree — was deleted.
|
||||
`ls ~/w7/p3a-gates-*` is empty.
|
||||
|
||||
---
|
||||
|
||||
## 5. What remains for the integrator
|
||||
|
||||
`gates-v1.md` §8's list stands, with items 8 (carry D6) and the G14 re-measurement discharged. What is
|
||||
left, in the order it bites:
|
||||
|
||||
1. **Settle the `FlushPendingRangesNow` duplication with package C** (§3). This is the one item that is not
|
||||
mechanical: either espryt's handle arm calls the untouched body, or the phase writes down an argued
|
||||
exception in D.5. Until then G5 is **rc 2** on any tree carrying espryt, and rc 2 must not be read as
|
||||
"the script is broken" — the message names the two definitions and their line extents.
|
||||
2. **Re-run `p3a_untouched_regions.sh 44c2b5cf HEAD` after every merge**, plus `--self-test`. Re-capture
|
||||
`~/w7/p3a-before-untouched.sha` with the **ten**-line listing above (§2, M4).
|
||||
3. **`p3a_vertex_input_negative_control.sh build-push` on the tree carrying package B** — it must report
|
||||
`negative control tripped, naming IsBgra` (rc 0). Anything else is a finding about G6, and rc 2 now
|
||||
means something different from what it means here. Its logs land in `<build-dir>/p3a-g7-logs/`.
|
||||
4. **The `.Handles` buffer arm must stop skipping** once package C registers `MGPipeResourceOps`; the four
|
||||
counting entries must stop skipping once package B emits `MapPersistentRoundtrips`, and then read
|
||||
`mpr == 3`, `1`, `2` (On) and `0` (Off). A green Off arm beside a skipping On arm is not the A/B
|
||||
(review item 11).
|
||||
5. **`MOBILEGL_PIPE_PUSH=0x7f ctest -L integration-gpu -j 8` beside the default `0x1ff`** — the label-wide
|
||||
third arm. The two `ResourceSubsystemOn/Off.` lanes now cover the adopted store's whole life *including
|
||||
the respecify path* in both arms, but the label-wide A/B is still the integrator's.
|
||||
6. **`cmake --build build-bench && ctest --test-dir build-bench -L benchmark`** once (C.3's block, m8).
|
||||
7. **`gh workflow run test.yml --ref feat/disaggregated`** — `pipe-gates` runs the two G5 rows (branch
|
||||
scoped, `BASELINE: "44c2b5cf"`, `fetch-depth: 0`); the `integration-verify` controls step now selects
|
||||
96 entries instead of 80.
|
||||
8. **The DirectGLES buffer ABA has no positive control** (review m10) — carry into package C's scope rather
|
||||
than losing it: `HandleRecycleScenario.cpp:319-321` names where a `Features.PipeHandleAbaControl`
|
||||
consumer over the resource slot table would go.
|
||||
@@ -0,0 +1,529 @@
|
||||
# P3a package A `c1`-`c3` — adversarial review of the applier bodies (`wire-review-v1`)
|
||||
|
||||
Reviewed `db0c93bb` / `cede041d` / `e9b4a263` on `p3a/wire`, parent `39722687` (tag `p3a/contract`), worktree
|
||||
`/home/swung/w7/p3a-wire` (not modified). Everything below was checked by opening the file at `e9b4a263`. A throwaway
|
||||
`git worktree` at `/home/swung/w7/p3a-review-wire` was used for a clang push build and one negative control, and was
|
||||
removed at the end.
|
||||
|
||||
## Verdict
|
||||
|
||||
**REWORK** — a small, fully-specified one. The three commits are well made: the record shapes are right, the serial
|
||||
order is right and I verified it against the Espryt code it is written for, the dispatch is by handle only, G13 and
|
||||
G1 hold, and the package is genuinely behaviour-neutral (nothing in the tree outside its own test calls a single one
|
||||
of the fourteen entry points). Six of the eight declared deviations are sound as written.
|
||||
|
||||
What forces a rework round rather than "accept with minors" is three things, none of them large:
|
||||
|
||||
1. **The context-reset hole is bigger than the report scopes it, and the applier makes its consequence invisible**
|
||||
(C1). `MGPipeApplierReset()` does not run once per fresh context — it runs at **every make-current between two
|
||||
live contexts** (`Tracker.h:192-195`). The refusal it produces is a `MOBILEGL_ASSERT` that compiles out at INFO,
|
||||
which is the level all three gate builds use, and there is no counter, so a dropped `glBufferSubData` is
|
||||
unobservable in every build that ships or gates.
|
||||
2. **Two of the three server-owned serials are reset to zero by that same call** (C2), which makes an `MGGen` go
|
||||
backwards — the exact wrap hazard D-G4 introduces them to retire, now with the identity patch deleted from the
|
||||
twin's side.
|
||||
3. **The contract review's `M1` and its minors `m1`-`m4` are all still open**, in files `C.5` makes A-only, and the
|
||||
contract review said `M1` was A's to land on this branch.
|
||||
|
||||
Nothing here needs the tag re-cut, nothing here is an ABI or a signature change, and the c2/c3 coverage gap (M-B) is
|
||||
new test code, not new applier code. The eight new ctest names, the three builds and the G1 zero-resize reading I
|
||||
have no reason to doubt; where I could re-derive a claim independently I did, and it held.
|
||||
|
||||
---
|
||||
|
||||
## Findings
|
||||
|
||||
### C1 (critical) — `MGPipeApplierReset()` runs at every context switch, so the records `c1`/`c2` define are gone for any object that outlives one; and the refusal that follows is invisible in all three gate builds
|
||||
|
||||
`MG_Pipe/PipeApply.cpp:543-569` (the reset), `:427-441` (the verdict comment), `:494-500` and `:867-870`, `:907-910`,
|
||||
`:938-941`, `:974-978`, `:1001-1006`, `:1027-1032` (the six refusal sites), `MG_Impl/Pipe/PipeFill.cpp:1188-1190`,
|
||||
`MG_Impl/Pipe/Tracker.h:192-195` and `:352-355`.
|
||||
|
||||
The report's §3 A2 argues the no-op verdict from "`MGPipeApplierReset()` runs at the **first validate of a fresh
|
||||
context**". That is true of `FreshlyPrimed()` but understates when it happens. `MGPipeTracker::Update` opens with
|
||||
|
||||
```cpp
|
||||
if (m_context != &ctx) { // Tracker.h:192-195
|
||||
Reset();
|
||||
m_context = &ctx;
|
||||
}
|
||||
```
|
||||
|
||||
so `Reset()` — and therefore `MGPipeApplierReset()` two frames up at `PipeFill.cpp:1190` — fires on **every change of
|
||||
the current `GLContext`**, including a make-current back to a context that is still alive and whose objects are all
|
||||
still there. `Tracker.h:322`'s own comment says as much ("Context teardown, server reset, a unit test's fixture"),
|
||||
and `PipeApply.cpp:553-557` restates the "fresh context is a fresh server" reading without noticing that a
|
||||
*returning* context is not fresh.
|
||||
|
||||
Failure scenario. A two-context application (a loader/worker context is the common shape, and MobileGL's own async
|
||||
paths make one) alternates make-current. At each switch `g_applier.Resources` is emptied (`:558`). Every subsequent
|
||||
`glBufferSubData` / `glBufferStorage` / `glFlushMappedBufferRange` on a share-group buffer created before the switch
|
||||
reaches `FindResource` (`:415-420`), resolves to `nullptr`, and is **dropped**: no store, no dispatch, no serial. In
|
||||
a shipped push build and in both gate builds the only trace is a `MOBILEGL_ASSERT` — inert at INFO, which is
|
||||
`MOBILEGL_LOG_ACTIVE_LEVEL` in `build-push/CMakeCache.txt` — and there is no counter and no `MGLOG_E`. The write
|
||||
never reaches Espryt, `IsBufferDrawClean` (re-keyed by D-A4 onto `record.Serial` and `record.Desc.Width`) has no
|
||||
record to consult, and the frame draws stale bytes with nothing anywhere saying so.
|
||||
|
||||
Refutations attempted, and why each failed:
|
||||
|
||||
- *"The twin re-uploads from the shadow anyway."* Not after D-A4: the twin's inputs become the applier's record, and
|
||||
there is no record. The shadow still has the bytes, but nothing tells the backend to go and get them.
|
||||
- *"This is the CSO store's own precedent — `bind_render_state` no-ops a dead CSO."* The precedent does not carry,
|
||||
because `MGPipeCsoCacheInstance().Reset()` runs on the line above (`PipeFill.cpp:1189`): the **client** forgets its
|
||||
CSOs at the same instant and re-creates them, so the two sides start over together. There is no client-side
|
||||
companion for buffers, and there cannot be one under D-A2: `ResourceCreate` is emitted from the `BufferObject`
|
||||
**constructor**, which a context switch does not re-run.
|
||||
- *"It is unreachable today, nothing emits."* True of behaviour, and it is why the package is behaviour-neutral. It
|
||||
is not a refutation of the finding, because the record semantics are precisely what B's `ResourceTracker.h` and C's
|
||||
`IsBufferDrawClean` / `SyncToBackend` re-key are being written against right now, and the report's own §5 item 1
|
||||
says it must be settled before `p3a/client` lands.
|
||||
|
||||
Credit where it is due: A found the hole, named it in the file and escalated it in §5 item 1. What is missing is the
|
||||
frequency and, more importantly, an **observable**. `ROADMAP.md:7` requires every gate to be able to go red for the
|
||||
reason it exists; a mutation that is silently dropped in all three builds is the inverse of that.
|
||||
|
||||
Rework:
|
||||
1. The reset's scope is decided **before** `p3a/client` lands, as §5 item 1 asks (re-emit create+respecify on first
|
||||
use after a reset, or take `Resources` / `VertexElementsCsos` out of the reset because they describe share-group
|
||||
objects). Record the decision in `INTEGRATOR-DECISIONS.md`, not only in a package report.
|
||||
2. Whichever is chosen, make the refusal countable: a `Uint64 RefusedResourceCalls` (or a small per-call array) in
|
||||
`MGPipeApplierState`, bumped on every `FindResource`-returned-null path, with a `ResourceEmit` case pinning that a
|
||||
legal sequence leaves it at 0 and a refused one moves it. It costs one increment on a path that already returns.
|
||||
3. Correct §3 A2's "at the first validate of a fresh context" to "at every change of the current context".
|
||||
|
||||
### C2 (critical) — `MGPipeApplierReset()` sends `VertexBuffersSerial` and `IndexBufferSerial` *backwards*, and both the code and the comment that defends it consider only the two wrong options
|
||||
|
||||
`MG_Pipe/PipeApply.cpp:565` and `:567` (`= 0`), with `:558-566` clearing the state those serials version;
|
||||
`MG_Test/Pipe/VertexInputEmitTest.cpp:67-100` (the comment and the case that pin it); `Tracker.h:192-195` again for
|
||||
the frequency; D-G4's twin table and `MG_Backend/DirectGLES/Managers.cpp:2452-2457` for what is being replaced.
|
||||
|
||||
D-G4 replaces `m_syncedIndexBufferVersion` (a wrapping `Uint16`) **plus** `m_syncedIndexBufferObject` (the identity
|
||||
that closes the wrap hole) with `m_syncedIndexSerial` vs `IndexBufferSerial` — "one monotone `Uint64`, no wrap, no
|
||||
identity patch". `ARCHITECTURE.md:44-49` defines an `MGGen` as monotone. This one is not: at every context switch it
|
||||
returns to 0 and counts up again, with nothing beside it.
|
||||
|
||||
There are exactly three things a reset can do to a version whose data it is clearing, and only one of them is
|
||||
right:
|
||||
|
||||
| | applier after reset | twin memo | first call after the switch | verdict |
|
||||
|---|---|---|---|---|
|
||||
| carry the count over | 42 | 42 | 42 == 42 → **clean** over cleared state | wrong immediately |
|
||||
| zero it (what landed) | 0 | 42 | 1 != 42 → dirty … until the count climbs back to 42 | wrong later, and reliably |
|
||||
| **advance it** | 43 | 42 | 43 != 42, and no stamped value can ever recur | right |
|
||||
|
||||
`VertexInputEmitTest.cpp:67-74` — landed at `c0`, and the only prose anywhere on the subject — argues only the first
|
||||
row: *"A reset that carried a previous context's count over would let a twin believe it had synced a configuration
|
||||
it has never seen."* That is true, and it is why zeroing looks like the answer. It is not: a counter that restarts
|
||||
at 0 walks back through every value it has already handed out. `VertexInputEmitTest.cpp:94-95` then pins
|
||||
`VertexBuffersSerial == 0` and `IndexBufferSerial == 0`, so the inversion is asserted, not merely written.
|
||||
|
||||
Failure scenario. Contexts A and B alternate. A `BackendVertexArrayObject` of context A survives the excursion —
|
||||
`OnBackendContextDestroyed` (`Managers.cpp:1527-1540`) runs on destroy, not on make-current, and it does not touch
|
||||
VAO twins at all, which have **no context-generation member** (`Managers.h:926-952`: `m_syncedConfigVersion`,
|
||||
`m_syncedIndexBufferVersion`, `m_syncedIndexBufferObject`, `m_syncedBufferIdGeneration`, and nothing else). On the
|
||||
next activation of A the counter climbs back through the value that twin last stamped; the first `set_index_buffer`
|
||||
that lands on it reads clean and the driver keeps the previous element-array binding. Because each activation
|
||||
restarts at 0 and does much the same work, landing on a previously-stamped value is not a coincidence — it is the
|
||||
normal case for a context whose per-activation call count is stable.
|
||||
|
||||
Refutations attempted:
|
||||
|
||||
- *"The handle is compared beside the serial."* True for `ContentSerial`, which D-G4 pairs with
|
||||
`m_syncedElementsHandle` and whose per-record reset is unavoidable (the records are cleared) and safe (a recycled
|
||||
slot moves `Gen`). False for `VertexBuffersSerial` and `IndexBufferSerial`, which D-G4 defines as single
|
||||
per-applier `Uint64` compares with the identity patch explicitly deleted on the twin side.
|
||||
- *"The twin dies with the context."* It does not; see above. `m_syncedBufferIdGeneration` catches a driver-id
|
||||
re-mint, not a serial that went backwards.
|
||||
- *"Just don't reset them, then."* That is the first row of the table and is worse.
|
||||
|
||||
Fix (one line each, on this branch): at reset, **advance** the two global serials instead of zeroing them —
|
||||
`++g_applier.VertexBuffersSerial; ++g_applier.IndexBufferSerial;` — so clearing the state is itself announced;
|
||||
correct `VertexInputEmitTest.cpp:67-74`'s comment and turn `:94-95`'s two assertions into "moved forward" (the
|
||||
**name** stays, which is all G14 protects); and add the sentence to §5's "Serial contract — for C".
|
||||
|
||||
(The reset body and that case landed at `c0`, and the contract review passed the reset as "clears exactly those
|
||||
eleven". The three members were inert then; `c1`/`c2` are what give them meaning, which is why this is reviewable
|
||||
here and why the fix belongs on this branch.)
|
||||
|
||||
### M-A (major) — contract-review **M1** is unaddressed: `Coverage.def`'s target split still omits `DispatchIndirect` and `Query`
|
||||
|
||||
`MG_Pipe/Coverage.def:41-47` at `e9b4a263`, unchanged from `39722687`. The five buckets still name 13 of the 15
|
||||
`BufferTarget` enumerators; `DispatchIndirect` (a live backend read at `DirectGLES.cpp:725` and
|
||||
`VulkanRenderer.cpp:7423`, and carried by no call — `MGPIndirectBuffers` is `DrawIndirect` + `Parameter` only) and
|
||||
`Query` appear in no bucket, not even the "still pulled" one, while `:48-56` argues the row may stay one row
|
||||
*because* the split is stated exhaustively here.
|
||||
|
||||
`contract-review-v1` classed this as a major and said "M1 is a comment-only fix that A can land on `p3a/wire`", and
|
||||
that `Coverage.def` is A-only under `C.5`, so no later package may correct it. `git diff 39722687 HEAD --stat` names
|
||||
three files and this is not one of them. Two comment lines, using the enum's own spelling so the list can be
|
||||
cross-checked mechanically against `BufferObject.h:15-33`.
|
||||
|
||||
### M-B (major) — `c2` shipped 191 lines and two new `Fatal{ProtocolCorruption}` gates with **zero** test coverage in any tree
|
||||
|
||||
`PipeApply.cpp:1060-1226` against `MG_Test/Pipe/ResourceEmitTest.cpp` (nine cases, all resource-family) and
|
||||
`VertexInputEmitTest.cpp` (still `c0`'s placeholder).
|
||||
|
||||
Nothing anywhere asserts: the `create_vertex_elements` count / `Blob.Size` refusal (`:1078-1092`), the
|
||||
`set_vertex_buffers` `Start + Count` window (`:1170-1181`), `ContentSerial`'s re-create-keeps-counting vs
|
||||
recycled-slot-starts-over rule (`:1104-1110`, `:1127`), the blob unpack itself (`:1113-1124`),
|
||||
`BindVertexElements`'s null-handle and dead-handle arms (`:1133-1147`), `DeleteVertexElements` clearing a bound
|
||||
handle (`:1162-1164`), or `SetIndexBuffer`'s independent serial (`:1213-1226`).
|
||||
|
||||
Concretely — and this was **measured, not argued** (see Experiment): I applied eight semantic mutations to
|
||||
`PipeApply.cpp` in a throwaway worktree at `e9b4a263` — both `std::memcpy`s in `MGPipeApplyCreateVertexElements`
|
||||
removed, `MGPipeApplySetVertexBuffers`' entry-copy loop removed, the `Start + Count` window gate removed, the
|
||||
`Blob.Size` gate removed, both `BufferRangeFault` calls in `resource_flush_range` and `resource_readback` removed,
|
||||
and `SubDataBoxFault`'s `Level` arm removed — rebuilt, and `ResourceEmitTest` reported **`[ PASSED ] 9 tests.`**,
|
||||
byte for byte what the unmutated build reports. `grep` over `MG_Test/` and `MG_IntegrationTest/` for the five
|
||||
vertex-input entry points returns nothing, and `VertexInputEmitTest.cpp` still holds `c0`'s single placeholder
|
||||
(`AResetApplierCarriesNoVertexInputStateOver`, `:75`), so there is no second suite that would have caught it. Two
|
||||
gates this package introduced cannot go red in the package that introduced them (`ROADMAP.md:7`), and three of the
|
||||
five gates in `c1` are in the same position.
|
||||
|
||||
The report defers these to B (§5 item 7, "the vertex-input applier's own cases — for B"). Unlike the splitter (A6,
|
||||
which genuinely needs a file that does not exist on this branch), these need no emitter and no client file: they are
|
||||
direct calls into `MGPipeApplyCreateVertexElements` / `…SetVertexBuffers` / `…SetIndexBuffer`, exactly the shape
|
||||
`ResourceEmitTest.cpp`'s nine cases already use. The deferral is a choice, and it leaves `c2` unguarded through
|
||||
D.1's `client` and `espryt` merges.
|
||||
|
||||
Rework: four cases, in `ResourceEmitTest.cpp` beside the existing ones or in `VertexInputEmitTest.cpp` (A owns
|
||||
neither exclusively; `C.5` gives the latter's *contents* to B, so appending A's applier cases to `ResourceEmitTest`
|
||||
and saying so in the header is the lower-collision choice) —
|
||||
(a) a blob round trip over all 32 attribute and 32 binding-point slots, plus a shrink that leaves nothing of the
|
||||
previous configuration; (b) the count/`Blob.Size` refusal in its forked-abort and log arms, like
|
||||
`AWriteOutsideTheDeclaredStorageIsRefusedNamingTheResource`; (c) `Start + Count` at 32 and 33; (d) `ContentSerial`
|
||||
counting up on a re-create and restarting at 1 on a recycled slot, plus `SetIndexBuffer` moving only
|
||||
`IndexBufferSerial`.
|
||||
|
||||
### M-C (major) — the new `Fatal{PipeLiveHostWrites}` wire (deviation A4) has no negative control, and skips the one call P5 will attach its producer to
|
||||
|
||||
`PipeApply.cpp:479-488` (the wire), `:876` / `:520` / `:926` (its three call sites), `ResourceEmitTest.cpp:403-435`.
|
||||
|
||||
`ResourceEmit.NoResourcePathInThisPhaseLeavesHostWritesLive` asserts `HasLiveHostWrites == false` after nine calls
|
||||
on a field that **no code in the tree writes**. Every one of those `EXPECT_FALSE`s passes with all fourteen applier
|
||||
bodies deleted (only `MGPipeApplyResourceCreate`'s `RecordAt` has to survive, for `RecordOf`'s `EXPECT_GT`). The
|
||||
true arm of the wire is never taken anywhere, in any build, so `Fatal{PipeLiveHostWrites}` is a gate that cannot go
|
||||
red — which is the mistake the deviation's own justification says it is avoiding.
|
||||
|
||||
It is one line to fix: `MGPipeApplier().Resources[slot].HasLiveHostWrites = true;` (the accessor returns a non-const
|
||||
reference) followed by the same forked-child assertion `AWriteOutsideTheDeclaredStorage…` already uses.
|
||||
|
||||
Second half: `PinNoLiveHostWrites` is called from `resource_respecify`, `ApplyBufferWrite` (both sub-data forms) and
|
||||
`resource_flush_range`, but **not** from `MGPipeApplyMapPersistent` (`:1001-1025`) — and D-A4 / `ARCHITECTURE.md:481`
|
||||
name the persistent-map push as exactly where P5 sets the flag. Add the call there (and to `resource_readback`,
|
||||
which reads the store the flag describes).
|
||||
|
||||
### M-D (major) — `RecordAt` resizes a slot-indexed table on an unbounded, client-supplied slot index
|
||||
|
||||
`PipeApply.cpp:405-410`, reached from `MGPipeApplyResourceCreate` (`:855`) and `MGPipeApplyCreateVertexElements`
|
||||
(`:1094`):
|
||||
|
||||
```cpp
|
||||
if (slot >= records.size()) records.resize(static_cast<SizeT>(slot) + 1);
|
||||
```
|
||||
|
||||
The only guard on the way in is `desc.Resource.Slot >= kMGPipeFirstAllocatableSlot` (`:843-846`, `:1061-1064`). A
|
||||
`Slot` of `0xFFFFFFFE` therefore asks for a four-billion-entry vector of 88-byte records from inside the bounds
|
||||
gate's own commit. This package polices `Blob.Size`, the destination range, `Level`, `RegionCount`, the null-bytes
|
||||
case and `Start + Count`; the one number it does not police is the one that reaches an allocator.
|
||||
|
||||
`contract-review-v1`'s M2 recorded the identical shape against `BackendSlotTable::EntryAt` (`SlotTables.h:427-430`,
|
||||
"does `m_slots.resize(slot + 1)` on a **client-supplied** slot index with no bound") and told C to bound-check at the
|
||||
call site — noting in the same breath that "the applier's blob-bounds gate (`c1`/`c2`) does not sit between the
|
||||
payload and this call for the resource family". The applier *is* the natural single place to do it: one bound, two
|
||||
call sites, `Fatal{ProtocolCorruption}` with the same identity in the line as its five siblings.
|
||||
|
||||
Refutation attempted, and it failed: *"the slot space is dense, the handle comes out of `MGPipeSlots().Acquire`"* —
|
||||
that is equally true of `AttributeCount`, `Start`, `Count` and `Blob.Size`, all of which this commit does gate; and
|
||||
`ARCHITECTURE.md:119` reserves the tag for records that would make the server act outside its own storage, which an
|
||||
unbounded `resize` does.
|
||||
|
||||
### M-E (major) — `MGPSubData::Blob` and `MGPVertexElements::Blob` are given opposite rules, and only one of them is written down
|
||||
|
||||
`PipeApply.cpp:1082-1085` (vertex elements: `desc.Blob.Size != declared` → `Fatal{ProtocolCorruption}`) against
|
||||
`:494-535` and `:907-936` (sub-data, resident sub-data, flush range: `record.Blob` is never read at all), with
|
||||
`MGPipeTypes.h:602-609` stating the same self-description for the buffer half — *"`Blob` holds exactly `Size` source
|
||||
bytes"*.
|
||||
|
||||
So B is required to fill `MGPVertexElements::Blob.Size` exactly, on pain of an abort in every verify build
|
||||
(correctly flagged in the report's §5 item 2), and is free to leave `MGPSubData::Blob` entirely zero, on three calls
|
||||
that actually carry content today. The `c1` deliverable's own words in `C.0` are "the bounds gate that refuses a
|
||||
blob outside its declared segment"; what landed refuses the *destination* range and never looks at the blob header
|
||||
on the family that has one.
|
||||
|
||||
Refutation attempted: *"segments do not exist in P3a (D-N: no `MGHostSpan`, no `SEG_*`), so there is nothing to check
|
||||
`Blob` against"* — that argument applies verbatim to `MGPVertexElements::Blob` and was not accepted there. Either
|
||||
gate `MGPSubData::Blob.Size == MGPipeSubDataBufferSize(record)` when `Blob.Size != 0` (which stays inert while B
|
||||
leaves it zero and becomes a real gate the moment a transport fills it), or state in the report and in
|
||||
`MGPipeTypes.h` that the buffer half's `Blob` is deliberately unpoliced until P5/P8 and that B must not fill it.
|
||||
Silence on one and a `Fatal` on the other is what B cannot act on.
|
||||
|
||||
### M-F (major) — contract-review must-know item 9 **is** addressed; the inherited minors `m1`-`m4` are **not**
|
||||
|
||||
Item 9 (`MGPipeApplySetVertexBuffers` must police `Start + Count`) is closed: `PipeApply.cpp:1170-1181` faults on
|
||||
`Uint64{hdr.Start} + Uint64{hdr.Count} > kMGPipeMaxVertexAttribs` and on `Count != 0 && tail == nullptr`, with the
|
||||
window's own numbers in the line. Good, and the `Uint64` widening means the addition cannot wrap.
|
||||
|
||||
The four A-owned minors are all untouched at `e9b4a263`, verified by opening each file:
|
||||
|
||||
| item | file:line | state |
|
||||
|---|---|---|
|
||||
| `m1` | `MG_Pipe/Coverage.def:187` | `X(GetBoundVertexArray, BindVertexElements)` still at position 2 of the otherwise `LC_ALL=C`-sorted `MGP_COVERAGE_EMITTED_LIST` |
|
||||
| `m2` | `MG_Pipe/MGPipeTypes.h:257` | `MGPBlobRef Blob; // VertexAttribute[] followed by VertexBufferBindingPoint[]` — the two types that cannot travel, contradicting `MGPipeValueTypes.h:552-559` and `PipeApply.h:307-312` |
|
||||
| `m3` (A's half) | `ConfigLoader.cpp:11` | include comment still reads "For `kMGPipeSubsystemsMigratedAtP2`, the push build's `PipePush` default" while `:256` uses `…AtP3a` |
|
||||
| `m4` | `MG_Impl/Pipe/PipeFill.cpp:688-701` | the `NewVertexElements` assert compares against `SubsystemForEmitter(...)`; the `NewVertexBuffers` and `NewIndexBuffer` asserts against the literal `kMGPipeSubsystemVertexInput` |
|
||||
|
||||
`m5` (`PipeCatalogueTest.cpp:352-362`'s name) is recorded-only and needs nothing. `m3`'s `MagmaPipeArms.h:112-115`
|
||||
half is the integrator's (no package owns `MG_Backend/DirectVulkan/**`). All four are one-line edits in files `C.5`
|
||||
makes A-only, and the contract review requires them closed before D.1's `espryt` merge.
|
||||
|
||||
---
|
||||
|
||||
## Minor findings
|
||||
|
||||
- **n1 — a dead handle at `delete_vertex_elements` is the one refusal with no assertion and no reason in place.**
|
||||
`PipeApply.cpp:1152-1154` is a bare `if (record == nullptr) return;`, where its five siblings all carry
|
||||
`MOBILEGL_ASSERT(record != nullptr, …, kResourceRefusalNote)`. If the omission is deliberate — a death notice can
|
||||
legitimately name a CSO the applier lost at a context switch (C1) — say so; otherwise it is an inconsistency a
|
||||
reader will "fix" one way or the other.
|
||||
- **n2 — `unmap_persistent` refuses on a dropped record** (`:1032-1036`), which is the one call where delivering it
|
||||
anyway is the safer answer: it releases a donation. Inert today (never emitted by P3a), worth a line.
|
||||
- **n3 — `SubDataBoxFault` holds three of the convention's seven statements.** `:460-473` checks `UnionBox.X`,
|
||||
`Level` and `RegionCount`; `MGPipeTypes.h:602-605` also fixes `Y = Z = 0` and `H = D = 1`. Inert (nothing reads
|
||||
them for a buffer), but the helper's comment claims "the buffer half's convention held to itself".
|
||||
- **n4 — `set_index_buffer` does not police `IndexSize`** (`:1213-1226`). D-I's three stated reasons cover `Res`
|
||||
(may be null) and `Offset` (the draw's); they do not cover `IndexSize`, which the backend uses as an element
|
||||
stride and which is `{0, 1, 2, 4}` and nothing else.
|
||||
- **n5 — a `MGPVertexBuffer` entry's own `BindingIndex` is stored unchecked** (`:1197-1199`). Contract-review item
|
||||
10 puts the `>= 256` rejection on B before the `Uint8` narrowing on the attribute side; nothing polices the
|
||||
`Uint32` side server-side. Inert while C indexes `VertexBuffers[]` by attribute index (D-H3), which it does.
|
||||
- **n6 — the applier's `MapPersistentRoundtrips` is per-context; PipeStats' `mpr` is not.** `:568` resets it and
|
||||
`ResourceEmitTest.cpp:576-577` pins that ("Per context, like every other member"), while D-B2 puts the counter G10
|
||||
actually greps in `PipeStats` at the **client** emitter, where nothing resets it. Two observables of one event
|
||||
that diverge across a context switch; say in §5 which one `StorageBufferRegrowScenario` asserts against.
|
||||
- **n7 — the resident-sub-data drop claims a fallback it cannot deliver.** `:526-533` drops the call when
|
||||
`SubDataResident` is null, after `++stored->Serial`, with the comment "the write is landed by its ordinary
|
||||
sub-data route instead". That fallback is `BufferObject::LandBytesIntoResidentStore`
|
||||
(`MG_State/GLState/BufferState/BufferObject.cpp:371-384`) and it is unreachable once the call has been emitted, so
|
||||
the bytes are lost. Unreachable in P3a (Espryt registers all nine members; Magma registers no table at all, so
|
||||
`MGPipeResourceSubsystemEnabled()` is false there) — but §5 must tell B that the client's dispatch gate is
|
||||
`MGPipeGetResourceOps()->SubDataResident != nullptr`, not `MGPipeResourceSubsystemEnabled()` alone.
|
||||
- **n8 — the by-handle assertion is half made.** `ResourceEmitTest.cpp:504-526` checks `g_spy.LastHandle` after
|
||||
`Create` and after `Destroy` only; `SubData`, `SubDataResident`, `FlushRange`, `Readback` and `MapPersistent` are
|
||||
counted but their handle is not asserted, so a dispatch that handed the backend the wrong handle would pass the
|
||||
case whose title is "DispatchesByHandle".
|
||||
- **n9 — `ARespecifyReplaces…` re-pins `MGPipeResourceRespecifyNeedsAck`** (`ResourceEmitTest.cpp:333-334`), which
|
||||
`PipeCatalogueTest.ResourceRespecifyAcksOnlyImmutableStorage` already pins per the contract review's D-A5 row.
|
||||
Harmless; recorded so nobody deletes the wrong one.
|
||||
- **n10 — `PipeApply.h` was edited after the `p3a/contract` tag.** Comment-only and declared (A1), and `C.5` makes
|
||||
the file A's, so this is not an ownership break. But `C.0` says nothing in `c0` may change after the tag "without
|
||||
telling the other three packages", and C's tree is branched **from the tag**: it will not see the corrected
|
||||
`VertexFetchBaseInstance` comment — the one that tells C the value is raw — until it rebases. The telling has to
|
||||
be an actual message from the integrator, not a line in a result file.
|
||||
|
||||
---
|
||||
|
||||
## Dimension-by-dimension
|
||||
|
||||
**(1) Semantics vs D-A / D-G4 / D-H / D-I.**
|
||||
|
||||
- *Record updates.* `resource_create` starts the record over (`:850-857`) rather than editing it, keeps only `Gen`
|
||||
from the handle, and leaves `Serial` at 0 — correct, and the reason given (a recycled slot must inherit no
|
||||
`Width`, no `Serial`, no `Immutable`) is the right one. `resource_respecify` replaces `Desc` whole (`:878`), which
|
||||
is what D-A2's "replaces the stored descriptor" means and what `ARespecifyReplaces…` pins with a shrinking
|
||||
immutable store. `resource_destroy` drops the record and keeps `Gen` (`:988-990`), matching D-L's rule that the
|
||||
bump belongs to the next handout, and does it **before** the backend hook (`:996`), which is the ordering its
|
||||
comment claims. The three content calls store nothing, correctly.
|
||||
- *Serial rules, and the report's "bump before the backend hook".* **Verified against the code it is written for,
|
||||
and it is right.** Espryt stamps its synced serial *inside* the hook at `Managers.cpp:925` (`RespecifyStorageNow`,
|
||||
reached from `Ops_Respecify`), `:1282` and `:1294` (`Ops_SubData`'s adopted and kill-switch arms), `:1334`,
|
||||
`:1369`, `:1376` (`Ops_FlushMappedRange`) and `:1414` (`Ops_ReadbackFromGpu`), and `IsBufferDrawClean:1599`
|
||||
compares that stamp against the frontend serial. Under D-A4 the stamp becomes `record.Serial`, so a bump after the
|
||||
hook would leave the twin one mutation behind on every landed write. `PipeApply.cpp:518-522`, `:879`, `:927` all
|
||||
bump first. The arms that do *not* stamp (the queue-only sub-data path `:1295-1296`, `Ops_Respecify`'s three early
|
||||
returns) leave the twin dirty, which is the safe direction. ✔
|
||||
- *`ContentSerial`.* `:1104-1110` + `:1127`: an existing record of the same identity keeps counting, a different
|
||||
`Gen` starts over, first create lands on 1 so 0 means "never created". Correct for D-G4's
|
||||
`m_syncedElementsHandle` + `m_syncedElementsSerial` pair, since the handle half covers the restart. The two
|
||||
arrays are zeroed before the unpack (`:1113-1114`), so a shrinking configuration leaves nothing behind — a real
|
||||
bug avoided, and untested (M-B).
|
||||
- *Blob bounds gate and `Fatal{ProtocolCorruption}` identity.* `:1078-1092` faults on both counts `>` 32, on
|
||||
`Blob.Size != AttributeCount*24 + BindingPointCount*16`, and on a non-empty blob with no bytes; the line carries
|
||||
`{slot, gen}`, both counts, both byte lengths. The tag is `ARCHITECTURE.md:119`'s and is spelled through
|
||||
`MGP_TRIP_WIRE_TAG`, so it reads `Fatal{ProtocolCorruption}` only in poison/verify and plain in a shipped push
|
||||
build — matching the file's existing five wires exactly. The two sizes are right: `MGPVertexAttribWire` is 24 and
|
||||
`MGPVertexBindingPointWire` is 16, pinned at `MGPipeValueTypes.h:623-628`, and the applier uses `sizeof` rather
|
||||
than literals, so they cannot drift. **Does the emitter side produce exactly `Blob.Size`?** Nothing produces it
|
||||
yet — `MGPipeSetSubDataBufferRange` has no `create_vertex_elements` counterpart, and there is no helper that fills
|
||||
`MGPVertexElements::Blob` — so B has to compute `A*sizeof(MGPVertexAttribWire) + B*sizeof(MGPVertexBindingPointWire)`
|
||||
by hand at the emitter. That is the asymmetry M-E is about, and the report's §5 item 2 is the right warning but
|
||||
only half the rule.
|
||||
- *`SetVertexBuffers` Start+Count.* Policed (M-F). ✔
|
||||
- *`VertexFetchBaseInstance` raw storage.* `:1209` stores `hdr.BaseInstance` unresolved. Sound; see deviation A1.
|
||||
- *`SetIndexBuffer` independence from the VAO config version (D5, `ARCHITECTURE.md:99`).* `:1213-1226` stores the
|
||||
record verbatim and bumps only `IndexBufferSerial`; it touches neither `BoundVertexElements` nor any
|
||||
`ContentSerial`. ✔ (C2 is about that serial's reset, not its independence.)
|
||||
- *`DeleteVertexElements` on a bound record.* `:1149-1165` drops the record whole, keeps `Gen`, and clears
|
||||
`BoundVertexElements` when it named this handle — using `MGPipeHandle`'s `operator==` (`MGPipeHandles.h:58-60`),
|
||||
so both `Slot` and `Gen` must match. ✔ Untested (M-B).
|
||||
- *`MGPipeApplierReset` clearing everything.* All eleven P3a members are cleared (`:558-568`), and the op table
|
||||
deliberately is not, which `TheResourceOpTableIsUnregisteredUntilABackendInstallsOne` pins. The *content* of that
|
||||
clearing is C1/C2.
|
||||
|
||||
**(2) Behaviour neutrality — yes, and I checked it rather than took it.** `grep` over `MobileGL/` for all fourteen
|
||||
entry points returns hits only in `MG_Test/Pipe/ResourceEmitTest.cpp`; `MGPipeSetResourceOps` / `MGPipeGetResourceOps`
|
||||
likewise. So no production path reaches a single body, `g_resourceOps` is `nullptr` in every build, and the frontend
|
||||
still dispatches `BufferBackendOps` verbatim. No new side effect is therefore *reachable* in a push or verify build.
|
||||
For when they are reached: there is one allocation, `RecordAt`'s amortised `resize`, on create only, never per draw;
|
||||
`create_vertex_elements` zeroes 1280 bytes per configuration change, which D-G2 explicitly budgets as
|
||||
once-per-configuration; `set_vertex_buffers` and `set_index_buffer` allocate nothing; no timer anywhere
|
||||
(`ROADMAP.md:7`). The stats counter (`:1008`) is a `Uint64` increment in the applier's own state, not a
|
||||
`PipeStats` call, so it costs nothing when stats are off. On **`Fatal` on legal sequences**: the five bounds wires
|
||||
can only fire on a record that contradicts itself, which is not a legal sequence — but the *dead-handle* verdict is
|
||||
the mirror image of that question and is C1: the no-op does hide a genuine protocol error a split build would need
|
||||
to see, and the report's stated reason (a legal context-reset sequence) is real but far more frequent than stated,
|
||||
which is why the answer is "keep the no-op, add the counter" rather than "make it Fatal".
|
||||
|
||||
**(3) The reverse channel's applier side (D-D) — satisfied.** `MGPipeApplyResourceReadback` (`:938-972`) calls
|
||||
`ops->Readback` synchronously and does nothing after it returns, so C is free to run the whole of D-D's five steps
|
||||
inside the hook in order: writeback → unmap → stamp `syncedChangeSerial` → `BumpBufferMutationEpoch()`. Nothing in
|
||||
the applier can reorder them and nothing bumps an epoch on this side. The applier deliberately does **not** move
|
||||
`Serial` on a readback, and that is right for the wrong-sounding reason: today `Ops_ReadbackFromGpu:1414` stamps the
|
||||
frontend serial *after* `WritebackFromBackend` precisely because the writeback moved it
|
||||
(`BufferObject.cpp:305-311` bumps `m_changeSerial`); under P3a neither side moves, the stamp is a no-op, and the
|
||||
buffer still reads clean afterwards — the same outcome by a shorter path. The one thing the applier cannot do is
|
||||
police the ordering, and it does not pretend to.
|
||||
|
||||
**(4) Persistent map (D-E, D-B) — correct, and it touches nothing it must not.** `MGPipeApplyMapPersistent`
|
||||
(`:1001-1025`) counts first and unconditionally (D-B2's "attempts, mint *or* decline"), resolves the handle, moves
|
||||
no serial and no descriptor, and returns `nullptr` for a decline — with the decline reached three ways (no table,
|
||||
null member, dead handle), all of which are the caller's existing branch. `MGPipeApplyUnmapPersistent`
|
||||
(`:1027-1041`) is the pair. The signature it dispatches through is D-A1's verbatim, which is the *only* thing D-E
|
||||
allows to change about `Ops_AcquirePersistentMap`; nothing here constrains the four-way capability gate, the
|
||||
stale-generation wipe order, the idempotency hit, `++g_bufferBackendIdGeneration`, `immutableStorage = true`, the
|
||||
`MGLOG_E_ONCE` decline or the success stamps. `AcquirePersistentMap` semantics are untouched. ✔ (n6 and M-C's second
|
||||
half are the two loose ends.)
|
||||
|
||||
**(5) G1, closure, purity.** `grep -c 'MG_State' MG_Pipe/PipeApply.h` → **0**; `grep -rc 'pGLContext'
|
||||
MobileGL/MG_Backend | grep -v ':0$'` → empty. No type from `MG_State` appears in `MGPipeResourceOps` or in any of
|
||||
the fourteen signatures — every parameter is an `MGPipeHandle`, an `MGP*` payload or a `const void*`. `PipeApply.h`
|
||||
includes exactly what it included at the tag (`Includes.h`, `MGPipeRenderStateSpans.h`, `MGPipeTypes.h`); the `.cpp`
|
||||
adds no include (`std::memcpy`'s `<cstring>` was already there at `:21`), so `MG_Pipe` gains no dependency on
|
||||
`MG_Impl` or `MG_State` and the closure result is unchanged by construction. Everything `c1`/`c2` add is inside
|
||||
`PipeApply.cpp`, which `CMakeLists.txt:482-493` appends to `SOURCE_FILES` only under push; `c3` is a test
|
||||
executable. The reported `27799 → 27799, 0 resized` is consistent with that and I have no reason to doubt it.
|
||||
|
||||
**(6) Tests.** The five things `C.0` asks `c3` for are all pinned, and the range-encoding case pins both bounds
|
||||
exactly, one byte either side, plus "a refused encoding leaves the record untouched" — which is the property the
|
||||
splitter needs and is the right thing to keep on this branch (A6). The lifecycle cases are not vacuous: deleting
|
||||
`FindResource`'s `Live` test or its `Gen` test turns `ADestroyDropsTheRecordAndAStaleGenerationResolvesToNothing`
|
||||
red at `:377-379` and `:392-395`, and deleting the create's `record = MGPipeResourceRecord{}` turns it red at
|
||||
`:369-371`. `EveryResourceCallDispatchesByHandleThroughTheInstalledTableOnly` is the strongest case in the file: it
|
||||
proves the null-table fall-through, the install, the per-hook arrival, the uninstall, and that the records keep
|
||||
moving through all of it.
|
||||
|
||||
Named cases that **would pass on a broken applier**:
|
||||
|
||||
- `NoResourcePathInThisPhaseLeavesHostWritesLive` — passes with every body deleted but `create`'s `RecordAt`; see
|
||||
M-C.
|
||||
- `TheSubDataRangeEncodingRefusesExactlyAtItsTwoBounds` — passes with both `c1` and `c2` deleted entirely; it tests
|
||||
two inline functions of `MGPipeTypes.h`. Deliberate (A5) and worth having, but it is one of the eight new names
|
||||
and it is not a test of this branch.
|
||||
- `AWriteOutsideTheDeclaredStorageIsRefusedNamingTheResource` — covers **one** fault on **one** call. Deleting
|
||||
`BufferRangeFault`'s call from `MGPipeApplyResourceFlushRange` (`:915`) and from `MGPipeApplyResourceReadback`
|
||||
(`:944`), and `SubDataBoxFault`'s `Level` arm (`:464`), leaves the suite green — measured, see Experiment.
|
||||
- Everything in `c2`: five entry points, two gates, no assertion anywhere. Measured, see M-B and Experiment.
|
||||
|
||||
**(7) Commit hygiene — clean.** Three commits, three single-line messages **byte-identical to `C.0`'s**, empty
|
||||
bodies (`git log --format='%b'` prints nothing for all three), no `Co-Authored-By` and no generator line, author and
|
||||
committer `Swung0x48 <swung0x48@outlook.com>`. `git diff --stat 39722687 HEAD` names exactly
|
||||
`MG_Pipe/PipeApply.{h,cpp}` and `MG_Test/Pipe/ResourceEmitTest.cpp`, all three A's under `C.5`; working tree clean;
|
||||
nothing pushed. The one nit is n10 (a post-tag edit to a contract file, declared, comment-only).
|
||||
|
||||
---
|
||||
|
||||
## Judgement on the eight declared deviations
|
||||
|
||||
| # | judgement |
|
||||
|---|---|
|
||||
| **A1** `VertexFetchBaseInstance` stores the raw value | **Sound, and it is the only resolution available.** D-H2.2 says "Espryt's applier computes `fetchBaseInstance = UseNativeBaseInstance() ? … ` and stores it in `MGPipeApplierState::VertexFetchBaseInstance`", but `MGPipeApplierState` lives in `MG_Pipe`, `UseNativeBaseInstance()` is a `MG_Backend` capability, and G13 greps for exactly that reach. The brief is internally inconsistent and A resolved it the right way: the value is raw, C's applier arm computes `BaseInstanceByteShift` out of each attribute's own stride and divisor, which is equivalent to today's `EmulatedFetchBaseInstance` at `DirectGLES.cpp:5128`. The comment-only header fix is the minimum change. The integrator owes D-H2.2 the correction (report §5 item 8) **and** owes C the message (n10). |
|
||||
| **A2** dead / unknown handle → defined no-op + debug assert | **The class is right; the implementation and the stated reason are not.** A no-op rather than `Fatal` is correct — a wire that aborts a verify lane on a legal sequence is the failure `ROADMAP.md:7` names. But the reason is stated as a corner case ("a shared store, a worker context") when `Tracker.h:192-195` makes it every make-current, and the refusal has no observable in any of the three gate builds. See C1. |
|
||||
| **A3** `MGPResourceDesc::Target` not gated | **Sound, and verified.** `MGPipeTypes.h:152`'s value set ("Buffer \| Tex1D.. \| Renderbuffer \| TexBuffer") has no minted enumerator anywhere — `TextureTarget` has no `Buffer` — so a gate here would be a guess handed to B as a contract. The call identifies the family, which is what `PipeCalls.def` already says, and the box convention is what is checked. |
|
||||
| **A4** a second trip-wire tag, `Fatal{PipeLiveHostWrites}` | **Sound in principle, incomplete in fact.** The reasoning is right (`MOBILEGL_ASSERT` is inert at INFO, which `build-push/CMakeCache.txt` confirms is the gate level, so D-A4's "a `MOBILEGL_PIPE_VERIFY` assertion pins that it is false" needs a real wire). But the wire has no negative control and skips `map_persistent`. See M-C. |
|
||||
| **A5** one of the eight cases is not push-gated | **Sound.** `MGPipeSetSubDataBufferRange` / `…BufferOffset` / `…BufferSize` are `inline` functions of `MGPipeTypes.h` and exist in a pull TU, so the case runs rather than skips in all three trees. `ctest -N` names stay identical between the pull and push trees either way (G2's name half is about the *name set*, not about which arm runs), and the bound is pinned for the transport that will read it. |
|
||||
| **A6** the splitter's case is B's | **Sound.** `MG_Impl/Pipe/ResourceTracker.h` does not exist on this branch and `C.5` gives it to B, so the split cannot be driven here. What `c3` pins instead is exactly the splitter's precondition — both bounds, and that a refused encoding leaves the record byte-identical, so the emitter can split against the record it just tried. The hand-off is written into the file header and into §5 item 6. The integrator should record the re-assignment explicitly, since `C.0`'s `c3` line asks for it by name. |
|
||||
| **A7** G5 could not run | **Sound, and verified independently.** `git diff --stat 39722687 HEAD` names three files and `Managers.cpp` is not among them, so the nine G5 functions are byte-identical by construction, script or no script. |
|
||||
| **A8** `check_include_closure.py --compiler clang++-20` | **Sound**, already recorded at `c0`; the no-argument form and `--compiler clang++` were both run. |
|
||||
|
||||
---
|
||||
|
||||
## Experiment — the suite's own negative control, run
|
||||
|
||||
A throwaway worktree `/home/swung/w7/p3a-review-wire` at `e9b4a263`, configured to match `p3a-wire`'s own
|
||||
`build-push` as read out of its `CMakeCache.txt` (`Release`, `/usr/sbin/clang++`, `MOBILEGL_PIPE_PUSH=ON`,
|
||||
`MOBILEGL_PIPE_VERIFY=OFF`, `MOBILEGL_FORCE_RELEASE_OPT=ON`, `MOBILEGL_LOG_ACTIVE_LEVEL=MOBILEGL_LOG_LEVEL_INFO`,
|
||||
integration tests and benchmark OFF, `CCACHE_BASEDIR=/home/swung/w7`).
|
||||
|
||||
**Baseline** — `ResourceEmitTest` at `e9b4a263`: `[ PASSED ] 9 tests.`, all nine named cases OK. So the report's
|
||||
push-arm result reproduces.
|
||||
|
||||
**Broken-applier control** — eight semantic mutations, applied together, all inside `PipeApply.cpp`:
|
||||
|
||||
| # | mutation |
|
||||
|---|---|
|
||||
| 1, 2 | both `std::memcpy`s removed from `MGPipeApplyCreateVertexElements` (`:1119`, `:1123`) — nothing is unpacked |
|
||||
| 3 | `MGPipeApplySetVertexBuffers`' `for` loop removed (`:1197-1199`) — no entry is ever stored |
|
||||
| 4 | the `Start + Count` window gate disabled (`:1173`) |
|
||||
| 5 | the `Blob.Size != declared` gate disabled (`:1084`) |
|
||||
| 6, 7 | `BufferRangeFault` removed from `MGPipeApplyResourceFlushRange` (`:915`) and `MGPipeApplyResourceReadback` (`:944`) |
|
||||
| 8 | `SubDataBoxFault`'s `Level != 0` arm removed (`:464`) |
|
||||
|
||||
Rebuilt (rc 0) and re-run: **`[ PASSED ] 9 tests.`** — identical output, every case still OK, including
|
||||
`AWriteOutsideTheDeclaredStorageIsRefusedNamingTheResource` (it drives `resource_subdata`, whose gate mutation 6/7
|
||||
did not touch). That is the evidence behind M-B and behind the "would pass on a broken applier" list under (6).
|
||||
|
||||
The worktree was removed with `git worktree remove --force`, `git worktree prune` run, and its three build logs
|
||||
deleted. `/home/swung/w7/p3a-wire` is clean at `e9b4a263`; no file in it was modified.
|
||||
|
||||
---
|
||||
|
||||
## The exact rework list
|
||||
|
||||
**Blocking (this branch, before `p3a/client` is merged in D.1):**
|
||||
|
||||
1. **C1a** — settle the reset scope with the integrator and record it in `INTEGRATOR-DECISIONS.md`, not only in a
|
||||
package report (`PipeApply.cpp:543-569`, `PipeFill.cpp:1188-1190`, `Tracker.h:192-195`).
|
||||
2. **C1b** — make the refusal countable: a refusal counter in `MGPipeApplierState` bumped on every
|
||||
`FindResource`-null path, plus a `ResourceEmit` case pinning 0 on a legal sequence and non-zero on a refused one.
|
||||
3. **C1c** — correct §3 A2's "the first validate of a fresh context" to "every change of the current context".
|
||||
4. **C2** — at reset, advance `VertexBuffersSerial` and `IndexBufferSerial` instead of zeroing them
|
||||
(`PipeApply.cpp:565`, `:567`); correct `VertexInputEmitTest.cpp:67-74`'s comment and turn `:94-95`'s two
|
||||
assertions into "moved forward" (the case's **name** is unchanged, which is all G14 protects); and add the
|
||||
sentence to §5's serial contract for C.
|
||||
5. **M-A** — close contract-review `M1`: two comment lines in `Coverage.def:41-47` putting `DispatchIndirect` and
|
||||
`Query` in the still-pulled bucket with their reason, in `BufferObject.h:15-33`'s own spelling.
|
||||
6. **M-B** — four applier-side cases for `c2` (blob round trip + shrink; the count/`Blob.Size` refusal in both
|
||||
build arms; `Start + Count` at 32 and 33; `ContentSerial` re-create vs recycled slot, and `SetIndexBuffer`
|
||||
moving only its own serial).
|
||||
7. **M-C** — a negative control that sets `HasLiveHostWrites` and observes `Fatal{PipeLiveHostWrites}`, and a
|
||||
`PinNoLiveHostWrites` call in `MGPipeApplyMapPersistent` (and `…ResourceReadback`).
|
||||
8. **M-D** — bound `handle.Slot` before `RecordAt` resizes on it (`PipeApply.cpp:405-410`, `:855`, `:1094`), with
|
||||
the same `Fatal{ProtocolCorruption}` identity line as its siblings.
|
||||
9. **M-E** — decide `MGPSubData::Blob`: either gate `Blob.Size` when non-zero, or state in `MGPipeTypes.h` and in
|
||||
§5 that the buffer half's `Blob` is unpoliced until P5/P8 and that B must not fill it. One rule, written once,
|
||||
for both blob-carrying families.
|
||||
|
||||
**Inherited from `contract-review-v1`, A-owned, due before D.1's `espryt` merge:**
|
||||
|
||||
10. **m1** — re-sort `Coverage.def:187` into the `LC_ALL=C` order of `MGP_COVERAGE_EMITTED_LIST`.
|
||||
11. **m2** — `MGPipeTypes.h:257`: name the wire views, not `VertexAttribute[]` / `VertexBufferBindingPoint[]`.
|
||||
12. **m3** — `ConfigLoader.cpp:11`: `kMGPipeSubsystemsMigratedAtP2` → `…AtP3a`. (`MagmaPipeArms.h:112-115` is the
|
||||
integrator's; no package owns `MG_Backend/DirectVulkan/**`.)
|
||||
13. **m4** — `PipeFill.cpp:688-701`: give all three pairing `static_assert`s the same right-hand side.
|
||||
|
||||
**Declared minors, non-blocking** (ID-4): n1-n10 above. n7 and n6 should nonetheless be added to the report's §5
|
||||
list for B, because they are cross-package and nothing else will say them.
|
||||
|
||||
**Report corrections owed by A:** §3 A2's frequency (C1c); §5 item 5's serial contract (C2); §5 gains n6 (the two
|
||||
roundtrip counters diverge across a context switch) and n7 (B's resident dispatch must gate on the op-table member,
|
||||
not on the subsystem alone).
|
||||
@@ -0,0 +1,256 @@
|
||||
# P3a package A, commits c1-c3 — the applier bodies (`wire-v1`)
|
||||
|
||||
Branch `p3a/wire`, worktree `/home/swung/w7/p3a-wire`, parent `39722687` (tag `p3a/contract`). **Not pushed.**
|
||||
Three commits, three files, +1066 / -46. Only A's own files after the tag: `MG_Pipe/PipeApply.{h,cpp}` and the
|
||||
applier-side half of `MG_Test/Pipe/ResourceEmitTest.cpp`.
|
||||
|
||||
| commit | message (single line, no body) |
|
||||
|---|---|
|
||||
| `db0c93bb95e166e9e184db720572a41af4abbf77` (`db0c93bb`) | `[Feat] (Pipe): apply the resource calls into a per-context slot-indexed record and dispatch them to the backend by handle` |
|
||||
| `cede041deb190cde6eebd13e93c26a21fcee13b1` (`cede041d`) | `[Feat] (Pipe): apply vertex elements, vertex buffers and the index buffer into the server's own working state` |
|
||||
| `e9b4a263c41b1d38eb88458a3b2f267e5651a6f8` (`e9b4a263`) | `[Test] (Pipe): pin the resource record's lifecycle and the buffer sub-data range encoding at both of its bounds` |
|
||||
|
||||
```
|
||||
MobileGL/MG_Pipe/PipeApply.cpp | 549 ++++++++++++++++++++++++++--
|
||||
MobileGL/MG_Pipe/PipeApply.h | 15 +- (comments only, §3 A1)
|
||||
MobileGL/MG_Test/Pipe/ResourceEmitTest.cpp | 548 +++++++++++++++++++++++++++-
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. The shared machinery (`c1`, file-static, `PipeApply.cpp`'s anonymous namespace)
|
||||
|
||||
| helper | what it is |
|
||||
|---|---|
|
||||
| `RecordAt(Vector<R>&, slot)` | grows a slot-indexed table to hold `slot`. Slot spaces are dense per kind, so the server's table is an array a handle indexes, never a map. |
|
||||
| `FindResource(MGPipeHandle)` / `FindVertexElements(MGPipeHandle)` | null unless the slot is in range **and** `Live` **and** `Gen` matches. Same three questions `FindCso` already asked for the CSO store. |
|
||||
| `BufferRangeFault(offset, size, width)` | null when `[offset, offset+size)` is inside `width`. Written so nothing can overflow: `offset > width` is answered before the subtraction the second question needs. |
|
||||
| `SubDataBoxFault(record)` | the buffer half's convention held to itself: offset `<= 0x7FFFFFFF` (a corrupt negative `UnionBox.X` read unsigned lands above it — that is what the decoder's own comment promises), `Level == 0`, `RegionCount == 0`. |
|
||||
| `PinNoLiveHostWrites(...)` | `#if MOBILEGL_PIPE_VERIFY` only: `Fatal{PipeLiveHostWrites}` if a record ever arrives with `HasLiveHostWrites` set (D-A4's pin). Empty inline otherwise. |
|
||||
| `ApplyBufferWrite(call, record, bytes, resident)` | the single gate + serial + dispatch path shared by `resource_subdata` and `buffer_subdata_resident`, so the bounds arithmetic exists once. |
|
||||
|
||||
**Two verdict classes, deliberately different** (written into the file beside the helpers):
|
||||
|
||||
- **a dead / stale / unknown handle** → `MOBILEGL_ASSERT` + a **defined no-op**: nothing stored, nothing dispatched,
|
||||
no serial moved. This is `MGPipeApplyBindRenderState`'s existing precedent for a dead CSO, and it is *not* a trip
|
||||
wire on purpose — see §3 D2, which names the legal sequence a wire here would abort on.
|
||||
- **a record that does not describe its own bytes** → `Fatal{ProtocolCorruption}` with the record's identity in the
|
||||
line, and the call refused. That is the class `ARCHITECTURE.md:119` reserves the tag for: the fault would have the
|
||||
*backend* read or write outside a store.
|
||||
|
||||
---
|
||||
|
||||
## 2. Per entry point
|
||||
|
||||
### 2.1 The nine resource calls (`c1`)
|
||||
|
||||
| entry point | record | serial | bounds gate | dispatch |
|
||||
|---|---|---|---|---|
|
||||
| `ResourceCreate` | slot 0 refused; otherwise the record is **started over** (`record = {}`) and given `Gen`, `Live`, `Desc`. A recycled slot inherits nothing — not a `Width`, not a `Serial`, not an `Immutable`. | stays **0**: a create is not a mutation, it defines no storage, and a fresh backend twin starts its own synced serial at 0, so the two agree from the first instant. | none (no range) | `ops->Create(desc.Resource, desc)` |
|
||||
| `ResourceRespecify` | descriptor replaced **whole** (not merged): a respecify restates extent, usage, storage flags, immutability and defined-content. | **++** | none | `ops->Respecify(res, desc, initialBytes)` |
|
||||
| `ResourceSubData` | nothing (contents are the backend's) | **++** | `SubDataBoxFault` then `BufferRangeFault(offset, size, Desc.Width)` then `size != 0 && bytes == nullptr` | `ops->SubData(res, record, bytes)` |
|
||||
| `BufferSubDataResident` | nothing | **++** | identical | `ops->SubDataResident` **if non-null** (`kOptional`, the frontend's own shape today) |
|
||||
| `ResourceFlushRange` | nothing | **++** | `BufferRangeFault(record.Offset, record.Size, Desc.Width)` + null-bytes. `AccessFlags` are passed through **unnormalised** — the backend reads INVALIDATE_RANGE / INVALIDATE_BUFFER / UNSYNCHRONIZED per call. | `ops->FlushRange(res, record, bytes)` |
|
||||
| `ResourceReadback` | nothing | **none** — a readback does not mutate the store; a bump would tell the twin its memo is stale and buy a re-upload of what it had just read out | `BufferRangeFault` | `ops->Readback(res, record)`, **synchronously**, so the writeback and the epoch bump that must follow it have both happened before this returns (D-D step 5) |
|
||||
| `ResourceDestroy` | record dropped **whole**, `Gen` **kept** (the client allocator owns the bump and takes it on the next handout). Applier state is consistent **before** the backend is told. | reset to 0 with the record | none | `ops->Destroy(handle)` |
|
||||
| `MapPersistent` | none | **none** (the donation re-mints a *driver* object; the backend's own id generation catches that) | none | `++MapPersistentRoundtrips` **first and unconditionally** (attempts, not acquisitions — mint *or* decline), then `ops->MapPersistent`; a missing table/member is a **decline**, i.e. `nullptr`, which is a real answer |
|
||||
| `UnmapPersistent` | none | none | none | `ops->UnmapPersistent` |
|
||||
|
||||
`kNeedsAck`: `MGPipeResourceRespecifyNeedsAck(desc)` is **documented at the call site and deliberately not branched
|
||||
on** — in monolith the acknowledgement *is* the return of `MGPipeApplyResourceRespecify`, so both arms of such a
|
||||
branch would be identical and the transport would have to find and delete it. `PipeCatalogueTest`
|
||||
(`ResourceRespecifyAcksOnlyImmutableStorage`) plus c3's `ARespecifyReplaces…` keep the predicate honest until the
|
||||
doorbell reads it.
|
||||
|
||||
**Serial ordering, and C depends on it:** the serial is bumped **before** the backend hook is called, because Espryt
|
||||
stamps its own `syncedChangeSerial` from `record.Serial` *inside* the hook. A bump afterwards would leave the twin
|
||||
one mutation behind and the next draw would re-upload what it had just landed.
|
||||
|
||||
### 2.2 The five vertex-input calls (`c2`)
|
||||
|
||||
These **dispatch to nobody**, and that is not an omission: `MGPipeResourceOps` is the *resource* family's table.
|
||||
The backend does not act on vertex input when it arrives — it reads this state at its own draw-time sync, which is
|
||||
what the three serials are for.
|
||||
|
||||
| entry point | record | serial | bounds gate |
|
||||
|---|---|---|---|
|
||||
| `CreateVertexElements` | slot 0 refused. An existing record of the **same identity** keeps its serial (a re-create on the same handle is how a configuration change travels); a **different** `Gen` is a recycled slot and starts over. Both arrays are zeroed before the unpack, so a configuration that shrinks leaves nothing of the one before it. `memcpy` (a blob pointer carries no alignment guarantee). | `++ContentSerial`; the first create of an identity lands on **1**, so **0 means "never created"** and a twin that has synced nothing can never accidentally match. | counts `<= kMGPipeMaxVertexAttribs`; **`desc.Blob.Size` must equal `AttributeCount*24 + BindingPointCount*16` exactly**; non-empty blob must carry bytes. Any of the four → `Fatal{ProtocolCorruption}` naming `{slot, gen}`, both counts, both byte lengths. **Does not rebind.** |
|
||||
| `BindVertexElements` | null handle is legal and clears the binding; a dead handle leaves the previous binding untouched (`bind_render_state`'s precedent) | — | kind assert |
|
||||
| `DeleteVertexElements` | dropped whole, `Gen` kept; clears `BoundVertexElements` if it named this handle | — | — |
|
||||
| `SetVertexBuffers` | entries copied into `[Start, Start+Count)` and **nowhere else** — entries outside the window are not cleared, because the record is "the last set as received" and a set that names four entries has said nothing about the rest. `VertexFetchBaseInstance = hdr.BaseInstance`, **raw** (§3 A1). | `++VertexBuffersSerial` | `Start + Count <= kMGPipeMaxVertexAttribs`, `Count != 0 => tail != nullptr` → `Fatal{ProtocolCorruption}` naming `{start, count, hash}` |
|
||||
| `SetIndexBuffer` | stored verbatim | `++IndexBufferSerial` | **none, with three reasons in place**: `Res` may legitimately be null (no element-array buffer bound); `Offset`/`IndexSize` are the *draw's* and are 0/0 until one supplies them, so there is no extent to check against; and it is an independent call, not a subset of the configuration (D5) |
|
||||
|
||||
---
|
||||
|
||||
## 3. Deviations, each with its reason
|
||||
|
||||
**A1 — `VertexFetchBaseInstance` stores the RAW value; the applier does not resolve the shift.** D-H2.2 says
|
||||
"Espryt's applier computes `fetchBaseInstance = UseNativeBaseInstance() ? 0 : hdr.BaseInstance`", and c0's header
|
||||
comment said the member holds a value "resolved by the server's own decision". `UseNativeBaseInstance()` is a
|
||||
**backend capability** living in `MG_Backend`, and `MG_Pipe` sits below it and may not ask (purity gate A; there is
|
||||
no capability hook in `MGPipeResourceOps`, which is a resource table). Emulation is server-owned and the backend
|
||||
*is* the server, so the raw value is stored and **package C's applier arm** turns it into a per-attribute byte
|
||||
shift out of each attribute's own stride and divisor (`BaseInstanceByteShift`). The two comments in `PipeApply.h`
|
||||
that said otherwise were corrected in `c2` — **comments only, no signature and no member changed**; this is the one
|
||||
post-tag edit to a contract file and it is recorded here for the other three packages.
|
||||
|
||||
**A2 — a dead / unknown handle is a defined no-op with a debug assert, not `Fatal{ProtocolCorruption}`.** A resource
|
||||
call is applied at the GL call that causes it, while `MGPipeApplierReset()` runs at the **first validate of a fresh
|
||||
context** (`PipeFill.cpp:1190`, `tracker.FreshlyPrimed()`). A buffer that outlives a context switch — a shared store,
|
||||
a worker context — therefore reaches this applier with its record already dropped, through no fault of any package.
|
||||
A wire there would abort the verify lane on a *legal* sequence, which is the failure mode `ROADMAP.md:7`'s "每个门必须
|
||||
能因它存在的理由变红" is the other half of. The refusal is loud in a debug build and silent-but-defined in the three
|
||||
gate builds (INFO ⇒ `MOBILEGL_ASSERT` compiles out), and `ResourceEmit.ADestroyDropsTheRecord…` pins that it changes
|
||||
nothing. **This is a real hole in the phase's design, not just in this package — see §5 item 1.**
|
||||
|
||||
**A3 — `MGPResourceDesc::Target` is not gated.** The field's documented value set ("Buffer | Tex1D.. | Renderbuffer |
|
||||
TexBuffer") has **no minted enumerator** anywhere in the tree — `TextureTarget` has no `Buffer`. Gating on a value
|
||||
this package would have to guess would hand package B a contract it could not read off any header. The buffer half is
|
||||
identified by the **call**, which is what `PipeCalls.def` already says, and the box convention is what is checked.
|
||||
|
||||
**A4 — one new trip-wire tag beyond the specified one.** `Fatal{ProtocolCorruption}` is `ARCHITECTURE.md:119`'s and is
|
||||
used exactly as specified. `Fatal{PipeLiveHostWrites}` is new and is D-A4's requirement spelled as this file spells
|
||||
verdicts ("a `MOBILEGL_PIPE_VERIFY` assertion pins that it is false") — `MOBILEGL_ASSERT` would have been inert in
|
||||
every build that ships, which is the mistake the file's own header comment forbids.
|
||||
|
||||
**A5 — `c3` is eight cases, and one of them is not push-gated.**
|
||||
`ResourceEmit.TheSubDataRangeEncodingRefusesExactlyAtItsTwoBounds` exercises an **inline function of the payload
|
||||
header**, which exists in a pull build too, so it runs in all three trees rather than skipping in one. The other
|
||||
seven skip visibly in a pull build, as the file's header requires.
|
||||
|
||||
**A6 — the splitter's own case is not here.** `c3`'s brief line asks for "the emitter's splitter produces contiguous,
|
||||
non-overlapping records that reassemble to the original range", but the splitter lives in package B's
|
||||
`MG_Impl/Pipe/ResourceTracker.h`, which does not exist on this branch (C.5 gives B that file). What `c3` pins is what
|
||||
the splitter is written **against** — the range encoding and both of its bounds, plus that a refused encoding leaves
|
||||
the record untouched, which is what lets the emitter split against the very record it just tried. The split test is
|
||||
**B's**, and the file's header comment now says so in those words.
|
||||
|
||||
**A7 — `bash scripts/p3a_untouched_regions.sh` (G5) could not run.** The script is package D's (ID-3) and is not in
|
||||
the tree. This package touches no `Managers.cpp` region at all, so the nine functions are byte-identical by
|
||||
construction.
|
||||
|
||||
**A8 — `check_include_closure.py --compiler clang++-20`** does not exist on this host (already recorded by c0);
|
||||
`clang++` was used, and the no-argument form was run as well.
|
||||
|
||||
---
|
||||
|
||||
## 4. Verification transcript
|
||||
|
||||
All in `/home/swung/w7/p3a-wire` at `e9b4a263`, `CCACHE_BASEDIR=/home/swung/w7`.
|
||||
|
||||
**G1 — pull build symbol identity**, rc **0**:
|
||||
|
||||
```
|
||||
python3 scripts/symbol_report.py --before /home/swung/w7/p3a-before-libMobileGL.so \
|
||||
--after build-linux/libMobileGL.so --threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0
|
||||
symbol-report: Total 17209979 -> 17209979 (+0)
|
||||
symbol-report: 27799 -> 27799 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
|
||||
`.text` 10792739 -> 10792739 (+0, +0.000%). ... 27060 unchanged.
|
||||
symbol-report: .data 76824 -> 76824 (+0) .bss 1296872 -> 1296872 (+0) .rodata 1534938 -> 1534938 (+0)
|
||||
```
|
||||
|
||||
P3a's admitted-resize set is empty, as §A.2 G1 requires. (Everything c1/c2 add is inside `PipeApply.cpp`, which is
|
||||
compiled only under `MOBILEGL_PIPE_PUSH`; c3 is a test executable.)
|
||||
|
||||
**Generators and closure**
|
||||
|
||||
```
|
||||
python3 scripts/gen_pipe.py --check rc 0 "gen_pipe: generated files are up to date"
|
||||
"71 calls (11 screen, 60 context), 71 verify payloads,
|
||||
63 PipeInputs fields (7 sticky, 34 emitted), 69 verbs, 9 classes"
|
||||
"inventory 477 rows: ... 0 UNMAPPED"
|
||||
python3 scripts/gen_pipe.py --self-test rc 0 "7 negative-control trip(s), positive control OK"
|
||||
git diff --exit-code -- MobileGL/MG_Pipe/generated rc 0
|
||||
python3 scripts/check_include_closure.py rc 0
|
||||
"4 probes, 0 skipped, 0 problem(s)" (value 66 / artifacts 65 / mutation 84 / wire 2)
|
||||
python3 scripts/check_include_closure.py --mode both --compiler clang++ --self-test --require-all
|
||||
rc 0 "6 negative-control trip(s), parser checks OK"
|
||||
```
|
||||
|
||||
**Three builds** (`cmake --build <dir> -j 24`, at HEAD): `build-linux` rc **0**, `build-push` rc **0**,
|
||||
`build-verify` rc **0**.
|
||||
|
||||
**Three unit runs** (`ctest --test-dir <dir> -L unit -j 12 --no-tests=error`):
|
||||
|
||||
```
|
||||
build-linux rc=0 100% tests passed, 0 tests failed out of 1579 (16.83 s)
|
||||
build-push rc=0 100% tests passed, 0 tests failed out of 1579 (14.16 s)
|
||||
build-verify rc=0 100% tests passed, 0 tests failed out of 1579 (12.85 s)
|
||||
```
|
||||
|
||||
(1571 at `c0` + 8 new names.)
|
||||
|
||||
**Name sets (G2's name half, G14)** — ID-4's extractor:
|
||||
|
||||
```
|
||||
ctest -N names: build-linux 2495, build-push 2495, build-verify 3323
|
||||
diff <build-linux names> <build-push names> -> empty (rc 0)
|
||||
comm -23 ~/w7/p3a-before-ctest-names.txt <build-linux names> -> empty (nothing removed)
|
||||
comm -13 ... -> 13 added: c0's 5, plus
|
||||
ResourceEmit.ACreateMarksTheSlotLiveAndCarriesItsDescriptor
|
||||
ResourceEmit.ADestroyDropsTheRecordAndAStaleGenerationResolvesToNothing
|
||||
ResourceEmit.ARespecifyReplacesTheDescriptorAndOnlyAMutationMovesTheSerial
|
||||
ResourceEmit.AWriteOutsideTheDeclaredStorageIsRefusedNamingTheResource
|
||||
ResourceEmit.EveryResourceCallDispatchesByHandleThroughTheInstalledTableOnly
|
||||
ResourceEmit.MapPersistentCountsEveryAttemptWhetherItMintsOrDeclines
|
||||
ResourceEmit.NoResourcePathInThisPhaseLeavesHostWritesLive
|
||||
ResourceEmit.TheSubDataRangeEncodingRefusesExactlyAtItsTwoBounds
|
||||
```
|
||||
|
||||
**The suite itself, in all three trees** (`ctest -R 'ResourceEmit\.' --no-tests=error --output-on-failure`):
|
||||
|
||||
```
|
||||
build-push 9/9 Passed
|
||||
build-verify 9/9 Passed (the bounds case takes its forked-abort arm here and reads
|
||||
"Fatal{ProtocolCorruption} resource_subdata {slot=7, gen=3, glName=41}"
|
||||
out of the log after SIGABRT)
|
||||
build-linux 8 Skipped, 1 Passed (the range encoding)
|
||||
```
|
||||
|
||||
**G13's two greps**: `grep -c 'MG_State' MobileGL/MG_Pipe/PipeApply.h` → **0**;
|
||||
`grep -rc 'pGLContext' MobileGL/MG_Backend | grep -v ':0$'` → empty.
|
||||
|
||||
**Ownership**: `git diff --stat 39722687..HEAD` names exactly `MG_Pipe/PipeApply.cpp`, `MG_Pipe/PipeApply.h` and
|
||||
`MG_Test/Pipe/ResourceEmitTest.cpp`. Working tree clean. Nothing pushed; no other worktree touched.
|
||||
|
||||
**Not run here, and why**: G2's execution half, G3/G3b/G4's retrace, G5 (§3 A7), G6-G12, G15. This package registers
|
||||
no `MGPipeResourceOps` and emits no call, so it changes no observable and those gates belong to the integrator's D.1
|
||||
merges.
|
||||
|
||||
---
|
||||
|
||||
## 5. What is left, and for whom
|
||||
|
||||
1. **The context-reset hole (§3 A2) — for the integrator, B and C.** `MGPipeApplierReset()` drops `Resources` at the
|
||||
first validate of a fresh context, but buffer objects are share-group-scoped and can outlive a context switch. The
|
||||
applier's refusal is defined and reported, so nothing corrupts — but a `glBufferSubData` on a shared store after a
|
||||
context switch would be **dropped** rather than applied. B (whose `ResourceTracker.h` mints the handles) or the
|
||||
integrator must decide: re-emit `ResourceCreate` + `ResourceRespecify` on first use after a reset, or take
|
||||
`Resources` / `VertexElementsCsos` out of the reset because they describe share-group objects. This is not
|
||||
reachable today (nothing emits), and it must be settled before `p3a/client` lands.
|
||||
2. **`create_vertex_elements` requires `desc.Blob.Size` to be filled — for B.** The applier refuses, as
|
||||
`Fatal{ProtocolCorruption}`, any record where `Blob.Size != AttributeCount*24 + BindingPointCount*16`. In monolith
|
||||
the *bytes* travel through the companion pointer, but the **declared length must still be set**, or every emission
|
||||
aborts a verify build. Both counts are also bounded by 32.
|
||||
3. **`resource_subdata` requires a `Width` — for B.** The applier refuses a write outside `record.Desc.Width`, so the
|
||||
store's extent must reach the applier (via `ResourceRespecify`) before any write to it, and `Width` must be the
|
||||
real `GetSize()`. Same for `resource_flush_range` and `resource_readback`.
|
||||
4. **`VertexFetchBaseInstance` is raw — for C.** The applier arm computes
|
||||
`UseNativeBaseInstance() ? 0 : MGPipeApplier().VertexFetchBaseInstance` itself; `EmulatedFetchBaseInstance` and
|
||||
`BaseInstanceByteShift` move inside that arm, exactly as D-H2.2 describes, but the `?:` is C's line and not this
|
||||
file's.
|
||||
5. **Serial contract — for C.** `Serial` 0 = created-never-mutated; `ContentSerial` 0 = never created (first create
|
||||
lands on 1); both bumped **before** the backend hook runs; both reset on a create at a recycled slot, and the twin
|
||||
re-keys on `Gen` (A's `BackendSlotTable::GetOrCreate` already resets a twin whose `Gen` moved).
|
||||
6. **The splitter's case — for B** (§3 A6), appended beside these in `ResourceEmitTest.cpp` as a disjoint `TEST`
|
||||
body; A landed first, so B's edit is an append.
|
||||
7. **The vertex-input applier's own cases — for B**, in `VertexInputEmitTest.cpp` (C.5 gives B that file's contents
|
||||
beyond c0's placeholder). Worth covering there, because `c3` could not: the counts/length refusal, a blob unpack
|
||||
round trip over all 32 slots, `Bind`/`Delete` and the null-handle bind, and that a create at a recycled slot resets
|
||||
`ContentSerial` while a re-create on the same handle counts up.
|
||||
8. **Doc corrections owed to the integrator**, beyond c0's list: D-H2.2's "Espryt's applier computes …" reads as if
|
||||
`MG_Pipe`'s applier resolved the shift; it is the backend arm (§3 A1). D-A2's `MGPResourceDesc::Target` row names a
|
||||
value set with no enumerator behind it (§3 A3).
|
||||
|
||||
Intermediate logs this package created — `~/w7/p3a-wire-build-*.log` and `~/w7/p3a-wire-names-*.txt` — were deleted.
|
||||
`~/w7/p3a-trees2.log` is kept, as instructed.
|
||||
@@ -0,0 +1,403 @@
|
||||
# P3a package A, rework round 2 — the applier bodies (`wire-v2`)
|
||||
|
||||
Branch `p3a/wire`, worktree `/home/swung/w7/p3a-wire`, on top of `e9b4a263` (the three landed commits are untouched).
|
||||
**Not pushed.** Three new commits, seven files, +2038 / -85 against the tag `39722687`.
|
||||
|
||||
| commit | message (single line, empty body, no attribution) |
|
||||
|---|---|
|
||||
| `cdc42379f6...` (`cdc42379`) | `[Fix] (Pipe): account for DispatchIndirect and Query in Coverage.def's target-by-target split, re-sort the new emitted row, and name the P3a default mask in ConfigLoader's include comment` |
|
||||
| `761faca1...` (`761faca1`) | `[Fix] (Pipe): give both blob-carrying record families one Blob rule, and name the wire views the vertex-elements blob actually carries` |
|
||||
| `48fe55be...` (`48fe55be`) | `[Fix, Test] (Pipe): a make-current is not a teardown - the applier keeps its object records across one, counts every call refused on a record it does not have, advances the two vertex-input serials instead of restarting them at 0, and bounds the slot it grows a record table on` |
|
||||
|
||||
```
|
||||
MobileGL/ConfigLoader.cpp | 5 +-
|
||||
MobileGL/MG_Pipe/Coverage.def | 33 +-
|
||||
MobileGL/MG_Pipe/MGPipeTypes.h | 32 +- (comments only)
|
||||
MobileGL/MG_Pipe/PipeApply.cpp | 683 ++++++-
|
||||
MobileGL/MG_Pipe/PipeApply.h | 104 ++-
|
||||
MobileGL/MG_Test/Pipe/ResourceEmitTest.cpp | 1232 +++++++++++-
|
||||
MobileGL/MG_Test/Pipe/VertexInputEmitTest.cpp | 34 +-
|
||||
```
|
||||
|
||||
**The granted `Tracker.h` waiver was not needed and not used.** The fix lives entirely inside A's files: the call
|
||||
site at `MG_Impl/Pipe/Tracker.h:192-195` and `MG_Impl/Pipe/PipeFill.cpp:1188-1193` are byte-identical to `e9b4a263`,
|
||||
`git diff 39722687..HEAD --stat` names no file of B's, and B's rebase sees no edit in `Tracker.h` or `PipeFill.cpp`.
|
||||
One thing B *does* have to know is in §6.
|
||||
|
||||
---
|
||||
|
||||
## 1. Per-finding disposition
|
||||
|
||||
| finding | disposition | where |
|
||||
|---|---|---|
|
||||
| **C1** reset scope + invisible refusal | **fixed** — the records are out of the reset; the refusal is counted, named and driven | `PipeApply.h:202-229`, `:266-300`; `PipeApply.cpp:439-490`, `:597-660` |
|
||||
| **C2** serials sent backwards | **fixed** — `++` at every reset, never 0 | `PipeApply.cpp:628-646`, `:649-660`; `VertexInputEmitTest.cpp:67-110` |
|
||||
| **M-A** / contract `M1` `Coverage.def` split | **fixed** — all 15 `BufferTarget` enumerators, in the enum's own spelling | `Coverage.def:40-58` |
|
||||
| **M-B** `c2`'s zero coverage | **fixed** — 9 new cases; all 8 review mutations measured red (§4) | `ResourceEmitTest.cpp:788-1330` |
|
||||
| **M-C** `Fatal{PipeLiveHostWrites}` control + `map_persistent` | **fixed** — pinned on `map_persistent` and `resource_readback`, with a negative control and a positive one | `PipeApply.cpp:1049`, `:1110`; `ResourceEmitTest.cpp:1218-1281` |
|
||||
| **M-D** unbounded `RecordAt` | **fixed** — two named bounds, `Fatal{ProtocolCorruption}`, never a resize | `PipeApply.h:112-113`; `PipeApply.cpp:416-421`, `:906-914`, `:1200-1210` |
|
||||
| **M-E** the two `Blob` rules | **fixed** — ONE rule, stated on both records and enforced on both | `MGPipeTypes.h:254-265`, `:624-632`; `PipeApply.cpp:516-525`, `:1171-1188` |
|
||||
| **m1** emitted-row order | **fixed** | `Coverage.def:202` |
|
||||
| **m2** `Blob` comment names frontend types | **fixed** | `MGPipeTypes.h:270-275` |
|
||||
| **m3** stale default-mask comment (A's half) | **fixed** | `ConfigLoader.cpp:11-13` |
|
||||
| **m4** `static_assert` form | **NOT A's** — see §1.9 | `MG_Impl/Pipe/PipeFill.cpp:687-701` |
|
||||
| **n1** bare `return` at `delete_vertex_elements` | fixed in passing (routed through the resolver) | `PipeApply.cpp:1266-1273` |
|
||||
| **n2, n3, n4, n5, n8, n9, n10** | recorded, not taken (ID-4 declared minors) | §7 |
|
||||
| **n6, n7** | carried into §6 for B, as the review asks | §6 |
|
||||
|
||||
### 1.1 C1 — the records are per-object, not per-draw, and the refusal is now an observable
|
||||
|
||||
**The rule that landed** (`PipeApply.h:200-229`, and the two functions' own comments):
|
||||
|
||||
* `MGPipeApplierReset()` — which runs at **every change of the current `GLContext`**, not once per fresh one — clears
|
||||
the render-state CSOs, the residual mirror and the vertex-input **working state**, and advances the two global
|
||||
serials. It does **not** touch `Resources` or `VertexElementsCsos`.
|
||||
* `MGPipeApplierReleaseObjectRecords()` (new, `PipeApply.h:279-300`, `PipeApply.cpp:649-660`) clears them. It is the
|
||||
**served context's teardown**: under split there is one applier per served context and this is what goes with it.
|
||||
* Between the two, a record is cleared by its object's own death signal — `resource_destroy`,
|
||||
`delete_vertex_elements` — which is what D-L already makes the buffer's death crossing.
|
||||
|
||||
**In the monolith `MGPipeApplierReleaseObjectRecords()` is deliberately wired to nothing**, and that is written into
|
||||
the header. There is one `g_applier` behind every context (`PipeApply.h:286` has always said so), so calling it on
|
||||
one context's destruction would drop every *other* context's records — C1 in its other direction. The only callers
|
||||
are the unit fixtures, which is the one place that legitimately means "this applier is going away". The records that
|
||||
would otherwise accumulate are bounded by the client's dense slot high-water mark and are dropped one at a time by
|
||||
the death notices, so nothing leaks.
|
||||
|
||||
**The observable.** Both refusal paths now go through `ResolveResource` / `ResolveVertexElements`
|
||||
(`PipeApply.cpp:472-490`), which assert *and* count into `MGPipeApplierState::RefusedResourceCalls` /
|
||||
`RefusedVertexInputCalls` (`PipeApply.h:220-229`). One place resolves, asserts and counts, so a call that forgets one
|
||||
of the three cannot exist. `ResourceEmit.ACallOnARecordTheApplierDoesNotHaveIsCountedRatherThanSilentlyDropped`
|
||||
(`ResourceEmitTest.cpp:859`) pins that a legal sequence leaves both at 0 and walks all nine resource entry points and
|
||||
both vertex-input ones to 9 and 2. Removing either increment is red (§4, M12/M13).
|
||||
|
||||
**Why it stays a defined no-op rather than becoming a `Fatal`, and the exact sequence that requires it.** The review
|
||||
allowed a no-op only if a legal sequence genuinely needs one. It does — one, and it is written at
|
||||
`PipeApply.cpp:439-470`:
|
||||
|
||||
```
|
||||
the served context is torn down
|
||||
-> MGPipeApplierReleaseObjectRecords() (the applier goes away with the context)
|
||||
-> ~BufferObject / ~VertexArrayObject for every object the context still owns
|
||||
-> resource_destroy / delete_vertex_elements, each naming a record the line above dropped
|
||||
```
|
||||
|
||||
Those death notices are legal, unavoidable and unordered with respect to the release, so a wire here would abort a
|
||||
verify lane on the ordinary shutdown of a context. The counter is what makes the *other* case — an unknown slot, a
|
||||
stale generation, a genuinely dropped `glBufferSubData` — visible in all three gate builds, where `MOBILEGL_ASSERT`
|
||||
is inert.
|
||||
|
||||
**§3 A2's frequency is corrected** (C1c): it read "at the first validate of a fresh context"; the truth is "at every
|
||||
change of the current context", and that is now what the code comments say (`PipeApply.cpp:604-608`,
|
||||
`PipeApply.h:279-292`).
|
||||
|
||||
### 1.2 C2 — the two global serials advance
|
||||
|
||||
`PipeApply.cpp:628-646` replaces `= 0` with `++`, with the three-row argument (carry over / restart / advance) in
|
||||
place, and `MGPipeApplierReleaseObjectRecords` does the same (`:658-659`) for the same reason. `PipeApply.h:251-264`
|
||||
carries the rule beside the members. `VertexInputEmitTest.cpp:67-110`'s comment is rewritten and `:104-110` now pins
|
||||
"moved forward" (`43`/`44` from `42`/`43`, plus the two strict inequalities); **the case's name is unchanged**, which
|
||||
is all G14 protects. `ResourceEmit.TheObjectRecordsSurvive…` (`:816-820`) pins the same property with real state
|
||||
behind it. Restoring `= 0` is red in both suites (§4, M15).
|
||||
|
||||
### 1.3 M-A — `Coverage.def`'s split is exhaustive
|
||||
|
||||
`Coverage.def:40-58` now lists all **15** `BufferTarget` enumerators in `BufferObject.h:15-33`'s own spelling
|
||||
(`Vertex`, `Index`, `DrawIndirect`, `Parameter`, …), so the list cross-checks mechanically. `DispatchIndirect` gets
|
||||
its own bucket with the reason the review asked for — both backends read it at every `glDispatchComputeIndirect` and
|
||||
**no call carries it**, `MGPIndirectBuffers` being the `DrawIndirect` + `Parameter` pair only — plus the sentence
|
||||
that a later phase must not read the split as covering it. `Query` gets a one-line bucket. `:63` now says "seven
|
||||
targets above are still pulled" rather than five. Comment-only: `gen_pipe.py --check` is clean and
|
||||
`git diff -- MobileGL/MG_Pipe/generated` is empty.
|
||||
|
||||
### 1.4 M-B — the `c2` coverage, in `ResourceEmitTest.cpp`
|
||||
|
||||
Nine new cases (`ResourceEmitTest.cpp:788-1330`), deliberately **not** in `VertexInputEmitTest.cpp`, whose contents
|
||||
`C.5` gives to B and which B is appending to now. The file header block at `:646-660` says so in those words.
|
||||
|
||||
| case | what it holds | line |
|
||||
|---|---|---|
|
||||
| `TheObjectRecordsSurviveAMakeCurrentAndOnlyTheWorkingStateIsReset` | C1's two scopes with live records behind them; the write after the switch lands | `:788` |
|
||||
| `ACallOnARecordTheApplierDoesNotHaveIsCountedRatherThanSilentlyDropped` | C1's observable, all eleven refusing entry points | `:859` |
|
||||
| `AVertexElementsBlobRoundTripsAndAShrinkLeavesNothingOfTheOneBeforeIt` | the blob unpack over all 32+32 slots, field by field; the shrink; `ContentSerial` re-create vs recycled slot; no rebind | `:930` |
|
||||
| `AVertexElementsRecordThatDoesNotDescribeItsOwnBlobIsRefusedNamingIt` | the counts/`Blob.Size` gate in both build arms, plus the "0 is not a fault" half of the Blob rule | `:984` |
|
||||
| `TheVertexBufferWindowIsBoundedAndItsEntriesLandWhereItSays` | entries land in the window and nowhere else; the raw `BaseInstance`; `Start + Count` at 32 and 33; the null-tail arm | `:1033` |
|
||||
| `SetIndexBufferMovesOnlyItsOwnSerialAndTheBindingFollowsTheHandle` | D5 independence; null index buffer; bind null / bind dead / delete-clears-the-binding | `:1111` |
|
||||
| `EveryContentCallsOwnBoundsGateRefusesAndNamesTheResource` | flush range, readback range, `Level`, and the new `MGPSubData::Blob` rule, each with a positive control | `:1166` |
|
||||
| `TheLiveHostWritesWireFiresOnTheCallAPersistentMapProducerWouldSetItOn` | M-C's negative control (§1.5) | `:1218` |
|
||||
| `ASlotOutsideTheRecordTablesBoundIsRefusedRatherThanAllocated` | M-D | `:1283` |
|
||||
|
||||
Every refusal case uses `ExpectRefusedNaming` (`:912-929`), which takes the file's two existing arms — forked child +
|
||||
`SIGABRT` + `Fatal{…}` in poison/verify, in-process log read + "nothing moved" in a shipped push build — and picks
|
||||
the right tag for the arm, so one needle serves both. Comparisons are **by field name**
|
||||
(`ExpectAttribEq` / `ExpectBindingEq` / `ExpectVertexBufferEq`, `:697-726`), which is what G7's negative control needs
|
||||
of this family.
|
||||
|
||||
### 1.5 M-C — the wire has a control, and it sits on the call P5 attaches its producer to
|
||||
|
||||
`PinNoLiveHostWrites` is now called from `MGPipeApplyMapPersistent` (`PipeApply.cpp:1110`, with the reason in place —
|
||||
D-A4 and `ARCHITECTURE.md:481` name the persistent-map push as exactly where the flag gets set) and from
|
||||
`MGPipeApplyResourceReadback` (`:1049`, which reads the store the flag describes), beside the three it already had.
|
||||
|
||||
`ResourceEmit.TheLiveHostWritesWireFiresOnTheCallAPersistentMapProducerWouldSetItOn` (`ResourceEmitTest.cpp:1218`)
|
||||
sets `MGPipeApplier().Resources[slot].HasLiveHostWrites = true` **inside a forked child** — so the parent's applier
|
||||
stays honest for the next drive — and asserts `SIGABRT` plus `Fatal{PipeLiveHostWrites} <call> {slot=8, gen=4}` for
|
||||
all five calls. Its negative control is the same `map_persistent` with the flag clear: it answers normally and logs
|
||||
nothing. In a shipped push build the wire is compiled out entirely, so the case is a **visible skip** there rather
|
||||
than a vacuous pass (`ctest -N` names stay identical: 2504 in both the pull and push trees).
|
||||
|
||||
### 1.6 M-D — the slot is bounded before it reaches an allocator
|
||||
|
||||
`PipeApply.h:97-113` mints `kMGPipeMaxResourceSlots = 1u << 20` and `kMGPipeMaxVertexElementsSlots = 1u << 16` with
|
||||
the reason for two numbers rather than one (a resource record is descriptor-sized; a vertex-elements record carries
|
||||
both unpacked views at ~1.3 KB, so one bound would mean two very different worst cases). `RecordAt`
|
||||
(`PipeApply.cpp:400-421`) takes the bound and returns `nullptr`; both call sites report
|
||||
`Fatal{ProtocolCorruption}` with the identity and the bound in the line (`:906-914`, `:1200-1210`) and return. The
|
||||
tables still grow only to the client's own dense high-water mark, so the bound costs nothing until a record is
|
||||
already corrupt. The case drives the bound exactly (`slot == kMGPipeMaxResourceSlots` and `0xFFFFFFFE` refused, the
|
||||
table not grown); the last slot *below* the bound is deliberately not driven, because naming it is a ~90 MB
|
||||
allocation and the direction that matters is the one that reaches the allocator.
|
||||
|
||||
### 1.7 M-E — one Blob rule, stated on both records and enforced on both
|
||||
|
||||
> `Blob.Size` is the record's own statement of how many bytes its blob holds, and the applier holds the record to
|
||||
> that statement **whenever the record makes it**: a non-zero `Blob.Size` that disagrees with the byte length the
|
||||
> record's other fields describe is `Fatal{ProtocolCorruption}` and the call is refused. A **zero** `Blob.Size` means
|
||||
> "this record does not declare its blob" — which is what a monolith emission is, because the bytes travel beside the
|
||||
> record through the entry point's companion `const void*` — and it is not a fault. Either way the bytes read are
|
||||
> bounded by the record's **other** fields (the two counts here, the destination range there), so the declared length
|
||||
> is a cross-check and never the safety property.
|
||||
|
||||
Written verbatim on `MGPVertexElements` (`MGPipeTypes.h:254-265`) and on `MGPSubData` (`:624-632`), and enforced on
|
||||
both: `SubDataBoxFault` gains the check (`PipeApply.cpp:516-525`) and `create_vertex_elements`'s gate relaxes from
|
||||
`!= declared` to `!= 0 && != declared` (`:1187`). Both directions are driven (§4, M5/M9).
|
||||
|
||||
**This changes what §5 item 2 told B**: B is no longer *required* to compute
|
||||
`A*sizeof(MGPVertexAttribWire) + B*sizeof(MGPVertexBindingPointWire)` by hand at the emitter — leaving
|
||||
`MGPVertexElements::Blob` entirely zero is now legal and inert. If B does fill it, it must be exact. The asymmetry
|
||||
the review objected to is gone in the direction that removes a verify-build abort from a legal emission rather than
|
||||
adding one, and the safety argument is unchanged because the counts (not the length) are what bound the unpack.
|
||||
|
||||
### 1.8 m1, m2, m3
|
||||
|
||||
`m1`: `Coverage.def:202` — `X(GetBoundVertexArray, BindVertexElements)` moved from position 2 to position 4, the
|
||||
`LC_ALL=C` place after `GetBlendFuncIndexed`. Regenerating leaves `MobileGL/MG_Pipe/generated` byte-identical
|
||||
(`gen_pipe.py` sorts the emitter enum itself), so this is presentation only, which is what `m1` said.
|
||||
|
||||
`m2`: `MGPipeTypes.h:270-275` — the comment now names `MGPVertexAttribWire[AttributeCount]` followed by
|
||||
`MGPVertexBindingPointWire[BindingPointCount]`, says why the frontend types cannot travel, and points at the one
|
||||
place the layout is stated (`MGPipeValueTypes.h`'s P3a block).
|
||||
|
||||
`m3`: `ConfigLoader.cpp:11-13` — "For `kMGPipeSubsystemsMigratedAtP3a`, the push build's `PipePush` default (the P2
|
||||
constant beside it is the phase-by-phase control, not the default)".
|
||||
|
||||
### 1.9 m4 is **not** in an A file, and neither is m3's other half
|
||||
|
||||
The review's M-F table calls all four minors "A-owned". For `m4` that is wrong against `C.5`:
|
||||
`MG_Impl/Pipe/PipeFill.{h,cpp}` — the `SubsystemForEmitter` / `static_assert` / `kMGPipeWiredSubsystems` block — is
|
||||
**"owner (contract commit only)" for A and "owner (after the tag)" for B**. The tag is cut, so the three pairing
|
||||
asserts at `PipeFill.cpp:687-701` are B's to make uniform. The one-line fix is to give the `NewVertexBuffers`
|
||||
(`:694-697`) and `NewIndexBuffer` (`:698-701`) arms the same right-hand side the `NewVertexElements` arm has,
|
||||
`SubsystemForEmitter(MGPipeFieldEmitter::BindVertexElements)`, rather than the literal `kMGPipeSubsystemVertexInput`.
|
||||
|
||||
`m3`'s `MG_Backend/DirectVulkan/Renderer/MagmaPipeArms.h:112-115` half is the integrator's, as the review says: no
|
||||
package owns `MG_Backend/DirectVulkan/**` in `C.5`.
|
||||
|
||||
---
|
||||
|
||||
## 2. What the applier's contract now is, in one place (for B and C)
|
||||
|
||||
1. **Records are object state.** They survive a make-current. They are cleared by `resource_destroy` /
|
||||
`delete_vertex_elements` and by `MGPipeApplierReleaseObjectRecords()`. Nothing else clears them.
|
||||
2. **`MGPipeApplierReleaseObjectRecords()` must not be wired in the monolith.** One applier serves every context.
|
||||
3. **The two global serials only ever advance.** `VertexBuffersSerial` and `IndexBufferSerial` are `++`-ed by their
|
||||
own calls, by `MGPipeApplierReset()` and by `MGPipeApplierReleaseObjectRecords()`, and are never assigned. A twin
|
||||
may safely memo either one; no value can recur. (`Serial` and `ContentSerial` are per record and restart with the
|
||||
record, which is safe because the handle's `Gen` moves with it — unchanged from `wire-v1`.)
|
||||
4. **A refused call is counted**, in `RefusedResourceCalls` / `RefusedVertexInputCalls`, per context. A non-zero
|
||||
count in a lane is a dropped call, and a legal sequence leaves it at 0 except during a context teardown.
|
||||
5. **`handle.Slot` is bounded** by `kMGPipeMaxResourceSlots` / `kMGPipeMaxVertexElementsSlots` (`PipeApply.h:112`),
|
||||
which C should reuse when it bounds `handle.Slot` before `BackendSlotTable::EntryAt` (contract-review M2).
|
||||
6. **The Blob rule** (§1.7) — one rule, both families, `0` means "not declared".
|
||||
|
||||
---
|
||||
|
||||
## 3. Deviations declared in this round
|
||||
|
||||
**R1 — `MGPipeApplierReleaseObjectRecords()` has no production caller.** It is the split-side teardown hook and the
|
||||
unit fixtures' "empty the applier". Wiring it in the monolith would be wrong (§1.1) and wiring it under split is P5's
|
||||
server bring-up, not P3a's. It is `push`-only source, so G1 is unaffected; the two fixtures and one case drive it.
|
||||
|
||||
**R2 — the review's C1a asked for an `INTEGRATOR-DECISIONS.md` entry.** `docs`/notes ownership is the integrator's
|
||||
(ID-5, and `C.5` gives `docs/Disaggregated/*.md` to nobody but the integrator), so the decision is written here and
|
||||
into the two functions' own comments instead. The integrator owes ID-9 the two sentences in §2 items 1-2.
|
||||
|
||||
**R3 — the vertex-elements `Blob.Size` gate was RELAXED, not tightened.** §1.7. It is the one place this round
|
||||
changes a rule rather than adding one, and it changes it in the direction that cannot abort a legal emission.
|
||||
|
||||
**R4 — `VertexInputEmitTest.cpp` was edited even though B is appending to it.** The edit is confined to `c0`'s
|
||||
placeholder case (`:67-110`) and is not optional: at `e9b4a263` that case asserts `VertexBuffersSerial == 0` after a
|
||||
reset, which is exactly the inversion C2 removes, so leaving it would leave the tree red. No case was added there.
|
||||
See §6 for the rebase note.
|
||||
|
||||
**R5 — the shared G1 baseline has drifted and G1 was run as a parent-vs-HEAD control instead.** §5.
|
||||
|
||||
---
|
||||
|
||||
## 4. Mutation evidence — 17 mutations, 17 reds, measured
|
||||
|
||||
Each mutation was applied to `MobileGL/MG_Pipe/PipeApply.cpp` in this worktree, the two test targets rebuilt, the two
|
||||
suites run, and the file restored with `git checkout --` (the tree was verified clean before and after every batch;
|
||||
no other worktree was created). The eight the review measured green at `e9b4a263` are M1-M8.
|
||||
|
||||
| # | mutation | verdict | first case to go red |
|
||||
|---|---|---|---|
|
||||
| M1 | `create_vertex_elements`: the attribute `memcpy` removed | **RED** | `AVertexElementsBlobRoundTripsAndAShrink…` |
|
||||
| M2 | `create_vertex_elements`: the binding-point `memcpy` removed | **RED** | `AVertexElementsBlobRoundTripsAndAShrink…` |
|
||||
| M3 | `set_vertex_buffers`: the entry-copy loop body removed | **RED** | `TheVertexBufferWindowIsBounded…` |
|
||||
| M4 | `set_vertex_buffers`: the `Start + Count` window gate disabled | **RED** | `TheVertexBufferWindowIsBounded…` |
|
||||
| M5 | `create_vertex_elements`: the counts/`Blob.Size` gate disabled | **RED** | `AVertexElementsRecordThatDoesNotDescribeItsOwnBlob…` |
|
||||
| M6 | `resource_flush_range`: `BufferRangeFault` removed | **RED** | `EveryContentCallsOwnBoundsGate…` |
|
||||
| M7 | `resource_readback`: `BufferRangeFault` removed | **RED** | `EveryContentCallsOwnBoundsGate…` |
|
||||
| M8 | `SubDataBoxFault`: the `Level` arm removed | **RED** | `EveryContentCallsOwnBoundsGate…` |
|
||||
| M9 | `SubDataBoxFault`: the new `MGPSubData` Blob rule removed | **RED** | `EveryContentCallsOwnBoundsGate…` |
|
||||
| M10 | `resource_create`: the slot bound widened by one | **RED** | `ASlotOutsideTheRecordTablesBound…` |
|
||||
| M11 | `create_vertex_elements`: the slot bound widened by one | **RED** | `ASlotOutsideTheRecordTablesBound…` |
|
||||
| M12 | the resource refusal counter removed | **RED** | `ACallOnARecordTheApplierDoesNotHave…` |
|
||||
| M13 | the vertex-input refusal counter removed | **RED** | `ACallOnARecord…` + `SetIndexBufferMovesOnlyItsOwnSerial…` |
|
||||
| M14 | **C1 reverted**: `MGPipeApplierReset` clears the records again | **RED** | `TheObjectRecordsSurviveAMakeCurrent…` |
|
||||
| M15 | **C2 reverted**: the two serials zeroed at a reset | **RED** | `TheObjectRecordsSurvive…` + `VertexInputEmit.AResetApplierCarriesNoVertexInputStateOver` |
|
||||
| M16 | `map_persistent`: the `PipeLiveHostWrites` pin removed | **RED** (verify tree) | `TheLiveHostWritesWireFires…` |
|
||||
| M17 | `resource_readback`: the `PipeLiveHostWrites` pin removed | **RED** (verify tree) | `TheLiveHostWritesWireFires…` |
|
||||
|
||||
M1-M15 were run in `build-push`, M16-M17 in `build-verify` (the wire is compiled out of a shipped push build, and its
|
||||
case skips visibly there). No mutation survived.
|
||||
|
||||
---
|
||||
|
||||
## 5. Verification transcript
|
||||
|
||||
All in `/home/swung/w7/p3a-wire` at `48fe55be`, `CCACHE_BASEDIR=/home/swung/w7`.
|
||||
|
||||
**G1 — and a baseline problem the integrator has to settle.** `~/w7/p3a-before-libMobileGL.so` and
|
||||
`~/w7/p3a-before-ctest-names.txt` were **re-captured at 03:17 today at `5cb826b0`** ("`[Merge] (dev): bring
|
||||
dev@9eae9858 into feat/disaggregated - the adopted-store respecify VAO rebind fix (d7655247) and the
|
||||
persistent-buffer ordering POST probe`"), which is **not an ancestor of `p3a/wire`** (`~/w7/p3a-before-head.txt`
|
||||
records it). Run against it, `symbol_report` now reports `27811 -> 27799, 0 added, 12 removed, 1 resized` — every
|
||||
removed symbol is `MG_Util::SelfTest::…PersistentBufferUpdateOrdering…`, i.e. dev code this branch does not have —
|
||||
and the name comparison shows 15 removals, all `PersistentBufferOrderingProbeTest.*` and
|
||||
`*.LargeArenaAdoptionScenario.Respecified*`. None of it is P3a's. `wire-v1` ran the same command against the
|
||||
*previous* baseline and got `27799 -> 27799`.
|
||||
|
||||
So G1 was run as the control that actually answers the question — **the pull library at `e9b4a263` versus the pull
|
||||
library at `48fe55be`**, both built in this worktree:
|
||||
|
||||
```
|
||||
python3 scripts/symbol_report.py --before <pull lib at e9b4a263> --after build-linux/libMobileGL.so \
|
||||
--threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0 rc 0
|
||||
symbol-report: .text 10792739 -> 10792739 (+0, +0.000%) .data +0 .bss +0 .rodata +0
|
||||
symbol-report: Total 17209979 -> 17209979 (+0)
|
||||
symbol-report: 27799 -> 27799 defined symbols: 0 added, 0 removed, 0 resized, 0 renamed
|
||||
symbol-report: 27060 -> 27060 normalised names, 27060 unchanged
|
||||
```
|
||||
|
||||
The two libraries are the same size to the byte. P3a's admitted-resize set stays empty. **Action for the
|
||||
integrator:** either re-capture `~/w7/p3a-before-*` at `44c2b5cf` (ID-1's stated base) or rebase every P3a package
|
||||
onto `5cb826b0` and re-capture there; until then the shared baseline answers a different question than G1 asks.
|
||||
|
||||
**Generators and closure**
|
||||
|
||||
```
|
||||
python3 scripts/gen_pipe.py --check rc 0 "gen_pipe: generated files are up to date"
|
||||
python3 scripts/gen_pipe.py --self-test rc 0 "7 negative-control trip(s), positive control OK"
|
||||
git diff --exit-code -- MobileGL/MG_Pipe/generated rc 0
|
||||
python3 scripts/check_include_closure.py rc 0 "4 probes, 0 skipped, 0 problem(s)"
|
||||
python3 scripts/check_include_closure.py --mode both --compiler clang++ --self-test --require-all rc 0
|
||||
```
|
||||
|
||||
**Three builds** (`cmake --build <dir> -j 24`): `build-linux` rc **0**, `build-push` rc **0**, `build-verify` rc **0**.
|
||||
|
||||
**Three unit runs** (`ctest --test-dir <dir> -L unit -j 12 --no-tests=error`):
|
||||
|
||||
```
|
||||
build-linux rc=0 100% tests passed, 0 failed out of 1588 (9.16 s)
|
||||
build-push rc=0 100% tests passed, 0 failed out of 1588 (9.20 s)
|
||||
build-verify rc=0 100% tests passed, 0 failed out of 1588 (9.28 s)
|
||||
```
|
||||
|
||||
(1579 at `e9b4a263` + 9 new names.)
|
||||
|
||||
**The two P3a suites** (`ctest -R 'ResourceEmit\.|VertexInputEmit\.'`):
|
||||
|
||||
```
|
||||
build-push 19 tests, 100% passed, 1 visible skip (the PipeLiveHostWrites wire is compiled out here)
|
||||
build-verify 19 tests, 100% passed, 0 skips (every forked-abort arm taken)
|
||||
build-linux 19 tests, 18 visible skips + the range-encoding case
|
||||
```
|
||||
|
||||
**Names (G2's name half, G14)**
|
||||
|
||||
```
|
||||
ctest -N: build-linux 2504, build-push 2504, build-verify 3332
|
||||
diff <linux names> <push names> -> empty (rc 0)
|
||||
comm -23 <names at e9b4a263> <names at HEAD> -> empty (nothing removed)
|
||||
comm -13 ... -> 9 added, all ResourceEmit.*
|
||||
```
|
||||
|
||||
**G13**: `grep -c 'MG_State' MG_Pipe/PipeApply.h` → **0**; `grep -rc 'pGLContext' MG_Backend | grep -v ':0$'` →
|
||||
empty.
|
||||
|
||||
**Ownership**: `git diff --stat 39722687..HEAD` names exactly `MG_Pipe/{PipeApply.h, PipeApply.cpp, MGPipeTypes.h,
|
||||
Coverage.def}`, `ConfigLoader.cpp` and the two `MG_Test/Pipe/*EmitTest.cpp` — all A's under `C.5`. No `MG_Impl`, no
|
||||
`MG_Backend`. Working tree clean; nothing pushed; no other worktree created.
|
||||
|
||||
**Not run here, and why**: G2's execution half, G3/G3b/G4's retrace, G5 (the script is D's and is not in the tree;
|
||||
this package touches no `Managers.cpp` region, so the nine functions are byte-identical by construction), G6-G12,
|
||||
G15. This package still registers no `MGPipeResourceOps` and emits no call, so it changes no observable and those
|
||||
gates belong to the integrator's D.1 merges. Behaviour neutrality is unchanged from `wire-v1`: `grep` over
|
||||
`MobileGL/` for the fourteen entry points and for `MGPipeSetResourceOps` still returns hits only in
|
||||
`MG_Test/Pipe/ResourceEmitTest.cpp`.
|
||||
|
||||
---
|
||||
|
||||
## 6. What is left, and for whom
|
||||
|
||||
1. **The rebase note for B** (R4). `MG_Test/Pipe/VertexInputEmitTest.cpp:67-110` changed: the placeholder case's
|
||||
comment is rewritten and its two serial assertions now read "moved forward" (43/44) instead of 0/0, and the two
|
||||
vacuous `…CsoCsos.empty()` / `Resources.empty()` assertions were removed because the records are no longer part of
|
||||
that scope. The case's **name** is unchanged. B's `b4` is still an append below `:110`; if it collides it is a
|
||||
union, never a choice.
|
||||
2. **`MGPipeApplierReset` no longer empties the applier** — a fixture that wants an empty one must also call
|
||||
`MGPipeApplierReleaseObjectRecords()`, as `ResourceEmitTest.cpp:139-150`'s `ApplierGuard` now does. Any B or C
|
||||
test that resets the applier and then asserts `Resources.empty()` needs the second call.
|
||||
3. **`MGPVertexElements::Blob.Size` may now be left 0** (§1.7), which supersedes `wire-v1` §5 item 2. If B fills it,
|
||||
it must be exact. The same rule now applies to `MGPSubData::Blob`, which B must leave 0 or fill exactly.
|
||||
4. **`resource_subdata` still requires a `Width`** — unchanged from `wire-v1` §5 item 3.
|
||||
5. **`VertexFetchBaseInstance` is raw** — unchanged, for C.
|
||||
6. **The serial contract for C**, complete: §2 items 3-5 above.
|
||||
7. **n7 (cross-package, from the review):** B's resident dispatch must gate on
|
||||
`MGPipeGetResourceOps()->SubDataResident != nullptr`, not on `MGPipeResourceSubsystemEnabled()` alone — the
|
||||
applier drops a resident write when the member is null, after bumping `Serial`, and
|
||||
`BufferObject::LandBytesIntoResidentStore` is unreachable once the call has been emitted. Unreachable in P3a
|
||||
(Espryt registers all nine members; Magma registers no table), but it is B's dispatch shape.
|
||||
8. **n6 (cross-package, from the review):** `MGPipeApplierState::MapPersistentRoundtrips` is **per context** (reset
|
||||
by `MGPipeApplierReset`, pinned at `ResourceEmitTest.cpp:585-587`) while `PipeStats`' `mpr` is not. D's
|
||||
`StorageBufferRegrowScenario` should assert against **`PipeStats`' `mpr`**, which is the one an operator greps and
|
||||
the one that survives a context switch.
|
||||
9. **Doc corrections owed to the integrator**, unchanged from `wire-v1` §5 item 8, plus: D-G4's reset prose should
|
||||
say the records are share-group state (§2 items 1-2), and the review's M-F table should record that `m4` is B's
|
||||
file after the tag (§1.9).
|
||||
10. **The baseline drift** (§5) — integrator.
|
||||
|
||||
## 7. Declared minors not taken (ID-4)
|
||||
|
||||
`n2` (`unmap_persistent` refuses on a dropped record) — left as is; delivering a release to a backend that has no
|
||||
record for it is the worse answer, and the refusal is now counted. `n3` (`SubDataBoxFault` holds three of seven
|
||||
statements) — the other four are inert for a buffer and the helper's comment no longer claims completeness beyond
|
||||
what it checks. `n4` (`IndexSize` unpoliced), `n5` (`BindingIndex` unpoliced) — both stated as deliberate at
|
||||
`PipeApply.cpp:1331-1345` and `:1305-1311`; policing either would hand B a contract this package cannot justify.
|
||||
`n8` (the by-handle assertion is half made), `n9` (`ARespecifyReplaces…` re-pins the ack predicate) — recorded.
|
||||
`n10` (`PipeApply.h` edited after the tag) — this round edits it again, comment and members both; C's tree branches
|
||||
from the tag and will see all of it on its rebase, and the integrator still owes C that message.
|
||||
|
||||
*Intermediate logs and the mutation harness under `~/w7/p3a-wire-mut/` were deleted at the end of the round.*
|
||||
@@ -0,0 +1,407 @@
|
||||
# P3a specification, extracted from the docs (scout, read-only)
|
||||
|
||||
Sources actually opened: `docs/Disaggregated/{README.md, ARCHITECTURE.md, ROADMAP.md, MEASUREMENTS.md}` in
|
||||
`C:/Users/geekerwan/AndroidStudioProjects/FoldCraftLauncher/MobileGL-disagg`, plus
|
||||
`~/w7/notes/p2/INTEGRATOR-DECISIONS.md` and `~/w7/notes/p2/BRIEF-P2.md` (sections A, D4, D12, D13, D14, D17, D18, D19, D20, D.5, E).
|
||||
Where a payload or a hook is quoted I also opened the tree file: `MobileGL/MG_Pipe/PipeCalls.def`,
|
||||
`MobileGL/MG_Pipe/MGPipeTypes.h`, `MobileGL/MG_State/GLState/BufferState/BufferObject.h`,
|
||||
`MobileGL/MG_Backend/DirectGLES/{Managers.h,Managers.cpp,DirectGLES.cpp}`,
|
||||
`MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.cpp`, `tools/trace_replay/trace_cases.json`.
|
||||
Line numbers are from those files as they stand on `feat/disaggregated` today.
|
||||
|
||||
---
|
||||
|
||||
## 1. The P3a row of the phase table
|
||||
|
||||
`docs/Disaggregated/ROADMAP.md:19`, verbatim (all five cells):
|
||||
|
||||
> | **P3a** handle wave 1(Espryt):buffer、VAO | 18–23 | 7 个 `BufferBackendOps` → `resource_*`、`buffer_subdata_resident`(可 null)、`resource_flush_range`、`resource_readback`、`map_persistent`(不碰实现);pool 与延迟释放原样搬;vertex elements 三件(两个视图都带);`set_vertex_buffers`(`baseInstance` 显式字段);`set_index_buffer`;Adreno SIGSEGV workaround 保留 | 全套门;buffer/VAO 族场景(`LargeArenaAdoption`、`StorageBufferRegrow` 发布 `map-persistent-roundtrips`、`VertexAttribBinding`、`MultiDraw`、`PrimitiveRestart`…);Create/rd12/26.3/sodium trace;MC 26.3 在 Adreno 上 p99 不变。**再基线检查点 1:超过 27 天必须重定基线** | P2 |
|
||||
|
||||
Cell by cell: title = handle wave 1, **Espryt only**, subject buffer + VAO (Magma's buffer path is P7; Magma's VAO memo re-key already landed in P2 as subsystem 4, `ROADMAP.md:18`, `BRIEF-P2.md:303`); days 18–23; cumulative low end P2 43 → **P3a 61** (`ROADMAP.md:32`); dependency = P2, and P4a depends on P3a (`ROADMAP.md:20` last cell).
|
||||
|
||||
### 1.1 Deliverables, item by item
|
||||
|
||||
**D-a — the seven `BufferBackendOps` become `resource_*` calls.**
|
||||
`struct BufferBackendOps` is `MobileGL/MG_State/GLState/BufferState/BufferObject.h:76-122`. The seven pointers, in declaration order, with the contract each doc comment states (these contracts are what the pipe call must preserve):
|
||||
|
||||
| hook | line | contract, as written |
|
||||
|---|---|---|
|
||||
| `Respecify(BufferObject&)` | `:80` | storage (re)definition = `glBufferData`/`glBufferStorage`; "The orphaning point - the backend decides (busy-tracking) whether to swap storage or write in place. Shadow already holds the new contents." |
|
||||
| `SubData(BufferObject&, SizeT offset, SizeT size)` | `:82` | "Contents update of [offset, offset + size) from the shadow." |
|
||||
| `ResidentSubData(BufferObject&, SizeT offset, DataPtr data)` | `:95` | update of an **adopted (GPU-resident)** store; `data` holds the app's bytes and is "valid for the duration of the call only (a write map's staging store is freed the moment the unmap that lands it returns)"; the frontend has **not** touched the resident mapping; an in-place host write would tear frames still reading the old bytes (Minecraft patches live chunk sections this way); the backend instead lands the bytes on the GPU timeline "after in-flight readers, before the next consumer"; the frontend marks the buffer gpu-write-pending so reads reconcile through `ReadbackFromGpu`; "Backends without this op keep the legacy ordered in-place host write." |
|
||||
| `FlushMappedRange(BufferObject&, Range1D, Flags<BufferMappingAccessBit> appAccess)` | `:99` | write-map flush (`glUnmapBuffer`/`glFlushMappedBufferRange`); "Carries the app's real mapping flags so the backend can honour INVALIDATE_* / UNSYNCHRONIZED semantics per call instead of merging them." |
|
||||
| `OnDestroy(SharedPtr<BackendBufferResource>&&)` | `:103` | "Final release of the backend resource (called from ~BufferObject). The backend defers actual destruction until the GPU is done with it." |
|
||||
| `AcquirePersistentMap(BufferObject&) -> void*` | `:114` | zero-copy persistent map; for a coherent (non-`FLUSH_EXPLICIT`) persistent write map the backend may return a host-visible, coherent, persistently mapped pointer into its own GPU storage for the whole buffer `[0, size)`, created with every buffer usage and seeded from the shadow; "From that point the GPU buffer is the single source of truth ... and NO further backend transfer ops are dispatched for this buffer"; returns `nullptr` when it cannot back the map; **must be idempotent**. |
|
||||
| `ReadbackFromGpu(BufferObject&)` | `:121` | pulls the backend's current contents for the whole buffer into the shadow through `WritebackFromBackend`; "Only ever called for a buffer the GPU may have written behind the frontend's back - a shader storage or atomic counter binding of a draw or dispatch"; backends that cannot read back leave it null and the shadow keeps its pre-dispatch bytes. |
|
||||
|
||||
Registration: Espryt's table `g_glesBufferBackendOps` sets **all seven** (`MG_Backend/DirectGLES/Managers.cpp:1482-1490`), installed by `RegisterBufferBackendOps()` (`:1505-1507`, called from `BackendObject_DirectGLES.cpp:849` and `DirectGLES.cpp:10402`), removed by `UnregisterBufferBackendOps()` (`:1512-1515`, and `:1528` notes it "also bumps the buffer-mutation epoch"). The dispatcher is `SetBufferBackendOps`/`GetBufferBackendOps` (`BufferObject.h:124-127`: "Registered by the active backend at init, cleared at shutdown. Null table (unit tests, benchmarks) => shadow-only state tracking.").
|
||||
|
||||
The call-catalogue targets (`MobileGL/MG_Pipe/PipeCalls.def`, screen block and `kCtxObject` block):
|
||||
|
||||
```
|
||||
X(ResourceCreate, MGPResourceDesc, kScreen, kNone)
|
||||
X(ResourceRespecify, MGPResourceDesc, kScreen, kNone)
|
||||
X(ResourceDestroy, MGPHandleOnly, kScreen, kNone)
|
||||
X(MapPersistent, MGPHandleOnly, kScreen, kReplySlot|kOptional)
|
||||
X(UnmapPersistent, MGPHandleOnly, kScreen, kOptional)
|
||||
X(ResourceSubData, MGPSubData, kCtxObject, kHasBlob|kVarTail)
|
||||
X(BufferSubDataResident, MGPSubData, kCtxObject, kHasBlob|kOptional)
|
||||
X(ResourceSubDataComplete, MGPSubDataComplete, kCtxObject, kNone)
|
||||
X(ResourceFlushRange, MGPFlushRange, kCtxObject, kNone)
|
||||
X(ResourceReadback, MGPReadback, kCtxObject, kReplySlot)
|
||||
X(ResourceCopyRegion, MGPCopyRegion, kCtxObject, kNone)
|
||||
```
|
||||
|
||||
Mapping (the one-to-one the phase asks for): `Respecify` → `ResourceRespecify`; `SubData` → `ResourceSubData`; `ResidentSubData` → `BufferSubDataResident`; `FlushMappedRange` → `ResourceFlushRange`; `OnDestroy` → `ResourceDestroy`; `AcquirePersistentMap`/unmap → `MapPersistent`/`UnmapPersistent`; `ReadbackFromGpu` → `ResourceReadback`. Plus `ResourceCreate`, which has no hook today: `ARCHITECTURE.md:204` — "`resource_create` 在前端对象构造时发,存储由 `resource_respecify` 惰性定义;`resource_destroy` 在析构时发."
|
||||
|
||||
**D-b — `buffer_subdata_resident` (nullable).** `kOptional` means "后端表里可为 null" and `ARCHITECTURE.md:102` names the exception explicitly: "`kOptional`(O,后端表里可为 null:Magma 故意不注册 `BufferSubDataResident` 与 `SetSwapInterval`)". Verified in the tree: `g_vulkanBufferBackendOps` (`MG_Backend/DirectVulkan/Renderer/VkBufferManager.cpp:105-112`) sets `.Respecify`, `.SubData`, `.FlushMappedRange`, `.OnDestroy`, `.AcquirePersistentMap`, `.ReadbackFromGpu` and **omits `.ResidentSubData`**. The standing rule against "fixing" it in flight is `ROADMAP.md:87` (open question 10): "**`ResidentSubData` 的不对称怎么收口。** null 项保住今天的行为;给 Magma 补真实现是行为变更,独立 `dev` PR." Espryt's arm is `Ops_ResidentSubData` (`Managers.cpp:1304`) wrapped as `Ops_ResidentSubDataTracked` (`:1457-1458`).
|
||||
|
||||
**D-c — `resource_flush_range`.** `MGPFlushRange` (`MG_Pipe/MGPipeTypes.h:629-636`), preceded by the comment "Carries the application's REAL access flags, not a normalized subset" (`:628`):
|
||||
|
||||
```cpp
|
||||
struct MGPFlushRange {
|
||||
MGPipeHandle Res;
|
||||
Uint64 Offset, Size;
|
||||
Uint32 AccessFlags; // Flags<BufferMappingAccessBit>
|
||||
Uint32 Pad0;
|
||||
};
|
||||
MGP_ASSERT_POD(MGPFlushRange, 32);
|
||||
```
|
||||
|
||||
**D-d — `resource_readback`.** `MGPReadback` (`MGPipeTypes.h:637-641`):
|
||||
|
||||
```cpp
|
||||
struct MGPReadback { MGPipeHandle Res; Uint64 Offset, Size; };
|
||||
MGP_ASSERT_POD(MGPReadback, 24);
|
||||
```
|
||||
|
||||
`kReplySlot` = "答进 `MGPReplySlot`,永不阻塞" (`ARCHITECTURE.md:102`); `MGPReplySlot{Uint64 Id;}` / 8 B (`MGPipeTypes.h:78-83`), documented as "Where an asynchronous answer lands. Every server query in this catalogue is async-with-handle; none of them blocks".
|
||||
|
||||
**D-e — `map_persistent`, implementation untouched.** This is D-B4, `ARCHITECTURE.md:466`: "`AcquirePersistentMap` 是永久的地址空间捐赠(返回 host-visible coherent 指针,成为该 buffer 的唯一真相源;≥16 MiB 可变 store 由 `TryAdoptLargeStorage` 自动走到,实测 MC 26.3 p99 163→21 ms、40→115 fps、省 ~400 MB)。**整个 monolith 改造期一动不动**(D-B4),只有 IPC 那一步会打破它。" P3a therefore routes the call through the pipe and changes nothing inside; the tiering work (T0/T1/T2/T3), `SEG_ADOPT`, and `MOBILEGL_IPC_ADOPT_TIER` are all P11 (`ARCHITECTURE.md:468-486`, `ROADMAP.md:28`).
|
||||
|
||||
**D-f — pools and deferred release move as-is.** `ARCHITECTURE.md:315` (§9.1, "原样不动的东西") lists for Espryt: "三条 persistent-mapped ring 与 `PersistentRing` 算法、**buffer pool**、7 条 fallback-repack 路径、`m_backendColorSlots` 置换表、三个 scratch FBO 及驱动侧影子、`PackState`、全部驱动绑定影子、**Adreno 禁用属性 SIGSEGV workaround**、Mali XFB 捕获丢失 workaround、`ScopedDefaultUnpackState`、SPIRV-Cross 会话与 post-emission ESSL 重写、驱动 POST 自检族、restart 重写与 multi-draw 五档." Pool maintenance entry points: `TrimBufferPool()` / `ClearBufferPool()` (`MG_Backend/DirectGLES/Managers.h:730-734` — "TrimBufferPool evicts over-budget entries (called once per frame from Present); ClearBufferPool drops all pooled ids"). The frame-boundary constraint that protects them: `ARCHITECTURE.md:515` — "**`present` 与 `eglSwapBuffers` 严格 1:1**:两个后端的帧边界排空(… Espryt 三个 ring 与 `TrimBufferPool` 的 retire)只在 `Present` 内发生,批量会饿死它们."
|
||||
|
||||
**D-g — vertex elements, three calls, both views.** `X(CreateVertexElements, MGPVertexElements, kCtxCso, kHasBlob)`, `X(BindVertexElements, MGPHandleOnly, kCtxCso, kNone)`, `X(DeleteVertexElements, MGPHandleOnly, kCtxCso, kNone)`. Payload (`MGPipeTypes.h:253-259`):
|
||||
|
||||
```cpp
|
||||
struct MGPVertexElements {
|
||||
MGPipeHandle Cso;
|
||||
Uint32 AttributeCount;
|
||||
Uint32 BindingPointCount;
|
||||
MGPBlobRef Blob; // VertexAttribute[] followed by VertexBufferBindingPoint[]
|
||||
};
|
||||
MGP_ASSERT_POD(MGPVertexElements, 40);
|
||||
```
|
||||
|
||||
"两个视图都带" is `ARCHITECTURE.md:130` verbatim: "blob 同时带解析后的 `VertexAttribute[]` **和** `VertexBufferBindingPoint[]`,缺一不可(pointer 调用的 stride 0 = element size,binding 模型的 stride 0 = 每顶点读同一 element);`IsLong` 与 `Type == Float64` 分开携带;仅供查询的 `LegacyStride/LegacyPointer` 留在 client." The CSO's server-side counterpart is `VertexInputStateFactory::m_cache` (`ARCHITECTURE.md:55`); CSO content addressing lives on the client with a per-kind `ska::flat_hash_map<xxHash, MGPipeHandle>`, capacity **vertex-elements 1024**, LRU eviction emits `delete_*` (`ARCHITECTURE.md:63`).
|
||||
|
||||
**D-h — `set_vertex_buffers` with an explicit `baseInstance`.** `X(SetVertexBuffers, MGPVertexBuffers, kCtxState, kVarTail)`. Landed payload (`MGPipeTypes.h:356-372`):
|
||||
|
||||
```cpp
|
||||
struct MGPVertexBuffer { MGPipeHandle Res; Uint64 Offset; Uint32 Stride; Uint32 Divisor; Uint32 BindingIndex; Uint32 Pad0; };
|
||||
MGP_ASSERT_POD(MGPVertexBuffer, 32);
|
||||
// Var-tail header: MGPVertexBuffer[Count] follows.
|
||||
struct MGPVertexBuffers { Uint32 Start, Count; Uint64 ContentHash; };
|
||||
MGP_ASSERT_POD(MGPVertexBuffers, 16);
|
||||
```
|
||||
|
||||
**There is no `BaseInstance` field yet** — `grep -rn "BaseInstance" MobileGL/MG_Pipe/` hits only draw-entry names in `FillPoints.def:86,88,90` and their generated mirrors. So this deliverable is a payload change (a size change, hence a new `MGP_ASSERT_POD` number and a G3 wire `static_assert` update). Why it is required: Espryt emulates `baseInstance` by baking a byte shift into the instanced arrays' offsets, driven by an **ambient process global** — `g_pendingFetchBaseInstance` (`MG_Backend/DirectGLES/Managers.cpp:2358-2366`, `SetPendingFetchBaseInstance`/`GetPendingFetchBaseInstance`), set by `VertexArrayImpl::ScopedFetchBaseInstance` around three draw entry points (`DirectGLES.cpp:5135, 5172, 5224`, value from `EmulatedFetchBaseInstance`, `:5128`), consumed in the VAO sync (`Managers.cpp:2463-2464` `const Uint32 fetchBaseInstance = g_pendingFetchBaseInstance; const Bool baseInstanceDirty = m_syncedFetchBaseInstance != fetchBaseInstance;`, then `:2524`, `:2589` `attrib.Offset + BaseInstanceByteShift(attrib, fetchBaseInstance)`, `:2646`, and `:2758-2801` inside `SyncFloat64AttributeAsFloat32`). The state comment names the problem exactly (`Managers.h:942-946`): "Byte shift currently baked into the instanced arrays' offsets by the baseInstance emulation (see SetPendingFetchBaseInstance). It is **draw state, not VAO state**, so it is deliberately NOT covered by the config version: the frontend never bumps for it. Kept here because it describes what was last EMITTED, which is what the next sync has to correct." An ambient global cannot cross a pushed boundary; `MGPDrawInfo` already carries `StartInstance` (`MGPipeTypes.h:719`), so the explicit field is the disambiguation between "the GL draw's baseInstance" and "the vertex-fetch shift the VAO was emitted with".
|
||||
|
||||
**D-i — `set_index_buffer`.** `X(SetIndexBuffer, MGPIndexBuffer, kCtxState, kNone)`; `MGPipeTypes.h:373-380`:
|
||||
|
||||
```cpp
|
||||
// An independent call, NOT a subset of the VAO configuration version (D5).
|
||||
struct MGPIndexBuffer { MGPipeHandle Res; Uint64 Offset; Uint32 IndexSize; Uint32 Pad0; };
|
||||
MGP_ASSERT_POD(MGPIndexBuffer, 24);
|
||||
```
|
||||
|
||||
Same rule in prose, `ARCHITECTURE.md:101`: "`SetIndexBuffer` 独立于 VAO 配置版本(D5):索引 slot 重绑不移动 VAO config version." The tracker's shutter for it is dirty bit 10 `NEW_INDEX_BUFFER`, "index slot version + bound object `{slot, gen}`" (`BRIEF-P2.md:133`ff table; `ARCHITECTURE.md:164`).
|
||||
|
||||
**D-j — the Adreno SIGSEGV workaround is kept.** `ARCHITECTURE.md:315` keeps it in the do-not-touch list. The code: `VertexArrayImpl::SyncFloat64AttributeAsFloat32(Uint attribIndex, const VertexAttribute&, Uint32 fetchBaseInstance)` (`MG_Backend/DirectGLES/Managers.h:886-896`), whose comment is the workaround's statement: "Narrows one enabled GL_DOUBLE array into a tightly packed float32 stream held in this VAO's own scratch buffer and declares the attribute against it. ES has no 64-bit vertex format ... Returns false when the stream cannot be built, in which case the caller must DISABLE the array - leaving a 64-bit array enabled with no pointer is what the Adreno driver turns into a SIGSEGV at the next draw." Two more SIGSEGV notes in the same path: `Managers.cpp:2520` ("and take the process with it (SIGSEGV in libGLESv2_adreno,") and `:2572` ("and kills the process rather than reporting an error (SIGSEGV in"). The memo that backs it is `ConvertedFloat64Stream` (`Managers.h:900-910`), keyed on `sourceLifetimeId`/`sourceChangeSerial`/`sourceOffset` — a `lifetimeId`-keyed memo, i.e. exactly the Track H re-key shape (`ARCHITECTURE.md:363`: "`ConvertedVertexStreamKey` 的 `sourcePin`" is one of the 11 memos the handle scheme deletes outright). The wire enabler is that `MGPVertexElements` carries `IsLong` and `Type == Float64` **separately** (`ARCHITECTURE.md:130`), and fp64 narrowing stays a server-side emulation (`ARCHITECTURE.md:236`: "fp64 顶点窄化 | server | 原始字节;`IsLong` 与 `Type` 分开过线"), advertised by `kCapFloat64VertexAttrib` (`ARCHITECTURE.md:106`).
|
||||
|
||||
### 1.2 The acceptance gate, decoded
|
||||
|
||||
The gate cell reads, verbatim: "全套门;buffer/VAO 族场景(`LargeArenaAdoption`、`StorageBufferRegrow` 发布 `map-persistent-roundtrips`、`VertexAttribBinding`、`MultiDraw`、`PrimitiveRestart`…);Create/rd12/26.3/sodium trace;MC 26.3 在 Adreno 上 p99 不变。**再基线检查点 1:超过 27 天必须重定基线**".
|
||||
|
||||
**(a) 全套门 = the five-part validation gate**, `ARCHITECTURE.md:497-507` (§13.2), which replaces the byte-identity gate:
|
||||
|
||||
1. **Three interface-purity gates** (non-verify builds only): **A — include graph**: compiling `MG_Backend` in the disaggregated configuration with `MG_State/GLState` removed from the include search path (`nm --undefined-only` is blind to "included but not called", and `RenderState.h → FramebufferObject.h → TextureObject.h` is exactly that coupling); depends on P0.5. **B — symbols**: `nm --undefined-only libMobileGLServer.so | grep -E 'MG_State::GLState::|glslang'` is empty. **C — undeclared**: `grep -c 'pGLContext' MG_Backend/` == 0. Plus a debug assertion "每个后端 memo 键都是 `{slot, gen}`,永不是裸前端指针", backed by `HandleRecycleScenario` (which "重键前必须在至少一个后端上是红的").
|
||||
2. **Semantic shadow comparison `MOBILEGL_PIPE_VERIFY=1`** — the decisive one; field-wise, per draw, prints the first diverging field and the draw index; catches fields the tracker forgot and **dirty bits that fire too rarely** (the dangerous direction); third CI mode; 40 traces + all integration tests; 5–10x slower; never shipped; field-wise not `memcmp` (padding false-DIFFERs). "**保留模式**" for consume-and-clear groups. "**活过 P13**".
|
||||
3. **Behavioural A/B**: 40 traces under `{monolith-pull, monolith-push, split}` at SSIM ≥ 0.99; `ctest -L integration-gpu` name-for-name identical between `DirectGLES.` and `DirectGLES.Pipe.`/`DirectGLES.Split.` (same for DirectVulkan); unit tests green; CTS per-backend conformance within 0.5 pp (rows = GL version/extension, columns = status counts, rate = Pass/(Pass+Fail), NS not in the denominator). The name-for-name functional baseline is "P1 出口的重构后 monolith"; `81b17c0b` is only the performance anchor.
|
||||
4. **Monolith performance non-regression**: two devices, reboot-clean, same thermal window, paired A/B, `tools/bench.sh` + trace replay `--benchmark` per-frame JSON; **metric is per-thread CPU time**, p50 and p99; **absolute threshold** — tracker ns/draw published with a ceiling; Blaze3D blend-toggle microbenchmark listed separately; CSO-content-addressing-off negative control. (See §5 for the 2026-09-08 amendment: for P3a this part is recorded, not gated.)
|
||||
5. **Coverage + poison + handle discipline**: G6 regenerates with 0 UNMAPPED; `gen_pipe_dirty_surface.py` regenerates with 0 unmapped mutators; per-verb generation poison; G7 setter-consistency test; `ResidualValueBlock`'s `offsetof` assertions.
|
||||
|
||||
Two byte-level equalities survive (`ARCHITECTURE.md:508`): with `MOBILEGL_BUILD_DISAGGREGATED=OFF`, `nm --defined-only libMobileGL.so | grep MG_Remote` is empty and the link line gains no library; `nm -D libMobileGL.so | grep mobilegl_server_main` hits in RelWithDebInfo. Symbol and `.text` drift are published per phase as informational.
|
||||
|
||||
**(b) The buffer/VAO scenario family, by name.** All five named scenarios already exist as files in the tree (so P3a extends/arms them rather than inventing them): `MobileGL/MG_IntegrationTest/Scenarios/LargeArenaAdoptionScenario.cpp`, `StorageBufferRegrowScenario.cpp`, `VertexAttribBindingScenario.cpp`, `MultiDrawScenario.cpp`, `PrimitiveRestartScenario.cpp`. Neighbours in the same directory that the P2 brief already binds to buffer/VAO behaviour: `CrossFrameBufferScenario.cpp`, `ResidentIndexScenario.cpp`, `HandleRecycleScenario.cpp` (P2's D18 negative control). The roadmap's "…" is open-ended; `BRIEF-P2.md:620` lists the existing must-not-break set for the Track H slice as `SanityTest.cpp:2575-2596, :2650-2665, :2757-2790, :3020-3062` plus `Scenarios/{SampledSetStalenessScenario, CrossFrameBufferScenario, VertexArrayEnableDisableScenario, VertexAttribBindingScenario, MultiDrawScenario, ResidentIndexScenario}.cpp`.
|
||||
|
||||
`StorageBufferRegrow` must **publish `map-persistent-roundtrips`**. Same counter is demanded at P5 (`ROADMAP.md:21`) and P11 (`ROADMAP.md:28`); its meaning is set by `ARCHITECTURE.md:474` (T1 costs "**每次存储定义一次 round trip**(不是每 store 一次),`StorageBufferRegrowScenario` 发布 `map-persistent-roundtrips`"). In monolith P3a the number is expected to be zero/absent — the point is that the counter exists and is wired before P5 needs it.
|
||||
|
||||
`LargeArenaAdoption` is the >=16 MiB adoption scenario; its P11 form is "`LargeArenaAdoptionScenario` 在所选档下绿" (`ROADMAP.md:28`).
|
||||
|
||||
**(c) Traces: Create / rd12 / 26.3 / sodium.** Exact case names in `tools/trace_replay/trace_cases.json` (40 cases total):
|
||||
- `minecraft-1.21.1-neoforge-create-indirect-in-world` — carries `"coherent_as_flush": true` (json `:270,275`)
|
||||
- `minecraft-1.21.1-neoforge-create-instancing-in-world` — carries `"coherent_as_flush": true` (json `:278,283`)
|
||||
- `minecraft-1.21.4-rd12-odinlite-in-world`
|
||||
- `improved-transparency-minecraft-26.3`
|
||||
- `minecraft-1.21.4-fabric-sodium-in-world`
|
||||
|
||||
Two caveats that bind P3a directly:
|
||||
- **`create-indirect` fails on BOTH devices today and it is a pre-existing `dev` bug**: `MEASUREMENTS.md:96` — "Adreno 830:Espryt ~4.5 分钟后黑帧,Magma 纹理上传提交时 `VK_ERROR_DEVICE_LOST`;Mali:SSIM 0.85 / 0.45 … Adreno 830 上用 `dev@81b17c0b` 基线 APK 复现,**是基线就有的问题,不是本分支造成**;它是 P3a/P8 验收清单里的用例,需先在 `dev` 修." Repeated as open question 17, `ROADMAP.md:90`. So P3a's gate is blocked on a `dev`-side fix that is not P3a's own work.
|
||||
- `MOBILEGL_COHERENT_AS_FLUSH` "在拆分模式下照常生效:两个带 `coherent_as_flush: true` 的 Create fixture 在 split 与 monolith 下走同一条 buffer 路径,逐名对比才有意义" (`ARCHITECTURE.md:485`).
|
||||
|
||||
**(d) "MC 26.3 在 Adreno 上 p99 不变"** — the one hard device number in the P3a gate. Its baseline is the adoption result recorded in `MEASUREMENTS.md:87`: "**persistent map 采纳的既有基线**(`dev`,MC 26.3,Adreno):>=16 MiB 可变 store 定义时采纳为 coherent persistent map 后 p99 163→21 ms、稳态 40→115 fps、省 ~400 MB。P11 的回归上限对着它." The corpus name is `improved-transparency-minecraft-26.3`, whose P0 boundary-counter baseline is in `MEASUREMENTS.md:60-61` (1200-frame window, 1320 draws/frame; Espryt acc/draw **8.44**, buf 333 K B/f, gates ers 156925/2791, etl 148606/11110, eub 148246/11470; Magma acc/draw **6.53**, buf 173 K B/f, `stage-ubo-named` **331 K B/f**, gates mfp 21360/137036, mpm 134421/2615, mdt 156611/1785).
|
||||
|
||||
**(e) Re-baseline checkpoint 1**, verbatim from the gate cell: "**再基线检查点 1:超过 27 天必须重定基线**", and again in the checkpoint table, `ROADMAP.md:63-64`: "| 触发 | 动作 | / | P3a > 27 天 | "窄句柄化"的前提错了,P4a 开始前重定基线 |". `ROADMAP.md:67`: "任一触发,先跑 `inproc` 的证伪数字再决定是否继续." (P4a's own is "> 39 天", `:65`; P7's is the midpoint <40% rule, `:66`, with the note that "P3a 的检查点发现不了 Magma 特有的超期".)
|
||||
|
||||
---
|
||||
|
||||
## 2. Every other mention of P3a in the docs
|
||||
|
||||
1. `ROADMAP.md:9` — the two lanes: "**monolith 跑道** P0 → P0.5 → P1 → P2 → **P3a** → P4a → P3b/P4b → P7 → P8 → P13,每段可独立交付、可随时中止且 monolith 严格好于起点;**IPC 跑道** P5 → P6 → P9 → P10 → P11 → P12."
|
||||
2. `ROADMAP.md:32` — day arithmetic: "P2 43 → **P3a 61** → P4a 87 …".
|
||||
3. `ROADMAP.md:34` — CTS turnaround: "`gl44to46` 约 56,271 例。逐阶段只跑该阶段可能影响的具名块(P4a `packed_pixels`、P3b/P4b `texture_*`/`shader_image_*`、P9 `transform_feedback*`);**完整 caselist 只在五个架构边界(P0.5、P3a、P4a、P3b/P4b、P13)与每次合并 `dev` 之前跑**,放 CI 不放关键路径。若周转仍主导排期,加宽估时而不是削弱门." → **P3a is one of the five boundaries that owes a full 56,271-case caselist run on both devices**, off the critical path.
|
||||
4. `ROADMAP.md:63-64` — re-baseline checkpoint 1 (see 1.2(e)).
|
||||
5. `ROADMAP.md:66` — "P3a 的检查点发现不了 Magma 特有的超期" (why P7 has its own).
|
||||
6. `ROADMAP.md:90` — open question 17: the `create-indirect` fixture failure "是 P3a/P8 验收清单里的用例,需要先在 `dev` 上修".
|
||||
7. `ARCHITECTURE.md:293` — ack policy: "目录里目前没有条目携带 `kNeedsAck`(`ResourceRespecify` 是 `kNone`),**标记随 P3a 的 buffer 路径落地**." Context (`:291-294`): texture allocation OOM is already deferred to sync time in monolith so that class does not ack; "**唯一允许同步 ack 的入口是 `glBufferStorage`(真同步分配)**"; `glRenderbufferStorage*` does not ack (41 trace fixtures, 0 OOM-probe idioms, 9 calls across 5 fixtures, none followed by `glGetError` within 3 calls; the corpus's real success check is `glCheckFramebufferStatus`, answered locally by the client); everything else arrives late through the ordered `OnGlError`. → **P3a is the phase that first sets `kNeedsAck`, on the `glBufferStorage` path only.**
|
||||
8. `ARCHITECTURE.md:367` — "对策:**编译期** `MOBILEGL_PIPE_LEGACY_MEMOS`(默认 ON)**在 P3a/P4a 期间**保留 registry / `TwinLookupMemo` 实现活在同一个 `PipeInputs` 接口之下,随 pull 路径在 P13 退役(各阶段 +1 天维护)." Reason (`:365-366`): after phase C the `MOBILEGL_PIPE_PUSH` bitmap is no longer a valid A/B, because with a bit cleared `SnapshotFromGLContext()` still synthesises handles and the backend still runs the re-keyed memo code — a re-key bug is in both arms.
|
||||
9. `MEASUREMENTS.md:96` — `create-indirect` is a P3a/P8 acceptance case, pre-existing on `dev` (quoted above).
|
||||
10. `BRIEF-P2.md:156` and `:956` — **P2 emits only for dirty bits 0–4; bits 5–17 are computed, counted and asserted but "their emission is P3a/P3b/P4a/P4b"**, and "the per-bit fire rates go into `MEASUREMENTS.md` **so P3a starts from data**". The bits P3a owns out of that table (`BRIEF-P2.md` D4): **5 `NEW_VERTEX_ELEMENTS`** (shutter `VertexArrayObject::GetConfigVersion()`), **9 `NEW_VERTEX_BUFFERS`** (object class, shutter `VertexArrayState::m_anyVaoAttributeGeneration`, then a 32-attribute prefix walk), **10 `NEW_INDEX_BUFFER`** (index slot version + bound object `{slot, gen}`), and the buffer-binding trio **15–17 `NEW_CONST_BUFFERS`/`NEW_SHADER_BUFFERS`/`NEW_SO_TARGETS`** (object class, shutter `BufferState::m_anyBufferChangeGeneration`, `GetTouchedBindPointCount()` prefix).
|
||||
11. `BRIEF-P2.md:293` — the set-hash suppressor: P2 wires exactly one of the seven `kVarTail` slots (`SetVertexAttribDefaults`) and unit-tests the class on all seven; "The other six are P3b/P4b (`ROADMAP.md:23`)" — note the tension with P3a landing `SetVertexBuffers`: the **call** is P3a's, its **suppressor slot** is scheduled P3b/P4b, and a hash of 0 is reserved for "never emitted" so the first emission always goes out.
|
||||
12. `BRIEF-P2.md:969` — "Widening the scan root [of `gen_pipe_dirty_surface.py`, today `MG_Impl/GLImpl` only, which leaves the four `MGP_NOTE_MUTATION` sites in `TextureState.h` outside it] is **recorded as a P3a item**." Its two sibling blind spots, also written into `DirtySurface.def`'s header comment: a mutator inside a lambda is attributed to the enclosing function; a mutation published through a helper reads as deferred.
|
||||
13. `BRIEF-P2.md:928` (D.4.6) — the Track H unit-cost census P3a inherits: `ARCHITECTURE.md:363` counts 11 direct deletions, 2 moved to client debounce, 7 re-keys, 1 unchanged; "P2 pays into that census: **11 of the 11 direct deletions and 2 of the 7 re-keys**. The remaining slices are P3a/P3b/P4a/P4b/P7 and their unit cost is extrapolated from these two." Criterion (`ROADMAP.md:56`): "Track H 单位成本不超出估计的 50%".
|
||||
14. `BRIEF-P2.md:822` — a P2 decision that lands on P3b, adjacent to P3a's buffer work: `integration`'s second, `MOBILEGL_ESPRYT_DISABLE_INVALIDATE_FLUSH=1` filtered pass (186 entries) is **not** run under the comparator in P2 ("the 186 entries are a buffer/readback filter that P2 changes nothing in; revisit at P3b").
|
||||
|
||||
---
|
||||
|
||||
## 3. What ARCHITECTURE.md says about buffers and VAOs at the boundary
|
||||
|
||||
### 3.1 Where a buffer op is pushed — the one exception to push-at-validate
|
||||
|
||||
`ARCHITECTURE.md:149-155` (§5.1) is the rule and its exception:
|
||||
|
||||
- Push happens at the **validate moment before a verb**, never in the GL setter: "Blaze3D 每个 batch 用 `glEnable/glDisable(GL_BLEND)` 包住(Espryt 代码自己标它为最热路径),per-setter 推送会把每次冗余开关变成一次接口调用加一次 server 侧 CSO 查表,严格慢于今天。正确形态是 gallium `st_validate_state`."
|
||||
- Eight validate entry points, generated from `PipeCalls.def`'s `kCtxVerb`/`kCtxObject` rows: `ValidateForDraw` (20 draw entry points), `ValidateForDispatch`, `ValidateForClear`, `ValidateForBlitOrCopy`, `ValidateForTextureOp` (GenerateMipmap / CopyTex* / BindImageTexture), `ValidateForReadback`, `ValidateForXfbSpan`, `ValidateForQuery`. Eight, not four, because of the ~70 table entries `MG_Impl` uses only ~22 are draw/dispatch. (P2's D1 raised this to nine — `BRIEF-P2.md` D.5 records the doc edit "`ARCHITECTURE.md:153` — 八个 validate 入口 → 九个".)
|
||||
- **The exception, verbatim (`ARCHITECTURE.md:155`)**: "**只有今天就在 GL 调用时刻分发的资源 op 在 GL 调用时刻推送**——即 `BufferBackendOps` 的七个 hook。纹理 subdata 不在此列(§6)." So the seven buffer hooks are the *only* calls P3a pushes at GL-call time; everything else P3a touches (vertex elements, vertex buffers, index buffer) is pushed at validate.
|
||||
- Contrast with textures (`ARCHITECTURE.md:247-249`): `glTexSubImage*` never calls the backend table at all; the client accumulates in its own `MipmapStorage` rect model and emits **one** `ResourceSubData` at the next validate/flush point, carrying union box **and** region list so the server picks the shape.
|
||||
|
||||
### 3.2 Ordering invariant for the calls P3a emits
|
||||
|
||||
`ARCHITECTURE.md:194` (§5.4, D-B3), verbatim: "**一条 verb 的全部 `set_*`/`bind_*` 必须在该 verb 之前完成;server 在 verb 处、从它此刻持有的全部已推送状态惰性特化 shader 与 pipeline。除"资源 create 先于对它的 bind"外,`set_*` 之间没有顺序要求。**" The recommended emission order is code organisation, not contract, and its vertex segment is "…render state/dynamic → **vertex elements/buffers/index/attrib defaults** → patch/XFB → verb".
|
||||
|
||||
Also §5.4 last line (`ARCHITECTURE.md:200`): "索引绑定范围在 validate 时刻实时解析(`glBindBufferBase` 之后再 `glBufferData` 是普通应用代码)" — i.e. `MGPBufferRange`s are resolved live, not cached from bind time. `MGPResourceDesc`'s `BufferForTexBuffer/BufOffset/BufSize` are likewise "实时解析(`kMGPipeWholeBuffer = ~0`)" (`ARCHITECTURE.md:127`).
|
||||
|
||||
### 3.3 The `resource_*` payloads, exactly as they stand
|
||||
|
||||
`MGPResourceDesc` (`MG_Pipe/MGPipeTypes.h:150-176`, `MGP_ASSERT_POD(MGPResourceDesc, 88)`, `kMGPipeWholeBuffer = ~0ull` at `:177`) — one discriminated create/respecify shape for buffer / every texture target / renderbuffer:
|
||||
|
||||
```cpp
|
||||
struct MGPResourceDesc {
|
||||
MGPipeHandle Resource;
|
||||
Uint8 Target; // Buffer | Tex1D..TexCubeArray | Tex2DMS.. | Renderbuffer | TexBuffer
|
||||
Uint8 StorageKind; // == TextureStorageType (Mipmap | Buffer)
|
||||
// VERTEX|INDEX|CONSTANT|SHADER_BUFFER|INDIRECT|SAMPLER|SHADER_IMAGE|RENDER_TARGET|
|
||||
// DEPTH_STENCIL|STREAM_OUTPUT|ATOMIC|ELEMENT_ARRAY. The ELEMENT_ARRAY bit is the
|
||||
// D-B7 switch: with kCapNeedsHostIndexBytes set the server mirrors this resource.
|
||||
Uint16 BindMask;
|
||||
Uint32 InternalFormat; // already resolved to an uncompressed fallback by the client
|
||||
Uint32 Width, Height, Depth;
|
||||
Uint16 ArrayLayers, Levels, Samples;
|
||||
Uint8 FixedSampleLocations, Immutable;
|
||||
Uint32 Usage; // BufferUsage
|
||||
Uint32 StorageFlags; // glBufferStorage flags
|
||||
Uint8 HasDefinedContent; // false after a NULL-data respecify
|
||||
Uint8 ImageBindableHint; // client-side everImageBound; pre-emptive allocation
|
||||
Uint16 Pad0;
|
||||
Uint32 GlNameForDiag; // diagnostics only; never an identity, memo key or hash input
|
||||
Uint32 Pad1;
|
||||
MGPipeHandle ViewOf; // storage owner for a texture view
|
||||
MGPipeHandle BufferForTexBuffer; // texture-buffer backing store
|
||||
Uint64 BufOffset, BufSize; // kWholeBuffer == ~0, resolved live
|
||||
};
|
||||
```
|
||||
|
||||
Prose gloss, `ARCHITECTURE.md:127`: "`BindMask` 的 `ELEMENT_ARRAY` 位是索引镜像的开关;`ImageBindableHint` 预防性分配 image-bindable 存储;`ViewOf` 是纹理视图的存储属主(server 侧 keep-alive);`BufferForTexBuffer/BufOffset/BufSize` 实时解析(`kMGPipeWholeBuffer = ~0`)。Renderbuffer 保持独立类(自己的 format-capability target、`ComponentSizes`、twin)。" So **P3a's buffer create/respecify is the call that first sets the `ELEMENT_ARRAY` bit that P8's index host mirror keys on** (§4.2 below). The buffer half also carries `Usage` and `StorageFlags` — the `glBufferStorage` flags that decide whether a store is immutable/persistent/coherent.
|
||||
|
||||
`MGPSubData` (`MGPipeTypes.h:587-607`, `MGP_ASSERT_POD(MGPSubData, 72)`), with the buffer-half convention spelled out in its own comment block (`:570-586`):
|
||||
|
||||
```cpp
|
||||
struct MGPSubData {
|
||||
MGPipeHandle Res;
|
||||
Uint16 Target, Level;
|
||||
Uint8 SourceIsVerbatimLevelShadow; // replaces the backend's `uploadData == mipData` compare
|
||||
Uint8 Pad0[3];
|
||||
MGPBox UnionBox;
|
||||
Uint32 RegionCount; // MGPSubRegion[] in the variable tail
|
||||
Uint32 Pad1;
|
||||
MGPBlobRef Blob;
|
||||
};
|
||||
```
|
||||
|
||||
The buffer half, verbatim from the header comment (`:574-585`): "THE BUFFER HALF. With `Target == Buffer` there is no level and no box, so the destination byte range rides in the box's first coordinate and first extent: `UnionBox.X` is the byte offset, `UnionBox.W` the byte size, `Y = Z = 0`, `H = D = 1`, `Level = 0`, `RegionCount = 0`, and `Blob` holds exactly `Size` source bytes. That caps ONE record at a 2^31-1 offset and a 2^32-1 size; a range beyond either is split by the emitter - the same rule, and at `SEG_STAGE`'s 32 MiB the far tighter one, that the ring's half-capacity bound already imposes on it. `MGPipeSetSubDataBufferRange` / `MGPipeSubDataBufferOffset` / `Size` below are the only spelling of this convention; nothing else reads the box for a buffer." The three helpers are `MGPipeSetSubDataBufferRange(MGPSubData&, Uint64 offset, Uint64 size) -> Bool` (`:609-618`, returns false and leaves the record untouched when the range does not fit — the emitter must split), `MGPipeSubDataBufferOffset` (`:619-623`, reads `UnionBox.X` as unsigned so a corrupt negative lands above the encodable bound and the applier's bounds gate refuses it) and `MGPipeSubDataBufferSize` (`:624`). The same rule in prose at `ARCHITECTURE.md:122`.
|
||||
|
||||
Supporting primitives: `MGPBlobRef{Uint64 Offset, Size; Uint32 Seg, Pad0;}` / 24 B (`:55-61`) — monolith: `Seg == kMGHostSpanSegNone` and `Offset` is an address in the caller's staging arena; split: `Seg` names a transport segment. `MGPRange{Uint64 Offset, Size;}` / 16 B (`:63-68`). `MGPBox{Int32 X,Y,Z; Uint32 W,H,D;}` / 24 B (`:70-76`). `MGPSubRegion{Int32 X,Y,Z; Uint32 W,H,D; Uint64 SrcOffset; Uint32 SrcRowStride, SrcSliceStride;}` / 40 B (`:566-579`) — "The source strides are CARRIED, not inferred from a pointer comparison" (texture path; `MGPSubRegion`'s stride rework is scheduled P3b/P4b, `ROADMAP.md:23`). `MGPHandleOnly{MGPipeHandle Handle; Uint32 Kind; Uint32 Pad0;}` / 16 B (`:93-99`) — "The payload of every call that carries nothing but an object identity", i.e. `ResourceDestroy`, `MapPersistent`, `UnmapPersistent`, `BindVertexElements`, `DeleteVertexElements`. `MGPSubDataComplete{MGPipeHandle Res; Uint16 Target, FirstLevel, LevelCount, Pad0; Uint64 PullSerial;}` / 24 B (`:621-627`) — texture-pull terminator, not a buffer call, but it shares the `kCtxObject` group.
|
||||
|
||||
`MGPipeHandle` itself is the 8-byte `{slot, gen}` POD in `MG_Pipe/MGPipeHandles.h`; `kMGPipeFirstAllocatableSlot = 1` (`:81`), `Gen` bumps only on slot reuse (`:44-48`), `kMGPipeDefaultFramebuffer` is `{0,1}` of kind Framebuffer (`:71`), and the top 1/16 of the `ShaderCso` slot space is reserved for program-pipeline composites (`:88-90`) — all cited from `ARCHITECTURE.md:35-40` and `BRIEF-P2.md:307ff`.
|
||||
|
||||
Payload record conventions that P3a's new/changed payloads must obey (`ARCHITECTURE.md:116-122`): every payload is a flat POD with explicit padding and a `static_assert` on trivial copyability **and exact size**, and **never contains a pointer**; var-tail records are fixed prefix + self-describing tail; `kHasBlob` records additionally validate that the `BlobRef` lands inside its declared segment; runtime violations are `Fatal{ProtocolCorruption}` (a `static_assert` cannot police a region the peer writes concurrently); the wire record header is `MGPWireRecHeader{Op:u16, Flags:u16, Size:u32}` (8 B, `Size` includes the header and is a multiple of 8); **the chunking upper bound is half the ring capacity** (`RingProducer::MaxRecordBytes()`), and payloads above it — explicitly "大 `ResourceSubData`" — are split by the emitter, while the ring outright refuses anything larger (nullptr + `MGLOG_E`).
|
||||
|
||||
### 3.4 Persistent maps (D-B4) and the ≥16 MiB adoption
|
||||
|
||||
- Untouched through the monolith work: `ARCHITECTURE.md:466` (quoted in §1.1 D-e). The tiers, the POST probe, `SEG_ADOPT`, `MOBILEGL_IPC_ADOPT_TIER` and the client-side push triplet are P5/P11 (`ARCHITECTURE.md:468-486`). P3a inherits none of it beyond routing `MapPersistent`/`UnmapPersistent` and publishing `map-persistent-roundtrips`.
|
||||
- Espryt's three persistent-mapped rings and the `PersistentRing` algorithm are in the do-not-touch list (`ARCHITECTURE.md:315`); the transport reuses that algorithm verbatim for its own allocation/backpressure (`ARCHITECTURE.md:445`).
|
||||
- The 20 `SyncPersistentMappedRange` + 6 `SyncGpuWrites` call sites have a **per-site** attribution table, not a blanket rule (`ARCHITECTURE.md:239-243`): client vertex-array range computation → nothing; max-index scan with an EBO source → `SyncPersistentMappedRange()` **and** `SyncGpuWrites()`; max-index scan from a client pointer → nothing; `*IndirectCount` count resolution → **only** `SyncPersistentMappedRange()`, because monolith does only that and adding the other would cost Create/Flywheel a publish-and-wait per batch; server-side restart rewrite / multi-draw flattening → the server reads the mirror. Those are P8's to move; P1 already produced the per-site ownership table (`ROADMAP.md:17`, `MEASUREMENTS.md:110`: 20 / 6, "与计划一致").
|
||||
- Open question 15 (`ROADMAP.md:88`) is a hands-off note that touches P3a's neighbourhood: "**monolith 的 `*IndirectCount` 不调 `SyncGpuWrites()` 是不是潜在缺口**(compute 写的 indirect buffer)。独立 `dev` 问题,**拆分不得借机顺手修**."
|
||||
|
||||
### 3.5 The index host mirror (server side, P8)
|
||||
|
||||
`ARCHITECTURE.md:383-389` (§10.3, `MG_Remote/Server/IndexHostMirror`, P8):
|
||||
|
||||
- Coverage: resources with `BindMask & ELEMENT_ARRAY`, and only when `kCapNeedsHostIndexBytes` (split, and the server needs index bytes for restart rewriting / multi-draw flattening).
|
||||
- "由 server 本来就要收的 `ResourceCreate/Respecify/SubData` 流增量维护:**零额外线上流量、零 round trip**." — i.e. the mirror is built entirely out of the three calls **P3a lands**. GPU writers' effect on the mirror is decided server-locally from the `OnGpuWritten` narrowed set.
|
||||
- Budget `MOBILEGL_PIPE_INDEX_MIRROR_MB` (default 64), publishes `index-mirror-bytes` per frame; over budget, that buffer degrades to per-draw shipping through `MGHostSpan` (`Seg` → `SEG_STAGE`), counted as `index-bytes-shipped`.
|
||||
- Why it must exist: `kMaxRestartRewriteBytes` = 64 MiB is twice the default `SEG_STAGE`, `kMaxFlattenedIndices` = 1<<24 is the same order; "它是本设计里唯一的"数据副本"".
|
||||
- `MGHostSpan` (32 B, `MG_Pipe/MGPipeHostSpan.h`) is "整份接口里**唯一形状随传输而变**的东西"; `Seg == kMGHostSpanSegFromServerIndexMirror` (`MGPipeHostSpan.h:26`) means "字节已在你那边的索引镜像里"; it appears only in variable tails (`DrawVbo`'s user indices, `SetShaderBuffers`' named-UBO bytes) and never inline in a fixed payload, "VBO 路径(MC/Sodium 的全部 draw)不为它付字节" (`ARCHITECTURE.md:120`).
|
||||
- Open question 16 (`ROADMAP.md:89`): the mirror's real memory footprint is unmeasured — element-array buffer totals across the MC/Sodium/Iris corpus are unknown; if materially over 64 MiB, the degraded path's frequency and cost must be measured.
|
||||
|
||||
### 3.6 The reverse channel a buffer needs
|
||||
|
||||
`ARCHITECTURE.md:267-284` (§8.1, `MobileGL/MG_Pipe/MGPipeCallbacks.h:27-51`, ten named callbacks + one forward terminator, replacing 95 call sites / 17 methods that poke frontend objects today). The two that a buffer needs:
|
||||
|
||||
- **`OnGpuWritten(res, ranges[])`** — replaces 6 `MarkGpuWritten` sites; "client 在每个 draw/dispatch 发射点**保守自建** pending 集,这是**收窄**通道" (i.e. the callback only ever narrows what the client already assumed). P9 narrows it further (`ROADMAP.md:26`: "`OnGpuWritten` 收窄").
|
||||
- **`OnBufferWriteback(res, offset, bytes)`** — replaces PBO readback and XFB capture; "**按操作级批处理**(今天两处逐行循环绝不能变成每扫描线一次 IPC);必须与 epoch bump 有序".
|
||||
|
||||
Ordering is a correctness requirement, `ARCHITECTURE.md:288` (§8.2), verbatim: "每一次 `WritebackFromBackend` 后面都紧跟 `BumpBufferMutationEpoch()`,否则 server 的 draw-clean memo 会在 epoch 背后变陈旧——split 里这变成反向通道上的排序规则:写回的 epoch bump 必须在任何后续读该 handle 的命令之前被 server 应用。**反向通道需要与正向通道相同的有序保证。**" (The epoch itself: `CurrentBufferMutationEpoch()`/`BumpBufferMutationEpoch()`, `MG_Backend/DirectGLES/Managers.cpp:1492-1499`; it is an `MGGen`, server-owned, and by §2.2 it **never crosses the line**.)
|
||||
|
||||
Other reverse-channel rows that bear on P3a's calls: `OnGlError(code)` must be ordered with the command stream (`glGetError` is always answered locally); `OnLog(level,text)` is lossy ≤WARN and lossless ≥ERROR with a rate limiter (`ARCHITECTURE.md:295`). The disposition of the other 95 writeback sites (`ARCHITECTURE.md:284`) removes exactly the things Track H replaces: "`SetBackendResource` 删除(server 拥有资源表);`SetBackendStateMemo`(前端 VAO 里存后端堆裸指针)**直接删除**;`SetBackendHashMemo/AuxMemo` → server 侧 per-slot 字段."
|
||||
|
||||
### 3.7 The Track H handle scheme for buffers and VAOs
|
||||
|
||||
Handles (`ARCHITECTURE.md:35-40`, §2.1): 8-byte POD passed by value in a register pair; **client mints, the server never returns a handle** → zero creation round trips (deviation D1 from gallium). Slots are dense and **allocated per kind** (free list + high-water mark) so the server's object table is an array, not a hash map — "与 `IndexGenerator` 无关——后者的 LIFO 名字复用正是句柄要关掉的问题". `gen` increments **only on slot reuse, never on respecify**; a debug allocator asserts on wrap (2^32 reuses of one slot ≈ 50 days at 1000 fps per-frame reuse). Kinds include `Buffer` and `VertexElementsCso`. GL names appear only as `GlNameForDiag` and are never an identity, never a memo key, never part of a content hash; `GetLifetimeId()` stays on the client as the tracker's own identity and the client keeps a `lifetimeId → slot` map.
|
||||
|
||||
Two generations, strictly separated (`ARCHITECTURE.md:44-49`, §2.2): `MGPipeHandle::Gen` is client-owned, answers "is this still the same GL object?", **crosses**; `MGGen` (`g_bufferMutationEpoch`, `m_textureImageEpoch`, `m_cacheStructureEpoch`, 12 backend epochs in all) is server-owned, answers "did I re-mint my driver object?", and **never crosses** — the only server→client appearance is a texture pull request (§8.4). Norm: "任何 MGPipe 调用不得要求 client 提供或知晓 `MGGen`;反过来,client 的回绕 `Uint16` 版本计数器永远不是新鲜度的唯一证明——过线时要么加宽、要么与 `{slot, gen}` 同行."
|
||||
|
||||
Lifetime hooks (`ARCHITECTURE.md:204`, §5.6): `resource_create` at frontend-object construction, storage lazily defined by `resource_respecify`, `resource_destroy` at destruction. Three ordering constraints are expressed **by payload**, not by protocol: a view is destroyed before its storage owner (`ViewOf` + server keep-alive); an FBO attachment pins its texture (the surface handle implies keep-alive); a **buffer texture pins its buffer** (`BufferForTexBuffer`, range resolved live).
|
||||
|
||||
P2's D13 already built the machinery P3a extends (`BRIEF-P2.md:307-336`): `MobileGL/MG_Impl/Pipe/SlotAllocator.{h,cpp}` (per-kind free list + high-water, `lifetimeId → slot` map per kind, debug wrap assert) and `MobileGL/MG_Backend/DirectGLES/SlotTables.h` (per-kind dense twin arrays). Crucially for P3a, D13 records that **buffers are the one kind that already has a death signal**: "Today nothing tells the backend an object died except buffers (`BufferBackendOps::OnDestroy`, `BufferObject.h:103`, fired from `BufferObject.cpp:39-41`); `Managers.h:306-314` quantifies the resulting dead gigabytes. P2 adds the death notification for the six kinds by emitting `delete_*` from the frontend's `Mark*ForDeletion` path (`Core.cpp:116-140, 167-169, 279-307, 346-352, 1188-1190, 1213-1225, 1252-1254`) when the object's last `SharedPtr` drops — **not** when the name is marked, because a still-bound object keeps living (`TextureState.cpp:118-155`). The hook follows `BufferBackendOps`' shape." (`BRIEF-P2.md:335`.) So P3a inherits: the six registries are already slot tables, the VAO's backend raw pointers are already gone, and buffer destroy already has the canonical shape.
|
||||
|
||||
The 21-memo census P3a pays into (`ARCHITECTURE.md:363`, §9.5): the unifying fact is "每个进入 memo 键的版本计数器要么是回绕 `Uint16`,要么根本不会被它害怕的那个 mutation bump;身份比较是堵回绕洞的补丁." `{slot, gen}` + explicit destroy delete 11 memos outright (six registries' co-located `weak_ptr` + GC, `TwinLookupMemo` x3 + `OwnerEquals`, `UnitSamplerLookupMemo`'s `WeakPtr` test, `SetBackendStateMemo`, `VkTextureManager::TextureIdentity` liveness probe, **`ConvertedVertexStreamKey`'s `sourcePin`**), 2 are deleted server-side with the debounce moved to the client, 7 are re-keyed (including "`VertexInputStateFactory::ComputeHash` 里的 lifetimeId → `gen` **混进** server 侧每个 content hash"), and 1 (D18's container discipline) is untouched.
|
||||
|
||||
Note for P3a's VAO work specifically: Espryt's `ConvertedFloat64Stream` memo (`MG_Backend/DirectGLES/Managers.h:900-910`) is keyed on `sourceLifetimeId` + `sourceChangeSerial` + `sourceOffset`; `m_syncedAttributeVersions` and `m_hasSyncedConfigVersion`/`m_syncedConfigVersion` (`Managers.h:938-942`) are the VAO twin's shutters; `BufferImpl::g_bufferBackendIdGeneration` (`Managers.h:800`) is a **driver-object epoch, not identity, and survives untouched** (`BRIEF-P2.md:333`) — the same list marks `g_attachmentBackendIdGeneration` (`DirectGLES.cpp:1891`) and `InProcessTeardown()` the same way.
|
||||
|
||||
### 3.8 The purity gates
|
||||
|
||||
Stated at `ARCHITECTURE.md:499` (part 1 of the five-part gate) and again as the build-layout goal at `:552-566`:
|
||||
|
||||
- **A — include graph**: build `MG_Backend` in the disaggregated configuration with `MG_State/GLState` removed from the include search path. `nm --undefined-only` is blind to "included but never called", and `RenderState.h → FramebufferObject.h → TextureObject.h` is exactly that coupling. Depends on P0.5. Today gate A asserts on `MGPipeValueTypes.h`, not `MGPipeTypes.h`, because `DynamicBackendParameters` stayed in `BackendObject.h` (`ROADMAP.md:15`, `ARCHITECTURE.md:262`).
|
||||
- **B — symbols**: `nm --undefined-only libMobileGLServer.so | grep -E 'MG_State::GLState::|glslang'` empty.
|
||||
- **C — undeclared**: `grep -c 'pGLContext' MG_Backend/` == 0. P1 already reached 0 (`MEASUREMENTS.md:135`: "`MG_Backend` 里的 `pGLContext` | 0(唯一保留处是开关头文件的 pull 分支)"); the purity grep is on `pGLContext`, **not** `pGLContext->` (`ARCHITECTURE.md:350`).
|
||||
- Plus the debug assertion that every backend memo key is `{slot, gen}` and never a raw frontend pointer, supported by `HandleRecycleScenario` (red before the re-key, on at least one backend).
|
||||
- P13, not P3a, is when the three purity gates turn green on non-verify builds (`ARCHITECTURE.md:369`, `ROADMAP.md:30`); `MOBILEGL_PIPE_VERIFY` and the `SnapshotFromGLContext()` + `MG_State` include it needs are deliberately kept (D-B5, verify builds never ship).
|
||||
- Related standing rule the P3a diff must not violate (`BRIEF-P2.md:334`): "Purity gate C: `grep -rc pGLContext MobileGL/MG_Backend` stays empty."
|
||||
|
||||
---
|
||||
|
||||
## 4. What P4a and P8 expect P3a to leave in place
|
||||
|
||||
### 4.1 P4a (`ROADMAP.md:20`)
|
||||
|
||||
Deliverables cell, verbatim: "`set_framebuffer_state`(解析后的 `ReadSurface`、内联格式、`ContentHash`、`{0,1}`);sampler CSO(含 `borderColorForm`);sampler view + `set_texture_params`;`set_sampler_views`/`bind_sampler_states`/`set_shader_images`;shader CSO(SPIR-V + 归档);`set_draw/dispatch_program`;`set_global_constants`;`CompositeResolver`;**纹理/renderbuffer 的 `resource_*`**。emulation 在 split 下显式 Fatal 直到 P8". Gate cell: "全套门;framebuffer/纹理/program 族场景;**新增"只作 attachment / image 单元 / CopyImage 端点的纹理其 `glTexParameter` 生效"场景(落地前必须红)**;两台设备 `KHR-GL46.direct_state_access.framebuffers*` 与整个 `packed_pixels` 块(~3300 例,句柄复用压力测试)。**再基线检查点 1b:超过 39 天**". Dependency cell: "P3a".
|
||||
|
||||
Therefore P4a expects P3a to leave behind, ready to reuse without redesign:
|
||||
|
||||
1. **The `resource_*` family itself, generalised.** P4a's textures and renderbuffers ride the *same* `ResourceCreate`/`ResourceRespecify`/`ResourceDestroy`/`ResourceSubData` calls and the *same* `MGPResourceDesc` (one discriminated shape for "buffer / 全部纹理 target / renderbuffer", `ARCHITECTURE.md:127`). P3a must not shape those calls or the descriptor around buffers only — the texture fields (`Levels`, `Samples`, `ArrayLayers`, `ImageBindableHint`, `ViewOf`, `HasDefinedContent`, `FixedSampleLocations`) are already in the 88-byte struct and their meaning must survive.
|
||||
2. **The `{slot, gen}` scheme and the slot allocator scaled to a second wave.** P4a is explicitly the "句柄复用压力测试" (the whole `packed_pixels` block, ~3300 cases), so P3a's allocator, its wrap assert, its `lifetimeId → slot` maps and its explicit-destroy path have to hold under heavy recycling.
|
||||
3. **`MOBILEGL_PIPE_LEGACY_MEMOS` alive as a compile-time arm** — `ARCHITECTURE.md:367` says it is retained "在 P3a/P4a 期间" and retires only with the pull path at P13 (+1 day of maintenance per phase). P3a must add its buffer/VAO legacy arm in that shape, and P4a will add more under the same switch.
|
||||
4. **The `kNeedsAck` mechanism, first used on `glBufferStorage`** (`ARCHITECTURE.md:293`), because P4a's texture/renderbuffer allocations explicitly do **not** ack and rely on that asymmetry being expressible.
|
||||
5. **A working `HandleRecycleScenario` + the ABA control arm** (P2's D18, `BRIEF-P2.md:423-437`): the three always-on ctest arms (`.Handles` green, `.Legacy` green, `.AbaControl` green-by-asserting-the-corruption via `MOBILEGL_PIPE_HANDLE_ABA_CONTROL` / `Features.PipeHandleAbaControl`). P3a's VAO/buffer re-keys extend that scenario's coverage; P4a re-uses it for textures and framebuffers (the P2 scenario already repeats its shape "for a texture (against `g_backendTextureObjects`) and a framebuffer").
|
||||
6. **The full `gl44to46` caselist run at the P3a boundary** (`ROADMAP.md:34`), which is P4a's conformance starting point (P4a itself only owes the named `packed_pixels` block plus `direct_state_access.framebuffers*`).
|
||||
7. **Per-dirty-bit fire rates in `MEASUREMENTS.md`** — P2 produced them "so P3a starts from data" (`BRIEF-P2.md:956`); P3a owes the same for the bits it turns from counted into emitted, so P4a's object-class bits (11–14) start from data too.
|
||||
|
||||
### 4.2 P8 (`ROADMAP.md:25`)
|
||||
|
||||
Deliverables: "`MG_Impl/Pipe/HostResolve.cpp`(client 数组范围、最大索引扫描、`*IndirectCount` 解析,各带逐站点 reconcile);`MGHostSpan` split 填法;**`Server/IndexHostMirror`**;CopyImage 镜像搬到 client;`draw_vbo` 收编 multi-draw 族(分档仍在 server);viewport-array 回放验证;`generate_mipmap` 计划 + CPU 回退纹素;G3 分块路径;无 present fence tick + 无 present split 用例;`kCapDriverOrderedXfbCapture`". Gate: name-for-name `'^DirectGLES\.Split\.'` vs `'^DirectGLES\.'` (same for DirectVulkan); 40 traces split, both backends, SSIM ≥ 0.99 **including the two `coherent_as_flush` Create fixtures**; `ClientArrayAfterComputeWriteScenario` green (removing the wait must show missing geometry); `roundtrips-per-frame` reads zero on `create-indirect`; `index-mirror-bytes`/`index-bytes-shipped` published per case. Day 145 = full-feature split.
|
||||
|
||||
P8 expects P3a to leave:
|
||||
|
||||
1. **`BindMask & ELEMENT_ARRAY` correctly set on every index buffer**, on `ResourceCreate` **and** `ResourceRespecify`, because that bit is the mirror's coverage switch (`MGPipeTypes.h:153-156`, `ARCHITECTURE.md:385`). Getting it wrong silently disables restart rewriting / multi-draw flattening in split.
|
||||
2. **A `ResourceCreate/Respecify/SubData` stream that is complete and incremental enough to rebuild buffer contents from nothing** — the mirror is maintained "由 server 本来就要收的 … 流增量维护:零额外线上流量、零 round trip" (`ARCHITECTURE.md:385`). Any buffer mutation path P3a leaves outside those three calls becomes a silent mirror hole.
|
||||
3. **The `MGPSubData` buffer-half convention and its emitter-side splitting** (`MGPipeTypes.h:574-618`), because P8 adds the G3 chunked path on top of it and because the mirror consumes exactly those records.
|
||||
4. **`OnGpuWritten` as a narrowing channel with a conservative client-side pending set** (`ARCHITECTURE.md:271`), because the mirror decides GPU-writer visibility server-locally from that narrowed set (`ARCHITECTURE.md:386`).
|
||||
5. **`map_persistent` untouched**, plus the `hasLiveHostWrites` question answerable per resource — P5's client-side persistent-map push adds "一个 `hasLiveHostWrites` 位" to the `ResourceRespecify/SubData` payload with "零新增记录种类" (`ARCHITECTURE.md:479`). P3a's payload shape must leave room for that rather than forcing a new record kind.
|
||||
6. **`MGPDrawInfo`'s index fields intact** — `IndexResource`, `IndexSize`, `RestartIndex`, `MinIndex/MaxIndex` under `kDrawHasIndexRange`, `kDrawIndicesAreClient`, the `MGHostSpan` in the variable tail only under `kDrawHasUserIndices` (`MGPipeTypes.h:696-729`) — because P8's `draw_vbo` multi-draw absorption and host-resolve work all key on them, and because "the client resolves the COUNT itself, so the server never reads an indirect command block" (`MGPDrawIndirect` comment, `:737-745`).
|
||||
7. **The `create-indirect` fixture usable as an acceptance case**, i.e. the `dev`-side failure fixed first (`MEASUREMENTS.md:96`, `ROADMAP.md:90`); P8 asserts `roundtrips-per-frame == 0` on precisely that fixture.
|
||||
8. **Emulation ownership unchanged**: restart rewriting and multi-draw tiering stay server-side with zero wire traffic; the client supplies index bytes only when caps ask (`ARCHITECTURE.md:229-237`, and the one-line rule at `:112`: "**multi-draw 分档与 restart 重写永远由 server 拥有;client 在 caps 说需要时提供索引字节**"). P3a must not move either into the client as a convenience.
|
||||
|
||||
---
|
||||
|
||||
## 5. Commit / CI discipline, and the 2026-09-08 rule
|
||||
|
||||
### 5.1 Per-commit discipline, verbatim
|
||||
|
||||
`ROADMAP.md:7` (the "通用纪律(每个 commit)" section), verbatim: "默认 ALL target 必须完整构建;禁止提交热路径插桩(CI grep 门);**每个门必须能因它存在的理由变红**;Windows 机器不是正确性门;设备对比走 reboot-clean + 同热窗口配对 A/B,CPU 定频按项目协议;每阶段出口跑一次五部分门;每阶段性能判据是**逐线程 CPU 时间**."
|
||||
|
||||
Unpacked into obligations P3a inherits:
|
||||
- the default ALL target builds;
|
||||
- no hot-path instrumentation is committed — enforced by a CI grep gate; the P2 restatement is "**The tracker gets no timer.** The absolute-ns number comes from `DriverBench`'s `ns_per_op` … which times whole frames from outside the library" (`BRIEF-P2.md:410-412`), and every counting site keeps the `if (PipeStats::Enabled())` shape so an off build pays one predicted branch (`BRIEF-P2.md:421`, `PipeStats.h:29`);
|
||||
- **every gate must be able to go red for the reason it exists** — this is why each phase ships negative controls (P2's `g7_negative_control.sh`, the `AbaControl` arm, the deliberately corrupted verify field, the pulled fill stamp);
|
||||
- Windows is not a correctness gate;
|
||||
- device comparisons are reboot-clean, same thermal window, paired A/B, CPU pinned per the project protocol;
|
||||
- the five-part gate runs once at each phase exit;
|
||||
- the per-phase performance criterion is per-thread CPU time.
|
||||
|
||||
### 5.2 CI lanes and generated-file discipline
|
||||
|
||||
- `pipe-gates` (`.github/workflows/test.yml:809`, P0 landed, `ARCHITECTURE.md:568`): regenerate with `gen_pipe.py` and `git diff --exit-code`; the stdio-instrumentation grep gate over `MG_Backend`/`MG_State`; `gen_pipe_dirty_surface.py --summary` (informational at P0, a gate from P1/P2 — P2's D.5 corrects the doc to say P2); `check_doc_citations.py` (warning level, `--strict` once the docs are final). Separate job `flatc-check`. Follow-ups listed: `include-graph-check` (P0.5) and `monolith-symbol-report`.
|
||||
- Generated files are committed and CI diffs them (`BRIEF-P2.md:461`, `test.yml:1492-1495`). Codegen never enters the default build graph (`ARCHITECTURE.md:424`).
|
||||
- **`PipeCalls.def` numbering never churns**: the wire opcode is the 1-based position in the file, new calls may only be **appended**, retired calls keep their slot, and `MGP_CALL_LIST_DOCUMENTED_COUNT = 71` is pinned by `MG_Test/Pipe/PipeCatalogueTest.cpp` (`PipeCalls.def:18-24, 69`; `ARCHITECTURE.md:75`; `BRIEF-P2.md:460`). Every call P3a emits already has an opcode, so P3a should not need to edit the catalogue — but **any payload whose size changes (e.g. `MGPVertexBuffers` gaining `baseInstance`) changes `MGP_ASSERT_POD` and the G3 wire `static_assert`, which is a deliberate, reviewed break, not a silent one.**
|
||||
- Commit messages (`BRIEF-P2.md:459`): single-line `[Type] (Scope): description`. **Never** add `Co-Authored-By` or any other attribution line.
|
||||
- Logging (`BRIEF-P2.md:462`): `MGLOG_D` for anything non-critical, `MGLOG_I` only where already justified; no stdio anywhere under `MG_Backend`/`MG_State` (the `pipe-gates` grep, `test.yml:1515-1522`).
|
||||
- Namespacing/layering (`BRIEF-P2.md:456-458`): no new namespaces, everything is `MobileGL::MG_Pipe`; run `python3 scripts/check_include_closure.py` after adding any file to the shared `MG_Pipe` directory; if the closure gate objects, the file moves to `MG_Impl/Pipe/` (the client side is unrestricted).
|
||||
- Docs at phase exit (`BRIEF-P2.md:930-946`, D.5): `scripts/check_doc_citations.py docs/Disaggregated/*.md` must stay clean — every `file:line` a doc edit adds has to be true. The phase updates `README.md:3` (status + hash), its own `ROADMAP.md` row (tick + the real numbers), any open questions it answers, the `ARCHITECTURE.md` lines its work makes stale, and adds a numbered `MEASUREMENTS.md` section with the phase's tables. Then `[Merge]` to `dev` per the milestone flow, and the full `gl44to46` caselist is scheduled on both devices **off the critical path**.
|
||||
- Local-verify convention that P1/P2 both used and P3a should expect to reuse (`BRIEF-P2.md:965`): the exit evidence is the local WSL run (`~/w7/pipe`), not CI; CI green is required before the `dev` merge, not before the phase verdict.
|
||||
|
||||
### 5.3 Durable locations and integrator decisions carried forward from P2
|
||||
|
||||
`INTEGRATOR-DECISIONS.md` (`~/w7/notes/p2/INTEGRATOR-DECISIONS.md`, dated 2026-09-07), five entries; the ones with life beyond P2:
|
||||
|
||||
- **ID-4, command errata** (apply when running the gates): ctest name extraction must be `grep -E "^[[:space:]]*Test[[:space:]]+#[0-9]+:" | sed -E "s/^ *Test +#[0-9]+: //" | LC_ALL=C sort` on both sides — "the brief's `^\s+Test #` drops every id under 1000"; `retrace_gate.py` has **no** `--ssim` / `--backend` flags, the SSIM threshold is the per-case one in `trace_cases.json`; the verify arming line is `MGPipe: verify armed - 63 fields, 69 verbs, fatal=1` and retrace case logs carry `MGPipe verify: <case> <backend> armed, zero divergences, zero unmigrated reads`.
|
||||
- **ID-5, durable locations** ("the Windows scratchpad was wiped once already"): brief at `~/w7/notes/<phase>/BRIEF-*.md`; scouts at `~/w7/notes/<phase>/scout-*.md`; results and reviews at `~/w7/notes/<phase>/<phase>-results/`; helper scripts at `~/w7/notes/tools/` (today: `p2_ab.sh`, `wsl_integrate_p2.sh`, `wsl_p2_bench.sh`, `wsl_p2_gate.sh`, `wsl_p2_tree.sh`). Write through a WSL script or the `//wsl.localhost/Arch/home/swung/w7/...` UNC path, not only to the scratchpad. Delete your own intermediate logs when a round ends; keep only the logs your result file cites.
|
||||
- **ID-1 / ID-2 / ID-3** are P2-specific (the ownership grant for the six destructor notifications, the integration order `contract -> spans -> espryt -> tracker -> magma -> gates`, and the G1 admitted resize set) but they set the precedent P3a's integrator should copy: an ownership deviation is a **recorded waiver**, integration order is chosen so the package carrying shared-file edits lands first and the others rebase, and any symbol resize outside a named, admitted set must be attributed per symbol.
|
||||
|
||||
For reference, P2's decoded gate set (`BRIEF-P2.md:33-58`) is the template a P3a brief should mirror: **G1** pull-build symbol identity via `scripts/symbol_report.py --threshold 0` (0 added / removed / renamed, resizes only from a named admitted set); **G2** `ctest -L integration-gpu` name-for-name identical between pull and push builds, green in both, on both backends; **G3** the 40-trace corpus under push at SSIM ≥ 0.99 (79 desktop cases = 40 x 2 minus `iterationrp x DirectGLES`) via `~/w7/retrace_gate.py`; **G4** the verify build with no `Fatal{PipeVerifyDiffer`, `Fatal{UnmigratedPipeInput`, `Fatal{PipeResidualDiverged` and every case armed; **G5** a named untouched region proven by `sha256sum` of an `awk`-extracted namespace across two refs; **G6/G7** a consistency test plus its scripted negative control (patch, build, expect non-zero ctest rc, revert); **G8** the always-on three-arm recycle scenario; **G9** `gen_pipe_dirty_surface.py --check` and `--self-test`; **G10** a `static_assert` ratchet plus a device counter reading non-zero; **G11** the two-device paired A/B; **G12** the microbenchmark plus a ctest that proves the negative-control switch actually changes behaviour; **G13** purity (no `pGLContext` under `MG_Backend/`, include closure, no stdio, generators regenerate clean); **G14** no test name ever removed, full CI matrix green.
|
||||
|
||||
### 5.4 The user's 2026-09-08 rule: speed over perf
|
||||
|
||||
**As given to me by the orchestrator** (it is not written in the docs I opened — `docs/Disaggregated/*` and the P2 notes contain no such clause, so this must be transcribed into the P3a brief and into `MEASUREMENTS.md`, and `ROADMAP.md:19`'s gate cell read in its light):
|
||||
|
||||
> Speed over perf: **performance is recorded, not gated**. The pull baseline is in `MEASUREMENTS.md`. **Correctness gates stay.**
|
||||
|
||||
Concretely, for P3a:
|
||||
|
||||
- Part 4 of the five-part gate (`ARCHITECTURE.md:504`: two devices, reboot-clean, same thermal window, paired A/B, per-thread CPU p50/p99, the tracker's absolute ns/draw ceiling, the blend-toggle microbenchmark, the CSO-content-addressing negative control) becomes a **measure-and-publish** obligation rather than a pass/fail gate. The P2-equivalent statement (G11, `BRIEF-P2.md`) "per-thread CPU p50 and p99 deltas are **not negative** on either device" does **not** block P3a.
|
||||
- Likewise "MC 26.3 在 Adreno 上 p99 不变" (`ROADMAP.md:19`) is recorded against the baseline, not enforced as a stop condition.
|
||||
- Everything in parts 1, 2, 3 and 5 of the gate stays a hard gate: purity A/B/C, `MOBILEGL_PIPE_VERIFY=1` zero divergence, name-for-name integration equality across `{pull, push}` on both backends, 40-trace SSIM ≥ 0.99, CTS within 0.5 pp, coverage/poison/handle discipline, and every negative control able to go red.
|
||||
- The **pull baseline to record against** is already in `MEASUREMENTS.md`: §3 the two-device / two-backend / four-trace boundary-counter table (`MEASUREMENTS.md:53-62`) — steady-state dynamic accessor cost is **6.5–9.3 per draw** (`:66`), which is what push must beat and from which the tracker's ns ceiling is derived; the six memo gates' hit/miss pairs; `stage-*` byte classes including the `stage-ubo-named` 331 KB/frame asymmetry (`:68`) and the union-box vs region-list 635 K vs 40 K, 16x (`:70`). §4 desktop points (`:74-88`), including the payload `static_assert` sizes and the **persistent-map adoption baseline p99 163→21 ms / 40→115 fps / ~400 MB** (`:87`) and the Mali +6 ms/frame upload-job cliff (`:88`). §8 (`:129-142`) is P1's acceptance table and the shape a P3a table should copy.
|
||||
- The reporting caveat that must travel with any `acc/draw` number (`BRIEF-P2.md:417-419`, `D17`): `CallClass::AccessorCalls` is a set of **static tallies at ~10 hot entry points** (`PipeStats.cpp:76-88`), so a tracker that merely *relocates* reads scores a lower `acc/draw` without removing work. Lead with the **gate hit/miss pairs** and the **CPU-time series**, and quote `acc/draw` only alongside a re-audit of the tally constants (`DirectGLES.cpp:1421,1524,2043,2053,2977`; `VulkanRenderer.cpp:5009,5016,5274,5927,5934,6416,6449,6462`). Write the caveat **above** the numbers, not below.
|
||||
- Counters available without new instrumentation (`ARCHITECTURE.md:599-601`, `MG_Util/Metrics/PipeStats.h:46-122`): byte classes `stage-buffer`, `stage-texture`, `stage-ubo-global`, `stage-ubo-named`, `stage-vertex-client`, `stage-index-client`, `stage-indirect-cmd`, `persistent-map-push`, `residual-value-block`; call classes `draws`, `accessor-calls`, `texture-upload-emissions/box/rect/jobs` (P2 added `RenderStateCsoMints`/`RenderStateCsoBinds`, short names `csom`/`csob`, `BRIEF-P2.md:414`); six memo gates each with hit/miss; a 24-bucket per-draw payload histogram (`RecordDrawPayloadBytes`, `PipeStats.h:129,154`) that the tracker became the first emitter of in P2. Summary line every `MOBILEGL_PIPE_STATS_PERIOD` frames (default 120); the list of paths that are **not** wired is at `PipeStats.cpp:16-100` and "那份清单是契约".
|
||||
|
||||
---
|
||||
|
||||
## 6. Traps and standing facts an implementer will otherwise re-discover
|
||||
|
||||
1. **The trace harness never reaches `MobileGL::DestroyImpl`**, so `MOBILEGL_PIPE_STATS_FILE`'s JSON dump is never written on device — only the periodic summary lines in `mobilegl.log`; a trace shorter than one period produces nothing (`MEASUREMENTS.md:92`). Set `MOBILEGL_PIPE_STATS_PERIOD` small enough.
|
||||
2. **Two devices must run serially from one tree**: `run_android_retrace_local.py` shares one `.trace-work/android-retrace-result` root per tree and `rmtree`s it on every invocation (`MEASUREMENTS.md:93`).
|
||||
3. **MSYS path conversion** mangles `/data/...` inside `--env` values; run with `MSYS_NO_PATHCONV=1` (`MEASUREMENTS.md:94`).
|
||||
4. `coherent_as_flush` is plumbed independently of `--env`: `--ez coherent_as_flush true` → `trace_replay_core.cpp`'s `setenv` (`MEASUREMENTS.md:95`).
|
||||
5. Repro command for the counter baseline (`MEASUREMENTS.md:72-78`): `ANDROID_SERIAL=<serial> MSYS_NO_PATHCONV=1 python3 tools/trace_replay/run_android_retrace_local.py --case <case> --backend DirectGLES --env MOBILEGL_PIPE_STATS=1 --env MOBILEGL_PIPE_STATS_PERIOD=120`, then `grep 'MGPipe stats:'` in the result directory's `mobilegl.log` and take the last complete window.
|
||||
6. **Devices**: `35d0befa` = Xiaomi 24129PN74C, Adreno 830, Android 16; `3B159D009VZ00000` = Oppo PLG110, Mali, Android 16 (ColorOS). Device-lock protocol as usual (`MEASUREMENTS.md:3`). ColorOS install trap: a first `adb install` of an unknown package stalls on `com.oplus.appdetail InstallGuideActivity` until "继续安装" is tapped (`MEASUREMENTS.md:30`).
|
||||
7. **Test-wiring traps** (`ARCHITECTURE.md:566`): ctest `ENVIRONMENT` **replaces** rather than appends, `;` must be escaped, and the property overrides job env — use `mgl_itest_join_environment(... ${MGL_ITEST_COMMON_ENV})`; `add_trace_replay_test` needs a `SPLIT` suffix (otherwise it collides with the same case+backend) plus `-DTRACE_TRANSPORT=`.
|
||||
8. **A test that calls a backend helper directly aborts on the per-verb poison** unless it declares its verb; `MG_Test/ScopedPipeVerb.h` exists for exactly that and eleven tests already use it (`ef6227e1`, `BRIEF-P2.md:971`). The poison is never weakened and no test name changes.
|
||||
9. **P1 left 8 over-approximated fill rows** — statically reachable but never exercised by the harness, and an over-approximation permanently disables that (class, field) poison; "**P2 收紧填充表时先复查这 8 行**" (`MEASUREMENTS.md:119`). If P2 did not close them, P3a inherits the item.
|
||||
10. **push-on-mutation** is the shape P1 chose for backend-writes-frontend inside a verb (`MEASUREMENTS.md:121-128`): `MGP_NOTE_MUTATION(Field)` (`MG_Pipe/PipeMutation.h`) refreshes one field in the pushed block when a frontend counter moves, keeping "the pushed block equals the live context at every read" literally true. The three fields and their hooks: `GetSamplingResolutionGeneration` / `TextureState::BumpSamplingResolutionGeneration()`; `GetTextureBindGeneration` / `BumpTextureBindGeneration()` and `NoteUnitTouched()`'s `bindingChanged` branch; `GetMaxTouchedTextureUnit` / `NoteUnitTouched()`'s high-water branch. Note the explicit statement that **`BufferObject`/`ProgramObject`/`VertexArrayObject` backend writes move no pushed field — "它们是句柄类读点"** (`MEASUREMENTS.md:128`), which is precisely why P3a's kinds are the handle wave.
|
||||
11. Espryt's `SyncTextureObjectToBackend`'s by-value copy and second `Find` (`DirectGLES.cpp:1310-1345`) were deleted in P2's D13 "in the same change, not left as harmless"; `g_fbSlotCache`/`GetFramebufferBindingSlotFast` (`DirectGLES.cpp:134-157`, five callers at `:1613, 1907, 2745, 2860, 2935`) was replaced by a plain `MGB_CTX->GetFramebufferBindingSlot(target)` read, which **closed a P1 poison bypass** — the fast getter handed out a raw pointer forever, so the per-verb poison stamp and the verify read hook were skipped at those five sites (`BRIEF-P2.md:318`). P3a should assume no equivalent fast-path getter survives in the buffer/VAO paths.
|
||||
12. Espryt-side things P3a must keep armed while moving the registries/pools (P2's D13 must-not-break list, `BRIEF-P2.md:325-334`): `EnsureProcessTeardownSentinel()` arming (`Managers.h:59-60`, `Managers.cpp:161-170`) moves to the slot table's first insertion — a registry destructor hook is wrong and `Managers.h:52-57` says why; the twin destructors' `g_backendContextGeneration` compare (`Managers.h:64-70`, pinned by `SanityTest.cpp:2650-2665, 2765-2773, 2786-2790`) so a twin outliving its ES context does not `glDelete*` a recycled name; the whole-registry save/reset/restore fixture `ScopedDirectGLESTextureBindings` (`SanityTest.cpp:145-197`); the one direct-iteration site `ScopedDetachedTextureFramebufferAttachments` (`DirectGLES.cpp:6413-6425`) needs a per-kind "which slots are live" bit.
|
||||
13. `MOBILEGL_PIPE_*` runtime switches that exist today (`ARCHITECTURE.md:586-596`, `Config.h:319-358`, `ConfigLoader.cpp:245-256`): `MOBILEGL_PIPE_PUSH` (0, a subsystem bitmap including one bit that disables CSO content addressing), `MOBILEGL_PIPE_VERIFY` (0), `MOBILEGL_PIPE_STATS` (0), `MOBILEGL_PIPE_LEGACY_MEMOS` (ON, tri-state, only an explicit falsy turns it off), `MOBILEGL_PIPE_TEXEL_RETAIN_MB` (0), `MOBILEGL_PIPE_INDEX_MIRROR_MB` (64), `MOBILEGL_PIPE_STATS_PERIOD` (120), `MOBILEGL_PIPE_STATS_FILE` (empty). Existing negative-control switches are all retained: `MOBILEGL_ESPRYT_DISABLE_{UBO,UNPACK,UPLOAD}_RING`, `_INVALIDATE_FLUSH`, `MOBILEGL_DISABLE_LARGE_BUFFER_ADOPTION`, `MOBILEGL_COHERENT_AS_FLUSH`.
|
||||
14. The two lanes are independent and P3a is on the monolith lane; the monolith argument is per-thread CPU numbers, **not** deleted lines — "monolith 净代码量是**增加**的(约 +6,650 手写 + 4,000 生成,对 ~372 行真删除)" (`ARCHITECTURE.md:381`). The monolith-side wins P3a's kind of work buys, listed at `:381`: an entire class of address-reuse ABA becomes inexpressible; the FBO→program ordering hazard disappears; the `SwapchainObject` layering inversion disappears; two latent bugs already fixed; one glslang compile leaves the startup path; `inproc` becomes the render thread; the `MG_Test` mock backend becomes the MGPipe recorder.
|
||||
@@ -0,0 +1,688 @@
|
||||
# P3a scout — Espryt (MobileGL/MG_Backend/DirectGLES) buffer surface
|
||||
|
||||
Worktree: `C:/Users/geekerwan/AndroidStudioProjects/FoldCraftLauncher/MobileGL-disagg`, branch `feat/disaggregated`.
|
||||
All paths below are repo-relative. Every line number was opened.
|
||||
|
||||
---
|
||||
|
||||
## 0. Map at a glance
|
||||
|
||||
| Thing | Where |
|
||||
|---|---|
|
||||
| Ops table type | `MobileGL/MG_State/GLState/BufferState/BufferObject.h:76-124` |
|
||||
| Ops table registry (global) | `MobileGL/MG_State/GLState/BufferState/BufferObject.cpp:18,27,31` |
|
||||
| Espryt implementations | `MobileGL/MG_Backend/DirectGLES/Managers.cpp:624-1490` (whole `BufferImpl` anon namespace) |
|
||||
| Espryt table instance | `Managers.cpp:1482-1490` (`g_glesBufferBackendOps`) |
|
||||
| Backend resource class | `MobileGL/MG_Backend/DirectGLES/Managers.h:592-644` (`GLESBufferResource`) |
|
||||
| Storage abstraction | `MobileGL/MG_State/GLState/BufferState/PipeResource.h:62-140` |
|
||||
| Draw-path entry | `Managers.cpp:1602-1706` (`EnsureBufferResource`), `1579-1601` (`IsBufferDrawClean`) |
|
||||
|
||||
Note on the ops-table shape: **every hook receives `BufferObject&` (a frontend heap
|
||||
reference), not a handle.** That is the single biggest P3a conversion fact — see §2.
|
||||
|
||||
---
|
||||
|
||||
## 1. `BufferBackendOps` — definition and Espryt's seven hooks
|
||||
|
||||
### 1.1 Definition (MG_State side)
|
||||
|
||||
`MobileGL/MG_State/GLState/BufferState/BufferObject.h:76` declares `struct BufferBackendOps`
|
||||
with exactly seven function pointers:
|
||||
|
||||
| # | Hook | Signature line |
|
||||
|---|---|---|
|
||||
| 1 | `Respecify(BufferObject&)` | `BufferObject.h:80` |
|
||||
| 2 | `SubData(BufferObject&, SizeT offset, SizeT size)` | `BufferObject.h:82` |
|
||||
| 3 | `ResidentSubData(BufferObject&, SizeT offset, DataPtr data)` | `BufferObject.h:95` |
|
||||
| 4 | `FlushMappedRange(BufferObject&, Range1D, Flags<BufferMappingAccessBit> appAccess)` | `BufferObject.h:99-100` |
|
||||
| 5 | `OnDestroy(SharedPtr<BackendBufferResource>&&)` | `BufferObject.h:103` |
|
||||
| 6 | `void* AcquirePersistentMap(BufferObject&)` | `BufferObject.h:114` |
|
||||
| 7 | `ReadbackFromGpu(BufferObject&)` | `BufferObject.h:121` |
|
||||
|
||||
The table is a single process-global pointer: `g_bufferBackendOps` at
|
||||
`BufferObject.cpp:18`, set/read by `SetBufferBackendOps` (`BufferObject.cpp:27`) and
|
||||
`GetBufferBackendOps` (`BufferObject.cpp:31`). A null table means shadow-only tracking
|
||||
(unit tests, benchmarks) — see `BufferObject.h:125-127`.
|
||||
|
||||
Contract stated in the header and relied on by Espryt: **every op must tolerate
|
||||
`GetBackendResource() == nullptr`** (`BufferObject.h:70-74`); the lazy draw-time
|
||||
`EnsureBufferResource` full-uploads from the shadow and thereby covers everything that
|
||||
happened before the resource existed. Contents are **always read from the shadow**, so
|
||||
ops carry only ranges and flags — never bytes — with the single exception of
|
||||
`ResidentSubData`, which carries `DataPtr data` valid **for the duration of the call
|
||||
only** (`BufferObject.h:85-94`).
|
||||
|
||||
Frontend dispatchers that reach these hooks:
|
||||
`NotifyRespecify` (`BufferObject.cpp:45`), `NotifySubData` (`:53`),
|
||||
`NotifyFlushMappedRange` (`:63`), `NotifyContentWrite` (`:73`),
|
||||
`LandBytesIntoResidentStore` (`:371`), `SyncGpuWrites` (`:319`),
|
||||
`TryAdoptLargeStorage` (`:186`), `EnsureGpuResidentStorage` (`:493`).
|
||||
|
||||
### 1.2 Espryt's backend resource (`GLESBufferResource`)
|
||||
|
||||
`Managers.h:592-644`. Derives from `MG_State::GLState::BackendBufferResource`
|
||||
(`PipeResource.h:66-70`). Fields, each of which P3a must decide client-vs-server for:
|
||||
|
||||
- `id` (GL buffer name), `storageSize`, `storageInitialized` — `Managers.h:598-600`
|
||||
- `contextGeneration` — `Managers.h:603`; compared against `g_bufferContextGeneration`
|
||||
(`Managers.cpp:646`), bumped in `OnBackendContextDestroyed` (`Managers.cpp:1529`)
|
||||
- `std::atomic<Uint64> syncedChangeSerial` — `Managers.h:608`; mirrors the FRONTEND's
|
||||
`GetChangeSerial()`
|
||||
- `pendingRespecify` (`Managers.h:614`), `VecRange1D pendingRanges` (`Managers.h:615`),
|
||||
`Vector<PendingResidentWrite> pendingResidentWrites` (`Managers.h:624`), guarded by
|
||||
`std::mutex pendingMutex` (`Managers.h:625`)
|
||||
- `drawCleanEpoch` — `Managers.h:631`
|
||||
- `persistentMapped`, `persistentPtr` — `Managers.h:637-638`
|
||||
- `immutableStorage` — `Managers.h:644`
|
||||
|
||||
### 1.3 Hook 1 — `Ops_Respecify` (`Managers.cpp:1213-1264`)
|
||||
|
||||
Wrapper `Ops_RespecifyTracked` at `Managers.cpp:1449-1452` (calls impl then
|
||||
`BumpBufferMutationEpoch()`).
|
||||
|
||||
Reads from `BufferObject`: `GetSize()`, `GetUsage()`, `HasDefinedContent()`,
|
||||
`MappedData()`, `GetChangeSerial()` — all via `RespecifyStorageNow`
|
||||
(`Managers.cpp:895-936`).
|
||||
|
||||
Behaviour:
|
||||
- `ResourceOf(bufferObject)` (`Managers.cpp:878-880`) → null ⇒ return (lazy create).
|
||||
- If `resource->immutableStorage` (`Managers.cpp:1224`): the store came from
|
||||
`glBufferStorageEXT` and `glBufferData` cannot respecify it. Clears
|
||||
`persistentMapped/persistentPtr`, and if on the context thread deletes the id
|
||||
(`NoteBufferIdDeleted` + `glDeleteBuffers`, `Managers.cpp:1229-1234`); otherwise leaves
|
||||
it flagged for `EnsureBufferResource` to retire. Sets `pendingRespecify = true` and
|
||||
clears both pending queues.
|
||||
- Off-thread / no id / stale context (`Managers.cpp:1244`): queue `pendingRespecify`.
|
||||
- Size 0 (`Managers.cpp:1250`): drop storage state, no GL.
|
||||
- Otherwise `RespecifyStorageNow` (`Managers.cpp:934`):
|
||||
- `BindBufferId(TempBufferTarget /* = GL_ARRAY_BUFFER, Managers.h:552 */, id)`
|
||||
- `glBufferData(target, size, initialData, usage)`, where `initialData` is
|
||||
`bufferObject.MappedData()` **only if `HasDefinedContent()`** — an orphaning
|
||||
respecify passes NULL so the driver renames without a stall
|
||||
(`Managers.cpp:906-912`).
|
||||
- PipeStats `StageBuffer` bytes accounted only when `initialData != nullptr`
|
||||
(`Managers.cpp:913-919`).
|
||||
- Clears `pendingRespecify`, `pendingRanges`, `pendingResidentWrites`; stamps
|
||||
`syncedChangeSerial` (`Managers.cpp:920-925`).
|
||||
- If the EXTENT moved, `InvalidateIndexedBufferBindingShadowsForId(resource.id)`
|
||||
(`Managers.cpp:933`) — Adreno resolves a whole-buffer indexed binding's extent at
|
||||
bind time, so a grown store would keep the old, smaller range.
|
||||
- **TODO in tree**: orphan-on-respecify as an id-swap is NOT implemented
|
||||
(`Managers.cpp:888-894`).
|
||||
|
||||
### 1.4 Hook 2 — `Ops_SubData` (`Managers.cpp:1266-1297`)
|
||||
|
||||
Tracked wrapper `Managers.cpp:1453-1456`.
|
||||
|
||||
- `pendingRespecify` ⇒ return (full re-upload pending).
|
||||
- No context / no id / stale generation / `!StorageMatches` (`Managers.cpp:939-942`) ⇒
|
||||
`pendingRanges.Add({offset, offset+size})` under `pendingMutex`.
|
||||
- Adopted zero-copy store (`persistentMapped && persistentPtr`, `Managers.cpp:1278`) ⇒
|
||||
bytes already there; just stamp `syncedChangeSerial`. No GL.
|
||||
- `MG_Config::Features.EsprytDisableUploadRing` (negative control) ⇒
|
||||
`UploadRangeNow` (immediate `glBufferSubData`, `Managers.cpp:946-955`).
|
||||
- **Default path**: queue the range only (`Managers.cpp:1295-1296`). This is the Mali
|
||||
WAR-stall fix — an immediate `glBufferSubData` parks the calling thread in
|
||||
`osup_sync_object_wait` (`Managers.cpp:1284-1292`, and `Managers.h:806-826`).
|
||||
|
||||
### 1.5 Hook 3 — `Ops_ResidentSubData` (`Managers.cpp:1304-1312`)
|
||||
|
||||
Tracked wrapper `Managers.cpp:1457-1460`. **Issues no GL at all** — thread-agnostic.
|
||||
Copies the caller's bytes into `resource->pendingResidentWrites` (a
|
||||
`{offset, Vector<Uint8> bytes}` record, `Managers.h:620-624`) under `pendingMutex`.
|
||||
Drained by `DrainResidentWritesNow` (`Managers.cpp:1084-1128`) at draw-time sync
|
||||
(`Managers.cpp:1670`) or at readback (`Managers.cpp:1391`):
|
||||
- stage into `g_uploadRing` + `glCopyBufferSubData(GL_COPY_READ_BUFFER →
|
||||
GL_COPY_WRITE_BUFFER)` (`Managers.cpp:1110-1117`);
|
||||
- fallback direct `glBufferSubData` (`Managers.cpp:1119-1122`) — legal because the
|
||||
adopted store carries `kDynamicStorageBit`.
|
||||
|
||||
This hook exists because an in-place host write into the coherent mapping tears the
|
||||
frames still reading the old bytes (`BufferObject.h:85-94`, `Managers.cpp:1074-1083`).
|
||||
|
||||
### 1.6 Hook 4 — `Ops_FlushMappedRange` (`Managers.cpp:1314-1379`)
|
||||
|
||||
Tracked wrapper `Managers.cpp:1461-1465`.
|
||||
|
||||
- `pendingRespecify` ⇒ return.
|
||||
- Off-thread / mismatched storage ⇒ queue the range (`Managers.cpp:1321-1325`).
|
||||
- Adopted store ⇒ stamp serial, return (`Managers.cpp:1334-1337`). The historical
|
||||
self-copy here mapped a buffer Espryt keeps persistently mapped — an
|
||||
`INVALID_OPERATION` whose fallback WAR-stalled.
|
||||
- Default (ring enabled) ⇒ queue the range (`Managers.cpp:1344-1348`).
|
||||
- Kill-switch path only: honours the app's real mapping flags
|
||||
(`InvalidateRange`/`InvalidateBuffer`/`Unsynchronized`, `Managers.cpp:1353-1356`),
|
||||
optionally `glMapBufferRange(WRITE | INVALIDATE_RANGE? | UNSYNCHRONIZED?)` + `Memcpy`
|
||||
+ `glUnmapBuffer` (`Managers.cpp:1357-1375`), else `UploadRangeNow`.
|
||||
|
||||
### 1.7 Hook 5 — `Ops_OnDestroy` (`Managers.cpp:1421-1447`)
|
||||
|
||||
Tracked wrapper `Managers.cpp:1466-1469`. Takes ownership of the
|
||||
`SharedPtr<BackendBufferResource>` moved out of the dying `BufferObject`.
|
||||
|
||||
Three outcomes:
|
||||
1. Stale `contextGeneration` ⇒ zero `id`, drop (`Managers.cpp:1424-1427`).
|
||||
2. Context current (`CanTouchGLNow()`, `Managers.cpp:882-884`):
|
||||
- `IsPoolable` (`Managers.cpp:700-708`: needs working fences, id != 0,
|
||||
`!persistentMapped`, `!immutableStorage`, live generation, initialized storage,
|
||||
`storageSize <= kMaxPoolableBufferBytes` = 8 MiB `Managers.cpp:694`) ⇒
|
||||
`EnrollIntoPool` (`Managers.cpp:712-745`);
|
||||
- else `InvalidateArrayBufferBindingCache` if bound, `ScrubBufferBindingShadowsForId`,
|
||||
`glDeleteBuffers` (`Managers.cpp:1434-1441`).
|
||||
3. Not on the context thread ⇒ push onto `g_deferredBufferReleases`
|
||||
(`Managers.cpp:669-676`) under `g_deferredBufferReleasesMutex`, and set the lock-free
|
||||
emptiness flag `g_hasDeferredBufferReleases` (`Managers.cpp:673-676`).
|
||||
|
||||
**Deferred-release / delayed-free machinery** (all of this must survive P3a):
|
||||
- Drain: `ProcessDeferredBufferReleases` (`Managers.cpp:1542-1572`), called per draw from
|
||||
`SyncNeccessaryBuffers`/`SyncComputeBuffers` (`DirectGLES.cpp:735` region and
|
||||
`DirectGLES.cpp:717`). Fast-outs on the atomic flag first.
|
||||
- Buffer pool (Mesa-style BO recycle), `Managers.cpp:678-762`:
|
||||
`struct PooledBuffer {id, size, contextGeneration, retireSerial}` (`Managers.cpp:685-690`),
|
||||
`UnorderedMap<SizeT, Vector<PooledBuffer>> g_bufferPool` (`Managers.cpp:691`),
|
||||
budget constants `kMaxPoolableBufferBytes` 8 MiB / `kMaxPoolBytes` 64 MiB /
|
||||
`kMaxEntriesPerBucket` 32 (`Managers.cpp:694-696`).
|
||||
`EnrollIntoPool` stamps `retireSerial = DirectGLES::CurrentFrameSerial() + 1`
|
||||
(`Managers.cpp:737-739` — the `+1` is explained there).
|
||||
`AcquireFromPool(size)` (`Managers.cpp:748-773`) hands back only entries with
|
||||
`retireSerial <= DirectGLES::CompletedFrameSerial()` (`DirectGLES.cpp:10859-10860`).
|
||||
`TrimBufferPool` (`Managers.cpp:1882`) is called once per frame from Present
|
||||
(`DirectGLES.cpp:10928`); `ClearBufferPool` (`Managers.cpp:1913`) on context loss.
|
||||
- The pool reseed path in `EnsureBufferResource` (`Managers.cpp:1657-1685`) does a
|
||||
whole-buffer `glBufferSubData` from `bufferObject->MappedData()`.
|
||||
|
||||
### 1.8 Hook 6 — `Ops_AcquirePersistentMap` (`Managers.cpp:1134-1210`)
|
||||
|
||||
Tracked wrapper `Managers.cpp:1470-1476` (bumps the epoch **even on decline**).
|
||||
|
||||
- Gate: `CanTouchGLNow()` + `glBufferStorageEXT` + `glMapBufferRange` + `glGenBuffers`
|
||||
(`Managers.cpp:1135-1138`); `size == 0` ⇒ null.
|
||||
- Creates the `GLESBufferResource` if absent (`Managers.cpp:1142-1147`) — the one op that
|
||||
calls `bufferObject.SetBackendResource(...)` besides `EnsureBufferResource`.
|
||||
- Stale generation ⇒ wipe the resource fields BEFORE stamping the new generation
|
||||
(`Managers.cpp:1151-1160`), otherwise idempotency would return a dead context's pointer.
|
||||
- Idempotent hit: `persistentMapped && persistentPtr && storageSize == size`
|
||||
(`Managers.cpp:1163-1165`).
|
||||
- Fresh id required: `NoteBufferIdDeleted`, `++g_bufferBackendIdGeneration`,
|
||||
`glDeleteBuffers`, `glGenBuffers` (`Managers.cpp:1169-1179`).
|
||||
- `glBufferStorageEXT(GL_ARRAY_BUFFER, size, bufferObject.MappedData(),
|
||||
GL_MAP_WRITE_BIT | PERSISTENT | COHERENT | DYNAMIC_STORAGE)` — bit constants defined
|
||||
locally at `Managers.cpp:1130-1132` (`0x0040/0x0080/0x0100`). Seeds from the shadow,
|
||||
which is still live at this point (`Managers.cpp:1179-1185`).
|
||||
- `immutableStorage = true` set as soon as the store exists, before the map result
|
||||
(`Managers.cpp:1188`).
|
||||
- `glMapBufferRange(0, size, WRITE|PERSISTENT|COHERENT)`; on failure logs
|
||||
`MGLOG_E_ONCE` and returns null with `persistentMapped=false`
|
||||
(`Managers.cpp:1189-1197`).
|
||||
- Success: stamps `persistentPtr/persistentMapped/storageSize/storageInitialized`,
|
||||
clears both pending queues, stamps `syncedChangeSerial` (`Managers.cpp:1198-1209`).
|
||||
|
||||
Frontend adoption then calls `PipeResource::AdoptPersistentMap` (`PipeResource.h:113-117`),
|
||||
which **drops the CPU shadow**. Espryt itself never calls `EnsureGpuResidentStorage`
|
||||
(only Magma does: `DirectVulkan/Renderer/UniformManager.cpp:1073,1229`,
|
||||
`VulkanRenderer.cpp:11620`); Espryt reaches adoption purely through the frontend's
|
||||
`TryAdoptLargeStorage` (`BufferObject.cpp:186-196`, threshold 16 MiB, kill switch
|
||||
`MG_Config::Features.DisableLargeBufferAdoption`) and through coherent persistent maps in
|
||||
`AcquireMemoryRange`.
|
||||
|
||||
### 1.9 Hook 7 — `Ops_ReadbackFromGpu` (`Managers.cpp:1382-1419`)
|
||||
|
||||
Tracked wrapper `Managers.cpp:1477-1480`.
|
||||
|
||||
- Bails on no resource / id 0 / uninitialized storage / off-thread / stale generation
|
||||
(`Managers.cpp:1384-1386`).
|
||||
- **Adopted store branch** (`Managers.cpp:1387-1394`): `DrainResidentWritesNow` then
|
||||
`glFinish()`. There is no backend copy to read back — the coherent mapping IS the data.
|
||||
- Otherwise: `FlushPendingRangesNow` first (`Managers.cpp:1404`) so queued app writes are
|
||||
not reverted, then `BindBufferId` + `glMapBufferRange(0, size, GL_MAP_READ_BIT)`,
|
||||
`bufferObject.WritebackFromBackend({mapped, size}, 0)` (`Managers.cpp:1410`),
|
||||
`glUnmapBuffer`, then stamp `syncedChangeSerial` so the next draw does not re-upload the
|
||||
readback over itself (`Managers.cpp:1413-1418`).
|
||||
|
||||
### 1.10 Registration lifecycle and the mutation epoch
|
||||
|
||||
- `RegisterBufferBackendOps` (`Managers.cpp:1505-1510`) — called from
|
||||
`BackendObject_DirectGLES::Initialize` (`BackendObject_DirectGLES.cpp:849`) and from
|
||||
every `MakeCurrent` (`DirectGLES.cpp:10402`).
|
||||
- `UnregisterBufferBackendOps` (`Managers.cpp:1512-1525`) — also clears the pool and the
|
||||
deferred-release list.
|
||||
- `OnBackendContextDestroyed` (`Managers.cpp:1527-1540`) — bumps
|
||||
`g_bufferContextGeneration`, invalidates every binding cache, and resets the UBO and
|
||||
unpack rings. Called from `DirectGLES.cpp:10938`.
|
||||
- **Buffer-mutation epoch**: `g_bufferMutationEpoch` (`Managers.cpp:653`),
|
||||
`CurrentBufferMutationEpoch`/`BumpBufferMutationEpoch` (`Managers.cpp:1493-1503`). The
|
||||
exhaustive list of bump sites and the acquire/release rules is documented at
|
||||
`Managers.h:556-590` — read it before touching anything, it is the correctness contract
|
||||
for the draw-clean memos.
|
||||
- `g_bufferBackendIdGeneration` (`Managers.cpp:1502`, declared `Managers.h:706`): bumped
|
||||
whenever a LIVE resource's driver id is re-minted (persistent-map adoption at
|
||||
`Managers.cpp:1173`, immutable-store retire at `Managers.cpp:1639`), because VAO twins
|
||||
bake ids against frontend versions that do not move.
|
||||
|
||||
### 1.11 Three persistent-mapped rings + shared machinery
|
||||
|
||||
Documented at `Managers.h:729-825`; implemented `Managers.cpp:764-870` (types) and
|
||||
`1922-2204` (create/allocate/present).
|
||||
|
||||
- `PersistentRingStore` (`Managers.cpp:800-819`), `RetiredRingStore` (`:823-827`),
|
||||
`RingFrameMark` (`:832-835`), `PersistentRing` (`:839-849`).
|
||||
- Instances: `g_uboRing` (`Managers.cpp:851`), `g_unpackRing` (`:852-858`),
|
||||
`g_uploadRing` (`:867-873`). Caps: 4 MiB initial / 64 MiB max each
|
||||
(`Managers.cpp:770-784`).
|
||||
- `CreateRingStorage` (`Managers.cpp:1930-1983`) — `glBufferStorageEXT` +
|
||||
`glMapBufferRange` persistent|coherent; retires the old store onto `ring.retired` with
|
||||
`CurrentFrameSerial()+1`.
|
||||
- `RingAvailable` (`Managers.cpp:1989-2000`) — self-heals a stale context generation via
|
||||
`ResetRingForNewContext` (`Managers.cpp:866-876`).
|
||||
- `RingAllocate` fast path `Managers.cpp:2016-2038`, slow path from `:2040`.
|
||||
- Exported wrappers `Managers.cpp:2172-2203`. Present-time upkeep is called from
|
||||
`DirectGLES.cpp:10925-10928` (`UboRingOnPresent`, `UnpackRingOnPresent`,
|
||||
`UploadRingOnPresent`, `TrimBufferPool`).
|
||||
- Upload-ring gate for the buffer path: `UploadRingUsableNow` (`Managers.cpp:963-967`) —
|
||||
kill switch `Features.EsprytDisableUploadRing`, `glCopyBufferSubData` present, ring up.
|
||||
- `FlushPendingRangesNow` (`Managers.cpp:1004-1072`) is the three-tier drain and the
|
||||
single most delicate function in the file:
|
||||
1. `glMapBufferRange(WRITE | INVALIDATE_BUFFER|INVALIDATE_RANGE)` + memcpy, taken only
|
||||
for a whole-buffer flush or a range `>= kInvalidateRangeMinBytes` (128 KiB,
|
||||
`Managers.cpp:975`) — `Managers.cpp:1054-1067`;
|
||||
2. upload ring + `glCopyBufferSubData` — `Managers.cpp:1058-1067` (ring branch at
|
||||
`:1069-1076` in the listing order shown by the file: `RingAllocate`, `Memcpy`,
|
||||
`BindBufferId(GL_COPY_READ_BUFFER/GL_COPY_WRITE_BUFFER)`, copy);
|
||||
3. direct `UploadRangeNow`.
|
||||
Ranges are flushed **as queued** (`VecRange1D::Add` already merges near-adjacent ones);
|
||||
collapsing to the union re-copied whole chunk arenas — `Managers.cpp:1000-1003`.
|
||||
Kill switch `Features.EsprytDisableInvalidateFlush` (`Managers.cpp:1017`) forces tier 2.
|
||||
- Unpack ring consumers (texture uploads, not buffers, but the same allocator):
|
||||
`Managers.cpp:3153,3172,3174,4484,4510,4562`.
|
||||
- UBO ring consumer: `DirectGLES.cpp:3652-3684` (global default-uniform block).
|
||||
|
||||
**Observation, low risk**: `OnBackendContextDestroyed` (`Managers.cpp:1537-1538`) resets
|
||||
`g_uboRing` and `g_unpackRing` but not `g_uploadRing`; `RingAvailable`
|
||||
(`Managers.cpp:1996-1998`) heals it on first use, so this is benign today but is an
|
||||
asymmetry worth preserving-or-fixing deliberately in P3a.
|
||||
|
||||
---
|
||||
|
||||
## 2. Every place Espryt holds or dereferences a frontend `BufferObject`
|
||||
|
||||
### 2.1 The twin registry question — answered
|
||||
|
||||
**The buffer twin is NOT one of the six `{slot, gen}` slot tables.** The six tables
|
||||
(`SlotTables.h:1-80` explains the mechanism) are, by their `MGPipeKind` template argument:
|
||||
|
||||
| Kind | Declared | Defined |
|
||||
|---|---|---|
|
||||
| `VertexElementsCso` (VAO) | `Managers.h:954` | `Managers.cpp:2877` |
|
||||
| `Texture` | `Managers.h:1275` | `Managers.cpp:5205` |
|
||||
| `Framebuffer` | `Managers.h:1366` | `Managers.cpp:5958` |
|
||||
| `ShaderCso` (program) | `Managers.h:1884` | `Managers.cpp:6269` |
|
||||
| `SamplerCso` | `Managers.h:1984` | `Managers.cpp:8787` |
|
||||
| `Renderbuffer` | `Managers.h:2011` | `Managers.cpp:8899` |
|
||||
|
||||
The `TwinRegistry` alias itself is `Managers.h:544-549`; `StateBackendObjectRegistry` is
|
||||
`Managers.h:300`.
|
||||
|
||||
Buffers instead use **owner-embedded twinning**: the `GLESBufferResource` is owned by the
|
||||
frontend `BufferObject` through `PipeResource::m_backend`
|
||||
(`PipeResource.h:127-131`), reached by `GetBackendResource()` /
|
||||
`SetBackendResource()` (`BufferObject.cpp:611,615`). Espryt's only accesses:
|
||||
|
||||
- `Managers.cpp:879` — `ResourceOf(BufferObject&)`, the ops' accessor
|
||||
- `Managers.cpp:1142`, `1146` — `Ops_AcquirePersistentMap` get + create
|
||||
- `Managers.cpp:1576` — `GetBufferResource(BufferObject*)` (no GL)
|
||||
- `Managers.cpp:1582` — `IsBufferDrawClean` identity compare
|
||||
- `Managers.cpp:1608`, `1613` — `EnsureBufferResource` get + create
|
||||
|
||||
Consequence for P3a: there is no existing slot table to extend; the buffer kind's
|
||||
`{slot, gen}` table has to be introduced, and `SetBackendResource` disappears (matching
|
||||
`docs/Disaggregated/ARCHITECTURE.md:284`, "`SetBackendResource` 删除(server 拥有资源表)").
|
||||
|
||||
### 2.2 Keyed by what, today
|
||||
|
||||
| Key | Site | Use |
|
||||
|---|---|---|
|
||||
| Raw `BufferObject*` | `DirectGLES.cpp:626` (`syncedBuffers[]` dedupe scratch), `DirectGLES.cpp:635` (`bufferKey`) | per-draw dedupe of the attribute walk |
|
||||
| Raw `BufferObject*` | `Managers.h:915-923` (`ResolvedDrawBuffers::Entry::frontend`, `iboFrontend`) | VAO draw-buffer memo; pinned by the VAO's attribute `SharedPtr`s |
|
||||
| Raw `const BufferObject*` | `Managers.cpp:2452`, `2636` (`m_syncedIndexBufferObject`) | IBO identity compare against a wrapping `Uint16` slot version |
|
||||
| `GetLifetimeId()` | `Managers.cpp:2812-2820` (`stream.sourceLifetimeId`) | fp64 → fp32 converted-stream memo key |
|
||||
| `GetChangeSerial()` | `Managers.cpp:2814`, `Managers.h:608` (`syncedChangeSerial`) | staleness of converted streams / backend storage |
|
||||
| `SharedPtr<BufferObject>` | `DirectGLES.cpp:747` (`XfbCaptureTarget::buffer`) | keeps the capture target alive across a span |
|
||||
| `SharedPtr<BufferObject>` (by value/ref from PipeInputs) | every `EnsureBufferResource(...)` call | see the site list below |
|
||||
|
||||
### 2.3 `EnsureBufferResource` / `GetBufferResource` call sites (Espryt)
|
||||
|
||||
`Managers.cpp`:
|
||||
- `2337` `BindAttributeBuffer` (vertex attribute → `GL_ARRAY_BUFFER`)
|
||||
- `2393` `SyncZeroStrideAttribute` (→ `glBindVertexBuffer`)
|
||||
- `2622` `BackendVertexArrayObject::SyncToBackend`, index-buffer branch (→ `GL_ELEMENT_ARRAY_BUFFER`)
|
||||
- `4724` texture-buffer (`TextureStorageType::Buffer`) → `glTexBuffer`/`glTexBufferRange`
|
||||
|
||||
`DirectGLES.cpp`:
|
||||
- `411` `SyncBufferBindingPoints` (indexed UBO/SSBO/XFB points)
|
||||
- `463` region `SyncTransformFeedbackBindingPoints`
|
||||
- `526` `SyncAtomicCounterBuffers` (mapped onto reserved SSBO bindings)
|
||||
- `560` `SyncBoundBuffer` (DrawIndirect / DispatchIndirect)
|
||||
- `612`, `645` the `ResolvedDrawBuffers` memo repair and full walk
|
||||
- `681` IBO memo miss
|
||||
- `4185`, `4247` indirect-draw `mg_IndirectParams` SSBO view
|
||||
- `4631` `BoundElementArrayBufferId()`
|
||||
- `9411` `glReadPixels` pack PBO
|
||||
- `9837` `glGetTexImage` pack PBO
|
||||
|
||||
### 2.4 Reads of `BufferObject` members from backend code
|
||||
|
||||
| Member | Espryt sites |
|
||||
|---|---|
|
||||
| `GetSize()` | `Managers.cpp:897, 1006 (limit), 1139, 1396, 1653, 1698, 1701, 2777, 4789 (via GetBufferRangeSizeInBytes compare), 4795`; `DirectGLES.cpp:299, 432-435 (range clamp), 480-483, 502-506, 7887, 7889, 9456, 9459, 9866, 9869`; `Utils.cpp:2322` |
|
||||
| `GetUsage()` | `Managers.cpp:903` |
|
||||
| `GetChangeSerial()` | `Managers.cpp:925, 1207, 1280, 1336, 1377, 1417, 1600, 1684, 1710-1714 (compare), 2814` |
|
||||
| `GetLifetimeId()` | `Managers.cpp:2813` |
|
||||
| `MappedData()` (host-visible base — shadow OR coherent map) | `Managers.cpp:911, 952, 1055, 1063, 1184, 1367, 1668, 2775`; `DirectGLES.cpp:301, 4965 region (restart rewrite `source = indexBuffer->MappedData()`), 5031-5038, 5074-5081`; `MultiDraw.cpp:513` |
|
||||
| `HasDefinedContent()` | `Managers.cpp:911` |
|
||||
| `IsMapped()` | `Managers.cpp:1594` (`IsBufferDrawClean`) |
|
||||
| `IsBackendPersistentMapped()` | `Managers.cpp:2815`; `DirectGLES.cpp:851` |
|
||||
| `GetExternalIndex()` (GL name, diagnostics only) | `Managers.cpp:4711`; `DirectGLES.cpp:9412, 9415, 9838, 9841` |
|
||||
| `GetBackendResource()` | §2.1 list |
|
||||
| `MarkGpuWritten()` | `DirectGLES.cpp:500` (`MarkShaderStorageBuffersGpuWritten`), `544` (`SyncAtomicCounterBuffers`), `2012` (`MarkWritableImageBufferTexturesGpuWritten`) |
|
||||
| `WritebackFromBackend()` | `DirectGLES.cpp:868` (XFB `ReadbackCapturedRanges`), `976` (`ScatterCapturedRecords`), `7896` (`StoreReadbackRowsToClient`), `9460` (`glReadPixels` PBO), `9870` (`glGetTexImage` PBO); `Managers.cpp:1410` (`Ops_ReadbackFromGpu`); `Utils.cpp:2343` (`ReadPixelsViaFormatConversion`) |
|
||||
| `SyncPersistentMappedRange()` / `SyncGpuWrites()` | §3 |
|
||||
|
||||
Note the "dirty ranges" question: Espryt never reads a frontend dirty-range list — the
|
||||
frontend has none. Ranges arrive only as op arguments and live on the BACKEND resource
|
||||
(`pendingRanges`).
|
||||
|
||||
`MGB_CTX` is the pushed `PipeInputs` block: `MG_Pipe/PipeInputsSwitch.h:19` (push) /
|
||||
`:24` (pull). The buffer accessors that hand Espryt a `SharedPtr<BufferObject>` are
|
||||
`PipeInputs::GetBufferBindingSlot` (`MG_Backend/MGPipe/PipeInputs.h:485-495`) and
|
||||
`GetBufferBindingPoint` (`:496-508`); the fill-point coverage is
|
||||
`MG_Pipe/FillPoints.def:156-158, 204-206, 269, 286, 289, 310-311` and
|
||||
`MG_Pipe/Coverage.def:42-45`.
|
||||
|
||||
---
|
||||
|
||||
## 3. `SyncPersistentMappedRange` and `SyncGpuWrites`
|
||||
|
||||
### 3.1 What they do (frontend)
|
||||
|
||||
`SyncPersistentMappedRange` — `BufferObject.cpp:291-303`. Returns immediately unless the
|
||||
buffer is mapped, NOT GPU-resident, PERSISTENT, WRITE, not FLUSH_EXPLICIT, with a
|
||||
non-empty mapped range. Then it calls `NotifySubData(start, len)` — i.e. it synthesises a
|
||||
`SubData` op for a write that never went through any GL entry point. For a GPU-resident
|
||||
(adopted) buffer it is a pure no-op (`BufferObject.cpp:295`).
|
||||
|
||||
`SyncGpuWrites` — `BufferObject.cpp:319-328`. If `m_gpuWritePending` (set by
|
||||
`MarkGpuWritten`, `BufferObject.cpp:314-317`), clears the flag **unconditionally** and
|
||||
dispatches `ReadbackFromGpu`.
|
||||
|
||||
### 3.2 Espryt's share of the 20 `SyncPersistentMappedRange` sites — 8
|
||||
|
||||
| Site | Context |
|
||||
|---|---|
|
||||
| `DirectGLES.cpp:297` | `ResolveIndirectCommandBytes` — before reading indirect commands from the shadow |
|
||||
| `DirectGLES.cpp:4710` | restart-substitution: element buffer, immediately followed by `SyncGpuWrites()` at `:4711` |
|
||||
| `DirectGLES.cpp:4964`, `:4965` | `MultiDrawElementsIndirectCount` — draw + parameter buffer |
|
||||
| `DirectGLES.cpp:5066`, `:5067` | `MultiDrawArraysIndirectCount` — draw + parameter buffer |
|
||||
| `Managers.cpp:1700` | `EnsureBufferResource` — the per-draw push, before respecify/flush |
|
||||
| `MultiDraw.cpp:511` | multi-draw index flattening |
|
||||
|
||||
(The other 11 backend sites are Magma's: `DirectVulkan.cpp:281,472,796`,
|
||||
`UniformManager.cpp:2024`, `VkBufferManager.cpp:628,679`,
|
||||
`VulkanRenderer.cpp:3542,3621,4016,7431,12426,12427`; plus the definition and the test
|
||||
sites.)
|
||||
|
||||
### 3.3 Espryt's share of the 6 `SyncGpuWrites` backend sites — 3
|
||||
|
||||
| Site | Context |
|
||||
|---|---|
|
||||
| `DirectGLES.cpp:4711` | restart substitution reads the index shadow |
|
||||
| `Managers.cpp:2774` | `SyncFloat64AttributeAsFloat32` before narrowing doubles from the shadow |
|
||||
| `MultiDraw.cpp:512` | multi-draw index flattening |
|
||||
|
||||
(Magma's three: `VulkanRenderer.cpp:3541, 4015, 4349`. The frontend's two are
|
||||
`MG_Impl/GLImpl/Buffer/GL_Buffer.cpp:957, 995` — `glGetBufferSubData` /
|
||||
`glGetNamedBufferSubData`.)
|
||||
|
||||
### 3.4 What a server without the frontend's address space needs instead
|
||||
|
||||
Both calls are the backend reaching **backwards** into client memory:
|
||||
|
||||
- `SyncPersistentMappedRange` exists only because the app writes into the shadow with no
|
||||
API call. A server cannot observe that. The design already names the replacement:
|
||||
a client-side tracker `m_livePersistentMaps` pushing block-granular dirty ranges at each
|
||||
validate point, over the union of exactly these 20 sites, chunked by
|
||||
`MOBILEGL_IPC_PERSISTENT_BLOCK_KB` (default 64) — `ARCHITECTURE.md:482`. Phase 1 is
|
||||
conservative (whole mapped span, block-split), Phase 2 exact (64 KiB dirty bits +
|
||||
`memcmp`). Also `ARCHITECTURE.md:481`: `ResourceRespecify/SubData` carry a
|
||||
`hasLiveHostWrites` bit — the one thing `IsBufferDrawClean` (`Managers.cpp:1594`) needs
|
||||
from the map state, with zero new record kinds.
|
||||
- The five Espryt sites that follow `SyncPersistentMappedRange` with a **CPU read of
|
||||
`MappedData()`** (`DirectGLES.cpp:301`, `:4965`, `:5031-5038`, `:5074-5081`,
|
||||
`MultiDraw.cpp:513`) are the harder half: they are `*IndirectCount` count resolution,
|
||||
restart rewriting and multi-draw flattening. `ARCHITECTURE.md:221` moves
|
||||
`*IndirectCount` count resolution to the CLIENT (server receives resolved
|
||||
`MGPDrawRange[]`); `ARCHITECTURE.md:106` adds `kCapNeedsHostIndexBytes` so restart
|
||||
rewriting / multi-draw flattening get an index mirror on the server side
|
||||
(`ARCHITECTURE.md:387`, budget `MOBILEGL_PIPE_INDEX_MIRROR_MB` default 64).
|
||||
- `SyncGpuWrites` becomes the `OnGpuWritten(res, rangeCount, ranges)` reverse callback
|
||||
(`MG_Pipe/MGPipeCallbacks.h:30-31`), and `WritebackFromBackend` becomes
|
||||
`OnBufferWriteback(res, offset, bytes)` (`MGPipeCallbacks.h:32`), batched per operation,
|
||||
ordered with respect to the epoch bump (`ARCHITECTURE.md:275`, `:288`).
|
||||
- Espryt's two remaining `SyncGpuWrites` consumers (fp64 narrowing at `Managers.cpp:2774`,
|
||||
index flattening at `MultiDraw.cpp:512`) both read `MappedData()` right after — same
|
||||
index-mirror / client-side-resolution treatment.
|
||||
|
||||
---
|
||||
|
||||
## 4. Readback paths and write-back into the frontend
|
||||
|
||||
### 4.1 `glGetBufferSubData` (frontend, not Espryt)
|
||||
|
||||
`MG_Impl/GLImpl/Buffer/GL_Buffer.cpp:957` and `:995` call `SyncGpuWrites()` then
|
||||
`DownloadSubData` (`BufferObject.cpp:434`), which reads `m_resource.Bytes()` — the shadow
|
||||
or the coherent map. Espryt's contribution is only `Ops_ReadbackFromGpu`
|
||||
(`Managers.cpp:1382`). A non-persistent mapping makes the call an `INVALID_OPERATION`
|
||||
(`GL_Buffer.cpp:948-955`).
|
||||
|
||||
### 4.2 Map-read
|
||||
|
||||
`BufferObject::AcquireMemory` (`BufferObject.cpp:466`) and `AcquireMemoryRange`
|
||||
(`BufferObject.cpp:518`) call `SyncGpuWrites()` (`:467`, `:537`) and hand back a pointer
|
||||
into `PipeResource::Bytes()`. Espryt never sees a read map directly — the reconciliation
|
||||
is the `ReadbackFromGpu` op.
|
||||
|
||||
### 4.3 Pack-PBO readback (Espryt owns these)
|
||||
|
||||
Four distinct writeback shapes, all landing through `WritebackFromBackend` and each
|
||||
followed by `BumpBufferMutationEpoch()`:
|
||||
|
||||
1. `glReadPixels` native + PBO: `DirectGLES.cpp:9406-9468`. Resolves the PBO via
|
||||
`EnsureBufferResource` (`:9411`), scopes the driver binding with
|
||||
`ScopedPixelPackBuffer` (`DirectGLES.cpp:6435-6441`), `glReadPixels`, then maps the PBO
|
||||
read-only and `WritebackFromBackend({pboMappedPtr, size}, 0)` (`:9460`), epoch bump
|
||||
(`:9462`).
|
||||
2. `glGetTexImage` + PBO: `DirectGLES.cpp:9832-9880`, structurally identical (`:9870`).
|
||||
3. Row-by-row conversion readbacks: `StoreReadbackRowsToClient`
|
||||
(`DirectGLES.cpp:7876-7906`) — per-row `WritebackFromBackend` at `:7896`, ONE epoch
|
||||
bump for the whole loop at `:7903`. Same shape in
|
||||
`Utils.cpp:2297-2354` (`:2343` writeback, `:2352` bump).
|
||||
4. Transform feedback: `XfbImpl::ReadbackCapturedRanges` (`DirectGLES.cpp:838-878`) maps
|
||||
each capture range read-only and writes back at `:868` (+ bump `:872`); persistently
|
||||
mapped targets are skipped at `:851`. `ScatterCapturedRecords`
|
||||
(`DirectGLES.cpp:918-985`) is a read-modify-write of the frontend shadow: it starts
|
||||
from `target.buffer->MappedData()` (`:961`), patches the captured varyings in, writes
|
||||
back (`:976`), bumps (`:978`), and re-uploads with `glBufferSubData` (`:980-984`).
|
||||
`ARCHITECTURE.md:310` and `MGPipeCallbacks.h:49-51` (`OnXfbScatterReady`) already
|
||||
specify how this survives the split — the scatter loop moves to the client.
|
||||
|
||||
Driver-side pack/unpack binding shadows that every readback routes through:
|
||||
`BindPixelPackBufferId` (`Managers.cpp:1739`), `BindPixelUnpackBufferId`
|
||||
(`Managers.cpp:1748`), `InvalidatePixelBufferBindingCaches` (`Managers.cpp:1757`),
|
||||
`NoteBufferIdDeleted` (`Managers.cpp:1764`). Resting state is 0; the reason is documented
|
||||
at `Managers.h:670-682`.
|
||||
|
||||
---
|
||||
|
||||
## 5. The Adreno SIGSEGV workaround the roadmap says to keep
|
||||
|
||||
`ROADMAP.md:19` names it as "Adreno SIGSEGV workaround 保留". `ARCHITECTURE.md:316`
|
||||
repeats it in the server-local-invariants list ("Adreno 禁用属性 SIGSEGV workaround").
|
||||
`grep SIGSEGV` in `MobileGL/MG_Backend/DirectGLES/` returns exactly three hits, and they
|
||||
are **two distinct workarounds plus one cross-reference**:
|
||||
|
||||
### 5.1 GL_DOUBLE / IsLong attribute with no buildable stream
|
||||
|
||||
`Managers.cpp:2517-2540` (rationale `:2516-2521`, and the forward reference at
|
||||
`Managers.h:888-895`): becoming long bumps `FormatVersion`, not `SwitchVersion`, so the
|
||||
enable/disable block above does not re-run and an already-enabled array would stay enabled
|
||||
with **no pointer and no `GL_ARRAY_BUFFER` binding**. That is not merely
|
||||
`GL_INVALID_ENUM` — "the Adreno driver dereference[s] null inside the next draw and take[s]
|
||||
the process with it (SIGSEGV in libGLESv2_adreno,
|
||||
KHR-GL43.vertex_attrib_binding.basic-input-case4)". Fix: try
|
||||
`SyncFloat64AttributeAsFloat32` (`Managers.cpp:2757-2874`), and on failure
|
||||
`glDisableVertexAttribArray(attribIndex)` (`Managers.cpp:2537`) with a `MGLOG_W_ONCE`.
|
||||
Note the re-enable at `Managers.cpp:2529` is explicitly non-redundant.
|
||||
|
||||
### 5.2 GL_BGRA vertex size refused by the driver
|
||||
|
||||
`Managers.cpp:2568-2612` (rationale `:2568-2582`). ES has no `GL_BGRA` vertex size; the
|
||||
rejection "leaves the array ENABLED with no pointer, and the Adreno driver then
|
||||
dereferences null inside the next draw and kills the process rather than reporting an
|
||||
error (SIGSEGV in libGLESv2_adreno,
|
||||
KHR-GL43.vertex_attrib_binding.basic-input-case5)". Mechanism: drain `glGetError` before
|
||||
the call (`Managers.cpp:2585-2588`), issue `glVertexAttribPointer` with
|
||||
`GL_BGRA` as the size (`Managers.cpp:2593-2596`), and if `glGetError() != GL_NO_ERROR`
|
||||
(`Managers.cpp:2603`) disable the array. Deliberately **only** for `attrib.IsBgra` — the
|
||||
comment says the per-draw sync must not grow a `glGetError` round trip for real formats.
|
||||
|
||||
Both live inside `BackendVertexArrayObject::SyncToBackend`, i.e. in P3a's vertex-elements
|
||||
half, and both depend on being able to observe a DRIVER error at attribute-declaration
|
||||
time — which under a split means the check has to stay server-side and the disable has to
|
||||
be a server-local decision, not a client one.
|
||||
|
||||
---
|
||||
|
||||
## 6. Test coverage that P3a must keep green
|
||||
|
||||
### 6.1 `MG_IntegrationTest` scenarios touching buffers on Espryt
|
||||
|
||||
Roadmap-named (`ROADMAP.md:19`): `LargeArenaAdoption`, `StorageBufferRegrow` (publishes
|
||||
`map-persistent-roundtrips`), `VertexAttribBinding`, `MultiDraw`, `PrimitiveRestart`.
|
||||
|
||||
Full `TEST_F` names, by file under `MobileGL/MG_IntegrationTest/Scenarios/`:
|
||||
|
||||
- `LargeArenaAdoptionScenario.cpp` — `SubDataAfterAnInFlightDrawReachesTheNextDraw` (:204),
|
||||
`ReadbackSeesTheLatestCpuWrite` (:227), `GpuWriteIntoTheArenaIsReadBack` (:245). File
|
||||
header at `:13` names `TryAdoptLargeStorage` explicitly.
|
||||
- `ResidentIndexScenario.cpp` — `PersistentCoherentEboWrittenEveryFrame` (:186),
|
||||
`EboAlsoBoundAsVertexBufferLater` (:225), `EboDeletedAndRecreatedAtTheSameName` (:271),
|
||||
`OneEboTwoVaosMutatedAcrossFrames` (:311), `PromotedDynamicEbo` (:351). Header comment at
|
||||
`:40` names `BufferObject::SyncPersistentMappedRange`.
|
||||
- `StorageBufferRegrowScenario.cpp` — `AGrownStoreIsVisibleThroughItsExistingIndexedBinding`
|
||||
(:124). This is the case behind `InvalidateIndexedBufferBindingShadowsForId`
|
||||
(`Managers.cpp:933`).
|
||||
- `CrossFrameBufferScenario.cpp` — `VertexBufferSubData` (:409), `VertexMapWriteUnmap`
|
||||
(:414), `VertexPersistentMapFlush` (:419), `VertexPersistentCoherentWrite` (:425),
|
||||
`VertexOrphanAndReupload` (:431), `VertexCopyBufferSubData` (:437), `IndexBufferSubData`
|
||||
(:446), `IndexMapWriteUnmap` (:451), `IndexPersistentMapFlush` (:456),
|
||||
`IndexPersistentCoherentWrite` (:481), `IndexOrphanAndReupload` (:487),
|
||||
`IndexCopyBufferSubData` (:493), `PartialStalenessIsCaughtByWholeRegionChecks` (:518);
|
||||
plus `StreamedArenaScenario` in the same file: `StreamedVertexDataSurvivesArenaRecycling`
|
||||
(:675), `StreamedIndexDataSurvivesArenaRecycling` (:731) — these two are the buffer-pool
|
||||
recycle cases.
|
||||
- `BufferTextureScenario.cpp` — `VertexStageTexelFetchReadsTheBufferAndTracksItsUpdates`
|
||||
(:162), `AnImageStoreIntoABufferTextureIsVisibleToTheCpu` (:238),
|
||||
`LevelQueriesDescribeTheAttachedBufferRange` (:311). Covers `Managers.cpp:4707-4800`.
|
||||
- `XfbCaptureBufferReuseScenario.cpp` — `EverySpanIntoABufferObjectOfItsOwn` (:182),
|
||||
`EverySpanIntoOneRespecifiedBufferObject` (:215),
|
||||
`ARespecificationMayChangeTheCaptureBufferSize` (:243),
|
||||
`EverySpanIntoOneImmutableStorageBuffer` (:283).
|
||||
- `AtomicCounterScenario.cpp` — `DispatchIncrementsTheBoundCounterBuffers` (:172),
|
||||
`CountersAccumulateAcrossDispatchesAndFollowAReseed` (:201),
|
||||
`SubDataAfterDispatchSurvivesAnImmediateReadback` (:242) — the `MarkGpuWritten` /
|
||||
`ReadbackFromGpu` round trip.
|
||||
- `PrimitiveRestartScenario.cpp` — 7 cases (:215, :236, :263, :281, :306, :332, :368);
|
||||
these drive the `MappedData()` index rewrite at `DirectGLES.cpp:4964-4980`.
|
||||
- `MultiDrawScenario.cpp` — 10 cases (:225 … :526); drive `MultiDraw.cpp:495-525`.
|
||||
- `PackedWordReadbackScenario.cpp` — :148, :167, :194 (PBO/readback writeback paths).
|
||||
- `VertexAttribBindingScenario.cpp`, `VertexArrayEnableDisableScenario.cpp`,
|
||||
`DoublePrecisionScenario.cpp` — the vertex-elements half incl. the fp64 narrowing and
|
||||
the two SIGSEGV workarounds.
|
||||
|
||||
### 6.2 Unit tests
|
||||
|
||||
- `MobileGL/MG_Test/Buffer/BufferTest.cpp` — 88 `TEST` macros. The ones that exercise the
|
||||
ops table directly use mock tables defined in-file: `kZeroCopyMockOps` (:1609),
|
||||
`kResidentSubDataMockOps` (:1640), `ScopedBackendOps` RAII (:1651-1654). Directly
|
||||
ops-shaped cases: `General_PersistentCoherentZeroCopyStressNoPerDrawReupload` (:1658),
|
||||
`General_PersistentCoherentFallbackSyncsPerDrawWhenBackendDeclines` (:1724),
|
||||
`General_CoherentAsFlush_*` (:1778, :1809, :1819, :1855, :1890),
|
||||
`RedefiningAnAdoptedBufferHandsTheMappingBack` (:1952),
|
||||
`RedefiningAnAdoptedBufferAtANewSizeStaysInBounds` (:1990),
|
||||
`ImmutableStorageOnAnAdoptedBufferHandsTheMappingBackToo` (:2029),
|
||||
`RedefiningAnAdoptedBufferToZeroBytesLeavesItOnTheShadow` (:2058),
|
||||
`RedefiningANonAdoptedBufferIsUnchanged` (:2093), the adopted-store map/unmap family
|
||||
(:2165, :2204, :2248, :2279, :2316), the `ResidentSubData` family (:2364, :2412, :2557,
|
||||
:2616, :2698), `MapBufferRangeAndUnmapBufferReseedAnAdoptedShaderStorageBuffer` (:2451),
|
||||
`ANonPersistentWriteMapOfAShadowBackedStoreStillFlushesThroughTheBackend` (:2483),
|
||||
`GlBufferSubDataIntoAnAdoptedStoreLandsInPlaceWithoutABackendTransfer` (:2533),
|
||||
`GlClearBufferSubDataRepeatsItsPatternThroughAnAdoptedStoreInPlace` (:2589),
|
||||
`GlCopyBufferSubDataIntoAnAdoptedStoreLandsAtTheDestinationOffset` (:2665),
|
||||
`AnExplicitFlushOfAPersistentMapOfAnAdoptedStoreOnlyPublishesTheChange` (:2733),
|
||||
`AZeroLengthExplicitFlushOfAnAdoptedStoreLeavesItUndefined` (:2779),
|
||||
`AWriteMapThatDiscardsWhatItMapsDoesNotReconcileAnAdoptedStoreAtMapTime` (:2817),
|
||||
`AStorageBindingDoesNotAdoptTheStoreWhileTheApplicationHoldsAMapping` (:2868),
|
||||
`RespecifyingAStoreWhileItIsMappedDoesNotLandTheStagedBytesIntoIt` (:2917),
|
||||
`RespecifyingAShadowBackedStoreWhileItIsMappedPushesNoRangeDown` (:2943).
|
||||
- `MobileGL/MG_Test/SanityTest.cpp:2535` —
|
||||
`DirectGLESStateGuards.PixelPackBindingCacheSkipsRedundantBindsAndRestsAtZero`, the only
|
||||
unit test that pokes `BufferImpl` symbols directly (`:2539-2551`).
|
||||
- `MobileGL/MG_Test/Backend/DirectGLES/` contains **no** buffer tests
|
||||
(`BaseInstanceInjectionTest.cpp`, `EsslShaderPassTest.cpp`,
|
||||
`ViewportIndexRoutingTest.cpp` only). `MG_Test/SelfTest/` likewise has none.
|
||||
- No unit test covers `EnsureBufferResource`, `IsBufferDrawClean`, the pool, the rings, or
|
||||
the deferred-release list — those are integration-only today. Worth knowing before P3a
|
||||
refactors them.
|
||||
|
||||
### 6.3 Trace cases the roadmap names (`ROADMAP.md:19` — "Create/rd12/26.3/sodium trace")
|
||||
|
||||
Fixtures present in `tools/trace_replay/fixtures/`:
|
||||
|
||||
| Roadmap name | Fixture |
|
||||
|---|---|
|
||||
| Create ×2 | `minecraft-1.21.1-neoforge-create-indirect-in-world.tgz` (ref `.0000504631.png`) and `minecraft-1.21.1-neoforge-create-instancing-in-world.tgz` (ref `.0000530333.png`) |
|
||||
| rd12 | `minecraft-1.21.4-rd12-odinlite-in-world.tgz` (ref `.0004660351.png`) |
|
||||
| 26.3 | `improved-transparency-minecraft-26.3.tgz` (ref `.0002667619.png`) |
|
||||
| sodium | `minecraft-1.21.4-fabric-sodium-in-world.tgz` (ref `.0000923340.png`) |
|
||||
|
||||
`ARCHITECTURE.md:485` records that both Create fixtures carry `coherent_as_flush: true`,
|
||||
so under split they must take the same buffer path as monolith for a name-by-name compare.
|
||||
`ROADMAP.md:90` warns that the create-indirect fixture already fails on Adreno 830 at
|
||||
`dev@81b17c0b` (baseline APK reproduces) — it is on the P3a/P8 acceptance list but must be
|
||||
fixed on `dev` first. `ROADMAP.md:19` also demands MC 26.3 p99 unchanged on Adreno.
|
||||
|
||||
---
|
||||
|
||||
## 7. Short list of the traps a P3a implementer will hit
|
||||
|
||||
1. Every hook takes `BufferObject&`, and four of them read `MappedData()` — the
|
||||
conversion is not "rename seven functions", it is "decide who owns the bytes".
|
||||
2. `EnsureBufferResource` (`Managers.cpp:1602`) both CREATES the twin and calls back into
|
||||
the frontend (`SyncPersistentMappedRange` at `:1700`). That callback is the pull the
|
||||
split must invert.
|
||||
3. `IsBufferDrawClean` (`Managers.cpp:1579`) reads five frontend facts —
|
||||
`GetBackendResource()`, `IsMapped()`, `GetSize()`, `GetChangeSerial()` — on the hot
|
||||
path, per draw, per buffer. `ARCHITECTURE.md:481` reduces it to one
|
||||
`hasLiveHostWrites` bit; the size/serial half still needs a home.
|
||||
4. The mutation-epoch bump list (`Managers.h:556-590`) is exhaustive by design, and three
|
||||
of its entries are backend-initiated writebacks with NO op (`DirectGLES.cpp:872, 978,
|
||||
7903, 9462, 9872`; `Utils.cpp:2352`). Under split the bump becomes an ordering rule on
|
||||
the reverse channel (`ARCHITECTURE.md:288`).
|
||||
5. `g_bufferBackendIdGeneration` (`Managers.cpp:1502`) exists purely because VAO twins bake
|
||||
driver ids against frontend versions. It stays server-side, but the VAO half of P3a has
|
||||
to keep reading it (`Managers.cpp:2446`, `:2649`).
|
||||
6. `PendingResidentWrite` (`Managers.h:620-624`) is the only place Espryt COPIES app bytes
|
||||
into its own storage. `BufferSubDataResident` is flagged `kOptional` in the catalogue
|
||||
(`ARCHITECTURE.md:91,94`) — Magma deliberately does not register it.
|
||||
7. `TempBufferTarget` is `GL_ARRAY_BUFFER` (`Managers.h:552`) and the redundant-bind cache
|
||||
for it (`Managers.cpp:631-632`) is invalidated from seven places. Any new code path that
|
||||
binds `GL_ARRAY_BUFFER` behind `BindBufferId`'s back silently corrupts it.
|
||||
@@ -0,0 +1,595 @@
|
||||
# P3a scout — Espryt's vertex-array surface
|
||||
|
||||
Worktree: `C:/Users/geekerwan/AndroidStudioProjects/FoldCraftLauncher/MobileGL-disagg`, branch `feat/disaggregated`.
|
||||
Every line number below was opened. Paths are repo-relative to `MobileGL/` unless they start with `docs/`.
|
||||
|
||||
---
|
||||
|
||||
## 0. One-paragraph shape
|
||||
|
||||
Espryt has **no vertex-elements CSO**. It has a **per-VAO twin object** (`BackendVertexArrayObject`) that owns
|
||||
one driver VAO name plus per-attribute scratch buffers, and that twin re-emits `glVertexAttribPointer` /
|
||||
`glEnable|DisableVertexAttribArray` / `glVertexAttribDivisor` / `glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)`
|
||||
**into the driver VAO** whenever a version compare says the frontend moved. So the three things P3a wants to
|
||||
separate — vertex *elements* (format), vertex *buffers* (which store + offset + stride), and the *index* buffer —
|
||||
are today one fused emit inside `BackendVertexArrayObject::SyncToBackend`, gated by one `Uint32` config version
|
||||
plus one `Uint16` index-slot version plus one global buffer-id generation. That fusion is the P3a work.
|
||||
|
||||
---
|
||||
|
||||
## 1. How a draw resolves its vertex input today
|
||||
|
||||
### 1.1 The draw prologue
|
||||
|
||||
`PrepareForDraw` — `MG_Backend/DirectGLES/DirectGLES.cpp:3163-3231` (decl `Managers.h:105`).
|
||||
Order of the vertex-relevant steps:
|
||||
|
||||
| line | step |
|
||||
|---|---|
|
||||
| `DirectGLES.cpp:3169` | `const auto& currentVAO = MGB_CTX->GetBoundVertexArray();` |
|
||||
| `DirectGLES.cpp:3170-3171` | `vaoTwin = VertexArrayImpl::ResolveVaoTwin(currentVAO)` — **one** twin resolve serves the whole draw |
|
||||
| `DirectGLES.cpp:3176` | early `vaoConfigVersion = currentVAO->GetConfigVersion()` (deliberate cold-line prefetch) |
|
||||
| `DirectGLES.cpp:3193-3195` | `BufferImpl::SyncNeccessaryBuffers(currentVAO, vaoTwin, vaoConfigVersion, syncBit & IndexBuffer, syncBit & IndirectBuffer)` |
|
||||
| `DirectGLES.cpp:3196` | `VertexArrayImpl::SyncCurrentVAO(currentVAO, vaoTwin)` → `vaoTwin->SyncToBackend(...)` |
|
||||
| `DirectGLES.cpp:3212-3220` | `vaoTwin->Bind()`, else `BindBackendVAOId(0)` |
|
||||
| `DirectGLES.cpp:3222` | `VertexArrayImpl::SyncCurrentVertexAttributeValues(vaoTwin, currentProgram)` |
|
||||
|
||||
`DrawSyncBit` (`Managers.h:74-83`): `None / IndexBuffer(1) / IndirectBuffer(2) / Instancing(4)`.
|
||||
Note the client-array upload is **not** here — it runs *after* `PrepareForDraw` at the draw entry point (§1.6).
|
||||
|
||||
### 1.2 `ResolveVaoTwin` — `DirectGLES.cpp:1236-1268`
|
||||
|
||||
Two arms:
|
||||
* `MOBILEGL_PIPE_PUSH` + `EsprytSlotTablesEnabled()` (`DirectGLES.cpp:1240-1252`): `g_backendVertexArrayObjects.Find(vao.get())`
|
||||
→ `GetOrCreate(vao)` → `MakeShared<BackendVertexArrayObject>()`. **No lookup memo on this arm.**
|
||||
* legacy (`DirectGLES.cpp:1254-1266`): `g_vaoTwinLookupMemo.Lookup(vao)` (a 4096-slot Fibonacci-hashed direct-map,
|
||||
declared `DirectGLES.cpp:128-129`, class at `DirectGLES.cpp:~80-121`) then the address-keyed registry.
|
||||
|
||||
`SyncCurrentVAO` — `DirectGLES.cpp:1270-1283`; it still calls `g_backendVertexArrayObjects.CollectGarbageIfNeeded()`
|
||||
at `1275` (legacy arm only — the slot arm has no GC, see `SlotTables.h:37-48`).
|
||||
|
||||
### 1.3 `SyncNeccessaryBuffers` — `DirectGLES.cpp:572-707`
|
||||
|
||||
Resolves the *stores* the draw fetches through. It is the `ResolvedDrawBuffers` memo host.
|
||||
|
||||
* `DirectGLES.cpp:601` `const Uint64 bufferEpoch = CurrentBufferMutationEpoch();` (decl `Managers.h:588`, doc `Managers.h:548-587`)
|
||||
* `DirectGLES.cpp:602-603` `auto* memo = vaoTwin ? &vaoTwin->GetResolvedDrawBuffersMemo() : nullptr;`
|
||||
* **hit path** `605-621`: memo valid && `configVersion` matches → if `vboCleanEpoch != bufferEpoch`, re-probe each
|
||||
distinct entry with `IsBufferDrawClean(entry.frontend, entry.resource)` (`Managers.h:675`), and repair only the dirty
|
||||
ones via `EnsureBufferResource(currentVAOObject->GetAttribute(entry.attribIndex).Buffer)` (`DirectGLES.cpp:613-614`).
|
||||
Stamp `vboCleanEpoch = allClean ? bufferEpoch : 0` (`619`).
|
||||
* **miss path** `622-664`: full walk over `GetAllAttributes()` (`629`), skip `!Enabled` / null `Buffer`, dedupe by
|
||||
frontend `BufferObject*` into a `MAX_VERTEX_ATTRIBS` scratch (`626-627, 634-642`), `EnsureBufferResource` each
|
||||
(`644`), rebuild memo entries (`645-651`), `memo->configVersion = configVersion; memo->valid = true; vboCleanEpoch = 0` (`654-660`).
|
||||
* **IBO** `666-694`: `currentVAOObject->GetIndexBufferBindingSlot().GetBoundObject()` (`669`), matched on
|
||||
**bound-object identity** `memo->iboFrontend == possibleIBO.get()` plus `iboCleanEpoch` (`673-687`) — explicitly not
|
||||
covered by the config version.
|
||||
* **indirect** `696-703`: binds `GL_DRAW_INDIRECT_BUFFER` from `MGB_CTX->GetBufferBindingSlot(BufferTarget::DrawIndirect)`.
|
||||
* tail `705-706`: `SyncBufferBindingPoints(ShaderStorage, GL_SHADER_STORAGE_BUFFER)` + `MarkShaderStorageBuffersGpuWritten()`.
|
||||
UBO binding points are deliberately **not** synced here (comment `696-704`) — the program rebind does it.
|
||||
|
||||
### 1.4 `ResolvedDrawBuffers` — `Managers.h:833-869`
|
||||
|
||||
```
|
||||
struct Entry { BufferObject* frontend; GLESBufferResource* resource; Uint8 attribIndex; } // Managers.h:849-853
|
||||
Bool valid; Uint32 configVersion; Uint count; Array<Entry, MAX_VERTEX_ATTRIBS> entries; // 854-857
|
||||
BufferObject* iboFrontend; GLESBufferResource* iboResource; // 858-859
|
||||
Uint64 vboCleanEpoch; Uint64 iboCleanEpoch; // 866-867
|
||||
```
|
||||
Accessor `GetResolvedDrawBuffersMemo()` `Managers.h:870`; member `m_resolvedDrawBuffers` `Managers.h:911`.
|
||||
Key: **VAO config version** for the VBO half, **bound-object identity + epoch** for the IBO half.
|
||||
|
||||
`PendingAttribValueMask` — `Managers.h:872-887` (`{valid, configVersion, activeMask, pendingMask}`), accessor
|
||||
`Managers.h:884`, member `Managers.h:912`; consumed by `SyncCurrentVertexAttributeValues`.
|
||||
|
||||
### 1.5 `BackendVertexArrayObject::SyncToBackend` — `Managers.cpp:2419-2647`
|
||||
|
||||
This is the function P3a converts into `create/bind_vertex_elements_state` + `set_vertex_buffers` + `set_index_buffer`.
|
||||
|
||||
Gate (`Managers.cpp:2437-2470`):
|
||||
```
|
||||
currentConfigVersion = stateVAOObject->GetConfigVersion(); // 2437
|
||||
currentIndexBufferVersion = ...GetIndexBufferBindingSlot().GetVersion(); // Uint16 // 2438
|
||||
currentBufferIdGeneration = BufferImpl::g_bufferBackendIdGeneration; // 2446
|
||||
bufferIdsRemitted = m_syncedBufferIdGeneration != currentBufferIdGeneration; // 2447
|
||||
attributesDirty = bufferIdsRemitted || !m_hasSyncedConfigVersion || version mismatch // 2448-2449
|
||||
indexBufferDirty = bufferIdsRemitted || version mismatch || OBJECT-IDENTITY mismatch // 2452-2456
|
||||
baseInstanceDirty= m_syncedFetchBaseInstance != g_pendingFetchBaseInstance // 2462-2463
|
||||
emitAttributes = attributesDirty || baseInstanceDirty || m_hasConvertedFloat64Attribute// 2467
|
||||
if (!emitAttributes && !indexBufferDirty) return; // 2468-2470
|
||||
```
|
||||
Per-attribute walk `2477-2617` over `GetAllAttributeVersions()` / `GetAllAttributes()`:
|
||||
* `SwitchVersion` → `glEnable/DisableVertexAttribArray` (`2489-2496`)
|
||||
* `FormatVersion` / `BufferVersion` → format + buffer (`2498-2502`)
|
||||
* **fp64 narrowing** `2521-2542`: `attrib.IsLong || attrib.Type == Float64` → `SyncFloat64AttributeAsFloat32`; on
|
||||
failure the array is **disabled** (Adreno SIGSEGV note `2495-2520`, `KHR-GL43.vertex_attrib_binding.basic-input-case4`)
|
||||
* **zero-stride** `2545-2560`: `attrib.Stride == 0 && HasVertexBindingApi()` → `SyncZeroStrideAttribute` (binding-point API)
|
||||
* `BindAttributeBuffer` (`Managers.cpp:2330-2346`) then `glVertexAttribPointer` / `glVertexAttribIPointer` at
|
||||
`fetchOffset = attrib.Offset + BaseInstanceByteShift(attrib, fetchBaseInstance)` (`2586-2600`)
|
||||
* **BGRA refusal probe** `2568-2582` + `2602-2611`: `glGetError` drain, attempt, re-check, disable on refusal
|
||||
(`basic-input-case5`). Deliberately the only format that pays a `glGetError` round trip.
|
||||
* `glVertexAttribDivisor` on `needsSyncFormat` (`2613-2615`)
|
||||
|
||||
Index half `2618-2638`: `EnsureBufferResource(indexBufferBinding)` → `BufferImpl::BindBufferId(GL_ELEMENT_ARRAY_BUFFER, id)`,
|
||||
else `glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)`; stamps `m_syncedIndexBufferVersion` + `m_syncedIndexBufferObject` (`2634-2637`).
|
||||
Stamps at `2640-2646`.
|
||||
|
||||
Twin private state — `Managers.h:906-953`:
|
||||
```
|
||||
m_resolvedDrawBuffers, m_pendingAttribValueMask // 911-912
|
||||
Uint m_backendVAOId // 913
|
||||
Array<Uint,32> m_clientAttributeBufferIds // 914
|
||||
Array<Uint,32> m_convertedAttributeBufferIds // 918
|
||||
Array<ConvertedFloat64Stream,32> m_convertedAttributeStreams // 919-920
|
||||
Bool m_hasConvertedFloat64Attribute // 924
|
||||
Uint16 m_syncedIndexBufferVersion // 927
|
||||
const BufferObject* m_syncedIndexBufferObject (raw, never dereferenced) // 931
|
||||
Bool m_hasSyncedConfigVersion; Uint32 m_syncedConfigVersion // 937-938
|
||||
Array<VertexAttributeVersion,32> m_syncedAttributeVersions // 939-940
|
||||
Uint32 m_syncedFetchBaseInstance // 946
|
||||
Uint64 m_syncedBufferIdGeneration // 952
|
||||
```
|
||||
ctor/dtor `Managers.cpp:2259-2296` (`glGenVertexArrays`; dtor deletes the VAO name and both scratch-buffer arrays,
|
||||
early-returns under `InProcessTeardown()`).
|
||||
`Bind()` `Managers.cpp:2323-2327` → `BindBackendVAOId` shadow (`Managers.cpp:2303-2312`), `InvalidateVAOBindingCache`
|
||||
`2314-2316`, `NoteVAOIdDeleted` `2318-2321`.
|
||||
|
||||
### 1.6 Client-array upload path
|
||||
|
||||
`BackendVertexArrayObject::SyncClientSideAttributesForDrawArrays(vao, first, count)` — `Managers.cpp:2651-2755`
|
||||
(decl `Managers.h:831-832`). Selects `attrib.Enabled && !attrib.Buffer` (`2662-2664`), then:
|
||||
* fp64 client array `2670-2715`: `NarrowDoubleStreamToFloat32` → `glBufferData(GL_STREAM_DRAW)` into
|
||||
`m_clientAttributeBufferIds[attribIndex]`, counts `PipeStats::ByteClass::StageVertexClient` (`2701-2704`)
|
||||
* ordinary `2717-2752`: `uploadSize = (first + count - 1) * stride + elementSize` (`2726`) — this is the exact
|
||||
formula ARCHITECTURE.md 5.7 assigns to the client; `glBufferData` then `glVertexAttribPointer(..., nullptr)`;
|
||||
bytes counted at `2740-2743`.
|
||||
|
||||
Call sites (both **after** `PrepareForDraw`, both re-`Find` the twin instead of reusing the resolve):
|
||||
* `DrawArrays` — `DirectGLES.cpp:4805-4821` (`Find` at `4814`, call at `4817`)
|
||||
* `MultiDrawArrays` — `DirectGLES.cpp:4837-4866`, per sub-draw range (`Find` at `4855`, call at `4857`)
|
||||
|
||||
There is **no** client-array upload on any `DrawElements*` path — `SyncClientSideAttributesForDrawArrays` is the only
|
||||
uploader and only `DrawArrays`/`MultiDrawArrays` call it.
|
||||
|
||||
### 1.7 fp64 vertex narrowing
|
||||
|
||||
`SyncFloat64AttributeAsFloat32` — `Managers.cpp:2757-2874` (decl `Managers.h:889-892`).
|
||||
* `bufferObject->SyncGpuWrites()` before reading the shadow (`2776`); `MappedData()` / `GetSize()` (`2777-2778`)
|
||||
* stride-0 = "never advances" → exactly one element converted (`2793-2796`)
|
||||
* baseInstance folds into `firstElement` (`2800-2806`)
|
||||
* memo `ConvertedFloat64Stream` keyed on `{sourceLifetimeId, sourceChangeSerial, sourceOffset, sourceStride,
|
||||
componentCount, elementCount}` and **never trusted for a persistently mapped buffer** (`2812-2820`)
|
||||
* emits `StageVertexClient` bytes (`2839-2845`)
|
||||
* stride-0 output requires the binding API (`2857-2866`), else `glVertexAttribPointer` with `normalized = GL_FALSE`
|
||||
deliberately (`2869-2873`, `basic-input-case5`)
|
||||
|
||||
### 1.8 `SyncCurrentVertexAttributeValues` — `DirectGLES.cpp:1291-1348`
|
||||
|
||||
Feeds `glVertexAttrib4fv / I4iv / I4uiv` for program-active locations with **no enabled array**, from
|
||||
`MGB_CTX->GetCurrentVertexAttribute(location)` (`1329`). Memo keyed on `{VAO config version, program active-attrib mask}`
|
||||
(`1311-1323`). This is the read that `set_vertex_attrib_defaults` (already landed at P2) supplies.
|
||||
|
||||
### 1.9 Complete list of Espryt reads of frontend vertex state
|
||||
|
||||
Every `MG_Backend/DirectGLES` read of `VertexArrayObject` / `VertexAttribute` / `VertexBufferBindingPoint`:
|
||||
|
||||
| file:line | read |
|
||||
|---|---|
|
||||
| `DirectGLES.cpp:128-129` | `TwinLookupMemo<VertexArrayObject, BackendVertexArrayObject, 12>` (legacy arm) |
|
||||
| `DirectGLES.cpp:572-573` | `SyncNeccessaryBuffers(SharedPtr<VertexArrayObject>&, BackendVertexArrayObject*, ...)` |
|
||||
| `DirectGLES.cpp:613-614` | `GetAttribute(entry.attribIndex).Buffer` |
|
||||
| `DirectGLES.cpp:626-627` | `MAX_VERTEX_ATTRIBS` dedupe scratch |
|
||||
| `DirectGLES.cpp:629` | `GetAllAttributes()` |
|
||||
| `DirectGLES.cpp:669` | `GetIndexBufferBindingSlot().GetBoundObject()` |
|
||||
| `DirectGLES.cpp:1236-1266` | `ResolveVaoTwin` |
|
||||
| `DirectGLES.cpp:1270-1283` | `SyncCurrentVAO` |
|
||||
| `DirectGLES.cpp:1291-1348` | `SyncCurrentVertexAttributeValues` (`1312` config version, `1317` `GetAttribute(location).Enabled`) |
|
||||
| `DirectGLES.cpp:3169-3176` | `GetBoundVertexArray()`, `GetConfigVersion()` |
|
||||
| `DirectGLES.cpp:4624` | `BoundElementArrayBuffer()` → `GetIndexBufferBindingSlot().GetBoundObject()` (restart path) |
|
||||
| `DirectGLES.cpp:4814`, `4855` | `g_backendVertexArrayObjects.Find(currentVAO.get())` (client arrays) |
|
||||
| `Managers.cpp:210` | death-notice case `MGPipeKind::VertexElementsCso` |
|
||||
| `Managers.cpp:2330` | `BindAttributeBuffer(const VertexAttribute&)` |
|
||||
| `Managers.cpp:2377` | `BaseInstanceByteShift(const VertexAttribute&, Uint32)` |
|
||||
| `Managers.cpp:2387` | `SyncZeroStrideAttribute(Uint, const VertexAttribute&)` |
|
||||
| `Managers.cpp:2437-2438`, `2453` | config version, index-slot version, index bound object |
|
||||
| `Managers.cpp:2477-2478` | `GetAllAttributeVersions()`, `GetAllAttributes()` |
|
||||
| `Managers.cpp:2619` | index bound object (emit) |
|
||||
| `Managers.cpp:2659` | `GetAllAttributes()` (client arrays) |
|
||||
| `Managers.cpp:2758` | `SyncFloat64AttributeAsFloat32(..., const VertexAttribute&, ...)` |
|
||||
| `Managers.cpp:2877-2878` | `TwinRegistry<VertexArrayObject, BackendVertexArrayObject, MGPipeKind::VertexElementsCso> g_backendVertexArrayObjects` |
|
||||
| `Managers.h:826-955` | class + registry decl |
|
||||
| `BackendObject_DirectGLES.cpp:1391` | `VertexArrayObject::MAX_VERTEX_ATTRIBS` clamp for the advertised limit |
|
||||
| `MultiDraw.cpp:98` | `GetIndexBufferBindingSlot().GetBoundObject()` |
|
||||
|
||||
**Finding.** Neither Espryt nor Magma reads `VertexBufferBindingPoint`, `GetAttributeBindingIndex` or
|
||||
`GetAttributeRelativeOffset` — grep over `MG_Backend/DirectGLES` and `MG_Backend/DirectVulkan` returns nothing.
|
||||
The frontend resolves the binding model eagerly into the flat `VertexAttribute` view
|
||||
(`VertexArrayObject.cpp:229-260` `ResolveAttributeFromBinding`, `262-269` `ResolveAttributesForBinding`,
|
||||
`146-181` `MirrorPointerIntoBinding`). See §4.2 for why this matters to the "two views" requirement.
|
||||
|
||||
---
|
||||
|
||||
## 2. After P2's Espryt 0b slot tables
|
||||
|
||||
### 2.1 Which kind holds the VAO twin
|
||||
|
||||
`MG_Backend/DirectGLES/Managers.cpp:2877-2878`:
|
||||
```
|
||||
TwinRegistry<MG_State::GLState::VertexArrayObject, BackendVertexArrayObject,
|
||||
MG_Pipe::MGPipeKind::VertexElementsCso> g_backendVertexArrayObjects;
|
||||
```
|
||||
decl `Managers.h:954-955`. So **`MGPipeKind::VertexElementsCso` (`MG_Pipe/MGPipeHandles.h:31`) is today the slot
|
||||
space of the per-VAO twin**, one slot per live frontend `VertexArrayObject`, minted off `GetLifetimeId()`.
|
||||
|
||||
`TwinRegistry` is an alias that swallows the kind in a pull build: `Managers.h:543-549`; the class carries
|
||||
`BackendSlotTable<StateObject, BackendObject, kKind> m_slotTable` only under `MOBILEGL_PIPE_PUSH`
|
||||
(`Managers.h:299-305`, macro `MGB_TWIN_KIND_PARAM` `Managers.h:293-297`).
|
||||
|
||||
`BackendSlotTable` — `MG_Backend/DirectGLES/SlotTables.h:139-...`:
|
||||
`GetOrCreate` `SlotTables.h:207-243` (`MGPipeSlots().Acquire(kKind, stateObj->GetLifetimeId())` at `225-226`, gen
|
||||
mismatch resets the twin at `229-233`); `Find` `246-253`; `FindByHandle` `255-262`; `HandleOf` `272-281`;
|
||||
`OnFrontendObjectDestroyed` (static, per-kind, walks every holder) `295-310`; `ForEachLive` `326-345`;
|
||||
`ReleaseTwinAt` `352-374`; one-entry lifetimeId→handle memo `m_memoLifetimeId/m_memoHandle` `429-431`
|
||||
(the comment at `407-428` names `ResolveVaoTwin` as one of the two callers the single-entry memo *does* help).
|
||||
|
||||
Arm selection: `ClassifyEsprytSlotArm` (`SlotTables.h:86-98`, impl `Managers.cpp:224-...`),
|
||||
`EsprytSlotTablesEnabled()` inline latch `SlotTables.h:131-134`,
|
||||
subsystem bit `kMGPipeSubsystemEsprytSlots = 1ull << 5` (`MG_Pipe/MGPipe.h:77`).
|
||||
|
||||
### 2.2 Death announcement
|
||||
|
||||
`VertexArrayObject::~VertexArrayObject()` — `MG_State/GLState/VertexArrayState/VertexArrayObject.cpp:42-54`,
|
||||
raising `NotifyStateObjectDestroyed(MG_Pipe::MGPipeKind::VertexElementsCso, m_lifetimeId)` (`53`).
|
||||
Declared only under push (`VertexArrayObject.h:26-31`, so the pull build keeps its implicit destructor for G1).
|
||||
Consumer: `OnFrontendStateObjectDestroyed` — `Managers.cpp:191-217`, VAO case at `209-211`
|
||||
(`g_backendVertexArrayObjects.DestroyByLifetimeId(lifetimeId)`); ops table `Managers.cpp:219-221`.
|
||||
|
||||
### 2.3 Recorded debt P3a inherits
|
||||
|
||||
`SlotTables.h:68-78` — the header is under `MG_Backend/` yet it **mints** handles off a frontend
|
||||
`SharedPtr`'s `GetLifetimeId()`, which `MGPipeHandles.h:13-16` forbids ("minted by the CLIENT"). Its own comment says
|
||||
the minting and the lifetimeId→handle resolution belong on the client and the backend should receive the handle in
|
||||
the verb payload — i.e. exactly what P3a is supposed to do for the VAO kind. `check_include_closure.py` does not
|
||||
probe `MG_Backend` headers, so nothing catches this automatically.
|
||||
|
||||
---
|
||||
|
||||
## 3. Index-buffer handling (and the P8 host-mirror hooks)
|
||||
|
||||
### 3.1 The element-array binding
|
||||
|
||||
Owned by the VAO twin (§1.5, `Managers.cpp:2618-2638`). Its freshness key is
|
||||
`{ BindingSlot::GetVersion() (Uint16, wrapping), bound-object raw pointer identity }` —
|
||||
`Managers.h:922-931` explains why identity joins the version (`BindingSlot` lives at `MG_Util/Types.h:181-204`,
|
||||
`m_version` is a `Uint16` bumped only on a real change, `Bind()` at `189-195`, `GetVersion()` at `198`).
|
||||
`SetIndexBuffer` being independent of the VAO config version (D5, `docs/Disaggregated/ARCHITECTURE.md:99`) matches
|
||||
what the code already does — the index slot is explicitly *not* covered by `m_configVersion`.
|
||||
|
||||
**Trap that any P3a re-emit must preserve:** two paths temporarily swap the element-array binding and must restore
|
||||
the *exact* previous GL name, because the twin memoised that it already synced it:
|
||||
* `ScopedRestartIndexSubstitution::~ScopedRestartIndexSubstitution` — `DirectGLES.cpp:4788-4791`
|
||||
(previous name captured at `4776` via `BoundElementArrayBufferId()`, `DirectGLES.cpp:4629-4634`)
|
||||
* `MultiDrawImpl` — `MultiDraw.cpp:101-109` (`BoundIndexBufferId`, comment states the memo hazard verbatim)
|
||||
and `MultiDraw.cpp:929-937` (flattened-stream draw restores `previousIndexBinding`).
|
||||
|
||||
### 3.2 Primitive-restart rewrite (server-owned at P8, client today)
|
||||
|
||||
`docs/Disaggregated/ARCHITECTURE.md:222` assigns restart rewrite to the **server**, reading through the index host
|
||||
mirror (`ARCHITECTURE.md:383-391`), with `kCapNeedsHostIndexBytes` as the switch (`ARCHITECTURE.md:106`) and
|
||||
`kMGHostSpanSegFromServerIndexMirror = 0xFFFFFFFF` (`MG_Pipe/MGPipeHostSpan.h:26`) as the "bytes are already yours"
|
||||
sentinel.
|
||||
|
||||
Today, in Espryt:
|
||||
* `RestartSubstitutionKind ResolveRestartSubstitution(GLenum)` — `DirectGLES.cpp:4636-4653`
|
||||
(`None` / `SuppressRestart` when `restartIndex > fixedMax` / `RewriteIndices`)
|
||||
* `ScopedSuppressedPrimitiveRestart` — `Managers.h:~130-145`, impl `DirectGLES.cpp:4657-4673`
|
||||
(toggles `GL_PRIMITIVE_RESTART_FIXED_INDEX` *around* the render-state shadow)
|
||||
* `ScopedRestartIndexSubstitution` — decl `Managers.h:157-194`, ctor `DirectGLES.cpp:4675-4786`, dtor `4788-4791`
|
||||
* `kMaxRestartRewriteBytes = 1<<26` (64 MiB) — `DirectGLES.cpp:4510`
|
||||
* EBO source: **whole buffer** is rewritten, never just the draw range (`4691-4721`), so a GPU-resident
|
||||
`firstIndex` still addresses the right element
|
||||
* **the two reconcile calls P8 must reproduce**: `indexBuffer->SyncPersistentMappedRange();`
|
||||
`indexBuffer->SyncGpuWrites();` then `MappedData()` — `DirectGLES.cpp:4709-4713`
|
||||
* client-pointer source: only the draw's own range (`4722-4741`)
|
||||
* widening `UBYTE→USHORT→UINT` when the source already contains the all-ones index
|
||||
(`ContainsFixedRestartIndex` `4553-4560`, `WiderIndexType` `4515-4521`, decision `4746-4764`)
|
||||
* `RewriteRestartIndices` `4562-4578`; `UploadRestartScratch` `4580-4617` (whole-buffer `glBufferData` orphan into
|
||||
`g_restartIndices`, staged through `BufferImpl::TempBufferTarget`), byte counter
|
||||
`PipeStats::ByteClass::StageIndexClient` at `4610-4614`
|
||||
* `OnRestartSubstitutionContextDestroyed` `4655-4659`
|
||||
* Call sites: `DirectGLES.cpp:4174` (indirect, `count=0` → whole-EBO form), `4799`, `4830`, `5099`, `5112`, `5137`,
|
||||
`5159`, `5174`, `5191`.
|
||||
|
||||
### 3.3 Multi-draw flattening (server-owned at P8, client today)
|
||||
|
||||
`MG_Backend/DirectGLES/MultiDraw.{h,cpp}`. Tier ladder documented `MultiDraw.h:15-31`:
|
||||
`Ext / MultiIndirect / Indirect / BaseVertex / DrawElements / Compute`.
|
||||
|
||||
* `DrawElementsBatch` — `MultiDraw.cpp:897-992` (the whole entry point, owns `PrepareForDraw` at `927`)
|
||||
* `ResolveTierForBatch(programReadsDrawID, perSubDrawBaseVertex, hasIndexBuffer, arbitraryRestart)` —
|
||||
`MultiDraw.cpp:294-347`; arbitrary restart forces the rewriting tier (`303-307`); batched tiers demote when the
|
||||
program reads `gl_DrawID` / per-sub-draw base vertex (`316-324`)
|
||||
* `RunRebasedDrawElements` — `MultiDraw.cpp:492-...`; **the CPU index read**:
|
||||
`indexBuffer->SyncPersistentMappedRange(); indexBuffer->SyncGpuWrites(); MappedData(); GetSize();`
|
||||
— `MultiDraw.cpp:508-514`. `RebaseIndices` `MultiDraw.cpp:353-380` (always widens to `GL_UNSIGNED_INT`).
|
||||
* `FlattenWithCompute` — `MultiDraw.cpp:690-...`; declines on non-list modes (`701-704`), on active restart
|
||||
(`706-717`), and with no real index buffer (`719-722`)
|
||||
* Ceilings: `kMaxFlattenedIndices = 1<<24` (`MultiDraw.cpp:74`), `kComputeWorkGroupSize = 64` /
|
||||
`kMaxComputeWorkGroups = 65535` (`MultiDraw.cpp:81-84`)
|
||||
* `BoundIndexBuffer` / `BoundIndexBufferId` `MultiDraw.cpp:94-109`, `BoundDrawIndirectBufferId` `86-92`
|
||||
|
||||
### 3.4 baseInstance emulation (the thing `set_vertex_buffers`' explicit field retires)
|
||||
|
||||
* `g_pendingFetchBaseInstance` — `Managers.cpp:2358`; `SetPendingFetchBaseInstance` / `GetPendingFetchBaseInstance`
|
||||
`Managers.cpp:2360-2366`; decl + doc `Managers.h:970-983` (`ScopedFetchBaseInstance` at `976-982`)
|
||||
* `BaseInstanceByteShift` — `Managers.cpp:2377-2383`: `baseInstance * attrib.Stride`, only for `Divisor != 0`,
|
||||
zero for a stride-0 array
|
||||
* applied at `Managers.cpp:2586` (`fetchOffset`) and inside the fp64 path at `Managers.cpp:2800-2806`
|
||||
* `EmulatedFetchBaseInstance` — `DirectGLES.cpp:5128-5130` (returns 0 when `GL_EXT_base_instance` exists,
|
||||
`UseNativeBaseInstance` `5122-5124`); scopes at `DirectGLES.cpp:5135`, `5172`, `5224`
|
||||
* **The shift is baked into the driver VAO's attribute offsets**, is draw state, and is deliberately *not* covered by
|
||||
any frontend version (`Managers.h:941-946`). Un-shifting on the next non-baseInstance draw is why
|
||||
`baseInstanceDirty` exists (`Managers.cpp:2462-2463`).
|
||||
|
||||
---
|
||||
|
||||
## 4. The MGPipe side as it exists
|
||||
|
||||
### 4.1 Catalogue entries (all present, none implemented)
|
||||
|
||||
`MG_Pipe/PipeCalls.def`:
|
||||
```
|
||||
95: X(CreateVertexElements, MGPVertexElements, kCtxCso, kHasBlob)
|
||||
96: X(BindVertexElements, MGPHandleOnly, kCtxCso, kNone)
|
||||
97: X(DeleteVertexElements, MGPHandleOnly, kCtxCso, kNone)
|
||||
108: X(SetVertexBuffers, MGPVertexBuffers, kCtxState, kVarTail)
|
||||
109: X(SetIndexBuffer, MGPIndexBuffer, kCtxState, kNone)
|
||||
117: X(SetVertexAttribDefaults, MGPVertexAttribDefaults, kCtxState, kVarTail) // landed at P2
|
||||
```
|
||||
Generated: dispatch-table members `generated/PipeTables.inc:43-45, 55-56`; thunks
|
||||
`generated/PipeThunks.inc:96-105, 144-149`; wire opcodes `generated/PipeWire.inc:66-68` (20/21/22) and `78-79` (32/33),
|
||||
wire record `PipeWire.inc:273-279`; field verifier `generated/PipeVerify.inc:62, 148, 376-378`.
|
||||
|
||||
`gMGPipeContext` (`MG_Pipe/MGPipe.h:97`) is **never populated** anywhere outside
|
||||
`MG_Test/Pipe/PipeCatalogueTest.cpp:102`. P2 does not emit through the table — it calls the applier directly
|
||||
(`MG_Pipe/PipeApply.h:100-121`: `MGPipeApplyCreateRenderState`, `…BindRenderState`, `…DeleteRenderState`,
|
||||
`…SetDynamicState`, `…SetPixelPackState`, `…SetPatchState`, `…SetVertexAttribDefaults`, `…SetResidualValueState`).
|
||||
**P3a's applier entry points follow that same shape**, with `MGPipeApplierState` at `PipeApply.h:47-86`.
|
||||
|
||||
### 4.2 Payloads
|
||||
|
||||
`MG_Pipe/MGPipeTypes.h`:
|
||||
```
|
||||
253-259 MGPVertexElements { MGPipeHandle Cso; Uint32 AttributeCount; Uint32 BindingPointCount; MGPBlobRef Blob; } // 40 B
|
||||
356-364 MGPVertexBuffer { MGPipeHandle Res; Uint64 Offset; Uint32 Stride, Divisor, BindingIndex, Pad0; } // 32 B
|
||||
367-371 MGPVertexBuffers { Uint32 Start, Count; Uint64 ContentHash; } // 16 B
|
||||
374-380 MGPIndexBuffer { MGPipeHandle Res; Uint64 Offset; Uint32 IndexSize, Pad0; } // 24 B
|
||||
484-488 MGPVertexAttribDefaults { Uint32 Mask, Count; } // 8 B
|
||||
714-728 MGPDrawInfo (56 B), 731-735 MGPDrawRange (12 B)
|
||||
```
|
||||
Draw flags `MGPipeTypes.h:701-707`: `kDrawHasUserIndices / kDrawPrimitiveRestart / kDrawIndicesAreClient /
|
||||
kDrawHasIndexRange / kDrawHasXfbCount`.
|
||||
|
||||
**The two views** the roadmap means (`docs/Disaggregated/ROADMAP.md:19` "vertex elements 三件(两个视图都带)",
|
||||
`ARCHITECTURE.md:130`) are the two arrays concatenated in `MGPVertexElements::Blob`:
|
||||
1. the resolved flat `MG_State::GLState::VertexAttribute[]` — `MG_Pipe/MGPipeValueTypes.h:491-527`
|
||||
(`Enabled, Size, Type, Normalized, Stride, Offset, IsInteger, IsLong, IsBgra, Divisor, Buffer`,
|
||||
plus query-only `LegacyStride`/`LegacyPointer` at `524-526` which the doc says stay client-side)
|
||||
2. `VertexBufferBindingPoint[]` — `MGPipeValueTypes.h:530-538` (`Buffer, Offset, Stride = 16 initial, Divisor`)
|
||||
|
||||
`VertexAttributeVersion` (3× `Uint16`, size-asserted 6) — `MGPipeValueTypes.h:540-544`, assert `561-562`.
|
||||
|
||||
> **Flag for the implementer.** The stated reason both views must travel (pointer stride 0 = element size vs binding
|
||||
> stride 0 = same element) is *already resolved in the frontend*: `VertexAttribute::Stride` is documented as the
|
||||
> RESOLVED distance and a surviving 0 can only have come from the binding model (`MGPipeValueTypes.h:496-507`), and
|
||||
> Espryt consumes exactly that (`Managers.cpp:2545-2560`). Today **no backend reads the binding-point array at all**
|
||||
> (§1.9). So the second view is either (a) for the `glGetVertexArrayIndexed*` query path, which
|
||||
> `VertexArrayObject.h:88-104` keeps client-side anyway, or (b) forward-looking. Decide and record it before shipping
|
||||
> a 2× blob for every VAO in a chunked-renderer workload.
|
||||
|
||||
> **Flag: `baseInstance` explicit field.** `ROADMAP.md:19` says "`set_vertex_buffers`(`baseInstance` 显式字段)",
|
||||
> but `MGPVertexBuffer` (`MGPipeTypes.h:356-364`) has **no** baseInstance member. The only explicit field in the
|
||||
> current catalogue is `MGPDrawInfo::StartInstance` (`MGPipeTypes.h:719`, `PipeFields.def:189`), which is on the draw
|
||||
> verb, not on `set_vertex_buffers`. Either the roadmap line means "the fetch shift stops being folded into the
|
||||
> vertex-buffer offsets and travels as `MGPDrawInfo::StartInstance`" — which is what the payloads support — or
|
||||
> `MGPVertexBuffer` needs a field, which changes an already-size-asserted POD. Resolve explicitly; `MGPVertexBuffer`
|
||||
> at 32 B has a `Pad0` at `MGPipeTypes.h:362` that could take it without moving the assert.
|
||||
|
||||
### 4.3 CSO caching
|
||||
|
||||
`ARCHITECTURE.md:57` sets the client-side content-addressed CSO capacities (render-state 64 / **vertex-elements 1024** /
|
||||
sampler 256 / sampler-view 4096). `MG_Impl/Pipe/CsoCache.h` implements **only** the render-state cache
|
||||
(`kMGPipeCsoCacheCapacity = 64`, `CsoCache.h:53`; eviction at `140`). There is no vertex-elements cache yet, and the
|
||||
negative control bit is `kMGPipeBehaviourNoCsoContentAddressing` (`CsoCache.h:30-37`).
|
||||
|
||||
Slot minting: `MG_Impl/Pipe/SlotAllocator.h:39-99` — `FindByLifetimeId` `53`, `Acquire` `55`, `Free` `60`,
|
||||
`FreeCount` `71`, singleton `MGPipeSlots()` `99`.
|
||||
|
||||
---
|
||||
|
||||
## 5. What the tracker already pushes for VAOs (P2)
|
||||
|
||||
`MG_Impl/Pipe/Tracker.h`:
|
||||
* dirty enum — `Tracker.h:56-84`; the vertex rows: `NewVertexAttribDefaults` `63`, `NewVertexElements` `65`,
|
||||
`NewVertexBuffers` `70`, `NewIndexBuffer` `71`
|
||||
* names — `Tracker.h:96-114` (`"NEW_VERTEX_ATTRIB_DEFAULTS"` `100`, `"NEW_VERTEX_ELEMENTS"` `101`,
|
||||
`"NEW_VERTEX_BUFFERS"` `105`, `"NEW_INDEX_BUFFER"` `106`)
|
||||
* `kMGPipeDirtyEmittedAtP2` — `Tracker.h:91-97`: only the five value bits, **vertex elements / buffers / index are
|
||||
computed and counted but not emitted**; `MGPipeSubsystemForDirty` returns 0 for them (`Tracker.h:122-136`,
|
||||
default arm `132-135`)
|
||||
* the shutters, `MGPipeTracker::Update` — `Tracker.h:178-...`:
|
||||
```
|
||||
Tracker.h:210-213 vaoIdentity = vao ? MGPipeMixShutter(vao->GetLifetimeId(), vao->GetConfigVersion()) : 0;
|
||||
now[NewVertexElements] = vaoIdentity;
|
||||
Tracker.h:243-244 now[NewVertexBuffers] = MGPipeMixShutter(ctx.GetAnyVaoAttributeGeneration(), vaoIdentity);
|
||||
Tracker.h:245-248 now[NewIndexBuffer] = MGPipeMixShutter(buffers, vaoIdentity); // over-fires on ANY buffer write
|
||||
Tracker.h:208 now[NewVertexAttribDefaults] = ctx.GetAnyVertexAttribDefaultGeneration();
|
||||
```
|
||||
`MGPipeMixShutter` `Tracker.h:143-146`; `MGPipeWidenedCounter` `Tracker.h:158-176`.
|
||||
The over-fire policy is stated at `Tracker.h:27-33` — a rarely-firing bit renders stale and P1's verify
|
||||
comparator cannot see it for object-class state.
|
||||
|
||||
`FillPoints.def` kDraw rows relevant to vertex state — `MG_Pipe/FillPoints.def:152-199`:
|
||||
`GetBoundVertexArray` `154`, `GetProgramForDraw` `155`, `GetBufferBindingSlot` `156`,
|
||||
`GetCurrentVertexAttribute` `165`, `GetPrimitiveRestartIndex` `193`.
|
||||
(`kDispatch, GetBufferBindingSlot` `204`; `kReadback, GetBufferBindingSlot` `289`.)
|
||||
|
||||
`Coverage.def` — accessor→call map: `GetBoundVertexArray → BindVertexElements` (`Coverage.def:36`);
|
||||
`GetBufferBindingSlot → SetIndirectBuffers` with the note at `37-41` that its rows **split across
|
||||
set_vertex_buffers / set_index_buffer / set_indirect_buffers / set_shader_buffers** once the inventory is
|
||||
re-vendored with the target argument (deferred out of P1 — P3a is where that split lands);
|
||||
`GetCurrentVertexAttribute → SetVertexAttribDefaults` `52`; `GetPrimitiveRestartIndex → DrawVbo` `70`.
|
||||
Emitted list `Coverage.def:158-192` contains **no** vertex-elements/buffers/index row yet
|
||||
(`GetCurrentVertexAttribute → SetVertexAttribDefaults` `164` and `GetPrimitiveRestartIndex → SetDynamicState` `178`
|
||||
are the only vertex-adjacent ones).
|
||||
|
||||
`PipeInputs` side — `MG_Backend/MGPipe/PipeInputs.h`: field list rows `79` (`GetBoundVertexArray → m_boundVertexArray`),
|
||||
`80` (`GetBufferBindingSlot`), `89` (`GetCurrentVertexAttribute`), `107` (`GetPrimitiveRestartIndex`);
|
||||
accessors `477-481`, `487-493`, `274-283`, `369-372`; storage `641`, `658`, `678-679`;
|
||||
`kMaxVertexAttribs` `175`. Fill: `MG_Impl/Pipe/PipeFill.cpp:80-82` (bound VAO), `83-91` (buffer binding slots),
|
||||
`126-129` (current attribs); aggregate note dispatch `PipeFill.cpp:537-538`.
|
||||
|
||||
---
|
||||
|
||||
## 6. The P2 aggregate generations that cover vertex state
|
||||
|
||||
| generation | owner | declaration | bumped from |
|
||||
|---|---|---|---|
|
||||
| `VertexArrayObject::m_configVersion` (`Uint32`, per object) | frontend | `VertexArrayObject.h:107` (getter), `:214` (member) | the three `Bump*Version` — `VertexArrayObject.cpp:313-332` |
|
||||
| per-attribute `VertexAttributeVersion{Format,Buffer,Switch}` (`Uint16`×3) | frontend | `MGPipeValueTypes.h:540-544`; array member `VertexArrayObject.h:207` | same three bumpers |
|
||||
| `VertexArrayState::m_anyVaoAttributeGeneration` (`Uint64`) | frontend | `VertexArrayState.h:36-42` (`NoteAttributeChanged` / `GetAnyAttributeGeneration`), member `:44` | `MGP_NOTE_AGGREGATE(VaoAttribute)` inside all three bumpers (`VertexArrayObject.cpp:317, 324, 331`) |
|
||||
| `BufferState::m_anyBufferChangeGeneration` (`Uint64`) | frontend | `BufferState.h:72-78` | every buffer mutator |
|
||||
| index slot `BindingSlot::m_version` (`Uint16`, **wraps**) | frontend | `MG_Util/Types.h:198, 202` | `BindingSlot::Bind` `Types.h:189-195` |
|
||||
| `BufferImpl::g_bufferBackendIdGeneration` (`Uint64`) | backend | `Managers.h:701-707` | driver-id re-mint (persistent-map adoption, immutable-store retire) |
|
||||
| buffer-mutation epoch (`CurrentBufferMutationEpoch()`) | backend | `Managers.h:548-588` | any path that can dirty any buffer |
|
||||
| `VertexArrayObject::m_lifetimeId` (`Uint64`, never reused) | frontend | `VertexArrayObject.h:70` (`GetLifetimeId`), member `:205`; allocator `:203` | ctor |
|
||||
|
||||
### How a server-side VAO object table would be keyed
|
||||
|
||||
* Handle: `MGPipeHandle{Slot, Gen}` of kind `VertexElementsCso`, minted client-side off `GetLifetimeId()`
|
||||
(`SlotTables.h:225-226`), freed on the destructor notice (`VertexArrayObject.cpp:53`), so the server table is a
|
||||
dense array indexed by `Slot` with a `Gen` compare — exactly `BackendSlotTable::Entry` (`SlotTables.h:145-158`)
|
||||
and `MGPipeApplierState::RenderStateCsos` (`PipeApply.h:47-51`) already do this shape for render state.
|
||||
* Freshness inside a slot: today the twin's own `{m_syncedConfigVersion, m_syncedAttributeVersions[32],
|
||||
m_syncedIndexBufferVersion + m_syncedIndexBufferObject, m_syncedFetchBaseInstance, m_syncedBufferIdGeneration}`
|
||||
(`Managers.h:906-952`). Under P3a the elements half becomes a **content hash** on the client (`CsoCache`-shaped)
|
||||
and the buffers/index halves become `MGPVertexBuffers::ContentHash` (`MGPipeTypes.h:370`) + a plain
|
||||
`set_index_buffer`, so `m_syncedConfigVersion` / `m_syncedAttributeVersions` / `m_syncedIndexBufferObject` all
|
||||
disappear — but `g_bufferBackendIdGeneration` **does not**: it answers "did *I* re-mint the driver id", which is a
|
||||
server-side `MGGen` and must never cross the wire (`ARCHITECTURE.md:73-79`).
|
||||
* `ARCHITECTURE.md:363` records that `SetBackendStateMemo` (the frontend VAO holding a backend heap pointer) is
|
||||
deleted outright; the three legacy memos on the frontend object are `VertexArrayObject.h:110-175`
|
||||
(`GetBackendHashMemo`/`SetBackendHashMemo` `121-129`, `GetBackendStateMemo`/`Set…` `137-149`,
|
||||
`GetBackendAuxMemo`/`Set…` `160-172`, storage `216-225`), all under `MOBILEGL_PIPE_LEGACY_MEMOS`.
|
||||
|
||||
---
|
||||
|
||||
## 7. Tests
|
||||
|
||||
### 7.1 Integration scenarios (`MG_IntegrationTest/Scenarios/`) — gtest `TEST_F`
|
||||
|
||||
`VertexAttribBindingScenario.cpp` (758 lines; every case captures the vertex shader's inputs with XFB under
|
||||
`GL_RASTERIZER_DISCARD`, poison-prefilled buffer — header note `:8-17`):
|
||||
`FormatAndBindingFeedTheDraw` `241`, `FormatBeforeBufferStillResolves` `269`,
|
||||
`BindingStrideZeroRepeatsOneElement` `297`, `PointerStrideZeroStaysTightlyPacked` `324`,
|
||||
`BindingDivisorAppliesToEveryAttributeOnThePoint` `349`,
|
||||
**`BaseInstanceMovesTheInstancedArraysStartElement` `406`**,
|
||||
**`BaseInstanceLeavesPerVertexArraysWhereTheyWere` `451`**,
|
||||
`RelativeOffsetComposesWithBindingOffset` `496`, `InputArrayCaptureProgramFeedsTheDraw` `532`,
|
||||
`EveryInputArrayElementGetsItsOwnCurrentValue` `617`, `DoubleArrayIsFetchedAtFloat32Precision` `681`,
|
||||
`NormalizedIsIgnoredForDoubleArrays` `708`, `LongDoubleArrayIsFetchedAtFloat32Precision` `734`.
|
||||
|
||||
`VertexArrayEnableDisableScenario.cpp`: `EitherHalfOfTheAttributesInTurn` `231`, `TheEvenHalfAlone` `245`,
|
||||
`TheOddHalfAlone` `255`.
|
||||
|
||||
`MultiDrawScenario.cpp`: `BaseVertexBatchMatchesUnrolledDraws` `225`, `PlainBatchMatchesUnrolledDraws` `253`,
|
||||
`UnsignedShortBatchMatchesUnrolledDraws` `288`, `UnsignedByteBatchMatchesUnrolledDraws` `317`,
|
||||
`BaseVertexBeyondIndexTypeRangeMatchesUnrolledDraws` `357`, `ClientSideIndicesBatchMatchesUnrolledDraws` `391`,
|
||||
`PrimitiveRestartStripBatchMatchesUnrolledDraws` `423`, `PrimitiveRestartUnsignedShortBatchMatchesUnrolledDraws` `456`,
|
||||
`ZeroCountSubDrawsMatchUnrolledDraws` `493`, `BaseVertexDrawsRejectMalformedArguments` `526`.
|
||||
|
||||
`PrimitiveRestartScenario.cpp`: `AnArbitraryRestartIndexDrawsInsteadOfKillingTheProcess` `215`,
|
||||
`TheFixedIndexValueTakesTheForwardingPath` `236`, `WithoutTheCapTheStripWeldsAcrossTheGap` `263`,
|
||||
`ChangingTheRestartIndexBetweenDrawsIsHonoured` `281`, `ANonIndexedListTopologyDrawIsUnaffectedByTheCap` `306`,
|
||||
`ARestartIndexTooLargeForTheIndexTypeRestartsNowhere` `332`, `AnAllOnesVertexIndexSurvivesTheSubstitution` `368`.
|
||||
|
||||
`DrawParametersScenario.cpp` (the `gl_BaseInstance`/`gl_DrawID`/`gl_BaseVertex` side of the same emulation):
|
||||
`DrawArraysReportsAZeroBaseVertexDespiteItsFirst` `213`,
|
||||
`DrawArraysInstancedBaseInstanceReportsItsBaseInstance` `221`, `APlainDrawAfterABaseInstancedOneSeesZeroAgain` `233`,
|
||||
`DrawElementsBaseVertexReportsItsBaseVertex` `245`, `DrawElementsAfterABaseVertexDrawReportsZeroAgain` `266`,
|
||||
`MultiDrawArraysNumbersItsSubDraws` `286`, `MultiDrawElementsIndirectCarriesEveryCommandsParameters` `301`,
|
||||
`MultiDrawArraysIndirectCountObeysItsParameterBuffer` `327`.
|
||||
|
||||
`ResidentIndexScenario.cpp` (element-array + persistent map — the closest thing to a P8 index-mirror gate):
|
||||
`PersistentCoherentEboWrittenEveryFrame` `186`, `EboAlsoBoundAsVertexBufferLater` `225`,
|
||||
`EboDeletedAndRecreatedAtTheSameName` `271`, `OneEboTwoVaosMutatedAcrossFrames` `311`, `PromotedDynamicEbo` `351`.
|
||||
|
||||
`HandleRecycleScenario.cpp`: `TheReproducerRecyclesEveryName` `440`,
|
||||
**`AVertexArrayAtARecycledAddressDoesNotInheritItsPredecessorsVertexInput` `483`** (the P2 re-key gate for this kind),
|
||||
`ATextureAtARecycledAddress…` `573`, `AFramebufferAtARecycledAddress…` `624`.
|
||||
|
||||
`DoublePrecisionScenario.cpp` vertex-array cases: `A64BitVertexFormatIsRecordedAndItsArrayIsDroppedAtDraw` `863`,
|
||||
`AnEnabledLongArrayDoesNotBreakADrawThatIgnoresIt` `916`.
|
||||
|
||||
Buffer-family scenarios the roadmap names for P3a: `LargeArenaAdoptionScenario.cpp`
|
||||
(`SubDataAfterAnInFlightDrawReachesTheNextDraw` `204`, `ReadbackSeesTheLatestCpuWrite` `227`,
|
||||
`GpuWriteIntoTheArenaIsReadBack` `245`), `StorageBufferRegrowScenario.cpp`
|
||||
(`AGrownStoreIsVisibleThroughItsExistingIndexedBinding` `124`).
|
||||
|
||||
### 7.2 Unit tests
|
||||
|
||||
* `MG_Test/VertexArray/VertexArrayTest.cpp` (1366 lines, 46 cases) — frontend state. Cases most load-bearing for
|
||||
P3a: `VertexAttributeSetup` `124`, `IndexBufferBinding` `156`, `MultipleAttributes` `221`,
|
||||
`BoundVAOPreservesState` `266`, `VertexBindingIndexIsBoundedByTheAdvertisedAttribLimit` `322`,
|
||||
`DefaultAttributeBindingIsIdentityAcrossFullCapacity` `338`,
|
||||
`General_ElementArrayBufferBindingIsVaoLocalAndZeroUnbinds` `557`,
|
||||
`General_ClientSideVertexAttribPointerIsAccepted` `602`, `General_ElementBufferBindingPoint` `750`,
|
||||
`ArrayFormat_PackedStored` `1207`, `ArrayFormat_BgraStored` `1228`,
|
||||
`ArrayFormat_BindingAndRelativeOffsetAreQueryable` `1324`.
|
||||
* `MG_Test/VertexArray/VertexAttribBindingStateTest.cpp` (430 lines) — the two-view invariant:
|
||||
`DefaultsMatchTheSpecInitialState` `198`,
|
||||
**`SeparateFormatSequenceKeepsLegacyStrideAndPointerAtZero` `209`**, `DivisorGoesThroughTheBindingPoint` `318`,
|
||||
`BindingApiRejectsTheDefaultVertexArrayInCoreProfile` `370`, `…StillAcceptsTheDefaultVertexArrayWhenRelaxed` `395`,
|
||||
`RelaxedSemanticsOverrideReopensTheDefaultVertexArray` `415`.
|
||||
* `MG_Test/SanityTest.cpp` `DirectGLESSlotTable` suite (20 cases, `3311`–`4044`). VAO-specific:
|
||||
`EveryReKeyedObjectClassAnnouncesItsOwnDeath` `3706` (VAO at `3727-3734`),
|
||||
`EverySwitchedOverKindResolvesItsTwinThroughTheHandleArm` `3857` (VAO at `3878-3879`),
|
||||
plus `ARecycledSlotIsANewHandleAndTheStaleOneResolvesToNothing` `3311`,
|
||||
`OneDeathNoticeDropsTheTwinInEveryHolderOfTheKind` `3532`, `AnAnnouncedDeathReturnsTheSlotWithoutASweep` `3657`,
|
||||
`EglBringUpUnderTheArmlessKnobPairReturnsInsteadOfStopping` `4044`.
|
||||
* `MG_Test/Pipe/TrackerTest.cpp`: `TrackerAggregates.AVertexArrayAttributeMovesOnlyTheVaoAggregate` `153`
|
||||
(skip-list row `55`), `AVertexAttribDefaultMovesOnlyItsOwnAggregate` `213`,
|
||||
`TrackerWalk.WrapAroundRePushesButNeverMisses` `384`, `TrackerAttribPayload.*` `490-524`.
|
||||
* `MG_Test/Backend/DirectGLES/BaseInstanceInjectionTest.cpp` — the *shader-side* baseInstance gate (`77-155`),
|
||||
not the fetch shift; `MG_Test/SanityTest.cpp:469-609` covers the SPIR-V rewrites.
|
||||
* `MG_Test/Pipe/SlotAllocatorTest.cpp`, `CsoCacheTest.cpp`, `PipeCatalogueTest.cpp` (pins
|
||||
`MGP_CALL_LIST_DOCUMENTED_COUNT = 71`, `PipeCalls.def:69`) — the catalogue/allocator gates P3a must keep green.
|
||||
|
||||
---
|
||||
|
||||
## 8. Traps an implementer will hit
|
||||
|
||||
1. **The twin bakes driver ids into the driver VAO, keyed on FRONTEND versions.** `g_bufferBackendIdGeneration`
|
||||
(`Managers.h:701-707`, read `Managers.cpp:2446`) exists solely because a backend-side re-mint moves no frontend
|
||||
version. A `set_vertex_buffers` keyed on client-side content hash alone reintroduces the bug commit `d7655247`
|
||||
fixed. The generation must stay server-local.
|
||||
2. **Element-array binding restore.** `ScopedRestartIndexSubstitution` (`DirectGLES.cpp:4788-4791`) and
|
||||
`MultiDrawImpl` (`MultiDraw.cpp:101-109`, `929-937`) restore the exact previous GL name *because the twin
|
||||
memoised it*. Whatever replaces the memo must keep an equivalent invariant, or the next draw silently draws
|
||||
through the scratch buffer.
|
||||
3. **fp64 streams are content-derived and covered by no version.** `m_hasConvertedFloat64Attribute`
|
||||
(`Managers.h:919-924`, set `Managers.cpp:2530`, cleared `2471`) forces a full re-walk each draw while any such
|
||||
array is live. A pure content-hash CSO would go stale here.
|
||||
4. **The zero-stride and BGRA paths are the two Adreno SIGSEGV corners** (`Managers.cpp:2495-2520`, `2568-2611`);
|
||||
both must survive the split, and the BGRA probe is the one `glGetError` on the draw path.
|
||||
5. **Client arrays are resolved after `PrepareForDraw`**, per draw range, and only for `DrawArrays` /
|
||||
`MultiDrawArrays` (`DirectGLES.cpp:4805-4821`, `4837-4866`). The push ordering contract (`ARCHITECTURE.md:194`)
|
||||
allows this, but the emitted `set_vertex_buffers` for a client-array attribute names a store that does not exist
|
||||
until the draw entry point runs.
|
||||
6. **`SyncNeccessaryBuffers` also does SSBO binding points and `MarkShaderStorageBuffersGpuWritten()`**
|
||||
(`DirectGLES.cpp:705-706`) — unrelated to vertex input, and it must not be dragged into `set_vertex_buffers`.
|
||||
7. **`ResolveVaoTwin`'s single-entry handle memo.** `SlotTables.h:407-428` names `ResolveVaoTwin` as one of the two
|
||||
callers a one-entry memo helps, *because* `PrepareForDraw` resolves the same VAO once per draw. Two resolves per
|
||||
draw (e.g. adding a second lookup for the elements CSO) would thrash it.
|
||||
8. **`CollectGarbageIfNeeded` at `DirectGLES.cpp:1275`** is legacy-arm-only; do not add a matching tick on the slot
|
||||
arm (`SlotTables.h:37-48`).
|
||||
@@ -0,0 +1,912 @@
|
||||
# P3a scout — the MGPipe scaffolding and the gates
|
||||
|
||||
Tree read: `C:/Users/geekerwan/AndroidStudioProjects/FoldCraftLauncher/MobileGL-disagg`, branch
|
||||
`feat/disaggregated`, HEAD `55d2af9b` ("make the handle-ABA negative control construct its own
|
||||
collision and defeat the {slot, gen} generation"). Read-only; nothing edited.
|
||||
|
||||
What P3a is, per the plan the tree carries (`docs/Disaggregated/ROADMAP.md:19`): handle wave 1 on
|
||||
Espryt — the seven `BufferBackendOps` become `resource_*` / `buffer_subdata_resident` (may be null) /
|
||||
`resource_flush_range` / `resource_readback` / `map_persistent`; pool and deferred release move as-is;
|
||||
vertex elements (all three calls, both backends); `set_vertex_buffers` with an explicit `baseInstance`
|
||||
field; `set_index_buffer`; the Adreno SIGSEGV workaround stays. Acceptance: the full gate set,
|
||||
buffer/VAO scenario families (`LargeArenaAdoption`, `StorageBufferRegrow` publishing
|
||||
`map-persistent-roundtrips`, `VertexAttribBinding`, `MultiDraw`, `PrimitiveRestart`), Create/rd12/26.3/
|
||||
sodium traces, and MC 26.3 p99 unchanged on Adreno. `ROADMAP.md:64` sets the rebaseline trip wire:
|
||||
**P3a over 27 days means the narrow-handle-ification premise was wrong.** `ROADMAP.md:34` puts the
|
||||
full `gl44to46` caselist (~56,271 cases) at P3a, because P3a is one of the five architecture
|
||||
boundaries.
|
||||
|
||||
---
|
||||
|
||||
## 1. MG_Pipe: the catalogue and the payloads P3a fills in
|
||||
|
||||
### 1.1 `MobileGL/MG_Pipe/PipeCalls.def` — the call catalogue
|
||||
|
||||
The wire opcode is the **1-based position in `MGP_CALL_LIST`** (`PipeCalls.def:20-23`): appending is
|
||||
the only legal edit; reordering is a protocol break; a retired call keeps its slot with a comment.
|
||||
`MGP_CALL_LIST_DOCUMENTED_COUNT 71` (`:69`) is the authority and `MG_Test/Pipe/PipeCatalogueTest.cpp`
|
||||
pins the arithmetic against the two generated tables.
|
||||
|
||||
The rows P3a lands (opcode = line order within `MGP_CALL_LIST`, which begins at `:74`):
|
||||
|
||||
| line | call | payload | class | flags |
|
||||
|---|---|---|---|---|
|
||||
| `:75` | `ResourceCreate` | `MGPResourceDesc` | `kScreen` | `kNone` |
|
||||
| `:76` | `ResourceRespecify` | `MGPResourceDesc` | `kScreen` | `kNone` |
|
||||
| `:77` | `ResourceDestroy` | `MGPHandleOnly` | `kScreen` | `kNone` |
|
||||
| `:78` | `MapPersistent` | `MGPHandleOnly` | `kScreen` | `kReplySlot\|kOptional` |
|
||||
| `:79` | `UnmapPersistent` | `MGPHandleOnly` | `kScreen` | `kOptional` |
|
||||
| `:95` | `CreateVertexElements` | `MGPVertexElements` | `kCtxCso` | `kHasBlob` |
|
||||
| `:96` | `BindVertexElements` | `MGPHandleOnly` | `kCtxCso` | `kNone` |
|
||||
| `:97` | `DeleteVertexElements` | `MGPHandleOnly` | `kCtxCso` | `kNone` |
|
||||
| `:108` | `SetVertexBuffers` | `MGPVertexBuffers` | `kCtxState` | `kVarTail` |
|
||||
| `:109` | `SetIndexBuffer` | `MGPIndexBuffer` | `kCtxState` | `kNone` |
|
||||
| `:110` | `SetIndirectBuffers` | `MGPIndirectBuffers` | `kCtxState` | `kNone` |
|
||||
| `:128` | `ResourceSubData` | `MGPSubData` | `kCtxObject` | `kHasBlob\|kVarTail` |
|
||||
| `:129` | `BufferSubDataResident` | `MGPSubData` | `kCtxObject` | `kHasBlob\|kOptional` |
|
||||
| `:130` | `ResourceSubDataComplete` | `MGPSubDataComplete` | `kCtxObject` | `kNone` |
|
||||
| `:131` | `ResourceFlushRange` | `MGPFlushRange` | `kCtxObject` | `kNone` |
|
||||
| `:132` | `ResourceReadback` | `MGPReadback` | `kCtxObject` | `kReplySlot` |
|
||||
|
||||
**`kNeedsAck` is declared but used by no call in the tree today.** It is defined at
|
||||
`MG_Pipe/MGPipe.h:42` (`1u << 0`, "the caller must not proceed until the server has acknowledged.
|
||||
Rare by design"), listed in the `PipeCalls.def:18` flag legend, and referenced once more only as
|
||||
prose in `MG_Remote/Transport/Doorbell.h:19`. **No `X(...)` row carries it** — verified by
|
||||
`grep -rn kNeedsAck`. So if P3a wants `glBufferStorage` to be acknowledged, it is *adding the first
|
||||
use of the flag*, not reusing an existing one: `ResourceCreate` (`:75`) / `ResourceRespecify` (`:76`)
|
||||
currently carry `kNone`, and the immutable-storage discriminator already exists in the payload as
|
||||
`MGPResourceDesc::Immutable` and `MGPResourceDesc::StorageFlags` ("glBufferStorage flags",
|
||||
`MGPipeTypes.h:161-163`). Changing a flag word does not move an opcode, so this is an in-place edit,
|
||||
but it does change the generated tables and therefore requires a `gen_pipe.py` regeneration + diff.
|
||||
|
||||
Deliberately **not** migrated, recorded in the footer `PipeCalls.def:163-177`: `GetIntegeri_v` /
|
||||
`GetInteger64i_v` (the six compute-workgroup answers live in `MGPCaps::Dynamic`), `GetProgramiv`,
|
||||
`ShaderStorageBlockBinding`, `set_pixel_unpack_state` ("no such state crosses the line"), a
|
||||
compressed-format concept, `pipe_transfer`, and a stage dimension on `set_sampler_views`.
|
||||
|
||||
### 1.2 `MobileGL/MG_Pipe/MGPipeTypes.h` — the payloads
|
||||
|
||||
Every payload is `MGP_ASSERT_POD(T, Size)` (`:44-46`): trivially copyable **and** an exact stated
|
||||
size. Adding a member is a build break until the number is updated, and the field list in
|
||||
`PipeFields.def` must be updated in the same commit or `gen_pipe.py` refuses.
|
||||
|
||||
- `MGPResourceDesc` — `:150-176`, **88 bytes**. One discriminated descriptor for buffers, every
|
||||
texture target and renderbuffers. `Resource` handle, `Target`, `StorageKind`, `BindMask`
|
||||
(`:154-157`; the `ELEMENT_ARRAY` bit is the D-B7 switch: with `kCapNeedsHostIndexBytes` the server
|
||||
mirrors this resource), `InternalFormat`, `Width/Height/Depth`, `ArrayLayers/Levels/Samples`,
|
||||
`FixedSampleLocations`, `Immutable`, `Usage` (`BufferUsage`), `StorageFlags` (glBufferStorage
|
||||
flags), `HasDefinedContent` ("false after a NULL-data respecify"), `ImageBindableHint`
|
||||
(client-side `everImageBound`, pre-emptive allocation), `GlNameForDiag` (**diagnostics only** —
|
||||
`:167-170`: a GL name is never an identity, never a memo key, never part of a content hash),
|
||||
`ViewOf`, `BufferForTexBuffer`, `BufOffset`/`BufSize` with `kMGPipeWholeBuffer == ~0ull` (`:177`).
|
||||
- `MGPSubData` — `:587-599`, **72 bytes**. `Res`, `Target`, `Level`,
|
||||
`SourceIsVerbatimLevelShadow` (`:590-592`, replaces the backend's `uploadData == mipData` pointer
|
||||
comparison), `UnionBox`, `RegionCount` (`MGPSubRegion[]` var-tail), `Blob`.
|
||||
**The UnionBox buffer convention** is `:579-586`: with `Target == Buffer` there is no level and no
|
||||
box, so the destination byte range rides in the box — `UnionBox.X` is the byte offset,
|
||||
`UnionBox.W` the byte size, `Y = Z = 0`, `H = D = 1`, `Level = 0`, `RegionCount = 0`, `Blob` holds
|
||||
exactly `Size` source bytes. That caps one record at a 2^31-1 offset and a 2^32-1 size; **the
|
||||
emitter must split a range beyond either**, and at `SEG_STAGE`'s 32 MiB the ring's half-capacity
|
||||
bound is the far tighter constraint. The three accessors are the *only* legal spelling:
|
||||
`MGPipeSetSubDataBufferRange(record, offset, size)` (`:603-611`, returns **false with the record
|
||||
untouched** when the range does not fit — that is the emitter's split signal),
|
||||
`MGPipeSubDataBufferOffset` (`:612-616`; reads `UnionBox.X` through `Uint32` so a corrupt negative
|
||||
X lands above the encodable bound and the applier's bounds gate refuses it) and
|
||||
`MGPipeSubDataBufferSize` (`:617`). Carrying source strides rather than inferring them is
|
||||
deliberate (`:562-565`): the old pointer test cannot survive a split.
|
||||
`MGPSubRegion` is `:566-573`, 40 bytes, `SrcRowStride`/`SrcSliceStride` where 0 means tightly
|
||||
packed. The union box **and** the region list both travel so the *server* picks the upload shape —
|
||||
Mali prices texture upload by job count, ~100 sprite rects vs one union box measured +6 ms/frame
|
||||
(`:575-577`).
|
||||
- `MGPVertexBuffer` — `:356-364`, 32 bytes: `Res`, `Offset`, `Stride`, `Divisor`, `BindingIndex`.
|
||||
**There is no `baseInstance` field here today**; `ROADMAP.md:19` asks P3a for an explicit one, and
|
||||
`MGPDrawInfo` currently carries `StartInstance` (`PipeFields.def:189`).
|
||||
- `MGPVertexBuffers` — `:367-371`, 16 bytes: `Start`, `Count`, `ContentHash`. Var-tail header;
|
||||
`MGPVertexBuffer[Count]` follows. The `ContentHash` is mandatory for **every** `kVarTail` `set_*`
|
||||
(`:350-352`): "or 26.2's redundant `glBindSampler` traffic reappears as a variable-length record
|
||||
per batch".
|
||||
- `MGPIndexBuffer` — `:374-380`, 24 bytes: `Res`, `Offset`, `IndexSize`. `:373` states it is **an
|
||||
independent call, NOT a subset of the VAO configuration version (D5)**.
|
||||
- `MGPIndirectBuffers` — `:382-386`, 16 bytes: `DrawIndirect`, `Parameter`.
|
||||
- `MGPBufferRange` — `:435-440`, 24 bytes: `Res`, `Offset`, `Size`. No inline host span, by design
|
||||
(`:429-434`): the named-UBO host bytes needed under `kCapNeedsHostUboBytes` (D-B8) travel as an
|
||||
*optional second* var-tail of `MGHostSpan[HostSpanCount]` behind the ranges, so SSBO / atomic /
|
||||
XFB ranges do not each pay 32 dead bytes.
|
||||
- `MGPShaderBuffers` — `:445-454`, 32 bytes: `Class` (Uniform | ShaderStorage | AtomicCounter),
|
||||
`Start`, `Count`, `WritableMask`, `HostSpanCount`, `ContentHash`. `HostSpanCount` is 0, or `Count`
|
||||
for the Uniform class under `kCapNeedsHostUboBytes`; a range with nothing to ship carries an empty
|
||||
span so the two arrays stay index-aligned.
|
||||
- `MGPVertexElements` — `:253-…`, `kHasBlob`; fields `Cso`, `AttributeCount`, `BindingPointCount`,
|
||||
`Blob` (`PipeFields.def:71-72`).
|
||||
- `MGPFlushRange` — `:629-635`, 32 bytes, carries **the application's real access flags**
|
||||
(`Flags<BufferMappingAccessBit>`), not a normalised subset.
|
||||
- `MGPReadback` — `:637-641`, 24 bytes. `MGPSubDataComplete` — `:621-626`, 24 bytes, the forward
|
||||
terminator for a server-initiated texture pull, may carry zero regions.
|
||||
- Shared primitives: `MGPBlobRef` `:55-61` (24 B; monolith `Seg == kMGHostSpanSegNone` and `Offset`
|
||||
is an address into the caller's staging arena), `MGPBox` `:70-74`, `MGPReplySlot` `:78-81`
|
||||
("every server query in this catalogue is async-with-handle; none of them blocks"),
|
||||
`MGPHandleOnly` `:93-98` (16 B, `Handle` + widened `Kind`).
|
||||
- Cap bits P3a cares about, `MGPCapBit` `:108-124`: `kCapResidentSubData` (bit 2),
|
||||
`kCapNeedsHostIndexBytes` (bit 7 — arms the index host mirror under split, D-B7),
|
||||
`kCapNeedsHostUboBytes` (bit 8, D-B8).
|
||||
|
||||
### 1.3 `MobileGL/MG_Pipe/MGPipeHandles.h` — identity
|
||||
|
||||
`MGPipeKind` `:24-40`: `None, Buffer, Texture, Renderbuffer, Framebuffer, Xfb, RenderStateCso,
|
||||
VertexElementsCso, SamplerCso, SamplerViewCso, ShaderCso, Fence, Query, Context, KindCount`.
|
||||
`MGPipeHandle` `:54-61` is `{Uint32 Slot, Uint32 Gen}`, 8 bytes, alignment 4, trivially copyable
|
||||
(`:63-65`). **Gen increments only when a SLOT IS REUSED — never on a respecify** (`:44-48`), so a
|
||||
`glBufferData` on a live buffer keeps its handle. Two generations exist and are strictly separate
|
||||
(`:50-53`): this one is the client's "is this the same GL object"; `MGGen` is the *server's* epoch
|
||||
for "did I recast my driver object", and **no MGPipe call may require the client to know MGGen**.
|
||||
Reserved: `kMGPipeNullHandle{0,0}` and `kMGPipeDefaultFramebuffer{0,1}` (`:72-73`),
|
||||
`kMGPipeFirstAllocatableSlot = 1` (`:81`). ShaderCso has a reserved composite band,
|
||||
`kMGPipeShaderCsoSlotLimit = 1<<20` and `kMGPipeShaderCsoCompositeSlotBase` = limit − limit/16
|
||||
(`:88-94`) — not P3a's business but it constrains the allocator.
|
||||
|
||||
### 1.4 `MobileGL/MG_Impl/Pipe/SlotAllocator.h` — minting and recycling
|
||||
|
||||
`MGPipeSlotAllocator` (`:39-96`), one free list plus a high-water mark **per kind** (`kKindCount` =
|
||||
`MGPipeKind::KindCount`, `:41`), so slots stay dense and the server's table is an array. API:
|
||||
`Allocate(kind)` `:47`, `AllocateFor(kind, lifetimeId)` `:49`, `FindByLifetimeId` `:53`,
|
||||
`Acquire(kind, lifetimeId)` `:55` (find-then-allocate — the ordinary client path),
|
||||
`Free(kind, handle)` `:60` (**the Gen bump happens on the NEXT handout of the slot, not here**, so
|
||||
a double free cannot skip a generation), `IsLive` `:62`, `GenOfSlot` `:65`, `LifetimeIdOfSlot` `:66`,
|
||||
`HighWater` `:69` (what a server-side slot-indexed table must be sized to), `LiveCount`/`FreeCount`
|
||||
`:70-71`, `Reset()` `:74`. Storage: `SlotState{Gen, Live, EverHandedOut, LifetimeId}` `:77-82`,
|
||||
`KindState{Vector<SlotState> Slots, Vector<Uint32> FreeList, UnorderedMap<Uint64,Uint32>
|
||||
ByLifetimeId, LiveCount}` `:84-90`. Process singleton `MGPipeSlots()` `:99`; compiled only under
|
||||
`MOBILEGL_PIPE_PUSH` (`:34-36`). The lifetimeId→slot map is what keeps a GL name out of every key
|
||||
(`:30-32`); it has nothing to do with `MG_State`'s `IndexGenerator`, whose LIFO name reuse is the
|
||||
problem `{slot, gen}` exists to close (`:19-22`). Implementation: `SlotAllocator.cpp` (174 lines);
|
||||
unit coverage `MG_Test/Pipe/SlotAllocatorTest.cpp` (recycle/gen/stale-free at `:63-102`, `:163`,
|
||||
`:263`).
|
||||
|
||||
### 1.5 The death notice — and the hole P3a has to fill
|
||||
|
||||
`MobileGL/MG_State/GLState/StateObjectDeathNotice.h` (`MOBILEGL_PIPE_PUSH` only, `:12`):
|
||||
`StateObjectDeathOps{ void (*OnDestroyed)(MGPipeKind, Uint64 lifetimeId) }` `:39-43`, a plain
|
||||
non-atomic pointer `g_stateObjectDeathOps` `:45` written once at backend bring-up,
|
||||
`SetStateObjectDeathOps` `:47`, and `NotifyStateObjectDestroyed(kind, lifetimeId)` `:55-59`. It
|
||||
carries `{kind, lifetimeId}` and **not the object**, because by the time the last `SharedPtr` drops
|
||||
there is nothing left to pass (`:23-26`); one entry point serves all kinds because the backend's
|
||||
answer is the same for all of them: free the slot, drop the twin (`:26-27`). In a pull build the
|
||||
header declares nothing (G1 requires a byte-identical symbol set).
|
||||
|
||||
Frontend raisers today (`grep NotifyStateObjectDestroyed`) — six, and **Buffer is not one of them**:
|
||||
|
||||
- `FramebufferState/FramebufferObject.cpp:36` (Framebuffer)
|
||||
- `ProgramState/ProgramObject.cpp:43` (ShaderCso)
|
||||
- `RenderbufferState/RenderbufferObject.cpp:40` (Renderbuffer)
|
||||
- `SamplerState/SamplerObject.cpp:39` (SamplerCso)
|
||||
- `TextureState/TextureObject.cpp:40` (Texture)
|
||||
- `VertexArrayState/VertexArrayObject.cpp:53` (VertexElementsCso)
|
||||
|
||||
Backend consumer: `MG_Backend/DirectGLES/Managers.cpp:191-217`
|
||||
`OnFrontendStateObjectDestroyed(kind, lifetimeId)`, installed as
|
||||
`g_glesStateObjectDeathOps = {.OnDestroyed = OnFrontendStateObjectDestroyed}` `:219-221`. It drops
|
||||
out early on `InProcessTeardown()` `:192` (a notice after `exit()` has begun is dropped — the twin
|
||||
is a *deliberate* leak, `:187-190`), then switches to `<Kind>Impl::g_backend<Kind>Objects.
|
||||
DestroyByLifetimeId(lifetimeId)`. **`MGPipeKind::Buffer` falls into `default:` with the comment
|
||||
"Buffer already has its own death signal (`BufferBackendOps::OnDestroy`)"** (`:212-215`).
|
||||
|
||||
That existing buffer signal is `BufferBackendOps::OnDestroy(SharedPtr<BackendBufferResource>&&)`
|
||||
declared at `MG_State/GLState/BufferState/BufferObject.h:103` and called from
|
||||
`~BufferObject` at `BufferState/BufferObject.cpp:39-43` — it hands over the *resource*, not
|
||||
`{kind, lifetimeId}`, and it fires only when `m_resource.Backend()` is set. **P3a must decide
|
||||
whether the buffer slot is freed through the ops table's `OnDestroy` or by adding the seventh
|
||||
`NotifyStateObjectDestroyed(MGPipeKind::Buffer, m_lifetimeId)` raiser and an arm in the
|
||||
`Managers.cpp` switch.** The `SlotTables.h` header prose already says "All six re-keyed object
|
||||
classes raise …" (`DirectGLES/SlotTables.h:38`), i.e. the seventh is exactly the P3a delta.
|
||||
|
||||
`DestroyByLifetimeId` is **static** and answered by *every live table of the kind*, not just the
|
||||
global — a by-value copy held by a fixture or a context reset is a real configuration — and the slot
|
||||
goes back **once, last**, after every holder has let go (`SlotTables.h:49-59`,
|
||||
`Managers.cpp:180-185`). That holder-list discipline is load-bearing because the allocator erases
|
||||
its lifetimeId→slot mapping on `Free`, so a notice resolved twice would find nothing the second time.
|
||||
|
||||
Other `SlotTables.h` facts P3a inherits: the key stops being a frontend heap address, so the
|
||||
`weak_ptr` per entry stops being an identity test and `OwnerEquals` / three `TwinLookupMemo`s /
|
||||
`UnitSamplerLookupMemo`'s owner compare lose their reason to exist (`:23-28`); the lookup becomes one
|
||||
bounds check plus one array index, so a returned `BackendPtr*` survives the next `Find` (`:29-32`);
|
||||
there is **no GC on this arm** — no draw tick, no creation tick, no sweep; the seven
|
||||
`CollectGarbageIfNeeded` sites in `DirectGLES.cpp` drive the legacy registry only (`:43-47`). The
|
||||
`weak_ptr` survives for one reason: `ForEachLive()` hands a strong reference to
|
||||
`ScopedDetachedTextureFramebufferAttachments` (`:61-68`).
|
||||
|
||||
**Recorded debt P3a should be aware of, `SlotTables.h:70-77`:** this header is under `MG_Backend/`
|
||||
and it *mints* handles (`MGPipeSlots().Acquire`) off a frontend `SharedPtr`'s `GetLifetimeId()`,
|
||||
which contradicts `MGPipeHandles.h:13-16` ("minted by the CLIENT and never by the server"). It is
|
||||
monolith glue; the minting and the resolution belong on the client and the backend should receive the
|
||||
handle in the verb payload. **Not covered by any gate** — `check_include_closure.py` does not probe
|
||||
`MG_Backend` headers.
|
||||
|
||||
Magma's side: `MG_Backend/DirectVulkan/Renderer/MagmaPipeArms.h`. `MagmaPipeIdentityTable` (entry
|
||||
storage `:369-378`: `m_entries`, `m_freeSlots`, `m_index`, plus a one-entry front memo
|
||||
`m_lastLifetimeId/m_lastIndex/m_lastHandle`), and `MagmaPipeIdentityTables` `:384-402` owning
|
||||
`m_vaos{"VertexElementsCso"}` and `m_buffers{"Buffer"}`. `HandleOf(kind, lifetimeId)` `:388-391`
|
||||
routes `Buffer` to the buffer mint and everything else to the VAO mint — **a VAO is kind
|
||||
`VertexElementsCso`** (`:386-387`). These are **per renderer, not process-global** (`:381-383`), so
|
||||
Magma is *not* a holder in Espryt's holder list and does not mint out of `MGPipeSlots()`.
|
||||
`MagmaPipeSlotIndex(handle)` `:411-417` is `handle.Slot - kMGPipeFirstAllocatableSlot` with an assert
|
||||
(compiled out at INFO) and a ternary that has effect in a shipped build.
|
||||
`MagmaPipeSlotTable<T, kChunkEntries=256>` `:427+` grows by appending chunks so **entry addresses
|
||||
never move** — the draw path holds references across nested calls.
|
||||
`VertexInputStateFactory.cpp:64` already calls
|
||||
`m_identity->HandleOf(MGPipeKind::Buffer, attr.Buffer->GetLifetimeId())`, i.e. Magma's vertex-input
|
||||
hash is already keyed on the buffer handle (commit `43f8b470`).
|
||||
|
||||
### 1.6 `PipeApply.{h,cpp}` — the in-process applier
|
||||
|
||||
`MG_Pipe/PipeApply.h` (150 lines) / `PipeApply.cpp` (667 lines), compiled **only** under
|
||||
`MOBILEGL_PIPE_PUSH` (`PipeApply.h:30`). Under split this file becomes
|
||||
`MG_Remote/Server/PipeApplier`; in the monolith it writes `MG_Backend/MGPipe/PipeInputs`'s
|
||||
`gPipeInputs` directly, so a call and its effect are one function call apart (`:15-18`).
|
||||
**The server's per-context working block *is* `PipeInputs::m_renderState`** (`:20-25`) — which is why
|
||||
DirectGLES' `SyncRenderState` did not change a line, and why the verify comparator is a real oracle
|
||||
("assembled == live", field by field, at every backend read).
|
||||
|
||||
Per-context stores, `MGPipeApplierState` `:48-87`:
|
||||
- `Vector<MGPipeRenderStateCsoRecord> RenderStateCsos` `:51`, indexed by `MGPipeHandle::Slot`, slot 0
|
||||
never live. Each record `:42-46` = `{Uint32 Gen, Bool Live, Array<Uint8,
|
||||
kMGPipePipelineChunkBytes> PipelineBytes}` — it keeps the 396 pipeline bytes because an incremental
|
||||
`create_render_state` names only the chunks that moved against a `BaseCso`.
|
||||
- `MGPipeHandle BoundRenderStateCso` `:53` — the last bind, so a rebind of the same handle needs no
|
||||
scatter.
|
||||
- `ResidualValueBlock Residual` + `Bool HasResidual` `:56-57`.
|
||||
- `Uint32 ScatteredChunkBits` `:77` — the applier's own ledger of which global chunk bits it (rather
|
||||
than the fill loop) wrote. Both trip wires arm off it, and the contract is spelled at `:62-76`:
|
||||
with the render-state subsystem OFF nothing is scattered, the ledger stays empty and the wires say
|
||||
nothing; with it ON the applier is the block's only writer. `set_patch_state`'s own write
|
||||
deliberately does **not** enter the ledger — a wire comparing against bytes it wrote itself is a
|
||||
tautology (`:74-76`).
|
||||
- Four observable counters `:83-86`: `ResidualCapabilitiesCompared`, `ResidualDivergences`,
|
||||
`PatchCarrierComparisons`, `PatchCarrierDivergences`. Rationale `:79-82`: only a poison or verify
|
||||
build aborts, so the shipped push build counts and logs and a unit case can see the wire fire in
|
||||
*every* build.
|
||||
- Singletons `MGPipeApplier()` `:90` (`PipeApply.cpp:393`) and `MGPipeApplierReset()` `:93`.
|
||||
|
||||
**Seven apply entry points today, and that is all of them** (`PipeApply.h:99-122`, definitions at
|
||||
`PipeApply.cpp:407, 457, 476, 490, 499, 503, 561, 607`):
|
||||
`MGPipeApplyCreateRenderState`, `…BindRenderState`, `…DeleteRenderState`, `…SetDynamicState`,
|
||||
`…SetPixelPackState`, `…SetPatchState`, `…SetVertexAttribDefaults`, `…SetResidualValueState`.
|
||||
**Nothing for buffers, resources, vertex elements, vertex buffers or the index buffer exists yet —
|
||||
that is P3a's server half.**
|
||||
|
||||
Plus the derivation step (`PipeApply.h:124-149`): `MGPipeDeriveRenderStateFields(inputs)`
|
||||
(`PipeApply.cpp:657`) recomputes every `PipeInputs` field that is a pure function of the working
|
||||
`RenderStateParameters`, and `MGPipeDeriveRenderStateFieldsForChunks(inputs, globalChunkBits)`
|
||||
(`:664`) is the scoped form the applier actually calls, so a per-frame `glViewport` (dynamic chunk D0
|
||||
alone) does not pay the 8-wide blend loop, the 16-wide depth-range loop or the 35-arm capability
|
||||
switch. Every guard's chunk set is computed with `MGPipeRenderStateChunkBitsCovering`, so a boundary
|
||||
move cannot leave one stale. Trip-wire log tag: `MGP_TRIP_WIRE_TAG(name)` = `"Fatal{" name "}"`,
|
||||
`PipeApply.cpp:29-31` — that is the marker G4 greps the retrace logs for.
|
||||
|
||||
Client-side CSO cache, `MG_Impl/Pipe/CsoCache.h` — the shape P3a's vertex-elements CSO should copy.
|
||||
Lookup (`:14-25`): (1) widened `m_pipelineStateVersion` did not move → reuse the last handle, **zero
|
||||
hashing, zero probing** — the steady state; (2) moved → hash the 396 pipeline bytes, probe, and
|
||||
**confirm with a memcmp** before reuse (a bare 64-bit equality would alias two states onto one CSO —
|
||||
silent wrong pixels with no gate that could see it; Mesa's `cso_cache` memcmps for the same reason);
|
||||
(3) miss → mint a slot, emit `create_render_state` with every chunk, bind. Capacity 64
|
||||
(`kMGPipeCsoCacheCapacity`, `:53`), ~26 KB per context, provisional pending the P13 retune.
|
||||
Counters `:57-69`: `Mints`, `Binds`, `Hits`, `Collisions`, `Evictions`.
|
||||
|
||||
---
|
||||
|
||||
## 2. The P2 tracker and the emission step
|
||||
|
||||
### 2.1 `MobileGL/MG_Impl/Pipe/Tracker.h` (436 lines, header-only)
|
||||
|
||||
Header-only for an ownership reason, not a design one (`:40-44`): the root `CMakeLists.txt` that
|
||||
would name a new `.cpp` belongs to package A and is frozen behind the `p2/contract` tag. Splitting it
|
||||
out is one `list(APPEND)` line. **P3a will hit the same wall if it wants `Tracker.cpp`.**
|
||||
|
||||
`enum class MGPipeDirty` `:57-80`, 18 bits, one per row of `ARCHITECTURE.md 5.2`:
|
||||
- value class, **emitted at P2** (`:58-63`): `NewRenderState` 0, `NewPipelineState` 1, `NewPixelPack`
|
||||
2, `NewPatchState` 3, `NewVertexAttribDefaults` 4.
|
||||
- value class, **computed and counted, emitted from P3a on** (`:64-68`): `NewVertexElements` 5,
|
||||
`NewShader` 6, `NewShaderBindings` 7, `NewGlobalConstants` 8.
|
||||
- object class, from P3b/P4b (`:69-78`): `NewVertexBuffers` 9, `NewIndexBuffer` 10, `NewFramebuffer`
|
||||
11, `NewSamplerViews` 12, `NewSamplers` 13, `NewShaderImages` 14, `NewConstBuffers` 15,
|
||||
`NewShaderBuffers` 16, `NewSoTargets` 17.
|
||||
|
||||
Names table `:95-114`, `kMGPipeDirtyEmittedAtP2` `:90-93`, `kMGPipeDirtyCount <= 32` asserted `:83`.
|
||||
**`ROADMAP.md:19` puts `set_vertex_buffers` and `set_index_buffer` in P3a, but bits 9 and 10 are
|
||||
labelled P3b/P4b in this enum — reconcile that before wiring, and update `:64-78`'s comments.**
|
||||
|
||||
`MGPipeSubsystemForDirty(bit)` `:119-135` maps a bit to its runtime `MOBILEGL_PIPE_PUSH` subsystem
|
||||
and **returns 0 for bits 5..17** ("no call of their own until P3a/P3b/P4a/P4b, so there is no
|
||||
subsystem to switch and the residual fill keeps supplying their fields"). Subsystem constants are in
|
||||
`MG_Pipe/MGPipe.h:72-85`: bit 0 RenderState, 1 PixelPack, 2 PatchState, 3 VertexAttribDefaults,
|
||||
4 ResidualValues, 5 EsprytSlots (Track H), 6 MagmaVertexInput (Track H); **bits 7..62 reserved,
|
||||
allocated in ROADMAP order and never reused** (`:79` — an operator's recorded `0x7f` has to keep
|
||||
meaning what it meant); bit 63 is `kMGPipeBehaviourNoCsoContentAddressing`, the negative control, not
|
||||
a subsystem. Default for a push build with the knob unset: `kMGPipeSubsystemsMigratedAtP2 = 0x7f`
|
||||
(`:85`). **P3a's new subsystem bits are 7 and up.**
|
||||
|
||||
`MGPipeMixShutter(acc, value)` `:143-146` is the composite shutter hash. Its collision caveat is
|
||||
explicit (`:137-142`): a collision costs a *missed* fire, which is acceptable **for bits 5..17 and
|
||||
only for them**, because nothing consumes those bits in P2 — "P3 replaces each with its own exact
|
||||
shutter as it takes the subsystem over". The five P2 emits for are never composed.
|
||||
`MGPipeWidenedCounter` `:159-177` widens a `Uint16` at the tracker boundary (`Observe` `:161`);
|
||||
a decrease is a wrap and adds 65536. The one case it cannot see is stated at `:153-158`: a counter
|
||||
advancing by exactly a multiple of 65536 inside one verb boundary reads as unchanged.
|
||||
|
||||
`MGPipeTracker::Update(ctx, verbClass)` `:188-307`, the dirty walk. A different context calls
|
||||
`Reset()` first (`:192-195`) so the first walk publishes a complete state. Shutters:
|
||||
- bits 0/1 `:202-205` — widened render-state and pipeline-state versions.
|
||||
- bit 4 `:208` — `ctx.GetAnyVertexAttribDefaultGeneration()`.
|
||||
- `vaoIdentity = MixShutter(vao->GetLifetimeId(), vao->GetConfigVersion())`, 0 when unbound
|
||||
(`:210-212`); bit 5 `NewVertexElements` **is exactly this** (`:213`).
|
||||
- bits 6/7/8 `:219-236` from the current program's `GetLinkVersion` / `GetImageUnitVersion` +
|
||||
`GetBackendStateVersion` + `GetBlockBindingVersion` + `GetUniformWriteSetVersion` /
|
||||
`GetUBOContentVersion`. `:215-218` — deliberately **not** `GetProgramForDraw`, which joins a
|
||||
pending link; the tracker must not force a compile to answer "did the shader move".
|
||||
- aggregate reads `:239-241`: `GetAnyTextureContentGeneration`, `GetAnyTextureParamsGeneration`,
|
||||
`buffers = ctx.GetAnyBufferChangeGeneration()`.
|
||||
- bit 9 `NewVertexBuffers` = `MixShutter(ctx.GetAnyVaoAttributeGeneration(), vaoIdentity)` `:243-244`.
|
||||
- bit 10 `NewIndexBuffer` = `MixShutter(buffers, vaoIdentity)` `:248`, with the reason at `:245-247`:
|
||||
the index buffer lives in the bound VAO's element slot, P2 has no cheap shutter for that slot
|
||||
alone, so it **shares the buffer aggregate and over-fires on any buffer write anywhere. "P3b
|
||||
narrows it when it takes the subsystem over."** — the narrowing P3a/P3b owes.
|
||||
- bits 15/16 `NewConstBuffers`/`NewShaderBuffers` are the raw `buffers` aggregate `:259-260`;
|
||||
bit 17 mixes it with the XFB generation `:261-262`.
|
||||
- bits 2 and 3 are `memcmp` shutters handled outside the loop (`:266-270`, `:275-293`) — bit 3
|
||||
because **NaN is a legal `glPatchParameterfv` value and must compare equal to itself**, which float
|
||||
equality denies and memcmp grants.
|
||||
- latch and count `:271-272`, `:299-305`, behind `MG_Util::PipeStats::Enabled()`.
|
||||
|
||||
`Reset()` `:313-326` clears the latches but **deliberately not the fire tallies** (`:311-312`): they
|
||||
are a per-run measurement. `ResetCounters()` `:328`. Readouts: `FireCount(bit[, verbClass])`
|
||||
`:333-340`, `WalkCount` `:341-349`, `LastDirty()` `:350`, `Primed()` `:351`, `FreshlyPrimed()` `:355`.
|
||||
**No timer lives here** (`:35-38`): ROADMAP forbids committing hot-path instrumentation; absolute
|
||||
ns/draw comes from DriverBench, from outside the library.
|
||||
|
||||
Design rule P3a must keep (`:27-33`): **every shutter over-fires on purpose.** A bit that fires too
|
||||
often costs one extra push; a bit that fires too rarely renders stale, and the P1 verify comparator
|
||||
**cannot see that for object-class state** (it compares those by identity only). Narrowing is P3's
|
||||
work, paid for with the fire rates this file publishes.
|
||||
|
||||
### 2.2 How a new call family gets an emitter — `MG_Impl/Pipe/PipeFill.cpp` (1198 lines)
|
||||
|
||||
`MGPipeValidateForVerb(verb)` `:1053-1197` is the validate point, five steps (declared in
|
||||
`PipeFill.h:21-35`):
|
||||
|
||||
1. `:1055-1075` — parse the poison knob, arm verify, bump `filled.CurrentVerbSerial` (starts at 1,
|
||||
so a read before the first bump is `Fatal{UnmigratedPipeInput, "<Field>@<none>"}` rather than
|
||||
default storage, `:1068-1071`), set verb and context identity. `MG_Config::Features.PipeVerify`
|
||||
set without the compiled comparator emits `MGLOG_W_ONCE` `:1061-1064` — a lane's arming assertion
|
||||
turns that into red.
|
||||
2. `:1084-1085` — the dirty walk.
|
||||
3. `:1087-1128` — emission. The gate closure `wants(bit)` `:1093-1097` is
|
||||
`MGPipeSubsystemForDirty(bit) != 0 && (pushMask & subsystem) && (dirty & bit)`. `:1088-1091`
|
||||
states the rule: **every gate goes through `MGPipeSubsystemForDirty`, the one map**; naming the
|
||||
constants inline would be a second copy of the map in the only path that runs.
|
||||
`tracker.FreshlyPrimed()` handling is **before** the per-subsystem gates `:1110-1115` and resets
|
||||
`MGPipeCsoCacheInstance()`, `MGPipeApplierReset()`, `MGPipeSetHashSuppressorInstance().
|
||||
InvalidateAll()` and `g_residualDue = true` — it used to live inside `EmitRenderState`, which runs
|
||||
only when bit 0 is set, so a per-subsystem A/B that cleared bit 0 gave a fresh context a
|
||||
never-reset applier (`:1100-1109`). Then the four emitters `:1117-1128`
|
||||
(`EmitRenderState` `:982`, `EmitPixelPackState` `:767`, `EmitPatchState` `:777`,
|
||||
`EmitVertexAttribDefaults` `:824`); each returns `payloadBytes`.
|
||||
4. `:1130-1161` — the residual fill. For each field in the verb class's mask: skip sticky fields
|
||||
(`:1136-1144`; under poison, stamp them once with `FilledGen = 1`), then compute
|
||||
`supplied = subsystem != 0 && (subsystem & kMGPipeWiredSubsystems) && (pushMask & subsystem) &&
|
||||
EmittedCallSuppliesTheWholeField(field) && (applierDerives || AppliedWithoutDerivation(field))`
|
||||
`:1150-1155`, and `CopyField` only when not supplied `:1156`. **The stamp is written either way**
|
||||
(`:1145-1149`) — a stamp says "this verb published this field", which is as true of an emitted
|
||||
field as of a copied one, and withholding it would abort every backend read of exactly the fields
|
||||
the migration just took over.
|
||||
4b. `:1162-1186` — the residual value block. `g_residualDue` is armed **outside** the subsystem gate
|
||||
`:1163-1170` (whether the capability set may have moved is a fact about the frontend), and the
|
||||
block is emitted **after** step 4 `:1171-1174` because its trip wire compares against the
|
||||
assembled mirror; it is held rather than dropped at verbs whose class does not read
|
||||
`IsCapabilityEnabled` `:1176-1185`.
|
||||
5. `:1187-1193` `PipeStats::RecordDrawPayloadBytes(payloadBytes)`; `:1194-1196` the verify
|
||||
`EntryCompare`.
|
||||
|
||||
**The wiring checklist for a new emitter** (from `:621-672`):
|
||||
- add rows to `Coverage.def`'s `MGP_COVERAGE_EMITTED_LIST` (§2.4);
|
||||
- add the emitter arm to `SubsystemForEmitter(MGPipeFieldEmitter)` `:624-638` — the map from a
|
||||
*field's emitter* to the subsystem;
|
||||
- add the matching `MGPipeSubsystemForDirty` arm in `Tracker.h`;
|
||||
- **add the `static_assert` pairing them.** `:640-644` states why: the two maps answer different
|
||||
questions (one takes an emitter, one takes a dirty bit) and must agree, because emission is gated
|
||||
on one and the residual-fill skip on the other; a divergence would push a call whose field is still
|
||||
pulled, or worse skip a field whose call was never emitted. Existing asserts `:645-663`;
|
||||
- extend `kMGPipeWiredSubsystems` `:669-672` — "it grows one commit at a time, and a field whose
|
||||
emitter is not wired here keeps being pulled, so adding a row to `Coverage.def` can never silently
|
||||
drop a field on the floor before the call that carries it exists";
|
||||
- extend `EmittedCallSuppliesTheWholeField` `:693+` if the call supplies a field completely.
|
||||
|
||||
Other machinery in this file P3a touches: `MGPipeNoteFrontendMutation` `:498`,
|
||||
**`MGPipeNoteAggregate(aggregate)` `:518`** (§2.5), the seven F-class forwarders `:568-604`,
|
||||
`MGPipeLeaveVerb` `:607`, `MGPipeVertexAttribDefaultRepairCount`/`…LastHeader` `:1049-1050`.
|
||||
|
||||
### 2.3 The set-hash suppressor — `MG_Impl/Pipe/SetHashSuppressor.h` (85 lines)
|
||||
|
||||
Coalescing rule 4 (`:12-13`): **every `kVarTail` `set_*` hashes the resolved set on the client and
|
||||
does not emit when the hash has not moved.** `MGPipeSuppressorSlot` `:36-45` already has the slots:
|
||||
`SetVertexBuffers = 0` (**marked P3b**), `SetSamplerViews`, `BindSamplerStates`, `SetShaderImages`,
|
||||
`SetShaderBuffers`, `SetStreamOutputTargets`, `SetVertexAttribDefaults` (**the one P2 wired**).
|
||||
`ShouldEmit(slot, contentHash)` `:53-59` latches and returns; **hash 0 is reserved for "never
|
||||
emitted"** and a computed 0 is remapped to 1 (`:23-25`, `:54`) — one collision in 2^64 costs an extra
|
||||
emission and never a missed one. `Invalidate(slot)` `:63`, `InvalidateAll()` `:65-67`,
|
||||
`LastEmitted(slot)` `:71`. Singleton `:80-83`. This is the carrier for the ~175 lines of debounce
|
||||
that move off the backends in P3b/P4b — Espryt's `UnitBindingsSnapshot` / `CaptureUnitBindings` /
|
||||
`UnitBindingsUnchanged` and Magma's equivalents (`:15-21`).
|
||||
|
||||
### 2.4 `MobileGL/MG_Pipe/Coverage.def` — the emitted list and the semantic-merge trap
|
||||
|
||||
`MGP_COVERAGE_ACCESSOR_LIST` `:29-104` joins the 477-row read inventory
|
||||
(`scripts/data/backend_read_inventory.md`, 57 files) against a pipe call. Three pseudo-calls stand
|
||||
for rows that never become a forward call (`:19-24`): `kClientResolved`, `kReverseChannel`,
|
||||
`kStructuralHandle`. Rows matching neither list are UNMAPPED — merely counted today, **zero from P5
|
||||
on** (`:16-17`).
|
||||
|
||||
Buffer/VAO rows:
|
||||
- `GetBoundVertexArray → BindVertexElements` `:36`
|
||||
- `GetBufferBindingSlot → SetIndirectBuffers` `:42`, with the caveat `:37-41`: **the accessor is
|
||||
polymorphic over `BufferTarget` and its rows really split across `set_vertex_buffers`,
|
||||
`set_index_buffer`, `set_indirect_buffers` and `set_shader_buffers`**; the split waits on the
|
||||
inventory being re-vendored carrying the target argument (the extractor lives in MobileGL-CS,
|
||||
deferred out of P1). It is named for the plan's explicit `DrawIndirect`/`Parameter` replacement.
|
||||
- `GetBufferBindingPoint` / `GetBufferBindingPointCount` / `GetTouchedBufferBindingPointCount →
|
||||
SetShaderBuffers` `:43-45`
|
||||
- `MGP_COVERAGE_DELTA_LIST` `:128-130`: `handle-ify (wire handle) → kStructuralHandle`,
|
||||
**`Buffer ops delta → ResourceRespecify`**. This list is read by `gen_pipe.py` only, never by the
|
||||
preprocessor, because the delta kinds are the inventory's free-text labels, not C tokens.
|
||||
|
||||
`MGP_COVERAGE_STICKY_LIST` `:116-123` — exactly the seven F-class accessors whose value is valid
|
||||
across verbs, so the poison's per-verb generation does not apply. The argument is uniform (`:106-115`):
|
||||
each takes an argument that is not verb state (a GL name, a lifetime id, a target), so there is no
|
||||
value the filler could copy and no verb whose fill could make it stale. **None of the
|
||||
version/generation accessors is sticky** — those change under verbs and are precisely what the poison
|
||||
must protect. A verify-lane `Fatal{UnmigratedPipeInput}` is fixed by a `FillPoints.def` row, **never**
|
||||
by a sticky row, and `gen_pipe.py` refuses a name that is not an accessor above.
|
||||
|
||||
`MGP_COVERAGE_EMITTED_LIST` `:154-187` — which P2 call now *supplies* a `PipeInputs` field so the
|
||||
residual fill loop can skip it; `gen_pipe.py` turns it into `kMGPipeFieldEmittedBy[]` in
|
||||
`generated/PipeFilled.inc`. A field with no row here keeps going through the fill loop, **which is
|
||||
what makes the `MOBILEGL_PIPE_PUSH` bitmask a true per-subsystem A/B rather than an all-or-nothing
|
||||
switch** (`:135-136`). 33 rows, all render-state / patch / attrib-default. The one row whose call
|
||||
differs from the accessor list's is `GetPrimitiveRestartIndex` (coverage maps it to `draw_vbo`
|
||||
because that is where a backend reads it, but the value travels in dynamic chunk D6, so
|
||||
`set_dynamic_state` supplies it) `:141-143`.
|
||||
|
||||
**`GetPixelStoreParameters` is deliberately absent, `:145-153`** — and this is the semantic-merge
|
||||
trap. The field is `PipeInputs::m_pixelStore[2]` (pack **and** unpack) while `set_pixel_pack_state`
|
||||
carries the pack half only, permanently (D10). A row here would be a half-truth: with the bitmask
|
||||
bit set, the unpack half would be written by nothing while its poison stamp said it was published, so
|
||||
neither the poison nor the verify comparator could see it. Until the field is split, the whole of it
|
||||
goes through the fill loop and the pack half is written twice.
|
||||
|
||||
**How the trap actually fired (commit `bb2a236d`, "drop the emitter arm for set_pixel_pack_state that
|
||||
spans retired"):** the spans work (`d1a7c5f1`) removed `GetPixelStoreParameters` from the emitted
|
||||
list, so the generated `MGPipeFieldEmitter` **no longer had a `SetPixelPackState` enumerator** — but
|
||||
the tracker's subsystem map and its `static_assert`, written against the contract, still named it, and
|
||||
**the push and verify builds did not compile on the integrated tree.** The fix
|
||||
(`PipeFill.cpp:651-657`) drops the emitter arm and keeps a `static_assert` on the *dirty bit* instead:
|
||||
`MGPipeSubsystemForDirty(NewPixelPack) == kMGPipeSubsystemPixelPack`, because the bit is what the
|
||||
emission gate consults while the field stays in the residual loop by design. **The lesson for P3a:
|
||||
`Coverage.def`'s emitted list is generated-enum input, and every semantic merge that touches it must
|
||||
be re-checked against `SubsystemForEmitter`'s switch arms and their static_asserts in `PipeFill.cpp`
|
||||
and `Tracker.h`. Green on two branches separately is not green on the merge — build push AND verify.**
|
||||
|
||||
### 2.5 Fields, verbs, mutation surface
|
||||
|
||||
`MobileGL/MG_Pipe/PipeFields.def` — the G4 comparator's field lists, one macro per payload. Padding
|
||||
is deliberately absent because verify must have **zero** false positives and a padding byte is what
|
||||
makes a `memcmp` of `RenderStateParameters` falsely differ (`:9-13`). Hand maintained alongside
|
||||
`MGPipeTypes.h`, `MGPipeValueTypes.h`, `MGPipeHostSpan.h`, `MG_Backend/BackendObject.h`;
|
||||
`gen_pipe.py` asserts **in both modes, hence in `pipe-gates`**, that every list names exactly the
|
||||
direct data members of its struct, `Pad<n>` excluded (`:16-19`). Rows relevant to P3a:
|
||||
`MGP_FIELDS_MGPResourceDesc` `:44-48` (22 fields), `MGP_FIELDS_MGPVertexElements` `:71-72`,
|
||||
`MGP_FIELDS_MGPVertexBuffer` `:96-97`, `MGP_FIELDS_MGPVertexBuffers` `:99-100`,
|
||||
`MGP_FIELDS_MGPIndexBuffer` `:102-103`, `MGP_FIELDS_MGPIndirectBuffers` `:105-106`,
|
||||
`MGP_FIELDS_MGPBufferRange` `:123-124`, `MGP_FIELDS_MGPShaderBuffers` `:126-127`.
|
||||
`MGP_VERIFY_PAYLOAD_LIST` at `:302-319` is the emission order — **`gen_pipe.py` reads this list to
|
||||
know what to emit**, so a new payload must be added there too.
|
||||
|
||||
`MobileGL/MG_Pipe/FillPoints.def` — `MGP_FILL_VERB_LIST(X)` `:73+`, one row per function-pointer
|
||||
member of `MG_Backend::GLFunctionsTable` (`BackendObject.h`) **in declaration order**;
|
||||
`gen_pipe.py` parses that struct and refuses a row set that is not exactly its member set (`:71-72`).
|
||||
Nine verb classes are in use (`kDraw`, `kClear`, `kBlitOrCopy`, `kTextureOp`, `kReadback`,
|
||||
`kDispatch`, `kQuery`, `kXfbSpan`, plus the class field masks). Note `:60-64`: retiring a
|
||||
class-field-mask row would need the poison omission run across the **full CTS caselist on both
|
||||
devices**, not the desktop corpus — and that is explicitly **recorded as P3a work**.
|
||||
Formatting constraint: `gen_pipe.py`'s block regexes end at a blank line, so keep the empty line
|
||||
after each macro (`:67`).
|
||||
|
||||
`MobileGL/MG_Pipe/PipeMutation.h` — `MGP_NOTE_MUTATION(Field)` `:79-80` and
|
||||
`MGP_NOTE_AGGREGATE(Aggregate)` `:81-82`, both `((void)0)` in a pull build `:84-85`.
|
||||
`enum class MGPipeAggregate` `:56-74`: `VaoAttribute` 0 (any VAO attribute format / buffer / enable
|
||||
moved), `FramebufferAttachment`, `TextureContent`, `TextureParams`, **`BufferChange`** (any buffer
|
||||
object contents moved), `VertexAttribDefault`. Counters are members of the owning `MG_State`
|
||||
container, all under `MOBILEGL_PIPE_PUSH so the pull build's state objects do not change size (G1)`
|
||||
(`:46-48`); the macro goes through a free function that finds the live `GLContext` because objects
|
||||
have no back-pointer to their state (`:48-51`). **Monotonic and never reset** — the tracker widens and
|
||||
compares, never subtracts (`:53-55`). Buffer bump sites are already in place:
|
||||
`BufferState/BufferObject.cpp:47` (`NotifyRespecify`), `:55` (`NotifySubData`), `:65`
|
||||
(`NotifyFlushMappedRange`), each also bumping `m_changeSerial`.
|
||||
|
||||
`MobileGL/MG_Pipe/DirtySurface.def` — the G9 completeness map. Verdict kinds include `kImmediate`,
|
||||
`kExplicitDestroy`, `kUnpublishedDestroy`, `kNoBackendRead` (`:75`); `kExplicitDestroy` means the
|
||||
mutation is published by the `delete_*` / `resource_destroy` call the Track H slice adds (`:98`).
|
||||
Buffer/VAO rows: `MarkBufferObjectForDeletion → kExplicitDestroy` `:252`,
|
||||
`MarkVertexArrayForDeletion → kExplicitDestroy` `:260` (and the other four kinds at `:253-259`).
|
||||
`MGP_DIRTY_SURFACE_UNDECIDED_LIST` is **empty** today (`:285`) — a row can be parked there when the
|
||||
scanner cannot answer. The TransformFeedbackBinding reasoning at `:239-249` is the worked example of
|
||||
how a binding that moves no shutter is argued.
|
||||
|
||||
`MobileGL/MG_Pipe/MGPipe.h:87-121` shows what a generator run produces and where each `.inc` lands
|
||||
inside the namespace: G1 `PipeTables.inc` (`:92`), G2 `PipeThunks.inc` (`:101`), G3 `PipeWire.inc`
|
||||
(wire records, size assertions **and the applier's bounds precondition**, `:104`), G4
|
||||
`PipeVerify.inc` (`:107`), G5 `PipeFilled.inc` (`:110`), G5b `PipeFillPoints.inc` (`:115`), G6
|
||||
`PipeCoverage.inc` (`:118`), G7 `PipeSpanTable.inc` (`:121`). All eight are committed in
|
||||
`MobileGL/MG_Pipe/generated/` — deliberately, so **the build never depends on python**.
|
||||
|
||||
---
|
||||
|
||||
## 3. The gates as they stand after P2
|
||||
|
||||
### 3.1 `scripts/check_include_closure.py` — interface purity
|
||||
|
||||
Four probes, `PROBES` at `:73-138`; each carries a `Why` printed in the summary, and `Allow` entries
|
||||
are deliberately awkward — each needs a Reason printed on every run so a whitelist entry has to be
|
||||
argued in the PR (`:70-72`). All four have empty `Allow` today.
|
||||
|
||||
| probe | header | forbidden | text limits |
|
||||
|---|---|---|---|
|
||||
| `value-header` `:74-88` | `MG_Pipe/MGPipeValueTypes.h` | `MG_State/`, `MG_Impl/`, `MG_Backend/`, `MG_Remote/` | — |
|
||||
| `artifacts-header` `:89-108` | `MG_State/GLState/ProgramState/ProgramArtifacts.h` | `ShaderObject.h`, `MG_Util/ShaderTranspiler/`, `Config.h`, `MG_Backend/`, `BufferState/`, prefix `ProgramState/Shader` | `glslang:: ≤ 2` |
|
||||
| `mutation-header` `:109-127` | `MG_Pipe/PipeMutation.h` | `MG_Impl/`, `MG_State/GLState/Core.h`, `MG_Remote/` | — |
|
||||
| `wire-header` `:128-137` | `MG_Remote/Transport/ITransport.h` | `MobileGL/Includes.h` | — (the gate's own canary) |
|
||||
|
||||
`REQUIRED_PROBE_NAMES = ("value-header", "artifacts-header")` `:141` — deleting a probe must be red,
|
||||
not quietly green. Modes `:35-40`: `text` (transitive walk of literal `#include` lines, no compiler),
|
||||
`clang` (`-H -E` on a one-line probe TU, the ground truth), `both` (runs both and additionally fails
|
||||
if they disagree about the violations). `--require-all` `:42-45` turns every SKIP (a probe whose
|
||||
header does not exist yet) into a failure — the ratchet the integrator flips as headers land.
|
||||
CI invocation, `.github/workflows/test.yml` job `include-graph-check` (`:738`, name "Include-closure
|
||||
purity gate"): `python3 scripts/check_include_closure.py --mode both --compiler clang++-20
|
||||
--self-test --require-all`, after `git submodule update --init include/ska 3rdparty/xxHash
|
||||
3rdparty/Vulkan-Headers` and installing `clang-20 libx11-dev`. It does not depend on `build-linux`.
|
||||
**`check_include_closure.py` does NOT probe `MG_Backend` headers** — which is exactly why
|
||||
`SlotTables.h`'s client/server minting debt (§1.5) is uncaught.
|
||||
|
||||
### 3.2 `scripts/symbol_report.py --threshold 0` — G1
|
||||
|
||||
G1 is spelled `added == removed == resized == renamed == 0` and `.text` delta 0 (`:36-40`); the
|
||||
canonical invocation is `--threshold 0 --fail-on-symbol-set-change --fail-on-added-bytes 0` (`:40`).
|
||||
`--fail-on-symbol-set-change` covers **all four buckets, not just added/removed**: a resize at zero
|
||||
net delta is what a same-size rewrite produces (`:42-44`), and it always compares at threshold 0
|
||||
whatever `--threshold` says (`:404-410` — `--threshold` is a *report* control, and a gate reading the
|
||||
thresholded buckets would quietly weaken itself). `bucket()` `:176-207`; `gate_failures()`
|
||||
`:251-269`; a `--self-test` (`:294-332`) pins the buckets and the three shapes that used to walk
|
||||
through (a shrunk `.text` under a zero budget, a resize at zero net delta, …).
|
||||
|
||||
The **four admitted resizes** are the integrator's, not the script's — `wsl_p2_gate.sh:24`:
|
||||
`RenderState::RenderState`, `RenderState::SetCapability`, `RenderState::IsCapabilityEnabled`,
|
||||
`_GLOBAL__sub_I_DirectGLES.cpp`. The gate script runs
|
||||
`symbol_report.py --before ~/w7/p2-before-libMobileGL.so --after build-linux/libMobileGL.so
|
||||
--threshold 0 --markdown ~/w7/p2g-symbols.md` (`:25`) and then prints the Resized table (`:26`) for
|
||||
the operator to compare against that list by eye. The CI counterpart is the `monolith-symbol-report`
|
||||
job (`test.yml:1359`), **`workflow_dispatch` only**, which builds the baseline in a worktree at
|
||||
`inputs.baseline_sha`, default `"087685d1"` (`test.yml:14-21` — "P1's G1 says the pull build is
|
||||
byte-identical to `feat/disaggregated@087685d1`").
|
||||
|
||||
The gate script also pins the pull build's `SyncRenderState` body by sha256 of the
|
||||
`namespace RenderStateImpl` block in `DirectGLES.cpp` against `~/w7/p2-before-syncrenderstate.sha`
|
||||
(`wsl_p2_gate.sh:27-28`), and asserts `grep -rc pGLContext MobileGL/MG_Backend` is empty (`:23`).
|
||||
|
||||
### 3.3 The generator gates — CI job `pipe-gates` (`test.yml:1538-1617`)
|
||||
|
||||
`name: MGPipe generators and hygiene gates`, `runs-on: ubuntu-latest`, **deliberately independent of
|
||||
`build-linux`** — source-level, seconds, and a broken build must not hide a drifted interface
|
||||
(`:1541-1542`). Steps:
|
||||
|
||||
1. `Regenerate the MGPipe interface (G1-G7)` `:1553-1556`: `python3 scripts/gen_pipe.py` then
|
||||
`git diff --exit-code -- MobileGL/MG_Pipe/generated`.
|
||||
2. `The MGPipe generators' checks can still fail` `:1562-1563`: `gen_pipe.py --self-test`. Rationale
|
||||
`:1558-1561`: regenerate-and-diff cannot see a check that silently stopped checking — a broken
|
||||
gate and a clean tree produce the same green. The controls are at `gen_pipe.py:1207-1246` — seven
|
||||
of them, each must trip, and **zero trips is itself an error** (`:1241-1242`), plus a mismatch
|
||||
count check `:1243-1244` and a positive control `:1240`. They cover: a struct member with no
|
||||
`F(...)`, an `F(...)` that is not a member, a payload with no struct, a verb missing from
|
||||
`FillPoints.def`, a verb that is not a `GLFunctionsTable` member, a field row naming a
|
||||
non-accessor, and **an emitted row naming a call that does not exist in `PipeCalls.def`**
|
||||
(`:1230-1234`) — the enum-generation guard the `bb2a236d` merge trap sits next to.
|
||||
The two structural checks it drives are `check_field_lists_cover_struct_members` `:416-421` and
|
||||
`check_call_payloads_have_field_lists` `:479-481`, **both of which run in `--check` mode too**.
|
||||
`parse_coverage` refuses an emitted field that is not an accessor `:522-523` or listed twice
|
||||
`:525`; `gen_emitted_by` `:809-845` refuses an emitted row whose call is not real `:817-819`.
|
||||
3. `The symbol report's buckets and gates can still fail` `:1566-1567`:
|
||||
`symbol_report.py --self-test`.
|
||||
4. `No stdio instrumentation in MG_Backend or MG_State` `:1576-1583`: greps for
|
||||
`fprintf(stderr|stdout)`, bare `printf(`, `puts(`, `std::cout|cerr`. **Zero exceptions today**, and
|
||||
any addition needs a PR reason rather than a quiet whitelist entry (`:1569-1575`) — per-draw
|
||||
instrumentation has been committed by accident before, once inside a mutex critical section.
|
||||
5. `MGPipe dirty-surface mapping is complete (G9)` `:1601-1604`:
|
||||
`gen_pipe_dirty_surface.py --check` then `--self-test`. `--check` **fails both directions**
|
||||
(`:1586-1588`): a mutator the scanner finds with no row in the def, *and* a row naming a mutator
|
||||
the scan no longer finds — so a deleted mutator cannot leave a stale row claiming coverage. The
|
||||
self-test is not optional (`:1590-1594`): two canned negative controls (a mutator withheld, a row
|
||||
naming a function that does not exist). What it does **not** cover, stated in `DirtySurface.def`'s
|
||||
header rather than left implicit (`:1596-1600`): a mutation inside a lambda is attributed to the
|
||||
enclosing function, a mutation published through a helper reads as deferred, and it scans only
|
||||
`MG_Impl/GLImpl`, so the four `MGP_NOTE_MUTATION` sites in `MG_State` are outside it entirely. It
|
||||
is a completeness gate over what the scanner can see; **the semantic proof is the verify lane.**
|
||||
6. `Documentation citation lint` `:1609-1617`: `check_doc_citations.py docs/Disaggregated/*.md`,
|
||||
**warning only** (`|| true`) until the documents settle.
|
||||
|
||||
Also independent of `build-linux`: `flatc-check` (`test.yml:710`) regenerates
|
||||
`MG_Remote/Protocol/generated/protocol_generated.h` and `git diff --exit-code`s it.
|
||||
|
||||
### 3.4 The verify lane and the retraces
|
||||
|
||||
Compile-time: `MOBILEGL_PIPE_VERIFY` is an *option*, and `PipeInputs.h` derives `MOBILEGL_PIPE_POISON`
|
||||
from it (`test.yml:313-314`, `:375-381`). Job `build-linux-verify` (`:315`) configures with
|
||||
`-DMOBILEGL_PIPE_VERIFY=ON` (`:396`) and then has a hard artifact check,
|
||||
**"The verify library really carries the comparator"** `:415-424`: if `libMobileGL.so` defines no
|
||||
`MGPipeVerifyInputs` it errors with "…every lane that consumes this artifact would run the
|
||||
comparator-free library and pass having compared nothing". It publishes
|
||||
`mobilegl-linux-runtime-verify`.
|
||||
|
||||
Job `integration-verify` (`:484`) unpacks that runtime and runs:
|
||||
- `ctest -L integration-verify` (`:524-549`) — 818 entries per the P2 brief.
|
||||
- `Unit tests on the verify runtime (G6, G10)` `:568-570` — `ctest -L unit`, because
|
||||
`MGPipeRenderStateSpans.cpp` / `PipeApply.cpp` are appended to `SOURCE_FILES` only inside the
|
||||
`if (MOBILEGL_PIPE_PUSH)` block, and the push-only tests `GTEST_SKIP()` elsewhere (`:555-559`).
|
||||
- `The handle-ABA and CSO-content-addressing controls (G8, G12)` `:589-600` —
|
||||
`ctest -L integration-gpu -R 'HandleRecycle|CsoContentAddressing'`. This is the **only** CI job
|
||||
that unpacks a `MOBILEGL_PIPE_PUSH` build (`:572-577`).
|
||||
- `The verify lanes armed the comparator` `:615+` — catches what ctest cannot: an arming entry that
|
||||
*skipped* still reports green (`:612-614`).
|
||||
- **Negative control A** `:641-656`: `MOBILEGL_PIPE_VERIFY_CORRUPT: GetRenderRateParameters`
|
||||
(`GetRenderStateParameters`) — the step passes when **ctest FAILS** (`if ctest …; then error`),
|
||||
the only shape that can catch a comparator that stopped comparing (`:633-637`). It counts matched
|
||||
tests first `:651` because an empty selection would also exit non-zero under `--no-tests=error`.
|
||||
The knob reaches the process through the **job** environment, not a ctest `ENVIRONMENT` property
|
||||
(`:637-640`) — the property-overrides-job-env trap.
|
||||
- **Negative control B** `:670`: an omitted fill point must turn the lane red on that verb
|
||||
(`MOBILEGL_PIPE_POISON_OMIT`, `PipeFill.h:46-52`).
|
||||
|
||||
Retrace: `trace-cases` (`:961`) emits three matrices from `tools/trace_replay/trace_cases.json` —
|
||||
**40 cases total, 39 CI-enabled, 77 full matrix entries, 8 verify cases → 16 verify matrix entries**
|
||||
(computed by running `trace_cases.py` against the tree). `verify: true` is validated where the
|
||||
manifest is parsed rather than where the matrix is built, so a typo is a loud manifest error in every
|
||||
consumer (`trace_cases.py:29-37`), and a case marked `verify` but excluded from CI raises (`:35-37`).
|
||||
Job `retrace-verify` (`:1202`) runs that 16-entry matrix, `max-parallel: 4`, `timeout-minutes: 240`,
|
||||
needing `build-linux-verify` + `build-retrace` + `trace-cases` + `trace-fixtures`; it unpacks the
|
||||
verify runtime over `build-retrace`'s frozen absolute library path (`:1259-1261`).
|
||||
|
||||
**The 79-case sweep is the integrator's local one, not CI's.** `~/w7/notes/p2/BRIEF-P2.md:37` (G3)
|
||||
defines it: "79 desktop cases: 40 × 2 minus `iterationrp × DirectGLES`", driven by
|
||||
`~/w7/retrace_gate.py` — a standalone script that parses the reference `build-retrace`
|
||||
`CTestTestfile.cmake` for case parameters and per-test `ENVIRONMENT`, rewrites library/fixture/output
|
||||
paths onto the tree under test, applies the CI per-case env, and runs `cmake -P run_trace_case.cmake`
|
||||
with bounded parallelism, writing JSON + text summaries; exit 0 only when every selected case passes.
|
||||
`wsl_p2_gate.sh:52-59` runs it twice (verify then push) and reports "verify armed: N of M" by
|
||||
grepping for `MGPipe verify:` and lists every log carrying `Fatal{`.
|
||||
|
||||
Trigger note: `test.yml:4-12` — `push` on `dev`, `Feat/Backend-Direct-GLES`,
|
||||
`Feat/Backend-Direct-Vulkan` and **`feat/disaggregated`**, the last marked
|
||||
"TEMPORARY, remove before merging the MGPipe work into dev … so a phase's landing is not gated on
|
||||
someone remembering to dispatch the workflow by hand", plus `workflow_dispatch`.
|
||||
|
||||
### 3.5 The HandleRecycle lanes and the G7 negative control
|
||||
|
||||
`MG_IntegrationTest/Scenarios/HandleRecycleScenario.cpp` (`MG_IntegrationTest/CMakeLists.txt:132`) is
|
||||
registered **four times** — `DirectGLES.HandleRecycle.Handles.` `:877-878`,
|
||||
`DirectVulkan.HandleRecycle.Handles.` `:886-887`, `DirectGLES.HandleRecycle.Legacy.` `:895-896`,
|
||||
`DirectVulkan.HandleRecycle.Legacy.` `:904-905` — all filtering `HandleRecycleScenario.*`. The
|
||||
`Handles` arm needs a backend keyed on `{slot, gen}` (packages C and D, `:326`); the CMake emits
|
||||
explicit warnings when a configuration will make an arm SKIP (`:418`, `:445`, `:456`, `:459`) and
|
||||
re-checks a marker before either arm asserts so a hand-forced configuration cannot pass silently
|
||||
(`:376`). `:814` records that the scenario is meaningful in a pull build too (lifetimeId + weak_ptr
|
||||
guards), so `ctest -R HandleRecycle` selects sensibly in both.
|
||||
|
||||
The arm selection is `ClassifyEsprytSlotArm(subsystemBitSet, legacyMemosEnabled)`
|
||||
(`Managers.cpp:226-237`): with `MOBILEGL_PIPE_LEGACY_MEMOS`, bit 5 set → `Handles`, else
|
||||
`PipeLegacyMemos` → `Legacy` else `NoArm`; without it, `Handles` is the only arm.
|
||||
`ResolveEsprytSlotTablesArm()` `:255-292` resolves **at the first twin lookup, not at bring-up** —
|
||||
deliberately, and it is the fix for a lane that went green by skipping: bring-up runs inside
|
||||
`eglMakeCurrent`, which the harness pre-flights in a forked child, and a child that aborts is
|
||||
reported as "no usable GPU" and skips every scenario (`:261-267`). `NoArm` is
|
||||
`Fatal{PipeLegacyMemosDisabled, …}` + `std::abort()` `:278-282`, because returning instead would run
|
||||
the very arm the operator disabled and hand back a green measured on it — "which is exactly the lever
|
||||
`HandleRecycleScenario`'s arms are selected with" (`:269-277`). The recent fix `55d2af9b` makes the
|
||||
ABA control construct its own collision and defeat the `{slot, gen}` generation.
|
||||
|
||||
**G7 negative control — `scripts/g7_negative_control.sh`.** Not a CI lane; it rebuilds the library
|
||||
twice and is run by hand and by the integrator at the five-part gate (`:31-32`). It breaks the
|
||||
pipeline/dynamic split on purpose — moves `ColorMasks` out of pipeline chunk P1 into a dynamic chunk
|
||||
by inserting boundaries at `ColorMasks` and `FramebufferSrgbEnabled` (`:19-25`) — deliberately a break
|
||||
the compiler **cannot** catch, since the chunks still ascend, do not overlap and cover
|
||||
`[0, sizeof(RenderStateParameters))`, so every structural `static_assert` still holds. What breaks is
|
||||
meaning: `glColorMask` bumps `m_pipelineStateVersion` but no longer moves the pipeline-subset hash,
|
||||
and `RenderStateSpansTest`'s SetterConsistency has to **name `SetColorMask`**. The four measurement
|
||||
pins (7/8 chunks, 396/772 bytes) are relaxed by the same patch, because leaving them would turn the
|
||||
control into a build break — proving the assertions compile rather than that the test still checks
|
||||
(`:27-29`). Exit codes `:44-51`: **0** = tripped *and* named `SetColorMask` (or, under
|
||||
`--verify-patch-only`, the patch compiled); **1** = did not answer — either it stayed green on a
|
||||
demoted member, or it went red without naming `SetColorMask` so the red cannot be attributed
|
||||
(both are findings about the test, and both leave the tree restored and rebuilt); **2** = could not
|
||||
run the control at all. Usage: `g7_negative_control.sh <build-dir> [--verify-patch-only]`, and
|
||||
`<build-dir>` must carry the push-only unit tests since `MGPipeRenderStateSpans.cpp` compiles only
|
||||
under `MOBILEGL_PIPE_PUSH` (`:37-39`).
|
||||
|
||||
### 3.6 `wsl_p2_gate.sh` — the integrator's gate script
|
||||
|
||||
`//wsl.localhost/Arch/home/swung/w7/notes/tools/wsl_p2_gate.sh`, 61 lines, run in `~/w7/pipe`.
|
||||
Usage `wsl_p2_gate.sh [quick]` — `quick` skips the two 79-case retrace sweeps (`:3`).
|
||||
|
||||
**The fail-fast rule, `:4` and `:19`:** three builds are made first — `build-linux` (pull),
|
||||
`build-push` (`-DMOBILEGL_PIPE_PUSH=ON`), `build-verify` (`-DMOBILEGL_PIPE_VERIFY=ON
|
||||
-DMOBILEGL_ITEST_REQUIRE_GPU=ON`) — and **if any returns non-zero the script prints
|
||||
`BUILD FAILED - gate aborted (no stale-binary verdicts)`, echoes `P2_GATE_DONE` and exits 1.**
|
||||
"Results from a stale binary must never look like a verdict." It also prints the first two `error:`
|
||||
lines of each build log (`:18`). Common flags `:10`: Ninja + clang/clang++ + ccache, `Release`,
|
||||
`MOBILEGL_LOG_ACTIVE_LEVEL=INFO`, tests and integration tests ON, **`BENCHMARK=OFF`**, mesa EGL
|
||||
vendor json and lvp Vulkan ICD, `CMAKE_POLICY_VERSION_MINIMUM=3.5`.
|
||||
`export CCACHE_BASEDIR=/home/swung/w7` `:6`.
|
||||
|
||||
Parts:
|
||||
- **Part 1, interface purity** `:21-29`: `check_include_closure.py`; `pGLContext` must not appear
|
||||
anywhere under `MG_Backend`; the G1 symbol report with the four admitted resizes named in the echo
|
||||
(`:24`); the `SyncRenderState` sha comparison; `HandleRecycle` under `build-verify`.
|
||||
- **Part 5, coverage/poison/handle discipline** `:31-34`: `gen_pipe.py --check` and `--self-test`;
|
||||
`gen_pipe_dirty_surface.py --check` and `--self-test`; `ctest -R 'RenderStateSpans\.|Residual'` in
|
||||
`build-push`.
|
||||
- **Part 3, behavioural A/B** `:36-48`: G2 — a `ctest -N` **name diff between pull and push must be
|
||||
zero lines** (`:39`); G14 — names removed/added versus `~/w7/p2-before-ctest-names.txt` (`:40`);
|
||||
`ctest -L unit` in all three builds; `ctest -L integration-gpu` in pull and push with a
|
||||
`--rerun-failed` pass; **`MOBILEGL_PIPE_PUSH=0` on the push build** (`:44`); the
|
||||
render-state-sensitive subset `ClipDistance|SampleMaskScope|SampleVariables|DualSourceBlend|
|
||||
ViewportArray|PrimitiveRestart` (`:45`); `g7_negative_control.sh build-push` (`:46`);
|
||||
`CsoContentAddressing` (`:47`); the controls `PoisonOmitted\.|VerifyCorrupted\.|HandleRecycle`
|
||||
under `build-verify` (`:48`).
|
||||
- **Part 2, semantic shadow comparison** `:50-60`: `ctest -L integration-verify` counting `Fatal{`
|
||||
lines and the top five `Fatal{Kind, "detail"}` by frequency; then, unless `quick`, the two
|
||||
`retrace_gate.py` sweeps described in §3.4, with `MOBILEGL_PIPE_VERIFY=1` on the verify one, and
|
||||
the two summaries copied out before the output trees are deleted.
|
||||
- Terminator: `echo P2_GATE_DONE` `:61`.
|
||||
|
||||
Sibling scripts in the same directory: `wsl_p2_bench.sh`, `wsl_p2_tree.sh`, `wsl_integrate_p2.sh`,
|
||||
`p2_ab.sh`.
|
||||
|
||||
---
|
||||
|
||||
## 4. Measurement infrastructure P3a inherits — for RECORDING, not gating
|
||||
|
||||
### 4.1 `tools/trace_replay/run_android_retrace_local.py --benchmark`
|
||||
|
||||
`--benchmark` (`:383-387`) replays each case end to end as a frame-timing benchmark instead of
|
||||
comparing images. Companions: `--benchmark-repeats` `:389`, `--benchmark-tail-frames` `:395`,
|
||||
`--benchmark-no-finish` `:401`, `--benchmark-timeout-seconds` `:407-410` ("a benchmark replays the
|
||||
whole trace, not just up to `target_call`"). `run_benchmark_case` `:312-361` passes `--benchmark`,
|
||||
`--benchmark-tail-frames`, `--benchmark-finish 0|1`, deletes the stale `benchmark.json` first `:332`,
|
||||
files each run as `benchmark-run<N>.json` (`read_benchmark` `:214-225`) and prints per-run plus
|
||||
best-of lines `:344-361`.
|
||||
|
||||
`benchmark.json` carries the **whole `frameCpuTimesMs[]` array** on purpose (`cpu_tail` `:265-281`):
|
||||
the device computes no p99, so p99 is a **host-side reduction over an artefact that already exists**.
|
||||
The window is the same trailing `tailFrames` the device summarised, so the host numbers sit beside
|
||||
the device's own rather than describing a different set of frames. `nearest_rank_percentile`
|
||||
`:247-262` uses nearest rank, not an interpolating percentile, "so that every number printed here is a
|
||||
frame that was actually observed" and so a host p95 agrees **exactly** with the device's for the same
|
||||
window; `series_median` `:240-244` recomputes p50 by the device's own median rule so it agrees with
|
||||
`medianFrameCpuMs` on the same run rather than merely sitting next to it (commit `af20dba6`).
|
||||
`format_benchmark` `:284-302` prints `frames / total / tail / mean / median / p95 / fps` and then the
|
||||
CPU half on the same line — **"it is what the disaggregation A/B is actually read on"**, because wall
|
||||
time under `--benchmark-no-finish` still contains everything the retrace thread waited for
|
||||
(`:294-296`). Per-frame thread CPU time was added by commit `e9499d38`
|
||||
("record per-frame thread CPU time beside wall time so a paired A/B can be read as CPU cost").
|
||||
|
||||
### 4.2 `//wsl.localhost/Arch/home/swung/w7/notes/tools/p2_ab.sh` — the paired A/B driver
|
||||
|
||||
`p2_ab.sh <serial> [case ...]`, run from **Windows Git Bash** with `adb.exe` on PATH (`:6`).
|
||||
Design (`:2`): `{pull, push} APK × {no-finish, finish} × cases × backends`, reboot-clean once, pinned
|
||||
for the whole session with the pin **verified and retried**, one device-lock hold per run. Outputs go
|
||||
to a Windows-local scratchpad dir because **Git Bash cannot create directories on `//wsl.localhost`**
|
||||
(`:3-5`, and I hit exactly that: `mkdir //wsl.localhost/... → Read-only file system`, though the
|
||||
`Write` tool and shell redirection into an existing directory both work); `copy_ab.sh` moves them into
|
||||
`~/w7/notes/p2/ab/<serial>/`. **Do not export `MSYS_NO_PATHCONV`/`MSYS2_ARG_CONV_EXCL` globally here**
|
||||
(`:7-8`): the runner passes `/c/...` paths to Windows python and relies on MSYS converting them.
|
||||
|
||||
Defaults `:10-16`: runner tree `…/MobileGL-disagg` ("must be at the integrated commit"), APKs read
|
||||
over UNC from `~/w7/notes/p2/apk/trace-{pull,push}.apk`, pin helper from
|
||||
`~/w7/notes/p2/devices/pin_device.sh`, package `top.mobilegl.plugin.trace`, four default cases:
|
||||
`minecraft-1.21.4-in-world`, `minecraft-1.21.4-fabric-iris-bsl-in-world`,
|
||||
`improved-transparency-minecraft-26.3`, `minecraft-1.21.4-startup`.
|
||||
Session start `:24-35`: reboot, wait for device, poll `sys.boot_completed`, poll for root (24 × 5 s),
|
||||
sleep 20, wake + unlock keyevent, uninstall the package, then **pin up to 3 times with a
|
||||
`check` after each and exit 43 if none verified**. Device lock is a `mkdir` mutex with a 900 s timeout
|
||||
and an owner file, exit 42 on timeout `:20-21`; `trap … EXIT` unlocks and unpins `:22`.
|
||||
Per-run `:39-52`: `pin check` before and after, install the arm, `--benchmark-no-finish` for the
|
||||
`nofinish` mode, then
|
||||
`ANDROID_SERIAL=$SER python tools/trace_replay/run_android_retrace_local.py --case … --backend …
|
||||
--benchmark $extra --benchmark-repeats 3 --benchmark-tail-frames 200 --env MOBILEGL_PIPE_STATS=1
|
||||
--env MOBILEGL_PIPE_STATS_PERIOD=120`, copies `benchmark*.json` / `mobilegl.log` / `result.json` out
|
||||
of `.trace-work/android-retrace-result/*-<backend>/`, and prints a one-line summary carrying
|
||||
`rc`, `pin=<before>/<after>`, elapsed seconds, the `cpu mean=… p99=…` extract, and the count of
|
||||
`MGPipe stats: frames` windows in the device log. Terminator `AB_DONE <serial>`.
|
||||
`7a2e2561` is the commit that lets the trace APK be built in the push shape for this A/B.
|
||||
|
||||
### 4.3 `MobileGL/MG_Benchmark/Driver/run_driver_bench.sh` — DriverBench
|
||||
|
||||
`./run_driver_bench.sh native|espryt|magma [<libMobileGL.so>] [bench args…]` (`:2-5`). The bench
|
||||
**dlopens exactly one EGL provider** through `DRIVERBENCH_EGL_LIB` — the system `libEGL.so.1` for
|
||||
native, or the given `libMobileGL.so` for a backend — with **no `LD_LIBRARY_PATH` shadowing**, so
|
||||
MobileGL's own loader still finds the real driver underneath (`:6-9`). Vendor libraries are pinned
|
||||
explicitly (`:11-15`): a bare `libEGL.so.1` on a glvnd system picks whatever
|
||||
`eglGetDisplay(EGL_DEFAULT_DISPLAY)` resolves first, which is Mesa/llvmpipe — "a software rasteriser
|
||||
silently replacing the GPU under a benchmark"; override `MGL_EGL_VENDOR` / `MGL_VK_ICD` to test
|
||||
another driver (defaults are the NVIDIA json/ICD, `:19-20`). `espryt` sets
|
||||
`MOBILEGL_BACKEND_TYPE=DirectGLES`; `magma` sets `DirectVulkan` plus `VK_ICD_FILENAMES` (`:30-38`).
|
||||
Binary override: `DRIVERBENCH_BIN` (`:18`). Sources: `Driver/DriverBench.c`,
|
||||
`Driver/DriverBenchCases.inc`, and the on-device entry `MG_Util/SelfTest/DriverBenchJni.cpp`.
|
||||
`Tracker.h:35-38` names DriverBench as the **only** source of absolute ns/draw, because it times whole
|
||||
frames from outside the library and the tree forbids committing hot-path timers. Note that
|
||||
`wsl_p2_gate.sh` configures with `-DMOBILEGL_BUILD_BENCHMARK=OFF`, so the gate build does not carry it.
|
||||
|
||||
### 4.4 `tools/device_bench/pin_device.sh` — the pin helper
|
||||
|
||||
`pin_device.sh <serial> pin|unpin|check` (`:2`). It exists because `bench.sh`'s
|
||||
`pin_freqs()`/`unpin_freqs()` are MediaTek-legacy-only (`/proc/ppm` + `/proc/gpufreq`) and **neither
|
||||
campaign device has those paths — on both of them `bench.sh`'s pin writes into nothing and exits 0**,
|
||||
the silent "the run looks pinned but is not" failure the `PROFILE_VERIFIED` guard was built to catch
|
||||
(`:4-9`). The prescribed sequence (`:12-15`): `pin`, then `bench.sh … --no-pin`, then `check ||
|
||||
"PIN DRIFTED - discard this run"`, then `unpin`. All three actions print live big/little/GPU
|
||||
frequencies, governors and the gate temperature, so the output of `pin` and `unpin` is itself the
|
||||
before/after evidence (`:17-18`).
|
||||
|
||||
**`check` is deliberately three-valued** (`:20-30`), because "no pin at all" and "a pin that slipped"
|
||||
are different facts: **0 PINNED** (every pinned node at its pin and every live frequency equal to it),
|
||||
**1 DRIFT** (partly pinned, or a live frequency left its pin — *the dangerous state: a run overlapping
|
||||
this is not comparable, discard it*), **2 UNPINNED** (no node at a pin this script set — the correct
|
||||
state to leave a device in, and still non-zero so `pin_device.sh X check && measure` cannot silently
|
||||
measure unpinned). UNPINNED is asserted against **our** pins, not the stock range, because ColorOS
|
||||
moves `policy4`'s max on its own within seconds of a release and an exact-stock comparison reported
|
||||
DRIFT on a correctly unpinned device (`:28-30`). Stock values are hardcoded from a 2026-09-07 reading
|
||||
rather than sampled at pin time, because a restore reading "stock" off an already-pinned device would
|
||||
make the pin permanent (`:32-36`). Git Bash hygiene: `export MSYS_NO_PATHCONV=1
|
||||
MSYS2_ARG_CONV_EXCL='*'` so MSYS does not rewrite `/sys/...` and `/proc/...` arguments (`:39-40`).
|
||||
Landed by `2d690754`; `13d7e32b` restored the executable bit on it and `profile.sh`.
|
||||
Siblings in `tools/device_bench/`: `bench.sh`, `profile.sh`, `session.sh`, `devices/`, `README.md`.
|
||||
|
||||
**None of §4 gates anything.** The A/B numbers are recorded evidence; the only performance-shaped
|
||||
acceptance criterion `ROADMAP.md:19` states for P3a is "MC 26.3 在 Adreno 上 p99 不变" — p99 unchanged,
|
||||
read off `frameCpuTimesMs` through the host-side reduction in §4.1.
|
||||
|
||||
---
|
||||
|
||||
## 5. Short checklist for a P3a implementer
|
||||
|
||||
1. Flags/opcodes: edit `PipeCalls.def` in place for `kNeedsAck` (first use in the tree); **never**
|
||||
reorder. Regenerate and commit `MG_Pipe/generated/*.inc`.
|
||||
2. Payloads: add the `baseInstance` field to `MGPVertexBuffer` → update its `MGP_ASSERT_POD` size,
|
||||
its `MGP_FIELDS_*` list, and (for a *new* payload) `MGP_VERIFY_PAYLOAD_LIST`.
|
||||
3. Buffer sub-data: encode only through `MGPipeSetSubDataBufferRange` and **handle its `false`
|
||||
return by splitting**; the tighter real bound is the ring's half capacity, not 2^32.
|
||||
4. Tracker: give bits 5 / 9 / 10 exact shutters, allocate subsystem bits **7 and up** in ROADMAP
|
||||
order, and wire `MGPipeSubsystemForDirty` + `SubsystemForEmitter` + the pairing `static_assert`
|
||||
+ `kMGPipeWiredSubsystems` in the same commit. Reconcile bits 9/10's "P3b" comments with
|
||||
`ROADMAP.md:19`.
|
||||
5. Suppressor: `MGPipeSuppressorSlot::SetVertexBuffers` already exists — use it; hash 0 is reserved.
|
||||
6. Death: decide `BufferBackendOps::OnDestroy` vs. a seventh `NotifyStateObjectDestroyed` raiser, and
|
||||
respect the holder-list "resolve once, free the slot last" discipline.
|
||||
7. Applier: add the new apply entry points and their per-context stores beside
|
||||
`MGPipeApplierState`; anything the applier writes into the working block must either enter the
|
||||
ledger or have a stated reason not to (the `set_patch_state` tautology precedent).
|
||||
8. Residual: `MGL_RESIDUAL_BLOCK_SIZE` is **8** (`MGPipeTypes.h:546`), one `Uint64 CapabilityBits`
|
||||
(`:521-533`). It only ever goes **down**; shrinking the block without lowering the number, or
|
||||
growing it at all, is a build break (`:535-539`). **P3a must not add anything to
|
||||
`ResidualValueBlock`** — buffer, VAO, vertex-buffer and index-buffer state gets a real call, and if
|
||||
any of it is not ready it stays in the per-verb residual *fill loop* (`kMGPipeFieldEmittedBy` /
|
||||
`CopyField`), which is a different mechanism from this block.
|
||||
9. Gates before pushing: `gen_pipe.py --check --self-test`, `gen_pipe_dirty_surface.py --check
|
||||
--self-test`, `check_include_closure.py --mode both --self-test --require-all`,
|
||||
`symbol_report.py --self-test`, and the full `wsl_p2_gate.sh` (build push **and** verify — that is
|
||||
where the `bb2a236d` merge trap surfaced).
|
||||
Reference in New Issue
Block a user