[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:
2026-10-15 20:01:45 -04:00
parent 0e3e2b7761
commit aabca3c171
1035 changed files with 410 additions and 398 deletions
@@ -0,0 +1,197 @@
# Per-context pipe dirty mask: plan (2026-10-09, PARKED)
**Status:** parked by the user on 2026-10-09 after the revised estimate (FCL ~0.012-0.03 ms/frame).
The persistent-map flush goes first; revisit this for draw-heavy content. C8, the cross-context
gap below, is approved as its own fix.
Replaces `MGPipeTracker::Update`'s per-verb polling of ~25 frontend counters with a per-context
mark word. Mutations OR in the subsystem bits they affect; the validate point visits only the
marked bits and keeps today's leaf compare. A sharper form of PLAN-P15 stage 1; it is client-side
only and the record stream stays byte-identical on every transport.
## Expected savings (revised by the planning pass)
The pool this change can touch on FCL is ~0.04-0.06 ms/frame:
- `Tracker::Update` 0.018-0.029;
- `CopyField` 0.018-0.021;
- part of `MGPipeValidateForVerb` self.
| workload | gain (ms/frame) |
|---|---|
| FCL | ~0.012-0.03 |
| rd12 | ~0.10-0.15 |
The 0.3-0.5 of PLAN-P15 stage 1 also skipped `ReadDrawBindings`, `MarkGpuWritesForDraw` and the
backend walks, which are out of scope here.
## Design
- `GLContext` gets:
- `Uint32 m_pipeDirty = ~0u`;
- an owner serial (`TakePipeDirty(trackerSerial)` returns all bits to a different tracker, so
the verify shadow walk or a test tracker cannot steal marks);
- `m_seenShareClock`.
- Root check = mask 0. No separate counter.
- Shutter groups are the visit unit, computed with today's formulas word for word:
| group | bits | covers |
|---|---|---|
| GR | 0, 1, 3 | render state, pipeline state, patch |
| GK | 2 | pixel pack |
| GA | 4 | attrib defaults |
| GV | 5, 9, 10 | VAO, vertex buffers + base instance, index |
| GP | 6, 7, 8 | program walk |
| GT | 12, 13, 14 | texture aggregates, bind generation, max unit |
| GF | 11 | framebuffer |
| GB | 15, 16, 17 | bind points |
Closure: GT and GB also compute GP, because they mix `shader`, `opaqueUnits` and `programImages`.
- **Share-group clock:** in `ShareGroupState`, an atomic gen plus a context count.
- Bumped by:
- the unclassified-entry prologue;
- classified bodies that write shared objects (`Uniform*`);
- texture aggregates;
- `BumpSamplingResolutionGeneration`;
- link publish.
- The bump is skipped while the group has one context; a later context starts with all bits.
- Ordering: release `fetch_add` after the object writes, acquire load in the tracker.
- Fan-out `{6, 7, 8, 12, 14, 15}`.
- **Pseudo-bit CV** (bit 18) for `EmitContextValues`. Its own accumulator is consumed only when a
verb class that reads context values runs.
## Mark sites (chokepoints first; no per-call-site edits where a funnel exists)
| site | marks |
|---|---|
| M1 RenderState: sink from the `GLContext` constructor | `BumpVersions` → GR; the bare `++m_version` sites go through one `BumpRenderVersion()`; `SetPixelStoreParam` → bit 2 |
| M2 `BindingSlot` change sink (`MG_Util/Types.h`), marks only on a real change | FBO draw/read slots → 11; each VAO's index slot → 10 |
| M3 TextureState | `NoteUnitTouched`, bind generation, content/params notes → GT, plus CV when the high-water mark grows; sampling-resolution bump → GT + clock; `SetActiveTextureUnit` → CV |
| M4 BufferState | bind-point change → GB by target; `TouchBindPoint` → CV |
| M5 VertexArrayState | bind, delete, attribute change → GV |
| M6 FramebufferState | attachment change → GF |
| M7 GLContext | `UseProgram` / pipeline bind / pipeline delete → GP\|GT\|GB; XFB state → 17 + CV; attrib defaults → 4 |
| M8 `MGPipeNoteAggregate` | via M3-M6; clock bump for TextureContent/TextureParams/FramebufferAttachment |
| M9 `BumpLinkObservableVersions` → `MGPipeNoteProgramObjectChanged()` | covers link, both joins and the binary failure path; the hot `ProgramObject` setters get no marks (a TLS read per uniform write) |
| M10 tracker carry | pending base instance → GV |
**Export prologue.** `DECLARE_GL_FUNCTION_END*` (`Definitions.cpp`) runs `MGP_ENTRY_PROLOGUE(name)`
with a compile-time lookup in a new `MG_Pipe/PipeDirtyEntries.def`.
- Default: mark all bits and bump the clock.
- A `kBodyMarks` row means the body and funnels mark.
- Hand-written exports that do not forward (`glFinish`, `glFlush`, debug stubs, ...) call the
prologue themselves.
- EGL/GLX/WGL/CGL entries mark all bits.
**Events outside GL entries:**
| event | coverage |
|---|---|
| MakeCurrent | tracker `Reset` + mark all on the incoming context; after the TLS rebase, move this into `CurrentGLContextSlot::operator=` |
| surface resize | not a tracker input (frontend default FB is a fixed placeholder); EGL mark-all covers it anyway |
| deletes that unbind | mark-all, plus the M2/M5 sinks on the inner unbinds |
| buffer realloc | no shutter reads buffer size; no change |
| GenerateMipmap mip growth | entry mark-all; the inner path also goes through the M8/M3 funnels |
| context reset / new session | `MGPipeForgetEndedSession` → `Reset` → all bits |
| backend in-verb writes | the M3/M8 funnels |
| async link completion | M9 |
| other contexts in the group | the share clock |
## Validate path
- **`Update` visit set:** the context marks, the tracker carry, the share fan-out when the clock
moved, and all bits until primed; mapped to groups and closed.
- If the set is empty, return 0.
- Otherwise compute, compare and latch the visited groups only.
- **Oracle** (verify builds, `PipeVerify` armed): a shadow full walk F against the gated walk G.
- It requires F == G, else `Fatal{PipeDirtyUnderMark, "<bits>@<verb>"}` with a ring of the last
8 entry names.
- It honours `VERIFY_FATAL=0`.
- **Emission:** wrapped in `if (liveDirty)`. Fired bits, and therefore records, are unchanged.
- **CV accumulator:** the existing generation and suppressor fast path stays as a second line of
defence. `VerbMaskReadsContextValues` is precomputed per class.
- **Optional residual gating (C5)** is limited to rows that depend only on the address or the
context identity.
- It is keyed on context id, the bound VAO lifetime id, a fill-plan rebuild epoch and an
applier-reset / pin-release epoch.
- `GetProgramForDraw` / `GetProgramForDispatch` are never skipped: `CopyField` joins pending
links and refreshes the uniform mirror there.
- The accumulator is cleared only inside `fillOwed`; under run-ahead, unbarriered verbs keep it.
- Poison stamps still stamp every walk field.
- **Left alone:** the run-ahead/barriered predicate, `QuiesceApplierBeforeFill` and the dual-block
(`ROLE_SPLIT_STATE`) semantics.
## Found during planning: a pre-existing cross-context gap
Shutters 11-14 compare per-context aggregate counters that a texture or renderbuffer change bumps
only on the live context.
- Effect: a change made through context B, with no verb on A in between, does not fire A's
framebuffer or texture bits.
- The mask keeps today's bytes exactly (visit only).
- Closing the gap means mixing the share clock into shutters 11-14 (C8). That changes the wire for
multi-context traces, so it is a separate decision.
- FCL is single-context.
## Tests
- **Existing, unedited:** `TrackerTest` (`TrackerWalk`, `TrackerShippedEmitter`,
`TrackerAggregates`) stays green; `RecorderGoldenTest` goldens are unchanged.
- **New `TrackerDirtyMarks`** table test, one row per tracker input. Each row:
- mutates through the real mutator, not the export, so mark-all cannot hide a gap;
- asserts the fired bits match the full walk;
- asserts the expected bits were marked.
- **New share-group cases:**
- deterministic: A walks, B writes a uniform on a shared program, A walks again and bit 8 must
fire;
- threaded: a hand-off between threads, checked by readback in `ConcurrentContextsTest`.
- **Red-once:** drop each funnel's mark in turn and see its row fail.
- **CI:**
- `integration-verify` runs the oracle fatally.
- Verify-only negative control `MOBILEGL_PIPE_DIRTY_DROP=<site>`, one site per class.
- With `FATAL=0`, `entry-prologue` lists every entry still relying on mark-all.
- `gen_pipe_dirty_surface.py --check` gains mark coverage.
- A scanner CTest checks that every export has a `.def` row or the default.
- **Wire identity:** spawn/inproc/TCP arms, `spawn_lane_parity.py`, the retrace legs, and PipeStats
fire counts identical to the baseline.
## Measurement
- **Host:** PipeStats per-group visits, the TrackerRoot hit rate, fires equal to the baseline.
- **Device:**
- cpuhunt, FCL monolith on both backends + rd12, 3 interleaved reps.
- Read from profiles: `Tracker::Update`, `ValidateForVerb` inclusive/self, `CopyField`, the
prologue, and the TLS resolver for extra reads.
- fps only as a no-regression check.
## Commits
| # | commit | size | risk | gain |
|---|---|---|---|---|
| C1 | regroup `Tracker.h` into shutter groups; still visits all | ~+250/-150 | low | 0 |
| C2 | mark plumbing M1-M10, prologues mark-all, `.def`, DROP knob, oracle in audit mode | ~+500, 14 files | medium | 0 (prologue +~0.004) |
| C3 | gate on, fatal oracle, share-group tests | ~+150 | medium | most of the `Update` cut |
| C4 | CV accumulator | ~+40 | low | ~0.002 FCL |
| C5 | residual gating (optional, measure first) | ~+120 | medium | 0.005-0.01 FCL / 0.03-0.05 rd12 |
| C6 | classify the FCL between-draw entries, table test, scanner, CI controls | ~+400 | medium-high | the actual win |
| C7 | docs, SCOREBOARD | small | - | - |
| C8 | optional, separate approval: close the cross-context aggregate gap | ~+60 | wire change in multi-context traces | correctness |
**C6 entry list:**
- draws (free);
- `BindVertexArray`, `BindBuffer`, `BindVertexBuffer`;
- float `Uniform*` / `UniformMatrix*` → {7, 8} + clock; `Uniform1i` → {7, 8, 12, 14};
- `UseProgram`, `BindFramebuffer`;
- `Viewport`, `Scissor`, `PolygonMode`, `BlendFunc*`;
- `Enable`/`Disable`, once every capability path is confirmed to use `SetCapability`;
- the depth, colour and stencil setters;
- `BindTexture`, `ActiveTexture`, `BindSampler`.
**Overlap with the TLS work (`tlshoist`):**
- `Core.h` / `Core.cpp`: separate hunks.
- `PipeFill.cpp`: medium conflict around `gPipeInputs` and `MGPipeNoteAggregate`.
- `TrackerTest` fixtures: use `.Take()`.
- `Definitions.cpp` macros and the GLImpl entry bodies: conflict if TLS hoists there.
Order:
1. C1 can run now.
2. C2-C5 after the TLS merge.
3. C6 after the TLS per-entry hoist.
+810
View File
@@ -0,0 +1,810 @@
# P15 handoff (living document)
The plan and its measurements are in [PLAN-P15.md](PLAN-P15.md); the audit is in
[PARITY-AUDIT.md](PARITY-AUDIT.md).
**Target** (PLAN §0.1, revised by the user 2026-10-08):
- CPU scenes: FCL presenting-thread CPU at or below dev monolith (Magma <= 1.79, Espryt <= 2.14
ms/frame), dev measured in the same session, ~5 % noise.
- GPU scene (Iris + BSL): fps within ~5 % of MobileGlues on both backends.
## RESUME HERE (2026-10-09 evening, end of the long P15 run)
**Rules from the user (2026-10-09):**
- A fresh agent per clear task boundary.
- Mechanical jobs (bench A/Bs that follow the existing scripts, builds, log/profile parsing, CI watching)
go to sonnet/haiku subagents. Design and implementation stay on opus.
- No minSdk raise for the shipped build: API 29 is a SEPARATE artifact (its own library, plugin APK and
FCL-embedded copy).
- No record bypass: monolith = record arm.
- TLS (superseded 2026-10-09): API 29 did not remove the TLS cost (native TLSDESC in a dlopen'ed library
costs about the same as emulated TLS), so portable hot-path TLS elimination is approved for all API
levels. No TLS-model attributes or API-level gates as the mechanism.
- No new Android API usage. Keep MobileGL platform-agnostic unless a platform path is measured and has
no portable alternative.
- ASurfaceControl, frame-rate hints and ADPF are deferred.
- Optimization is driven by Perfetto traces (2026-10-09). Results are reported as a per-frame
timeline: phases in order with offsets within a typical frame, the waits, and the critical path.
Do not report them as ms tables. simpleperf is for function-level zoom-in inside a phase.
**Where the code is (worktree `.claude/worktrees/p15`, branch `p15impl`):**
- `origin/feat/disaggregated` = db346f28 plus the pushes listed in SCOREBOARD.
- Local on `p15impl`, not pushed:
- 14d63881, docs.
- 8d548d5b, window-scoped freqcheck.
- ca0a3b74, a cherry-pick of the coordinator's LTO commit 190580f2 on `build-opt`. The coordinator
pushes 190580f2, so drop ca0a3b74 when rebasing.
- a0015bad, Magma 2a + 2b. Its message carries the m2ab result, or says it is pending.
- `wip/espryt-depthcopy-measured` (the two Espryt BSL GPU items rebased onto origin 9f610167, with the
device numbers in its message; the old `wip/espryt-depthcopy` eb7572ff is the unmeasured original).
**Measured 2026-10-09 on device, NOT landed: no gain on BSL.** x = with both items, b = without, both
LTO builds of origin 9f610167; gpuhunt, 3 VALID reps each, one arm per cooldown:
- BSL: x 51.4 fps (0.921 of MobileGlues 55.8), b 51.9 (0.930); GPU 100 % busy in all runs, GPU
19.45 vs 19.29 ms/frame (MobileGlues 17.88). The target of 0.95 is not reached; the items are neutral.
- Vanilla cpuhunt check (Espryt monolith): x 248.5 fps / 2.87 ms GL CPU, b 254.0 / 2.83 (-2.2 % fps,
within noise; no CPU regression worth the name, but no gain).
- Engaged: the simpleperf profile of the BSL render thread shows `BlitDepthTexture2D` 0.100 ms/frame in
b and gone in x; `FramebufferImpl::SyncToBackendByHandle` 0.178 -> 0.162. The saved CPU is hidden by the
GPU-bound frame, and the GPU time per frame did not move, so the Espryt BSL gap is not in these
items. See SCOREBOARD (ebbsl).
Original description:
- (1) Depth glCopyImageSubData goes to the driver (ES 3.2 / EXT/OES_copy_image), with the
scratch-FBO depth blit as fallback. Knob MOBILEGL_ESPRYT_NATIVE_DEPTH_COPY.
- (2) A per-point attachment shadow on the Espryt FBO twin skips an attach call for a point that already
holds the same surface. It is keyed on the surface handle {slot, gen} plus driver id, level, layer,
call and re-mint generation; texture-side syncs still run. Knob MOBILEGL_ESPRYT_ATTACHMENT_SHADOW.
- Tests: DepthCopyImageScenario (2 cases) and AttachmentReattachScenario (4 cases), both registered on
the split arms. Red-once: a shifted native copy fails all DepthCopyImage cases on DirectGLES; dropping
Level from the shadow key fails the level case; keying on the driver id alone fails the
recycled-name case.
- Host suites: 1672 DirectGLES ctest entries (monolith + Split) pass serially in WSL (362 skipped by
design), including DepthCopyImage, AttachmentReattach, PassOrder and every blit case.
- `wip/api29-switch` (42922d21, on p15impl): `-Pmobilegl.androidApi=29` in build.gradle and the plugin's
build.gradle.kts.
- It sets minSdk 29 and therefore ANDROID_PLATFORM android-29; the plugin gets the `.api29` id suffix
and `-api29` version suffix. The CMake API-guard comment is updated. Default stays 26.
- Verified: the API 29 lib has 95 R_AARCH64_TLSDESC relocs and a TLS segment. __emutls remains only for
3 libc++abi variables.
- No A/B yet. The next agent runs the H2 A/B: API 26 vs 29, monolith + inproc, both backends,
MobileGlues control.
- Nothing in the tree needs a compile-time API gate yet, so none was added.
- The FCL-embedded 29 copy needs a matching FCL-side switch (FCL's own minSdk).
**The m2ab device job was still running at hand-off. Do not interrupt it.**
- What it is:
- Started as a background chain: `bash p15/m2ab_job.sh > p15/runs/m2ab_job.out; bash p15/espg_job.sh`.
- `espg_job.sh` is parked: it only echoes "espg parked". The real Espryt BSL job is `espg_job.sh.next`.
- m2ab_job waits for the device lock, cools to battery ≤ 33.0 °C, then runs
`PROFILE=cpuhunt devjob2.sh p15/runs/m2ab.log bash p15/m2ab_session.sh`.
- Arms: cpuhunt H2, 3 interleaved reps, PF=1. Both libs are LTO builds of the same tree:
- `n` = `libs/p15en`, without 2a/2b; monolith with sp=1, plus inproc;
- `e` = `libs/p15e`, with 2a/2b (it also carries the Espryt items, which do nothing on Magma); monolith
with sp=1, plus inproc;
- MobileGlues.
- Results:
- per run in `p15/runs/m2ab/<arm>-r<N>/` (fps.txt, valid.txt, perf.data on sp=1 runs);
- the summary is appended to `p15/runs/m2ab.log` (look for the `n=` lines).
- Device restore: the session script runs `fcl_scene.sh restore` and `fcl_p14.sh restore`, and devjob2's
exit trap stops the bench session and releases the lock.
- Interim at hand-off (GL CPU ms/frame):
| arm | n (without 2a/2b) | e (with 2a/2b) |
|---|---|---|
| monolith r1 / r2 | 2.39 / 2.48 | 2.29 / 2.45 |
| inproc GL thread | 1.20 / 1.20 | 1.17 |
| inproc fps | 343.5 / 371.6 | 363.8 |
- When it ends:
1. Summarize with `fclsum.py runs/m2ab`. Judge 2a/2b on monolith GL CPU and on the inproc apply thread
(threads.txt `mgl-srv-apply`).
2. Build the profile caches offline: `prof_prep_offline.sh <run> p15e|p15en runs/c1c2/x-DirectVulkan-r1`.
Compare RenameBusyWireStore, VkBufferObject::Create, SweepDeferredWireReleases and
IsSubmitIndexComplete.
3. If neutral-or-better: amend a0015bad's message with the numbers. Push the p15impl commits WITHOUT
ca0a3b74, i.e. cherry-pick onto origin after the coordinator pushes 190580f2. Then CI.
- Host suites for 2a/2b: done and at baseline (92 environment unit failures, 2 ColdStart).
- The one extra unit failure seen once, CompositorRecovery.ACompositorOnTheServerWindowRecovers..., is a
pre-existing load flake: under full CPU load it fails 6/20 without the change and 2/20 with it.
**Hot-path TLS cut (2026-10-09 night, worktree `.claude/worktrees/tlshoist`, branch `tlshoist` on origin
e70925d3, local, not pushed):**
- c0a9b2cd pGLContext and gPipeInputs become constant-initialized pointer slots (no TLS init wrapper or
guard; the owning SharedPtr lives in a second thread_local, released before the slot is cleared at
thread exit). 36f55af8 the applier lookup cache is one block. 6191cbf2 Magma session read and built-slot
lookup inline. abb22eef Espryt bound serial and per-context cache share one block (epoch bump closes ABA).
d4a00835 owner release order + SanityTest fix.
- Host: unit 92 failures, the same set as the baseline; integration 2 (Spawn.ColdStart.ClearThenReadPixels
on both backends), as the baseline. Split-OFF NDK arm64 and the plugin LTO build compile.
- Device (SCOREBOARD tls): Magma +6.3 % fps, GL CPU -0.14 ms; Espryt +0.9 %, -0.05 ms. TLS resolver
0.058 -> 0.034 (Magma), 0.049 -> 0.035 (Espryt) ms/frame.
- Remaining emutls per frame (~3-4k): pGLContext ~2.3k, gPipeInputs 0.6-1.1k, Magma session 0.6k
(GetActiveRenderPass), ResolveAttributeFromBinding note bumps, SetupWireDraw. Each further cut is
~0.002 ms; not done.
- Perfetto traces of a second A/B (tlspf) are in `runs/tlspf/*/p15.pftrace` for the present-wait work.
**LTO and the server check (coordinator):**
- libMobileGLServer.so is built and packaged by the LTO-ON assemblePluginRelease. Its only libMobileGL
import, `mobilegl_server_main`, is exported by the LTO lib.
- The spawn-transport smoke was **NOT run**. It needs the LTO-ON plugin APK (`libs/p15lto/plugin.apk`)
installed, because the FCL mgdebug install has no libMobileGLServer.so.
**Open items, in order:**
1. CI fix: the reds of Test run 37925410578 on db346f28 (integration-split-strict, the two DirectVulkan
retrace reds, skip census). Then push the LTO commit (190580f2 on `build-opt`) and the local p15impl
commits (without ca0a3b74), and confirm CI is green.
2. `userguide/` at the repo root, an end-user guide for every setup: which setup to use, how to build,
integrate and run it. Covers:
- Android FCL-embedded;
- the plugin APK (inproc, spawn with `MOBILEGL_IPC_SURFACE=server`, TCP);
- the API 26 and API 29 artifacts;
- Linux/anland;
- the Windows WGL drop-in;
- build options, user-facing knobs and troubleshooting.
3. DONE 2026-10-09: Espryt BSL GPU items (`wip/espryt-depthcopy-measured`): device A/B measured, no gain,
not landed (see above and SCOREBOARD ebbsl). The Espryt BSL gap to MobileGlues (0.92) is still open;
the next lead is the GPU side (render-stage trace of Espryt vs MobileGlues passes), not driver calls.
4. Small CPU batch: ValidateForVerb residue, Tracker::Update (0.018, mostly inherent),
EmitGlobalConstants (0.026). Expected ≤0.03 ms in total.
- DONE on host, branch `cpubatch` (2026-10-09). Measured on device 2026-10-09 (SCOREBOARD egc): EmitGlobalConstants 0.022 -> 0.014 ms/frame on both backends, consistent over 3 reps; whole-frame fps inside noise. Line-level
profile of fbm2 h-r1..r3 (both backends, p15h syms) and m2ab e-DirectVulkan r1..r3 (LTO).
- EmitGlobalConstants, cut: the (ShaderCso, Version) key is per handle (the applier keeps one
block per record), so switching back to a program whose uniforms did not move sends nothing,
and a moved one sends a span against its own held image instead of the whole block. The span
is the range the frontend wrote (ProgramObject::MarkUBOContentDirtyRange / TakeUBODirtyRange),
so the client shadow and its two-ended diff scan are gone. The scan plus shadow copies were
~0.0065 ms/frame; with the skipped switch-back sends, expect ~0.007-0.010 ms/frame.
- Tracker::Update: inherent, skipped. ~30 ns per verb over ~25 frontend counters; the only real
cut is the epoch skip (PLAN stage 1), which is not a small item.
- ValidateForVerb residue: skipped. The largest named piece (~0.008 ms/frame) is the
MOBILEGL_PIPE_POISON stamp walk, armed by MOBILEGL_BUILD_DISAGGREGATED. The bench libraries
are the plugin build (split ON); the FCL-embedded build (split OFF, INFO) compiles it out.
The rest (prologue, singleton guards, gates) is spread below 0.002 each.
5. DONE 2026-10-09: API 29 build plus its A/B (`wip/api29-switch`, 42922d21). Result in SCOREBOARD (api29):
- cpuhunt vanilla, 3 interleaved reps, 27 of 27 VALID. fps api29/api26: Magma monolith 1.041, Magma inproc 1.044,
Espryt monolith 1.008, Espryt inproc 1.015; GL-thread CPU -3 % / -7 % / -0.6 % / -3.4 %.
- The gain is not TLS: simpleperf puts `tlsdesc_resolver_dynamic` (api29) at the same 0.05 ms/frame, about 2 % of the
render thread, as `__emutls_get_address` (api26), because a dlopen'ed library takes the dynamic resolver.
- Open: whether a static TLS model (initial-exec) on the hot variables can remove the 0.05 ms in a dlopen'ed lib on
bionic; and what actually makes the api29 Magma build faster (not isolated).
- The shipped build stays API 26. The FCL-embedded 29 copy still needs FCL's own minSdk switch.
5b. DONE 2026-10-09 (offline), see [PRESENT-WAIT.md](PRESENT-WAIT.md). Cause: the display buffer release (~every other frame renders into the buffer just handed back) gates the whole single-batch frame, then ~0.8 ms GPU start latency + 0.5 ms execution; the next queueBuffer throttles on it. MobileGL CPU is not on that path. Options: more Magma swapchain images, gate only the window pass, present off the GL thread. Original scope: present-wait timeline from the existing P15 traces (fbm, c4, c1c2: sched, kgsl submit/retire, gfx atrace, SF frametimeline). Confirm against the TLS agent's base-vs-change Perfetto traces on e70925d3.
- Finding (egc profiles, e70925d3, cpuhunt, monolith): render-thread on-CPU + off-CPU = frame time.
| | Espryt | Magma |
|---|---|---|
| on-CPU ms/frame | 3.08 | 2.63 |
| off-CPU ms/frame | 0.89 | 1.09 |
| of which in Present | 0.82 | 1.03 |
- The blocked stack is the same on both backends: `queueBuffer`'s producer throttle
(`Fence::waitForever`) on the previous frame's GPU-completion fence.
- So frame time = CPU + present wait. CPU cuts reach fps only if the wait does not absorb them.
- The GPU is only ~17 % busy at cpuhunt, so the fence signals late rather than the GPU running
long. Candidates:
- work submitted only at swap (~1 batch/frame);
- the GPU waiting on the compositor's buffer release.
- Trace (both backends, monolith + inproc, MobileGlues control):
- MobileGL submit/flush points;
- kgsl GPU busy spans and frequency;
- fence create/signal times;
- SurfaceFlinger latch/release.
- Decide whether earlier submission (or another portable change) shrinks the wait.
5c. QUEUED 2026-10-10, after the quick before/after fps run:
- Capture: one Perfetto run per arm (Espryt monolith base vs pwgate+pmflush; Magma monolith base vs
pwgate+pmflush+extra 2), traces in scratchpad p15/runs/pwlat.
- Derive offline: a rough per-frame timeline, and the input-to-present latency from the SF
frametimeline.
- Write it up in docs/Disaggregated/pwait/: what the levers do, the effect on fps and latency,
the knob, and the FIFO caveat (extra images add latency only with vsync on).
6. Smaller follow-ups:
- DONE 2026-10-09: `bench_session.sh stop` now runs `pin_clocks.sh restore` first (verified over a
17-session run: max clocks back to stock after every session, daemons running, no session file).
The scratchpad `devjob2.sh` / `fcl_bench.sh` hard-code the p15 worktree's copy of the harness;
point them at a tree that has this commit.
- The `Fatal{UnmigratedSurface, "AndroidNativeWindow@P12"}` text and the tests asserting on it still
point at P12. The rule is permanent: a client window cannot cross processes, so windowed spawn uses
`MOBILEGL_IPC_SURFACE=server`. Reword the message to say that.
- DONE 2026-10-09: the windowed out-of-process smoke of the LTO plugin APK passes on both backends.
The plugin is debug-signed and replaced the installed one, with the user's OK. Setup:
- server: the plugin's `MobileGLDisplayActivity`, i.e. the `:mglwin` in-process server on
`tcp://127.0.0.1:40613`;
- client: FCL with `MOBILEGL_TRANSPORT=spawn`, `MOBILEGL_IPC_CONTROL=tcp://127.0.0.1:40613` and
`MOBILEGL_IPC_SURFACE=server`. ServerOwned 1280x800 window, Espryt and Magma both in-world.
A plain spawned child has no display (`NoServerDisplay`). Evidence is in the coordinator scratchpad,
`p15/runs/spawn_smoke2/`.
- Open from that run: every run logs `MG_Remote server: shared image 1 could not be sent on the aux
socket (rc=3)`. Rendering continues, apparently on the non-zero-copy fallback. Find out why the
loopback-TCP aux-socket send fails.
**Harness rules (all in scratchpad `p15/`; the tools live in `tools/device_bench/disagg/`):**
- H2 = `fcl_bench.sh`, driven by `fclab2.sh` for interleaved arms; summaries come from `fclsum.py`.
- Every session goes through `devjob2.sh` (device lock, bench session, restore on exit). Profiles:
- `PROFILE=cpuhunt` for CPU work (CPU 1.5/1.25 GHz, GPU 903);
- `PROFILE=gpuhunt` for BSL (CPU 2.4/1.8, GPU 578).
- BSL: **one arm per cooldown** (battery ≤ 33.0 °C between runs), arms interleaved across cooldowns. At
gpuhunt the scene hits thermal limits by the second back-to-back rep.
- Validity: `freqcheck.py` judges clocks over the measurement windows only (measure_raw.txt spans) and
thermal over the whole run.
- Stop a session on thr>0, a thermal_pwrlevel below the pin, or "max capped". Discard INVALID runs and go
on. Never stop on tpl alone: it is 6 by construction at gpuhunt.
- Build simpleperf binary caches only after a session, or offline with `prof_prep_offline.sh`
(donor cache plus the build-id entry in build_id_list). Never adb-pull during a session.
- Never edit a bash script that a running job will still read (bash reads scripts incrementally).
- TaskStop does not reliably kill child bash processes on this host: kill the PIDs, and only the inner
session processes, so devjob's cleanup runs.
- Libraries live in `scratchpad/p15/libs/<tag>/lib/arm64-v8a/libMobileGL.so`, with symbols in
`syms/<tag>/` and runs in `runs/<session>/`. Tags:
| tag | contents |
|---|---|
| p15e | LTO + 2a/2b + Espryt items |
| p15en | p15e without 2a/2b |
| p15lto / p15off | LTO ON / OFF, both with 2a/2b |
| p15a29 | API 29 |
| p15h | the pipe batch |
| p15y | 1c |
| p15t | before 1c |
- Profile tools: `topinc.py`, `callers.py`, `callees.py`, `layerfns.py`, `layerdiff.py`, `diffprof.py`,
`appside.py`, `pftstate.py` (Perfetto SQL), `threadstate.py`.
**Device state at hand-off:**
- At hand-off the m2ab session was still running; it restores FCL, the scene and the bench session itself.
- The device lock is released by devjob2 when m2ab ends.
- The plugin installs `top.mobilegl.plugin.*.trace` from earlier phases are still on the device.
## Open: Espryt small-store write rename (branch `pmflush`, 2026-10-09, host-verified, needs device)
**Not a p15 regression.** MONOLITH-DIFF's top Espryt row (`FlushPendingRangesFrom` driver 0.091 + libc
0.025, "dev 0") is the rename the doc's own caveat lists: dev's `FlushPendingRangesNow` costs 0.086 + 0.019
in the same profiles. Both are the same three-tier ladder, unchanged since dev f973008c. Inclusive:
dev 0.066 / p15 0.078 (feat-esp-1), 0.106 on the newer api29ab e26 run. So the drain is real cost that
dev pays too.
**What the drain is.** Under it, 0.080 of 0.106 ms/frame is one Adreno driver routine reached from
`glCopyBufferSubData` (dispatch slot 0x670 -> 0x3250c0 -> 0x2ee9d0, with heap allocations inside).
So it is the upload-ring tier: one GPU copy job per queued partial range. The 1.21.5 in-world trace
(5998912 calls, last 252 frames) shows the shape: 162 glBufferSubData a frame. 122 of them are partial
writes from offset 0, mostly 96 or 192 bytes into 288-byte vertex stores, and ~3 KB into 6.7 KB ones.
That is Minecraft's per-format immediate vertex buffer. Magma already renames these stores
(`RenameBusyWireStore`, S0 M4); `WriteWireBuffer` costs 0.031 ms/frame there, so Magma needs nothing.
**Change.** `RenameSmallStoreForDrain` (Managers.cpp) runs before the draw-time drain. For a store
<= 64 KiB whose unwritten bytes are <= 8 KiB, it replaces the queue with [0, store). The pinned ladder
then takes its tier 1, the whole-buffer orphan-map: no copy job, and recorded draws keep the old
storage. It refuses when the store holds bytes the host copy does not have: `serverGpuWritten`,
queued resident writes, persistent/immutable/imported stores, or split staged coverage short of the
whole store. On the trace this renames 108 of 122 partial writes a frame, at +101 KiB of host memcpy a
frame; a plain 64 KiB bound would cost +811 KiB, because of 128-byte writes into a 53 KiB index store.
The ladder bodies and the G5 pins are untouched.
**Tests.** EsprytFlushLadder has 3 new unit cases. There are 2 new scenarios, one per backend on every
arm: AtomicCounterScenario.APartialSubDataBetweenDispatchesKeepsTheShaderWrittenNeighbour and
CrossFrameBufferScenario.APartialSubDataBetweenTwoDrawsOfOneFrameKeepsTheFirstDrawsBytes. The skip
census mirrors their siblings' skipped lanes. Red-once: dropping the `serverGpuWritten` refusal reds
the atomic case on DirectGLES.Spawn, which reads back 16 instead of 32; monolith and inproc pass
because the frontend reads GPU writes back before a partial CPU write.
**Suite results.** WSL archlinux, clang Release, lavapipe, env MOBILEGL_ITEST_REQUIRE_GPU=1, suites run
one at a time:
- unit 2907/2907;
- integration 5300/5300 on the labels gpu, split, magma-all-split, magma-full-split,
monolith-control, cold-start, cpu-mip-split, clientarrays-split and remint-fallback-split;
- 354/354 spawn+TCP buffer, SSBO, atomic, persistent, XFB and index scenarios;
- 18/18 Espryt retraces (OpenRA, 1.21.4-in-world, 1.21.11-main-menu, sodium, create-instancing, Iris
BSL; each monolith, SPLIT and SPAWN);
- both Android arm64 shapes compile (disaggregated ON and OFF, android-26).
A first run with the dozen ICD (REQUIRE_GPU=ON in the cache) failed 1488 DirectVulkan cases. That is
the ICD, not this change: there were 0 DirectGLES failures.
**Host blocker for retrace evidence (pre-existing).** Espryt on llvmpipe segfaults in the 1.21.5 fixture
at call 75682 (a glDrawElements right after vertex buffer 8 is deleted and recreated). This happens on
the base tree too. Magma completes (SSIM 0.985 on dozen). So Espryt cannot be checked for SSIM on this
trace on the host.
**Device ask (Perfetto first, per the 2026-10-09 rule).** FCL MC 1.21.5 vanilla bench scene, monolith,
cpuhunt pinned, base = origin e70925d3 vs pmflush, same LTO settings. Run Espryt (the arm under test)
and Magma (control, expected identical). Capture a Perfetto trace per arm with:
- sched_switch/wakeup, cpu_frequency;
- atrace gfx/view/hal;
- kgsl gpu_frequency and GPU busy/slices;
- dma-fence signals;
- SurfaceFlinger frame timeline.
Report one typical frame as a timeline: render thread runnable/running/blocked, queueBuffer/dequeueBuffer
waits, the GPU slice and its end against the next frame's throttle wait. The question is whether
removing ~100 copy jobs a frame shortens the GPU slice and with it the ~0.8-1.0 ms queueBuffer wait (a
shorter frame), or only cuts CPU (a longer wait, the same frame). simpleperf zoom: `FlushPendingRangesFrom`
inclusive and its callees, expected to drop from ~0.106 towards ~0.03 ms/frame (the orphan-map plus the
extra memcpy). Also check the driver's map path (slot 0x550 -> 0x1db8a0) does not grow into new
allocations per rename. Correctness: SSIM/golden on the device retrace of minecraft-1.21.5-vanilla-fcl
plus the Iris/BSL cases, Espryt.
## Present-wait levers A + B (branch `pwgate`, worktree `.claude/worktrees/pwgate`, 2026-10-09)
Built on origin/feat/disaggregated a759b4b7. Host-only so far; the device plan is below. Mechanism:
PRESENT-WAIT.md (p15/pwait): every other frame renders into the buffer the display just released,
and the whole frame batch was gated behind that buffer's release fence.
**Commits (local, not pushed):**
- 168451bc Magma: submit a frame's off-screen work ahead of the swapchain acquire wait.
- 66adc7aa Espryt: flush once per frame ahead of the window buffer's first use.
- dd3e608a Tests: WindowPassGateScenario covers frames split around the window pass.
- cdd2160f Magma: MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES asks for swapchain images beyond the
surface minimum.
**Lever A, Magma (no knob).**
- `FrameData::acquiredImageReferenced` means the open recording uses the acquired swapchain image.
It is reset at every acquire (`WaitAndAcquireNextImage`, `AcquireNextImageInCurrentSlot`).
- `SubmitPendingCommandBuffer` waits on `imageAvailableSemaphore` only when the recording references
the image, or when the caller forces the wait (`ParkActiveTarget`'s wait-out). It marks the
semaphore consumed only when it waited. Present's own submission still waits whenever the
semaphore is unconsumed.
- `SubmitAheadOfAcquiredImage()` runs before the frame's first use of the acquired image. It flushes
what is recorded so far without the wait, then marks the image referenced. It is called from:
- `SetupDraw` when the draw framebuffer is the default one, next to `SplitOversizedRecording`,
before anything of the draw is recorded. Splitting later in setup lands after the draw's
descriptor bind, because the attachment pre-resolve reads the default framebuffer's read index.
That was measured as VUID-vkCmdDraw-None-08600 plus an llvmpipe segfault.
- `ClearWireFramebuffer` for the default framebuffer.
- `ResolveWireImage` for the acquired colour image. This is the net under blits, copies, readbacks
and shared-image presents.
- `Present`. A frame that never touched the window submits its work unwaited, and the present's
own submission carries the wait, possibly with no command buffer.
- Inside a draw's preparation (`m_wirePreparationDepth != 0`) it only marks the image; it never
submits.
- Wait stage: every acquire wait now uses `FrameContext::kAcquireWaitStages`
(COLOR_ATTACHMENT_OUTPUT | TRANSFER). Before, mid-frame flushes waited at ALL_COMMANDS and the
present submit at TOP_OF_PIPE, which waits for nothing.
- `TransitionWireImage` adds those stages to the source scope when a default colour image leaves
PRESENT_SRC_KHR or UNDEFINED.
- Engagement proof: one latched log line,
`DirectVulkan: a frame's off-screen work goes to the queue ahead of its window pass ...`.
- Acquire timing is unchanged: the next image is still acquired at the end of Present.
- Acquiring later cannot move the gate. The buffer queue's free list is FIFO, so a later dequeue
gets the same buffer, or a more recently released one, with the same release time R.
- It would also break the buffer-age contract: `CurrentDrawBufferAge` answers for the image
acquired at the previous present.
- So no device A/B was spent on it.
**Sync-correctness argument (Magma).**
- One wait per signal. Each acquire signals imageAvailableSemaphore once. Exactly one submission
waits on it: the first whose recording references the image, or the present's, or the park
wait-out. All three check and set `imageAvailableSemaphoreConsumed`. The next acquire on the slot
comes after the slot's fence wait, so by then the semaphore is unsignaled with no pending wait.
- Recordings that never reference the acquired image carry no wait. That is correct because none of
their commands access it.
- Reads of `m_defaultFramebufferImageIndex` that name the previously presented image touch a
different image.
- The old code did not order those reads against an acquire either.
- Every first access of an acquired image is a layout transition out of PRESENT_SRC_KHR or UNDEFINED:
- `TransitionWireImage`, whose source scope includes kAcquireWaitStages;
- `TransitionToPresent`, whose source scope is ALL_COMMANDS.
- The semaphore wait's second scope covers kAcquireWaitStages in its own batch and in every later
batch. So the transition is ordered after the presentation engine's release, even when the use is
in a later submission than the wait. Through the transition's ALL_COMMANDS destination, everything
after it is ordered too.
- renderFinished is signaled by the present submission. That is last in submission order, so its
first scope covers the off-screen submissions too.
- Unchanged by this work:
- Frames in flight: split submissions take pooled fences and advance `lastSubmitIndex`, and the
present's slot wait covers them.
- Wire render-pass guard: `FlushPendingCommands` ends the open pass.
- Pass-barrier coalescing: barriers order across submissions.
- Deferred clears: the default framebuffer never defers.
- Not machine-checked. lavapipe syncval does not flag a broken acquire chain.
- Positive control: removing the source-stage fix while keeping the narrowed wait still gave
0 hazards.
- It never flagged the old present submit's TOP_OF_PIPE either.
- The argument above rests on the spec.
**Lever A, Espryt (no knob).**
- `FlushAheadOfWindowBufferUse()` issues one `glFlush` per frame, just before `BindCurrentFBO` or
`SyncAndBindFramebufferByHandle` moves the driver's binding to framebuffer 0. A thread-local flag
limits it to once per frame and is reset at the present's swap.
- Window surfaces only: a pbuffer has no lazy dequeue.
- Not issued on MobileGL's own scoped binding restores, or when the binding is already 0. A frame
that renders straight into framebuffer 0 has nothing to flush ahead.
- No wait and no glFinish. Adreno dequeues lazily at the first default-framebuffer use.
- Host coverage is pixels only, because the harness has no window surface.
**Lever B (knob, default 0).**
- `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES` (0-16) requests
`max(frames-in-flight hint, surface minImageCount + extra)` images, clamped to maxImageCount.
- Logged as `Set minImageCount = N (surface min M, max X, extra K)`.
- Documented in userguide/configuration.md and the README knob table.
- Cost per extra image at 2560x1600: one RGBA colour buffer (~16 MB) plus the default framebuffer's
same-size depth/stencil image.
- Vulkan only. Espryt's EGL buffer count needs a platform API, so it is deferred.
**Host verification.** Setup: WSL archlinux, clang, CMake 3.31.10, `~/mgl-pwgate-ci31`, lavapipe,
suites run serially.
| Check | Result | Baseline |
|---|---|---|
| Unit | 2904 tests, 92 failed (ServerSpawn / PeerLatch / FuzzArm2) | same 92, environmental |
| Integration: `integration-gpu`, `-magma-all-split`, `-magma-full-split`, minus spawn and tcp, `MOBILEGL_ITEST_REQUIRE_GPU=1` | 3883 tests, 2 failed (both Spawn.ColdStart ClearThenReadPixels) | same 2 |
| Syncval (submit-time, shader heuristic): WindowPassGate + CrossFrameBuffer + DefaultFramebufferAcrossSwap.ADraw*, monolith and inproc | 0 hazards, 0 VUIDs; also clean with EXTRA_SWAPCHAIN_IMAGES=2 and FRAMES_IN_FLIGHT=2 | — |
| CI gates `magma_runahead_checks.py negative`, `validation`, `magma_cache_checks.py` | rc 0 | — |
| EXTRA_SWAPCHAIN_IMAGES=2 | 85 present-shaped Magma entries pass; minImageCount 4+2 = 6 on the headless surface | — |
| Android arm64 plugin release (`assemblePluginRelease`), API 26 and API 29 | both rc 0 | — |
- The integration run includes WindowPassGateScenario on DirectGLES and DirectVulkan (monolith,
Split, Split.Full), plus the `DirectVulkan.WindowPassGate.` arming entry.
- Verb tables are unchanged, so split_coverage was not needed.
- The spawn and tcp lanes fail on this host for every scenario: TcpServer.Start fails, and spawn
bring-up aborts with CapsBeforeFirstSnapshot.
- Pre-existing, not from this work: DefaultFramebufferAcrossSwap.AReadbackAfterASwap reads an image
already handed to presentation, which syncval reports as WRITE_AFTER_PRESENT. That is why the new
scenario reads back before its swaps.
**Device plan (not run; another agent has the phone).**
- Libs: both are API 26 default plugin builds.
- base: origin/feat/disaggregated a759b4b7.
- A: pwgate cdd2160f.
- Setup: same FCL, MC 1.21.5 vanilla frozen world, cpuhunt clocks, FCL pinned to cpu2-6.
- Validity rules: `fcl_bench.sh` VALID, freq and thermal sampled every 1-2 s, throttled runs dropped.
- Perfetto (PF=1): `p15_perfetto.cfg` with every `kgsl/*` ftrace event removed (not on this kernel).
Keep:
- sched (switch, waking, wakeup, blocked_reason), cpu_frequency and cpu_idle;
- atrace `gfx` + `view` for the FCL package and surfaceflinger (gfx is what creates the
`GPU completion` / `HWC release` FenceMonitor threads);
- process_stats and `android.surfaceflinger.frametimeline`;
- 5 s duration.
- Arms, 3 interleaved reps each:
1. Espryt monolith: base, A.
2. Espryt inproc: base, A.
3. Magma monolith: base, A, A+`MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES=1`, A+`=2`.
4. Magma inproc: base, A, A+1, A+2.
- Engagement proof:
- Magma A: logcat has the latched "goes to the queue ahead of its window pass" line, and the trace
shows QueueSubmit per frame rising from ~1.33 to ~2.3 (one submit just before the blit's draw,
one at present).
- Extra images: logcat shows `Set minImageCount = 6/7 (surface min 5 ...)`.
- Espryt A has no marker. Take one extra `gpu.renderstages` capture per Espryt arm (it works on
this device); it should show A's off-screen stages running before R.
- Analysis, with the scratchpad `p15/pwait/` scripts:
- `cycle.py <label> <runs...>`
- `pairs.py`
- `gexec.py`
- `sim.py <label> <start> <exec> <runs...>`
- Report per-frame timelines, not ms tables.
- Expected for lever A (PRESENT-WAIT, "What a fresh trace should confirm"):
- Gated frames stay at ~50 %.
- For gated frames, E - R falls from ~1.35 to ~0.9 ms: start latency plus the window pass only.
- Back-to-back execution is unchanged at ~0.5 ms.
- sim's throttle, ms/frame: Espryt mono 0.62 -> 0.49, Magma mono 0.72 -> 0.54,
Magma inproc 1.31 -> 1.09, Espryt inproc 1.09 -> 0.91.
- If E - R does not fall, either the driver gates the off-screen submission too, or the split is
not engaged. Check the submit count, and when the GPU work starts relative to R.
- Expected for lever B:
- `HWC release fence N has signaled` at >= 85 % of AcquireNextImageKHR.
- Gated frames < 20 %.
- Throttle < 0.2 ms/frame on monolith.
- inproc may need +2 (sim: 23 % still gated at k=2).
- The user picks lever B's default from these curves.
## Earlier (2026-10-09): cuts 1b + 1c, cut 4, pipe-record pieces
- **Landed locally (pushed after the BSL gpuhunt check):**
- 66e3b2c1 (rebased as 65d4b808): Espryt surface-size memo, GL CPU 3.18 -> 3.05.
- 533a2564: Magma deferred clears (1c) plus coalesced pass-begin barriers (1b).
- Per frame: passes 11.5 -> 4.3 (dev 4.1), barriers 15.5 -> 9.0 (dev 3.4).
- Inproc +5.0 % fps, apply thread -0.17 ms; monolith GL CPU -0.09 ms.
- **Landed 2026-10-09 afternoon:**
- 485dff14: pipe client batch, i.e. the per-framebuffer FB-state memo (MOBILEGL_PIPE_FRAMEBUFFER_STATE_MEMO),
handle hints, per-buffer handle reuse and the per-verb gate cache.
- c85c9439: Magma hash TLS hoist.
- Effect: H2 GL CPU Magma 2.68 -> 2.62, Espryt 3.03 -> 3.00. The profile is in SCOREBOARD (fbm2).
- 9eed5a27 / 9ff97c2e: CI branch fixes. The E1 control follows ApplierReset, and ScenarioIsolation is
listed as unarmed in verify-split.
- **Small-cut policy:** pieces below about 0.03 ms are verified by their own before/after function profile
plus a red-once, and get one H2 A/B per batch.
- **Order (coordinator, 2026-10-09):** FB-state memo, then handle cache on objects, vertex input,
program, samplers, accessor/TLS hoist, the ValidateForVerb dirty walk, Tracker.
- No record-bypass design change until the user decides.
- **Parked: the Espryt attrib-format split** (MONOLITH-DIFF.md).
- **Remaining Magma barriers:** CPU ceiling ≤0.02 ms. Revisit only if BSL shows a Magma GPU gap.
- **Harness gotchas found today:**
- `tpl` in the freq sampler is kgsl `thermal_pwrlevel`. Under gpuhunt it is 6 by construction
(the 578 MHz pin); freqcheck already maps it. Stop a session on INVALID or `thr > 0`, never on
`tpl > 0`.
- Never run `binary_cache_builder` (adb pulls) while a session is measuring. Build binary caches
after the session ends.
- FCL sometimes dies at bootstrap with signal 34 (seen on every build including MobileGlues);
fclab2 retries, and a run that never reaches the world is lost.
- **Monolith floor estimate (MONOLITH-DIFF.md, structural):**
- Pipe record: 0.35 -> about 0.10-0.13 if every local piece lands.
- Whole Magma GL thread: about 2.35-2.40 ms (native TLS: about 2.30), against dev 2.00.
## Earlier (2026-10-08 late): harness H2, dev reference, scoreboard
- **Every FCL vanilla number now goes in [SCOREBOARD.md](SCOREBOARD.md).** It has one row per
session, as fps ratio to MobileGlues plus CPU ms/frame. It also holds the fixed dev reference, so
"vs dev" no longer needs dev in every session. The per-function dev baseline is in
[MONOLITH-DIFF.md](MONOLITH-DIFF.md).
- **The old probe's variance was core placement.** The scheduler gave MobileGL's monolith render
thread the X4 core 72-90 % of the time and MobileGlues' 47-60 %. MobileGlues' fps tracked its X4
share (fifi: 60 % -> 378, 47 % -> 344).
- **Harness H2 (scratchpad `p15/fcl_bench.sh`, `fclab2.sh`, `benchwin.py`):** the same for every
arm.
- After world entry, `taskset -a -p 7c` pins FCL to cpu2-6 (A720).
- fps comes from the SurfaceView BLAST layer `frame=` in `dumpsys SurfaceFlinger`. It agrees
with the MobileGL fps log over the same span (252.1 vs ~253).
- Warmup: 20 s, then 5 s windows until two consecutive ones agree within 3 %.
- Measurement: two 5 s windows with no tracer; CPU from schedstat.
- atrace, then the optional simpleperf (`sp=1`), run only after the windows.
- **Frozen bench saves** (1.21.5 and 1.21.4-Fabric, scratchpad `p15/freeze_world.py`):
- Rules: no daylight, weather or mob-spawn cycle, randomTickSpeed 0, no fire tick.
- DayTime 6000, clear weather.
- Before this, the vanilla save's day cycle was running.
- The originals are on the device as `level.dat.p15-orig`.
- **Spread over 3 interleaved reps, (max - min) / mean:**
- Old probe: Espryt 9.3 %, Magma 5.6 %, MobileGlues 1.3 %; MobileGlues spanned 322-376 across
sessions.
- H2: Espryt 1.2 %, Magma 2.9 %, MobileGlues 2.0 %, dev 6-7 %.
- **Dev reference (H2, safter, all VALID):** MobileGlues 321.5 fps / 1.70 ms. dev Magma is 0.950
of that (2.01 ms) and dev Espryt 0.887 (2.38 ms).
- **On A720 the monolith gap is larger than the X4 hid:** p15s Magma is 0.768 of MobileGlues (0.81
of dev, 2.91 ms) and Espryt 0.746 (0.84 of dev, 3.18 ms). That is +0.90 / +0.80 ms/frame of CPU
over dev.
- **Inproc p15s Magma on H2:** 327.7 fps against MobileGlues ~321.
- **Emulated TLS:** `__emutls_get_address` costs ~0.06 ms/frame of self time on the p15 monolith
render thread, spread over many callers. dev shows almost none. The structural fix is native TLS
(minSdk), which is the user's call.
## Earlier (2026-10-08, after S0)
Every number below carries its profile and passed the validity check (`state.txt`). `cpuhunt` =
CPU about 1.5/1.25 GHz, GPU 903 MHz (cleanly CPU-bound); interval 0, anland off, daemons stopped.
- **The S0 milestone's absolute numbers are superseded.** The perf stack's `msm_performance` caps
(787 / 1286 / 1075 / 1248 MHz) were clamping the CPU under the pin for some of that session. Only
same-session deltas from it stand. Measurement now uses `bench_session.sh` and the sampler (PLAN
§1), and the probe reports only clean fps windows taken before any tracing (`P15PROBE
trace-start` marker, 25 s settle).
- **FCL vanilla 1.21.5, cpuhunt, presenting-thread CPU ms/frame:**
| build | Espryt | Magma |
|---|---|---|
| dev | 1.76 | 1.60 |
| p15k (S0 + VAO shadow) | 2.10 | 2.03 |
| p15l (+ vertex-elements dedup) | 2.10 | 2.08 |
MobileGlues: 1.58 in an earlier cpuhunt session (needs a same-session re-run with clean windows).
Floor gap: Espryt +0.34, Magma +0.43 ms.
- **Driver-call redundancy:**
- Measured with a diagnostic build that counts every host GLES/EGL call and redundant re-sets
(`p15diag` worktree, never committed; HostCount.inl and VkCount.cpp).
- Espryt sent 3717 host calls/frame against MC's ~874: 2118 `glDisableVertexAttribArray`, 378
enable, 378 divisor, all re-sets.
- Two fixes, each independently removes the walk churn:
- b4e209e1: a shadow of each driver VAO (850 calls/frame);
- c8a5abe5: the client no longer re-creates an identical vertex-elements record on every
`glBindVertexBuffer`. With the shadow off it takes 3724 down to 1228.
- CPU gain is small (about 0.1 ms): the calls were cheap in the driver.
- Magma issues about 380 Vulkan calls/frame with essentially none redundant.
- **Where Espryt's gap to dev is now:** the driver time equals dev's (0.50 vs 0.48). The excess is
libMobileGL itself, 0.75 vs 0.32: client half 0.51, backend 0.24, applier 0.02. The client half
is spread thin (validate, tracker, emitters, residual copy): S1's draw-delta.
- **Inproc (cpuhunt):**
- Espryt reaches 306 fps vs MobileGlues about 319; GL thread 1.68 ms, apply thread 1.83 ms of a
3.27 ms frame.
- Neither thread is saturated. The apply thread waits in `queueBuffer` on a GPU fence
(present pacing), and the GL thread waits on the apply thread.
- `MOBILEGL_IPC_PRESENT_CREDIT=2` changes nothing (300 fps).
- Beating MobileGlues on inproc needs a present-path change (stage P territory, dropped by the
user), not CPU work.
- **S0b:** the fixture `minecraft-1.21.5-vanilla-fcl-in-world` is landed (4e27342e) and is in the
SSIM gate as `fcl` (32/32 on p15j).
- **Knobs on FCL:** `adb shell setprop debug.mobilegl.env "MOBILEGL_A=1;MOBILEGL_B=0"` (49c6394d);
`fclab.sh` takes a 6th field `K=V,K=V`.
- **MC's AFK frame limit:** `inactivityFpsLimit:"afk"` (MC 1.21.2+) made later probe windows and
profiles spin in `System.nanoTime`. `fcl_scene.sh` now sets `"minimized"` for bench scenes and
restores the original options files (`/data/local/tmp/p15-opts-121{5,4}.txt`). Profiles taken
before this are partly AFK-polluted.
- **BSL at `gpuhunt`** (CPU 2380/1689 MHz, GPU 578 MHz, all 100 % GPU busy):
- MobileGlues 53.4 fps;
- dev Magma 53.2;
- p15l Magma 51.8 (3 reps, -3.0 % vs MobileGlues: target met, -2.6 % vs dev to bisect);
- Espryt dev and p15l 48.3 (-9.6 %): the GPU gap, inherited from dev.
- **Same-session cpuhunt, apply thread:**
| build | fps | apply ms/frame |
|---|---|---|
| MobileGlues | 329 | CPU 1.55 |
| Magma inproc p15m | 300 | 1.6 |
| Espryt inproc | 296 | 1.65-1.8 |
- Inproc beats MobileGlues only when the apply thread's CPU is below MobileGlues' (both pay the
same queueBuffer wait). About 0.3 ms per frame beyond the apply CPU is still unexplained.
- 500b63ea: per-store reuse of renamed-away wire buffers (Magma apply -0.13 ms).
- ONE_TIME_SUBMIT: no effect (A/B'd, knob dropped).
- Magma's driver work is about 2x dev's: vkResetCommandBuffer 0.09 + vkEndCommandBuffer 0.11
ms/frame.
- **Inproc serialization found (2026-10-08, p15l cpuhunt profiles):** every blit reached the
client as `BlitNamedFramebuffer`, a verb with no `MGP_VERB_OP_LIST` row, so
`ClientVerbIsBarriered` answered barriered and the GL thread quiesced the applier once per frame
(1.65 ms/frame parked in `WaitForApplyToCatchUp`, plus 0.11 from the following `glBindTexture`).
The apply thread then idled 0.24 ms parked plus 0.2 ms spinning in `Doorbell::Wait`. e00db8e6
replaces the inverse and its barriered fallback with a verb -> record-op table
(`MG_Pipe/VerbRecordOps.h`, one row per verb by static_assert; no knob, user decision).
- Same-session blab (cpuhunt): Magma inproc 319.6 -> 334.9 fps (+4.8 %), Espryt inproc
324.4 -> 338.1 (+4.2 %).
- Wait census (`MOBILEGL_IPC_WAIT_STATS=1`, 7acf3ea8): FCL vanilla inproc waits only on the
present credit (1.00/frame). BSL waits 7 times per frame on three kWaitApplied rows plus 22
follow-on quiesces; see [WAIT-AUDIT.md](WAIT-AUDIT.md). User decision applied in 2fbcc224:
fire-and-forget rows async, inproc creates and PBO readbacks no longer wait, and the dual block
(`MOBILEGL_IPC_ROLE_SPLIT_STATE`, now default on) lets a barriered verb cost one wait. BSL
census after it still owed (gpuhunt only; FCL's 1.21.4-Fabric profile exited with signal 34 at
JVM start on both backends in the last attempt).
- db915f76: a client parked on the present credit is rung only by the credit (apply-thread
futex wakes 0.056 ms/frame before).
- Frames in flight (0b96a3ef): `MOBILEGL_FRAMES_IN_FLIGHT` (default 3) drives Magma's frame
contexts, Espryt's post-present fence wait and the split present credit max(1, N-2); the Magma
name is an alias. Default latency unchanged; the FIF A/B is the user's input for the default.
- Present credit 2 (cens, cpuhunt, all VALID): Magma 309.0 -> 319.9, Espryt 299.1 -> 319.1 fps
vs MobileGlues 321.9 in the same session; apply CPU 1.40-1.43 vs MobileGlues' GL thread 1.57.
Credit 2 costs a frame of latency: user decision. The remaining inproc gap is the queueBuffer
fence wait (GPU-side), not CPU.
- BSL at cpuhunt (GPU 903 MHz) reaches GPU 95 C and kgsl thermal_pwrlevel 1 (834 MHz cap): the
census run was INVALID twice and the job was stopped. Run BSL only at gpuhunt.
- Apply-thread frame (Magma inproc): on-CPU 1.75 (0.2 of it spin), queueBuffer fence wait 1.45,
parked 0.24 ms.
- Magma apply on-CPU by verb: draws 0.55 (SetupWireDraw 0.40, of it descriptor binding 0.13),
present 0.37 (End CB 0.10, queueBuffer CPU 0.08, submit 0.07, wire-store sweep 0.035),
clear 0.19 (the frame's recording begin 0.09 + pass begin 0.05), buffer writes 0.09, blit
0.06 (two image views and a VkFramebuffer created and retired per blit).
- **Device contention, root cause (2026-10-08):** the anland app was relaunched by `fclab.sh`'s own
end-of-run `monkey` (launchedFromUid=0); its activity takes the foreground back whenever paused,
so FCL launched over it never reaches the world (RenderDoc job: 0 of 4 worlds). c41dfdda:
`bench_session.sh start` force-stops it and `stop` relaunches it only if it ran before.
- **Open user decision:** Espryt's apply thread spends 0.06 ms/frame in `LatchIfGuiltyBeforeApply`
(glGetGraphicsResetStatus is a kgsl ioctl, queried on every wake). Rate-limiting it to 2 ms
breaks `ServerLoopEglLatchTest.AGuiltyResetEndsTheSessionBeforeItsNextRecord...`, the designed
promptness guarantee, so it was reverted. Trading that guarantee for 0.06 ms is the user's call.
- **CI:** 4a8ecf9a green. 49c6394d: one job failed on a hosted runner's `apt-get update` timeout
(45 min, infrastructure); the failed job is re-run.
- **Next:**
- RenderDoc (rdc GLES layer, remote server stopped): Espryt vs MobileGlues BSL pass structure;
- S1 (client validate 0.25 ms) and S3 (backend by-handle syncs, descriptor resolve) for the CPU
floor and the inproc apply thread.
## Status (2026-10-08)
**Branch:** `p15impl` (worktree `.claude/worktrees/p15`, short path `W:/p15`), pushed to
`feat/disaggregated`.
**S0.1 parity audit:** written.
**S0.2, Magma wire non-draw ports:**
- **M1a, clears become part of the draw pass** (`ClearWireFramebufferInPass`; `PrepareWireDrawPass`
split out of `SetupWireDraw`):
- A whole-area clear that begins the pass begins it with a LOAD_OP_CLEAR variant of the pass's
render pass (`RenderPassEntry::clearVariants`, compatible with the framebuffer).
- Any other clear (into the open pass, or scissored) is `vkCmdClearAttachments` in the pass. A
forced pass restart for depth clears (an LRZ hypothesis) was tried and reverted: it cost CPU
and fixed nothing.
- Kill switches: `MOBILEGL_MAGMA_INPASS_CLEAR=0`; `MOBILEGL_MAGMA_INPASS_CLEAR_DEFAULT=1` puts
default-framebuffer clears in the pass too (off by default, see the open item).
- **Open item: default-framebuffer clears stay standalone.** With them in the pass, the openra
retrace on Adreno 750 loses its palette-sampled sprites (SSIM 0.956378, deterministic). What was
measured:
- Both `vkCmdClearAttachments` and LOAD_OP_CLEAR fail; so does splitting the clear calls.
- Colour-only or depth-only in the pass, with the other part standalone, passes.
- Event traces: the first draw flushes the recording (the palette `glTexImage2D`'s upload flush,
`FlushPendingCommands`) right after the clear. Command order otherwise matches the standalone
path.
- Not explained yet. Lavapipe and the InPassClear scenarios on FBOs are clean.
- Ruled out by reading: a missing ordering edge. Default-framebuffer images get the same
pass-begin barrier as FBO images (a full ALL_COMMANDS memory barrier, or their transition),
with their layout tracked per swapchain index through the swapchain object.
- Still open: the in-pass path commits the freshly acquired swapchain image
(`DefaultFramebufferWriteIndex(true)` in `PrepareWireDrawPass`) at the clear; check whether
the standalone path's clear and the in-pass clear address the same index on the trace route.
- Cost of leaving it: small for FCL (MC renders into its own FBO and blits to the default one).
- **M2, draw-pass cache across frames:** one cache, entries pruned when their image epochs move,
destroyed after their last submit. Kill switch: `MOBILEGL_MAGMA_PASS_CACHE=0`.
- **M3, blit descriptor sets:** one pool per frame slot.
- **M9, converted vertex streams** (wrongly marked "have" in the first audit). The wire arm
re-converted the whole remaining stream on every draw: Sodium's multi-draws over one arena cost
49 ms/frame of CPU on BSL (19.5 fps against dev's 64.7).
- Now one conversion per (store content serial, layout), kept across frames in
`VkBufferManager` (`LookupConvertedStream` / `StoreConvertedStream`).
- Each entry owns a vertex buffer. Bounded at 192 MB (least recently used first); entries idle
for 256 frames go. A replaced buffer is released when its frame slot comes round.
- The content serial is process-wide monotonic and moves on every host write, respecify,
GPU-write mark, shader-writable bind and donation.
- Kill switch: `MOBILEGL_MAGMA_VERTEX_CONVERSION_CACHE=0`.
- **M4, write renaming.** A busy `glBufferSubData` used to take a staged copy, which ended the
render pass with two full barriers (FCL: ~5.6 per frame, all on one 288-byte store). Now:
- A store of 64 KB or less keeps a host shadow (64 MB budget), from respecify on.
- A busy write into a shadowed store gives it a fresh VkBuffer filled from the shadow and
releases the old one like a glBufferData orphan. No copy is recorded and the pass stays open.
- GPU-written marks, shader-writable binds, donation and import drop the shadow.
- `ReadWireBuffer` serves shadowed stores from the shadow, so no host wait.
- Kill switch: `MOBILEGL_MAGMA_WRITE_RENAME=0`.
- **Tests:**
- `InPassClearScenario`: 4 cases, monolith and split, both backends.
- `ConvertedVertexStreamScenario`: 3 cases (reuse, same-frame sub-data, cross-frame sub-data).
Red-once: a lookup that ignores the content serial turns both sub-data cases red.
- `WriteRenameScenario`: 4 cases (order and carry, one-byte writes, uniform and index buffers,
multi-frame). Red-once: a rename that skips the shadow fill turns all 4 red, which also
proves the rename engages.
- Red-once checks: the colour index and the scissor (2 cases red); the depth clear-load bit
(depth/stencil case red).
- Syncval gates green (cache 7/7, run-ahead 14/14), plus the InPassClear cases under syncval.
- **Gates:**
- SSIM 24/24 (openra, rd12, bsl × 4 arms × 2 backends) on `p15e`.
- Host unit and integration-gpu green, apart from the known environmental `ServerSpawn` /
`FuzzArm2` / `PeerLatch` / spawn ColdStart failures.
- `CompositorRecovery` flakes under -j16 and passes alone 3/3.
**S0 milestone (one device session, FCL, interval 0, 2 reps; `runs/ms-s0i`):**
| scene | build | Magma CPU ms/frame | Magma fps | Espryt CPU ms/frame | Espryt fps | GPU busy |
|---|---|---|---|---|---|---|
| vanilla 1.21.5 (CPU) | fin | 3.27 | 170 | 2.81 | 190 | 12-15 % |
| | p15h (S0 without M4) | 2.59 | 191 | - | - | 15 % |
| | p15i (S0) | 2.56 | 190 | 2.77 | 193 | 13-15 % |
| | dev | 1.79 (n=1) | 234 | 2.14 | 218 | 14 % |
| | MobileGlues | 1.59 | 256 | | | 15 % |
| BSL (GPU) | p15i | 7.26 | 77.2 | 7.61 | 70.6 | 99 % |
| | dev | 13.85 | 66.1 | 7.17 | 70.5 | 85-100 % |
| | MobileGlues | 6.25 | 78.2 | | | 98-100 % |
(BSL before the converted-stream cache: Magma 19.5 fps at 26 % GPU busy, 49 ms CPU/frame.)
- Espryt's `base` lib (p15plan, unchanged) read 2.84 in the same session: the earlier "p15e
Espryt regression" was session variance. S0 does not touch Espryt.
- **Target status.** Magma BSL is met (within 1.3 % of MobileGlues, GPU-bound). Espryt BSL is
GPU-bound at 99 % and 10 % below MobileGlues, same as dev: a GPU-side gap still to explain (the
load/store and clear audit of PLAN §0.1). CPU scene: Magma 2.56 vs MobileGlues 1.59, Espryt 2.77.
- **Where Magma's CPU goes now** (p15i profile, `runs/prof-hi`, ms/frame inclusive):
`VerbChannel::Port` 0.85, `OnDrawVbo` 0.62, `SetupWireDraw` 0.46, `Present` 0.32,
`MGPipeValidateForVerb` 0.27, in-pass clears 0.18. The draw path is S1-S3's; S0's non-draw ports
are done. Proof that M4 engages: `StagedWireRangeCopy` 0.067 is gone and `RenameBusyWireStore`
costs 0.048 (a VMA allocation per rename; a recycle pool could take most of it).
**Stage P:** dropped for the target.
## Harness
| purpose | where |
|---|---|
| FCL probes and reducers | `tools/device_bench/disagg/` (README "P15 FCL probes") |
| FCL vanilla A/B, H2 (pinned, SF frame source, stability warmup, `sp=1` profiles after the windows) | scratchpad `p15/fclab2.sh "<name>:<lib>:<backend>[:sp[:transport[:K=V,...]]] ..." <reps>` -> `fcl_bench.sh`; `fclsum.py`, `residency.py`, `diffprof.py`, `prof_prep.sh` |
| FCL milestone (CPU + BSL scenes, fin / new / dev / MobileGlues) | scratchpad `p15/fcl_milestone.sh`, `fcl_scene.sh`, `fclab.sh`, `fclsum.py` |
| SSIM gate (openra, rd12, bsl × 4 arms × 2 backends) | scratchpad `p15/ssim_gate.sh`; `matrix_p14.sh` now takes `PREP_WLS` and a `bsl` workload |
| host CI-shaped build (WSL archlinux) | `~/mgl-p15-ci31`, scratchpad `p15/wsl_ci.sh`, `w_suite.sh`, `w_syncval.sh`, `w_sv_one.sh`, `w_one.sh` |
| trace APK builds | scratchpad `build_trace.sh W:/p15 .<tag>` (rerun once on the `IncrementalSplitterRunnable` failure) |
**Host-build trap:** editing a header while ninja is compiling leaves objects newer than the header
but built from its old text. This happened once and gave a `bad_alloc` in every scenario. Never
edit sources during a build; `touch` the edited headers if in doubt.
**Device facts:**
- Clocks: CPU 2035.2 MHz on policies 2/5/7 and 1574.4 MHz on policy0, GPU 680 MHz (new default since
2026-10-08, pending the soak). Pinned per session by `bench_session.sh`, which every `devjob.sh`
job runs.
- Frequency daemons are stopped only inside a bench session: `thermal-engine`, `perf2-hal-1-0`,
`vendor.perfservice`, `performance` and `hyperschedule_hal_service`. Their prior state is in
`/data/local/tmp/p15-bench-session` while a session is open, and they are restarted and verified
on exit. If that file exists with no job running, a session was left open: run
`bench_session.sh stop`.
- The perf stack's game-mode caps in `/sys/kernel/msm_performance/parameters/cpu_max_freq` survive
its services and silently override the pin. The session releases them.
- FCL's original lib md5 is `00c09f0a…`.
- MC 1.21.5 options md5 is `93b3f708…`; it is backed up at `/data/local/tmp/p15-options.txt`.
- Iris properties are backed up at `/data/local/tmp/p15-iris.properties`.
- `fcl_scene.sh restore` restores Iris; `fcl_p14.sh restore` restores the lib and `config.json`.
- The anland desktop is stopped during runs and restarted afterwards.
## pwab: device A/B of the present-wait levers (2026-10-10)
Result table, engagement evidence and the failed lever-B expectations are in [SCOREBOARD.md](SCOREBOARD.md) (section pwab). Summary: before a759b4b7, after pwgate cdd2160f + pmflush eec5e6e8 (+ `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES=2` on Magma). fps after/before: Magma inproc 1.32 (1.495 of MobileGlues), Magma mono 1.34 (1.176), Espryt inproc 1.09 (1.102), Espryt mono 1.12 on reps 1+3 (0.896; before rep 2 NO WORLD, not re-run).
- Libs: `p15/libs/{pwbase,pwA,pwF,pwAF}`, symbols in `p15/syms/`. Worktrees `.claude/worktrees/{pwbase,pwF,pwAF}` hold the builds (pwF/pwAF are detached HEADs with eec5e6e8 cherry-picked, not pushed). The 3rdparty copy also needs `include/ska` (a gitlink) copied into a fresh worktree.
- Harness: `p15/pw/dev/` (chain.sh, session.sh, fcl_bench.sh with the post-Perfetto atrace stage made opt-in, devjob.sh), run data in `p15/runs/pwab`, Perfetto in `p15/runs/pwlat`.
- Not done: the per-arm timeline analysis (cycle.py/pairs.py/gexec.py) and the separate lever A / F / extra=1 arms, both cut by the user. Next: derive the timelines from `runs/pwlat` and find why the Magma gain exceeds the lever-B model.
- Harness note: a launch can fail with NO WORLD after four 240 s attempts (b-DirectGLES-r2); fclab2.sh only retries INVALID runs, not NO WORLD.
@@ -0,0 +1,321 @@
# Monolith render-thread diff: dev vs p15 (FCL MC 1.21.5 vanilla, H2, cpuhunt)
The fixed function-level baseline for the monolith CPU cuts (SCOREBOARD.md has the fps
reference). Every cut starts from a symbolized profile of the p15 side and ends with a
before/after of the same function.
**Sources:**
- **Profiles:** simpleperf `cpu-clock --trace-offcpu --call-graph fp -f 4000 --duration 6`, taken
after the measurement windows of an H2 run (FCL pinned to cpu2-6).
- **dev:** 08124c99 in `runs/safter/dev-Direct{Vulkan,GLES}-r1`.
- **p15:** p15t = HEAD 3def5cb2 (p15s 0b96a3ef plus the Magma blit view cache) in
`runs/pt/t-Direct{Vulkan,GLES}-r1`.
- **Scope and units:** render thread only (the GL thread, which in monolith also applies), off-CPU
samples dropped, in ms/frame. Frames are the run's measured fps × 6 s; profiling overhead
inflates both sides alike.
- **Reducer:** `layerdiff.py` in the scratchpad.
**Attribution:** each sample goes to its innermost libMobileGL function, then to one layer.
- The leaf DSO decides first: driver (Adreno), libc+TLS (libc, libc++, `__emutls_get_address`,
TLS init), or kernel.
- Otherwise the function's namespace decides:
- client frontend: `MG_Impl`, `MG_State`;
- pipe record: `MG_Pipe` validate, tracker and emitters, plus the record channel;
- applier: `MG_Record` sinks and record emitters, plus `MG_Pipe` applier state;
- backend: `MG_Backend`.
- Samples with no libMobileGL frame are app-side (JIT/JVM).
**Caveat on function rows:** some functions were renamed between dev and p15, so a "+" row and a
"-" row can be the same work. Read such pairs together:
- Espryt `FlushPendingRangesNow` -> `FlushPendingRangesFrom` (0.105 -> 0.116);
- `BackendVertexArrayObject::SyncToBackend` -> `SyncToBackendFromApplier` (0.062 -> 0.058);
- `BackendFramebufferObject::SyncToBackend` -> `SyncToBackendByHandle`;
- Magma `SetupDraw` -> `SetupWireDraw`.
## Where the excess lives (summary)
| layer | Magma diff | Espryt diff | what it is |
|---|---|---|---|
| pipe record | +0.36 | +0.35 | `MGPipeValidateForVerb` (0.34 inclusive on Magma). Its pieces: framebuffer-state build 0.06, vertex-buffer emit 0.04, global constants 0.03, slot lookups (`FindByLifetimeId` + `Acquire`) 0.05, residual `CopyField` 0.02, tracker 0.02 |
| driver | +0.23 | +0.06 | Magma: per-frame fixed Vulkan work (below). Espryt: about even once renames are paired |
| libc+TLS | +0.22 | +0.14 | `__emutls_get_address` 0.055-0.075 plus `pGLContext` TLS init 0.016 (dev: ~0). Magma: libc under the extra command-buffer and pass begins. Espryt: `QueryCurrentSurfaceSize` |
| client frontend | +0.12 | +0.17 | Spread thin. Atomics (`__aarch64_ldadd8_*`) +0.02, state lookups 0.005 each |
| backend | -0.10 | +0.11 | Magma's wire backend is cheaper than dev's `SetupDraw` (no XXH64 vertex-input hash). Espryt pays per-handle registry lookups |
| JIT/JVM (app) | +0.04 | +0.08 | Not ours; profiling noise between runs |
**Magma per-frame fixed costs** (inclusive ms/frame, dev -> p15):
- BeginRenderPass 0.045 -> 0.117.
- EndCommandRecording 0.054 -> 0.113.
- BeginCommandRecording 0.052 -> 0.089.
- EndRenderPass 0.023 -> 0.033.
- Present 0.303 -> 0.352.
- p15 also has `SyncTextureResourceByHandle` 0.068, of which `UploadPendingWireLevels` is 0.038
and `FlushPendingCommands` 0.025.
Cause: every wire texture upload first submits the frame's recorded work
(`FlushWirePendingCommandsForTextureUpload`) and then uploads in a separate batch. MC updates
textures every frame, so the frame pays an extra submit, an extra command-buffer end/begin and a
render-pass restart. `GpuProgressMarkers::SubmitBracketed` is NOT new work: it wraps Present's
queue submit, which dev pays inside `Present` (0.121 vs 0.115).
**Espryt-only:** `QueryCurrentSurfaceSize` costs 0.065 ms/frame and dev pays nothing for it. It
is two `eglQuerySurface` calls on every dirty render-state sync (draws 0.048, clears 0.022). It
substitutes the surface for a scissor box the app never wrote (and for an empty viewport).
## Correction after cut 1 (2026-10-09): what the Magma fixed costs really are
Cut 1 (wire texture uploads stop flushing the frame recording) engaged on device:
`FlushPendingCommands` and `SubmitPendingCommandBuffer` left the profile, and
`UploadPendingWireLevels` went from 0.038 to 0.016. But Begin/EndCommandRecording and
BeginRenderPass did not move. H2 c1: 254.1 -> 249.8 fps, inside the noise.
Their cost is in the driver and scales with what is recorded:
| driver call | dev | p15 |
|---|---|---|
| vkResetCommandBuffer | 0.044 | 0.077 |
| vkEndCommandBuffer | 0.053 | 0.111 |
| vkCmdBeginRenderPass | 0.037 | 0.105 |
Host call counts per frame (diagnostic counting builds; FCL vanilla; 600-frame windows):
- **Magma, Vulkan calls: dev 331.6 vs p15 379.**
- The draw-level stream is identical and almost free of repeats: DrawIndexed 86.1,
BindVertexBuffers 87.1, BindDescriptorSets 87.1, BindPipeline 15.1, UpdateDescriptorSets 14,
dynamic state 2 each.
- Render passes: 4.1 -> 12.6.
- Pipeline barriers: 3.4 -> 27.5.
- CopyBufferToImage: 0.1 -> 2.2.
- By call site (unwinding counter):
- Pass begins: 6.5 at draws, 5.2 at clears, 1 at the blit.
- Pass ends: 5.3 from `ResolveWireImageDescriptor` (sampling an image written earlier), 4.2
from `TransitionWireImage` in the in-pass clear, 1.2 from `TransitionWireImage` in
`SetupWireDraw`, 2 at the blit.
- Barriers: 11.8 from `TransitionWireImage` at draw-pass begin, 6.3 at clear-pass begin, 5.6
from `ResolveWireImageDescriptor`, 2 at the blit, 1 at present.
- Cause: each new wire draw pass runs `TransitionWireImage(GENERAL -> GENERAL)` per
attachment. That ends the open pass and records a full ALL_COMMANDS memory barrier whether or
not a hazard exists.
- **Espryt, host GLES calls: dev 850.7 (479 repeat their previous arguments) vs p15 835.6 (446).**
- p15 does not issue more GLES calls than dev.
- In both, most of the repeats are glVertexAttribPointer 302 + glVertexAttribIPointer 75: the
same layout re-pointed at a new VBO on every draw.
## Levers beyond the local cuts (evaluated 2026-10-09)
Estimates are ms/frame of FCL GL-thread CPU. "Measured" rows come from H2 A/Bs (SCOREBOARD).
| lever | result | status |
|---|---|---|
| Pipe batch (FB memo, handle hints, buffer reuse, gate cache, Magma hash TLS) | measured: Magma -0.06, Espryt -0.03 | landed 485dff14, c85c9439 |
| ThinLTO + -O3 + ICF/gc (gradle default ON) | measured: Magma -0.16 (2.52 -> 2.36), Espryt -0.09 | 190580f2 (coordinator pushes) |
| Magma rename spares 4 -> 12 + fence-poll quiet window | profile ceiling ~0.05-0.06 (Create 0.031, Destroy 0.014, vkGetFenceStatus 0.020) | a0015bad; m2ab A/B |
| API 29 separate artifact (native ELF TLS) | estimate 0.08-0.1 (emutls 0.054 + pGLContext TLS init 0.024 on Magma) | wip/api29-switch, A/B open |
| AutoFDO/PGO | estimate 0.1-0.25 | with the user |
| Emulated-TLS work below 29 (mirror, owner-thread path, dual lib) | estimate 0.024-0.08 | dropped by the user |
| App-side JIT delta | +0.065 vs dev (0.708 -> 0.773 app-only), cause unknown | needs a GL entry-count A/B |
| shared_ptr refcount avoidance in bind paths | 0.005-0.01 | not started |
| Espryt VertexAttribPointer split | <=0.04 | parked |
## Cuts, biggest first
**Revised order:**
1. **1b (Magma):** explicit external subpass dependencies on the wire draw passes. Barrier only
images last written by transfer or storage, once and coalesced before the pass.
Estimate: passes 12.6 -> ~5, barriers 27 -> ~5, and the driver's command-buffer and
pass-begin cost with them.
2. **Cut 1 stays local** (no measurable gain).
**Order from 2026-10-09:**
1. 1c deferred clears (PARITY-AUDIT M1).
2. The remaining Magma barriers.
3. The pipe-record pieces.
4. The TLS hoist.
**Measured and parked: Espryt `glVertexAttribPointer` -> `glBindVertexBuffer` + `glVertexAttribFormat`.**
- Ceiling: `SyncToBackendFromApplier` costs 0.060 ms/frame inclusive, driver calls included
(0.015 self). Source: the c4 p15w Espryt profile, cpuhunt.
- The repeats are MC's per-draw re-point: the same layout with a new buffer at offset 0, about
4 attributes per buffer. The split would turn 1 `glBindBuffer` + ~4 pointer calls into 1
`glBindVertexBuffer`.
- Expected saving: ~0.02-0.04 ms/frame. That is below H2 resolution (1.2-2.9% spread).
- Cost: a second VAO shadow (format + binding). ES `glVertexAttribPointer` and
`glVertexAttribDivisor` silently rebind attribute -> binding, so the change is
correctness-sensitive.
The original list follows.
Estimates are ms/frame on the H2 render thread. Each cut gets a before/after profile of its
function and an H2 A/B.
1. **Magma: record wire texture uploads into the frame's command buffer** instead of
flush + separate batch. Estimate 0.10-0.15. It removes the extra submit, the command-buffer
end/begin and the pass restart. Correctness-sensitive: draw / TexSubImage / draw ordering, and
staging lifetime per frame. Red-once with the existing between-draws upload scenarios, plus
syncval.
2. **Shared: the pipe-record layer**, about 0.35 on both backends. Parts:
- (a) framebuffer-state build per verb: memo on the framebuffer's version;
- (b) slot lookups by lifetime id;
- (c) residual `CopyField` on monolith, where `fillOwed` is always true;
- (d) vertex-buffer and global-constant emit.
Each part is 0.02-0.06. Profile-driven, one at a time.
3. **Shared: TLS.** `__emutls_get_address` plus TLS init is ~0.07-0.09. The structural fix is
native TLS (minSdk, the user's call). The in-code mitigation is to read
`pGLContext` / `gPipeInputs` once per verb and pass the pointer down.
4. **Espryt: memoize the surface size** per draw surface, invalidated at swap and make-current.
Estimate 0.06.
5. **Magma: the clear path** (`glClear` 0.285 vs dev ~0.13): first re-profile after cut 1, since
much of it is the command-buffer and pass begins cut 1 removes.
## Magma (DirectVulkan): +0.88 ms/frame on the render thread (schedstat: 2.84 vs 2.00)
| layer | dev | p15 | diff |
|---|---|---|---|
| client frontend | 0.257 | 0.376 | +0.119 |
| pipe record | 0.000 | 0.363 | +0.363 |
| applier | 0.000 | 0.026 | +0.026 |
| backend | 0.516 | 0.416 | -0.100 |
| driver | 0.394 | 0.622 | +0.228 |
| libc+TLS | 0.213 | 0.430 | +0.218 |
| kernel (from MobileGL) | 0.112 | 0.115 | +0.003 |
| mgl other | 0.066 | 0.049 | -0.017 |
| JIT/JVM (app) | 0.659 | 0.697 | +0.038 |
| kernel (app) | 0.049 | 0.047 | -0.001 |
| **total** | 2.265 | 3.142 | +0.877 |
Top 15 p15 excess rows:
| layer | function (attributed) | dev | p15 | diff |
|---|---|---|---|---|
| libc+TLS | `__emutls_get_address` | 0.000 | 0.075 | +0.075 |
| driver | `VkRenderPassManager::BeginRenderPass` | 0.029 | 0.081 | +0.052 |
| driver | `FrameContext::EndCommandRecording` | 0.045 | 0.090 | +0.045 |
| kernel (from MobileGL) | `GpuProgressMarkers::SubmitBracketed` | 0.000 | 0.045 | +0.045 |
| driver | `VulkanRenderer::SetupWireDraw` | 0.000 | 0.040 | +0.040 |
| pipe record | `MG_Pipe::MGPipeValidateForVerb` | 0.000 | 0.035 | +0.035 |
| backend | `VulkanRenderer::SetupWireDraw` | 0.000 | 0.034 | +0.034 |
| driver | `VulkanRenderer::DrawElements` | 0.101 | 0.129 | +0.028 |
| pipe record | `MG_Pipe::MGPipeSlotAllocator::FindByLifetimeId` | 0.000 | 0.026 | +0.026 |
| driver | `GpuProgressMarkers::SubmitBracketed` | 0.000 | 0.024 | +0.024 |
| driver | `UniformManager::ResolveWireImageDescriptor` | 0.000 | 0.023 | +0.023 |
| pipe record | `MG_Pipe::MGPipeTracker::Update` | 0.000 | 0.022 | +0.022 |
| libc+TLS | `VkRenderPassManager::BeginRenderPass` | 0.010 | 0.032 | +0.022 |
| libc+TLS | `FrameContext::BeginCommandRecording` | 0.018 | 0.039 | +0.021 |
Per layer (top 6 each):
| layer | function (attributed) | dev | p15 | diff |
|---|---|---|---|---|
| client frontend | `__aarch64_ldadd8_acq_rel` | 0.013 | 0.023 | +0.010 |
| client frontend | `MG_State::GLState::FramebufferAttachmentObject::IsEmpty` | 0.000 | 0.008 | +0.007 |
| client frontend | `MG_State::GLState::BufferState::GetBindingSlot` | 0.000 | 0.006 | +0.006 |
| client frontend | `__aarch64_ldadd8_relax` | 0.004 | 0.010 | +0.006 |
| client frontend | `MG_State::GLState::ShareGroupState::GetBufferObject` | 0.000 | 0.005 | +0.005 |
| client frontend | `MG_State::GLState::FramebufferObject::CheckCompleteness` | 0.000 | 0.004 | +0.004 |
| pipe record | `MG_Pipe::MGPipeValidateForVerb` | 0.000 | 0.035 | +0.035 |
| pipe record | `MG_Pipe::MGPipeSlotAllocator::FindByLifetimeId` | 0.000 | 0.026 | +0.026 |
| pipe record | `MG_Pipe::MGPipeTracker::Update` | 0.000 | 0.022 | +0.022 |
| pipe record | `MG_Pipe::MGPipeFillAccess::CopyField` | 0.000 | 0.021 | +0.021 |
| pipe record | `MG_Pipe::MGPipeVertexInputEmitter::EmitVertexBuffers` | 0.000 | 0.018 | +0.018 |
| pipe record | `MG_Pipe::MGPipeProgramEmitter::EmitGlobalConstants` | 0.000 | 0.011 | +0.011 |
| applier | `MG_Record::RecordVerbSink::OnDrawVbo` | 0.000 | 0.005 | +0.005 |
| applier | `MG_Record::{anon}::EmitDrawRecord` | 0.000 | 0.004 | +0.004 |
| applier | `MG_Record::{anon}::EmitClear` | 0.000 | 0.003 | +0.003 |
| applier | `MG_Record::{anon}::EmitIndexedDraw` | 0.000 | 0.003 | +0.003 |
| applier | `MG_Record::{anon}::EmitDrawElements` | 0.000 | 0.003 | +0.003 |
| applier | `MG_Pipe::MGPipeApplierState::DrawFramebuffer` | 0.000 | 0.003 | +0.003 |
| backend | `VulkanRenderer::SetupWireDraw` | 0.000 | 0.034 | +0.034 |
| backend | `VulkanRenderer::GetOrCreatePipelineWithInput` | 0.000 | 0.021 | +0.021 |
| backend | `UniformManager::PrepareWireTextureResources` | 0.000 | 0.018 | +0.018 |
| backend | `_t const&, std::__ndk1::tuple<unsigned long const&>, std::__ndk1::tuple<> >` | 0.000 | 0.016 | +0.016 |
| backend | `UniformManager::ResolveWireImageDescriptor` | 0.000 | 0.014 | +0.014 |
| backend | `VkTextureManager::ResolveWireTextureStorage` | 0.000 | 0.012 | +0.012 |
| driver | `VkRenderPassManager::BeginRenderPass` | 0.029 | 0.081 | +0.052 |
| driver | `FrameContext::EndCommandRecording` | 0.045 | 0.090 | +0.045 |
| driver | `VulkanRenderer::SetupWireDraw` | 0.000 | 0.040 | +0.040 |
| driver | `VulkanRenderer::DrawElements` | 0.101 | 0.129 | +0.028 |
| driver | `GpuProgressMarkers::SubmitBracketed` | 0.000 | 0.024 | +0.024 |
| driver | `UniformManager::ResolveWireImageDescriptor` | 0.000 | 0.023 | +0.023 |
| libc+TLS | `__emutls_get_address` | 0.000 | 0.075 | +0.075 |
| libc+TLS | `VkRenderPassManager::BeginRenderPass` | 0.010 | 0.032 | +0.022 |
| libc+TLS | `FrameContext::BeginCommandRecording` | 0.018 | 0.039 | +0.021 |
| libc+TLS | `thread-local initialization routine for MG_State::pGLContext` | 0.000 | 0.017 | +0.017 |
| libc+TLS | `EndActiveRenderPassOn` | 0.000 | 0.014 | +0.014 |
| libc+TLS | `FrameContext::EndCommandRecording` | 0.009 | 0.023 | +0.014 |
## Espryt (DirectGLES): +0.93 ms/frame on the render thread (schedstat: 3.13 vs 2.34)
| layer | dev | p15 | diff |
|---|---|---|---|
| client frontend | 0.238 | 0.404 | +0.166 |
| pipe record | 0.000 | 0.349 | +0.349 |
| applier | 0.000 | 0.041 | +0.041 |
| backend | 0.245 | 0.356 | +0.111 |
| driver | 0.800 | 0.861 | +0.062 |
| libc+TLS | 0.209 | 0.350 | +0.141 |
| kernel (from MobileGL) | 0.209 | 0.221 | +0.011 |
| mgl other | 0.134 | 0.113 | -0.021 |
| JIT/JVM (app) | 0.693 | 0.774 | +0.081 |
| kernel (app) | 0.055 | 0.050 | -0.005 |
| **total** | 2.584 | 3.518 | +0.935 |
Top 15 p15 excess rows:
| layer | function (attributed) | dev | p15 | diff |
|---|---|---|---|---|
| driver | `BufferImpl::{anon}::FlushPendingRangesFrom` | 0.000 | 0.091 | +0.091 |
| libc+TLS | `__emutls_get_address` | 0.000 | 0.055 | +0.055 |
| driver | `VertexArrayImpl::BackendVertexArrayObject::SyncToBackendFromApplier` | 0.000 | 0.040 | +0.040 |
| pipe record | `MG_Pipe::MGPipeValidateForVerb` | 0.000 | 0.040 | +0.040 |
| driver | `DrawElements` | 0.276 | 0.312 | +0.036 |
| pipe record | `MG_Pipe::MGPipeTracker::Update` | 0.000 | 0.029 | +0.029 |
| libc+TLS | `QueryCurrentSurfaceSize` | 0.000 | 0.026 | +0.026 |
| libc+TLS | `BufferImpl::{anon}::FlushPendingRangesFrom` | 0.000 | 0.025 | +0.025 |
| driver | `FramebufferImpl::BackendFramebufferObject::SyncToBackendByHandle` | 0.000 | 0.025 | +0.025 |
| mgl other | `QueryCurrentSurfaceSize` | 0.000 | 0.023 | +0.023 |
| pipe record | `MG_Pipe::MGPipeSlotAllocator::FindByLifetimeId` | 0.000 | 0.022 | +0.022 |
| pipe record | `MG_Pipe::MGPipeVertexInputEmitter::EmitVertexBuffers` | 0.000 | 0.021 | +0.021 |
| pipe record | `MG_Pipe::MGPipeFillAccess::CopyField` | 0.000 | 0.018 | +0.018 |
| backend | `VertexArrayImpl::BackendVertexArrayObject::SyncToBackendFromApplier` | 0.000 | 0.018 | +0.018 |
Per layer (top 6 each):
| layer | function (attributed) | dev | p15 | diff |
|---|---|---|---|---|
| client frontend | `__aarch64_ldadd8_acq_rel` | 0.012 | 0.026 | +0.014 |
| client frontend | `__aarch64_ldadd8_relax` | 0.003 | 0.013 | +0.011 |
| client frontend | `MG_State::GLState::FramebufferAttachmentObject::IsEmpty` | 0.000 | 0.006 | +0.006 |
| client frontend | `MG_State::GLState::ShareGroupState::ValidateBufferObject` | 0.000 | 0.006 | +0.006 |
| client frontend | `MG_State::GLState::BufferState::GetBindingSlot` | 0.001 | 0.006 | +0.005 |
| client frontend | `MG_State::GLState::GLContext::GetProgramForDraw` | 0.002 | 0.007 | +0.005 |
| pipe record | `MG_Pipe::MGPipeValidateForVerb` | 0.000 | 0.040 | +0.040 |
| pipe record | `MG_Pipe::MGPipeTracker::Update` | 0.000 | 0.029 | +0.029 |
| pipe record | `MG_Pipe::MGPipeSlotAllocator::FindByLifetimeId` | 0.000 | 0.022 | +0.022 |
| pipe record | `MG_Pipe::MGPipeVertexInputEmitter::EmitVertexBuffers` | 0.000 | 0.021 | +0.021 |
| pipe record | `MG_Pipe::MGPipeFillAccess::CopyField` | 0.000 | 0.018 | +0.018 |
| pipe record | `MG_Pipe::MGPipeProgramEmitter::EmitGlobalConstants` | 0.000 | 0.009 | +0.009 |
| applier | `MG_Record::RecordVerbSink::OnDrawVbo` | 0.000 | 0.009 | +0.009 |
| applier | `MG_Record::{anon}::EmitDrawRecord` | 0.000 | 0.009 | +0.009 |
| applier | `MG_Pipe::MGPipeApplierState::DrawFramebuffer` | 0.000 | 0.005 | +0.005 |
| applier | `MG_Record::{anon}::EmitIndexedDraw` | 0.000 | 0.004 | +0.004 |
| applier | `MG_Record::{anon}::EmitDrawElements` | 0.000 | 0.002 | +0.002 |
| applier | `MG_Pipe::MGPipeApplierState::ReadFramebuffer` | 0.000 | 0.002 | +0.002 |
| backend | `VertexArrayImpl::BackendVertexArrayObject::SyncToBackendFromApplier` | 0.000 | 0.018 | +0.018 |
| backend | `TextureImpl::BackendTextureObject::IsDrawSyncCleanByRecord` | 0.000 | 0.013 | +0.013 |
| backend | `BufferImpl::EnsureBufferResourceForHandle` | 0.000 | 0.012 | +0.012 |
| backend | `eRegistry<MG_State::GLState::BufferObject, BufferImpl::GLESBufferResource, ` | 0.000 | 0.011 | +0.011 |
| backend | `stry<MG_State::GLState::ITextureObject, TextureImpl::BackendTextureObject, ` | 0.000 | 0.010 | +0.010 |
| backend | `ry<MG_State::GLState::ProgramObject, PrgramImpl::BackendProgramObjectImpl, ` | 0.000 | 0.009 | +0.009 |
| driver | `BufferImpl::{anon}::FlushPendingRangesFrom` | 0.000 | 0.091 | +0.091 |
| driver | `VertexArrayImpl::BackendVertexArrayObject::SyncToBackendFromApplier` | 0.000 | 0.040 | +0.040 |
| driver | `DrawElements` | 0.276 | 0.312 | +0.036 |
| driver | `FramebufferImpl::BackendFramebufferObject::SyncToBackendByHandle` | 0.000 | 0.025 | +0.025 |
| driver | `QueryCurrentSurfaceSize` | 0.000 | 0.016 | +0.016 |
| driver | `PrepareForDraw` | 0.005 | 0.010 | +0.005 |
| libc+TLS | `__emutls_get_address` | 0.000 | 0.055 | +0.055 |
| libc+TLS | `QueryCurrentSurfaceSize` | 0.000 | 0.026 | +0.026 |
| libc+TLS | `BufferImpl::{anon}::FlushPendingRangesFrom` | 0.000 | 0.025 | +0.025 |
| libc+TLS | `thread-local initialization routine for MG_State::pGLContext` | 0.000 | 0.016 | +0.016 |
| libc+TLS | `TextureImpl::SyncTextureToBackendByHandle` | 0.000 | 0.013 | +0.013 |
| libc+TLS | `FramebufferImpl::BackendFramebufferObject::SyncToBackendByHandle` | 0.000 | 0.007 | +0.007 |
@@ -0,0 +1,56 @@
# P15 S0.1: parity audit of the deleted frontend-arm mechanisms
**Question.** P13 W4 moved monolith onto the record/wire arm, and W6e / `de6ab167` then deleted the
frontend arm as dead code. Which performance mechanisms did that arm have, and does the wire arm
have an equivalent?
**Sources:**
- `origin/dev` and the pre-W6 tree `88a11b81` (the frontend arm);
- the HEAD wire arm;
- [PARITY-SEED.md](PARITY-SEED.md), the regex-extracted list of deleted definitions;
- the profiles in PLAN-P15.md §2.2: FCL MC 1.21.5 and rd12, render thread, ms/frame.
**Verdicts:**
- **port**: measured as missing, and the port is planned;
- **have**: the wire arm has an equivalent;
- **skip**: not shown in any profile; reconsider only if one shows it.
## Magma (DirectVulkan)
| # | mechanism (dev / 88a11b81) | wire arm at HEAD | profile evidence | verdict, cost |
|---|---|---|---|---|
| M1 | **Clears.** `VkClearManager`: a glClear inside the active pass on the same attachments became `ClearAttachmentsOnActiveRenderPass`; otherwise a pending clear keyed (texture identity, level, layer) turned the next pass's load op into CLEAR, materialised before reads, blits and copies | `ClearWireFramebuffer`: ends the draw pass; per surface, a new view + render pass + framebuffer, its own pass, then retire | FCL 0.42-0.46 ms (dev ~0.05); rd12 ~0.27 ms. Dev's per-draw `HasPendingClear` probe cost ~0.6 ms/frame on rd12 | **port, in two steps.** (a) The in-pass half: the clear takes the draw pass a draw to the same framebuffer would take (`PrepareWireDrawPass`) and records `vkCmdClearAttachments` in it. No new state, nothing deferred, so no read path has to materialise anything. (b) LOAD_OP_CLEAR only if a GPU-side reason appears; CPU-wise (a) removes the object churn and the pass break. Small cost, low risk **Update 2026-10-09 (cut 1c):** (a) covered same-framebuffer clears only. Minecraft 1.21.5 clears through framebuffers of their own (a depth-only one for the shared depth texture, one per colour target) and draws through another framebuffer holding the same images. Every such clear then began a LOAD_OP_CLEAR pass that did nothing but clear: 11.5 passes/frame against dev's 4.1. Dev handled the cross-framebuffer case with its texture-keyed pending clears, deleted as dead code in P13 W6. Cut 1c restores it, keyed on the image itself (the storage resource, level and layers; never a GL name): a clear of images the open pass holds goes in-pass, a whole-image clear of other images waits on the image (folded into the next pass that draws into it as LOAD_OP_CLEAR, or run at the first other use through SyncTextureResourceByHandle), and the default framebuffer stays excluded (the known openra Adreno in-pass issue). See MONOLITH-DIFF.md. |
| M2 | **Render pass + framebuffer cache.** `VkRenderPassManager::GetOrCreateRenderPass`, hash-keyed `RenderPassEntry` (render pass, framebuffer), garbage-collected at present | `m_wireDrawPassCaches`: exact-key reuse within one frame slot, emptied when the slot's frame begins (`ClearWireDrawPassCache`). Every frame rebuilds each framebuffer's pass, views and VkFramebuffer | FCL: vkCreateFramebuffer in SetupWireDraw 0.04, `~RenderPassEntry` 0.04-0.05, plus views | **port**: keep entries across frames while the key's image epochs hold, and retire through the submit-indexed list when an image goes away. Medium cost, medium risk (view lifetime against image release) |
| M3 | **Blit resources.** `InitializeBlitResources`, `TryBlitToDefaultFramebufferWithShader` (persistent pipeline and pool) | `BlitWireColorImage`: persistent pipelines, but per blit a descriptor **pool** + set, 2 views and a framebuffer, all retired | FCL 0.13 ms (vkCreateDescriptorPool 0.084 + destroy) vs dev 0.02 | **port**: one pool per frame slot, reset when the slot's frame begins; a full pool falls back to the old path. Views and framebuffer are next if they show up. Small cost, low risk |
| M4 | **Buffer sub-data.** `VkBufferManager::OnSubData`: a busy resident buffer took a staged copy (`StagedRangeCopy`, as now). A *streamed* buffer (`AcquireStreamedSlice`) updated only the CPU shadow, and the next draw streamed the whole buffer into a fresh arena slice, so no copy and no pass break | `WriteWireBuffer`: busy → `StagedWireRangeCopy`, which ends the pass and records two full barriers; idle → host memcpy. No streamed/renamed buffers on the wire | FCL 0.28 ms (11 sub-data calls/frame, ~25 µs each), and each one splits the pass on the GPU. WBUF probe: 4.5 host + 6.7 staged writes/frame; ~5.6 of the staged ones hit one 288-byte store | **ported**: write renaming for stores of 64 KB or less with a host shadow; the rename goes through the same orphan release as glBufferData, which every bind memo already handles (VkBuffer compare + destroy epoch) |
| M5 | **Draw fast path.** `TrySetupDrawFastPath` / `SetupDrawSnapshot` (4 snapshots on program lifetime id) | P14 wire memos: pass continuation (`WirePassMemoHolds`), unit sampler memo, pipeline / vertex / index bind dedupe, vertex input on its record | FCL SetupWireDraw 0.55 ≈ dev SetupDraw 0.54 | **have** |
| M6 | **Uniform rebinds.** `UniformManager` `FastRebindMemo`, `SampledBindingsUnchanged`, `CollectSampledTextures` walk-skip | P14 descriptor-set rebind with fresh offsets, walk-skip | small | **have** |
| M7 | **Vertex input.** `VertexInputStateFactory` per-VAO memos (`VaoBackendMemos`, memoised hash) | vertex input kept on its record (`ResolveWireVertexInput`) | small | **have** |
| M8 | **Texture sync.** `VkTextureManager` `SyncedTextureMemoEntry`, `DrawSyncScope` | P14 direct-mapped texture fronts, record-serial checks | small | **have** |
| M9 | **Vertex streams.** `UploadAndBindVertexBuffers`, `ConvertedVertexStream` cache (per frame, pointer + changeSerial), `LookupVaoDrawMemo` | wire vertex slices + bind shadow, but NO converted-stream cache: every draw re-converted the whole remaining stream | FCL: none (no conversion). BSL: `ConvertWireVertexStream` 49 ms/frame, Sodium multi-draws over one arena (Magma 19.5 fps vs dev 64.7) | **ported** (corrected from "have"): per-frame cache keyed on a monotonic store content serial, then kept across frames in `VkBufferManager` |
| M10 | **Depth mipmap / MSAA resolve / YUV**: per-op descriptor pools existed in dev too | same per-op pools | not in FCL/rd12 profiles | **skip** |
| M11 | **Command-buffer reset/end** | larger, more fragmented recordings | FCL +0.16 ms | re-measure after M1-M4 (follows from the pass count) |
## Espryt (DirectGLES)
| # | mechanism | wire/record arm at HEAD | profile evidence | verdict |
|---|---|---|---|---|
| E1 | `StateBackendObjectRegistry` (pointer-keyed twins, GC) | twins keyed on applier serials / lifetime ids (P14) | backend +0.09 ms on FCL | have |
| E2 | `SyncCurrentProgram`, `BindCurrentProgramWithResources` | `SyncCurrentProgramByHandle` + P14 memos | rd12 +0.05/+0.07 | covered by S3 (backend draw-delta) |
| E3 | `SyncVaoAttributeBuffersByHandle` | `SyncVaoAttributeBuffersByRecord`, `AdoptUnchangedBufferSets` | rd12 +0.09 | covered by S2/S3 |
| E4 | `BackendFramebufferObject::SyncToBackend` (dirty-bit sync) | record-serial sync, clean-attachment skip (P14) | small | have |
| E5 | clear / blit (host GL) | same host calls | FCL clear 0.16 vs 0.13, blit 0.125 vs 0.11 | have (no Espryt port; user confirmed) |
| E6 | buffer sub-data (`Ops_SubDataTracked`) | `Ops_H_SubDataTracked` via record | 0.024 vs 0.007 | skip |
Espryt's FCL gap is the client half of the draw path (+0.39 ms), which stages S1-S3 address.
## Order of ports (S0.2)
1. M1a: in-pass clear.
2. M3: blit frame pools.
3. M2: cross-frame pass cache.
4. M4: sub-data renaming.
5. Re-measure M11.
Every step: FCL presenting-thread CPU before and after, in the same session, with the MobileGlues
and dev reference rows.
+617
View File
@@ -0,0 +1,617 @@
# Deleted-symbol inventory: 88a11b81 (OLD) -> a0f4aa83 (NEW)
Seed for the stage 0.1 parity audit (PLAN-P15.md). Regex-based extraction, not compiler-accurate. See method notes at the end.
## Summary
| file | present at NEW | OLD bytes | NEW bytes | deleted names | of which gone |
|---|---|---|---|---|---|
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkClearManager.cpp` | yes | 24665 | 4092 | 29 | 29 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkClearManager.h` | yes | 8751 | 2769 | 11 | 11 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp` | yes | 102628 | 6349 | 23 | 22 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.h` | yes | 24416 | 8866 | 8 | 7 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp` | yes | 1009784 | 534405 | 85 | 85 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h` | yes | 148622 | 108551 | 10 | 10 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp` | yes | 224566 | 120448 | 25 | 23 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.h` | yes | 46216 | 38007 | 2 | 2 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp` | yes | 291971 | 138980 | 51 | 50 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.h` | yes | 61972 | 45328 | 12 | 12 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.cpp` | yes | 116229 | 84585 | 25 | 25 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.h` | yes | 28699 | 22339 | 3 | 3 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp` | yes | 49266 | 26249 | 7 | 7 |
| `MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.h` | yes | 13262 | 8134 | 3 | 2 |
| `MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp` | yes | 1149763 | 898589 | 53 | 50 |
| `MobileGL/MG_Backend/DirectGLES/Managers.cpp` | yes | 1063201 | 912235 | 49 | 48 |
| `MobileGL/MG_Backend/DirectGLES/Managers.h` | yes | 254434 | 229808 | 14 | 14 |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkClearManager.cpp`
OLD defs: 32, NEW defs: 3, deleted: 29 (gone 29, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `VkClearManager::QueueClear(GLbitfield mask, const ClearFramebufferPayload& clearPayload, const MG_State::GLState::Fra...` | 48 | gone | 0 | |
| `VkClearManager::GetPendingClear(const PendingClearKey& key, ClearAttachmentPayload& outPayload, SharedPtr<MG_State::G...` | 29 | gone | 0 | |
| `VkClearManager::CollectGarbage()` | 23 | gone | 3: VkTextureManager.cpp, VkTextureManager.h, ... | |
| `VkClearManager::GetPendingClears(MG_State::GLState::ITextureObject* texture, Vector<PendingClearEntry>& outEntries)` | 23 | gone | 0 | |
| `VkClearManager::QueueClear(const ClearAttachmentPayload& clearPayload, const MG_State::GLState::FramebufferAttachment...` | 22 | gone | 0 | |
| `VkClearManager::LockTextureIdentityLocked(const TextureIdentity& identity, SharedPtr<MG_State::GLState::ITextureObjec...` | 21 | gone | 0 | |
| `VkClearManager::HasPendingClear(MG_State::GLState::ITextureObject* texture)` | 20 | gone | 0 | |
| `VkClearManager::MergeClearPayload(ClearAttachmentPayload& dst, const ClearAttachmentPayload& src)` | 20 | gone | 0 | |
| `VkClearManager::MakePendingClearKey(MG_State::GLState::ITextureObject* rawTexture, Uint32 mipLevel, Uint32 baseArrayL...` | 18 | gone | 0 | |
| `VkClearManager::PopPendingClear(const PendingClearKey& key)` | 18 | gone | 0 | |
| `VkClearManager::HasPendingClear(const PendingClearKey& key)` | 16 | gone | 0 | |
| `VkClearManager::MakeTextureIdentity(MG_State::GLState::ITextureObject* texture)` | 15 | gone | 0 | |
| `VkClearManager::ErasePendingClearsForTextureLocked(const TextureIdentity& identity)` | 14 | gone | 0 | |
| `VkClearManager::QueueClear(const ClearAttachmentPayload& clearPayload, const SharedPtr<MG_State::GLState::ITextureObj...` | 14 | gone | 0 | |
| `ForceOpaqueClearAlpha(ClearAttachmentPayload& payload)` | 13 | gone | 0 | |
| `VkClearManager::PopPendingClear(MG_State::GLState::ITextureObject* texture)` | 13 | gone | 0 | |
| `GetClearableAttachment(const MG_State::GLState::FramebufferObject& drawFbo, FramebufferAttachmentType attachmentType)` | 12 | gone | 0 | |
| `ResolveAttachmentBaseArrayLayer(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 10 | gone | 1: BackendObject_DirectVulkan.cpp | |
| `VkClearManager::MakePendingClearKey(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 10 | gone | 0 | |
| `ClearStorageTextureOf(MG_State::GLState::ITextureObject* texture)` | 7 | gone | 0 | The texture a pending clear is actually ABOUT. A clear issued through a GL texture view |
| `VkClearManager::GetPendingClear(const MG_State::GLState::FramebufferAttachmentObject& attachment, ClearAttachmentPayl...` | 7 | gone | 0 | |
| `ResolveAttachmentBaseArrayLayer(TextureUploadTarget target)` | 6 | gone | 1: BackendObject_DirectVulkan.cpp | |
| `VkClearManager::HasPendingClear(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 6 | gone | 0 | |
| `VkClearManager::LockTextureLocked(const PendingClearKey& key, SharedPtr<MG_State::GLState::ITextureObject>& outTexture)` | 6 | gone | 0 | |
| `VkClearManager::PopPendingClear(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 6 | gone | 0 | |
| `VkClearManager::Shutdown()` | 6 | gone | 26: BackendObjects.h, BufferArena.cpp, ... | |
| `VkClearManager::GetPendingClear(const PendingClearKey& key, ClearAttachmentPayload& outPayload)` | 4 | gone | 0 | |
| `PendingClearMatchesTextureIdentity(const PendingClearKey& key, const TextureIdentity& identity)` | 3 | gone | 0 | |
| `VkClearManager::Initialize()` | 3 | gone | 32: BackendObject.h, BackendObjects.h, ... | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkClearManager.h`
OLD defs: 13, NEW defs: 2, deleted: 11 (gone 11, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class VkClearManager` | 55 | gone | 5: VkClearManager.cpp, VkRenderPassManager.cpp, ... | |
| `class PendingClearKeyHash` | 15 | gone | 0 | |
| `PendingClearKeyHash::operator()(const PendingClearKey& key)` | 13 | gone | 0 | |
| `class PendingClearKey` | 13 | gone | 0 | |
| `class TextureIdentity` | 8 | gone | 0 | |
| `class TextureIdentityHash` | 7 | gone | 0 | |
| `PendingClearKey::operator==(const PendingClearKey& other)` | 5 | gone | 0 | |
| `TextureIdentityHash::operator()(const TextureIdentity& key)` | 5 | gone | 0 | |
| `class PendingClearEntry` | 4 | gone | 0 | |
| `TextureIdentity::operator==(const TextureIdentity& other)` | 3 | gone | 0 | |
| `VkClearManager::HasAnyPendingClears()` | 1 | gone | 0 | Lock-free probe for the consecutive-draw fast path: any pending clear |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp`
OLD defs: 35, NEW defs: 13, deleted: 23 (gone 22, params differ 1).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `VkRenderPassManager::GetOrCreateRenderPass(const MG_State::GLState::FramebufferObject& fbo, Uint32 swapchainImageInde...` | 760 | gone | 2: VkRenderPassManager.h, VulkanRenderer.cpp | |
| `VkRenderPassManager::GetOrCreateRenderbufferResource(const SharedPtr<MG_State::GLState::RenderbufferObject>& renderbu...` | 169 | gone | 0 | |
| `VkRenderPassManager::ComputeHash(const MG_State::GLState::FramebufferObject& fbo, Uint32 swapchainImageIndex, Bool in...` | 163 | gone | 5: PipelineFactory.cpp, PipelineFactory.h, ... | |
| `VkRenderPassManager::OnPresent()` | 43 | gone | 6: DirectGLES.cpp, DirectVulkan.cpp, ... | |
| `ResolveCompleteColorAttachmentTexture(const MG_State::GLState::FramebufferObject& fbo, FramebufferAttachmentType atta...` | 35 | gone | 0 | |
| `ResolveAttachmentViewType(const MG_State::GLState::FramebufferAttachmentObject& attachment, const VkTextureManager::T...` | 30 | gone | 0 | VUID-VkFramebufferCreateInfo-flags-04113: every view handed to vkCreateFramebuffer must have |
| `VkRenderPassManager::CollectRenderbufferGarbage()` | 30 | gone | 0 | |
| `VkRenderPassManager::QueueRenderbufferClear(const ClearAttachmentPayload& clearPayload, const MG_State::GLState::Fram...` | 27 | gone | 0 | |
| `VkRenderPassManager::QueueRenderbufferClear(GLbitfield mask, const ClearFramebufferPayload& clearPayload, const MG_St...` | 24 | gone | 0 | |
| `VkRenderPassManager::RenderbufferResource::Destroy(VkDevice device, VmaAllocator allocator)` | 24 | gone | 17: BackendObjects.h, DirectGLES.cpp, ... | |
| `VkRenderPassManager::CollectDeferredRenderbufferReleases(Bool destroyAll)` | 21 | gone | 0 | |
| `ResolveAttachmentBaseArrayLayer(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 19 | gone | 1: BackendObject_DirectVulkan.cpp | |
| `TryResolveSampleCountFlagBits(Int requestedSamples, VkSampleCountFlagBits& outSampleCount)` | 17 | gone | 1: VkTextureManager.cpp | |
| `ResolveImageAspectMaskForFormat(VkFormat format)` | 16 | gone | 0 | |
| `VkRenderPassManager::GetPendingRenderbufferClear(MG_State::GLState::RenderbufferObject* renderbuffer, ClearAttachment...` | 15 | gone | 0 | |
| `VkRenderPassManager::DeferRenderbufferBackingRelease(RenderbufferResource& resource)` | 14 | gone | 0 | |
| `VkRenderPassManager::PurgeRenderPasses()` | 10 | gone | 0 | |
| `VkRenderPassManager::RetireAgeFrames()` | 8 | gone | 0 | |
| `VkRenderPassManager::HasPendingRenderbufferClear(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 7 | gone | 0 | |
| `VkRenderPassManager::VkRenderPassManager(VkDevice device, VkPhysicalDevice physicalDevice, VmaAllocator allocator, co...` | 7 | params differ | 12: PipelineFactory.cpp, PipelineFactory.h, ... | |
| `VkRenderPassManager::PopPendingRenderbufferClear(MG_State::GLState::RenderbufferObject* renderbuffer)` | 5 | gone | 0 | |
| `IsCubeMapFaceUploadTarget(TextureUploadTarget target)` | 4 | gone | 2: VkClearManager.cpp, VkTextureManager.cpp | |
| `ColorFormatLacksAlpha(const MG_State::GLState::ITextureObject* texture)` | 3 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.h`
OLD defs: 21, NEW defs: 13, deleted: 8 (gone 7, params differ 1).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class RenderbufferResource` | 26 | gone | 0 | |
| `class TrackedAttachmentLayoutInfo` | 13 | gone | 0 | |
| `class PendingClearAttachmentInfo` | 12 | gone | 0 | |
| `class DeferredRenderbufferRelease` | 7 | gone | 0 | A superseded renderbuffer backing (glRenderbufferStorage respecify) parked |
| `class IEvictionObserver` | 5 | gone | 2: ProgramFactory.h, VulkanRenderer.h | Notified once per OnPresent sweep with every aged-out entry's VkRenderPass |
| `class PendingRenderbufferClear` | 4 | gone | 0 | |
| `RenderPassEntry::RenderPassEntry(Uint64 hash, VkRenderPass renderpass, VkFramebuffer framebuffer, Uint64 compatibilit...` | 1 | params differ | 4: VkRenderPassManager.cpp, VulkanRenderer.cpp, ... | |
| `VkRenderPassManager::SetEvictionObserver(IEvictionObserver* observer)` | 1 | gone | 2: ProgramFactory.h, VulkanRenderer.cpp | Observer may be null (no notifications). Not owned. |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.cpp`
OLD defs: 301, NEW defs: 216, deleted: 85 (gone 85, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `VulkanRenderer::BlitNamedFramebuffer(const SharedPtr<MG_State::GLState::FramebufferObject>& readFbo, const SharedPtr<...` | 624 | gone | 5: BackendObject.h, DirectGLES.cpp, ... | |
| `VulkanRenderer::UploadAndBindVertexBuffers(VkCommandBuffer commandBuffer, const MG_State::GLState::VertexArrayObject&...` | 417 | gone | 0 | |
| `VulkanRenderer::TrySetupDrawFastPath(FrameContext::FrameData& frame, GLenum mode, Flags<DrawSetupAspect> aspects, con...` | 401 | gone | 0 | |
| `VulkanRenderer::GenerateDepthMipmapWithShader(FrameContext::FrameData& frame, MG_State::GLState::ITextureObject& text...` | 351 | gone | 2: VulkanRenderer.h, WireDepthMipmap.inc | |
| `VulkanRenderer::GetTextureImage(const SharedPtr<MG_State::GLState::ITextureObject>& textureObject, TextureUploadTarge...` | 235 | gone | 2: BackendObject.h, RecordVerbSink.cpp | |
| `VulkanRenderer::TryBlitToDefaultFramebufferWithShader(FrameContext::FrameData& frame, MG_State::GLState::FramebufferO...` | 195 | gone | 0 | |
| `VulkanRenderer::UploadAndBindIndexBuffer(FrameContext::FrameData& frame, const MG_State::GLState::VertexArrayObject& ...` | 179 | gone | 2: DirectVulkan.cpp, VulkanRenderer.h | |
| `VulkanRenderer::MaterializePendingClearForTexture(VkCommandBuffer commandBuffer, MG_State::GLState::ITextureObject& t...` | 175 | gone | 2: VkClearManager.cpp, VkTextureManager.h | |
| `VulkanRenderer::QueueClearBufferPayloadForFramebuffer(const MG_State::GLState::FramebufferObject& framebuffer, GLenum...` | 132 | gone | 0 | |
| `VulkanRenderer::ReadDepthStencilPixels(MG_State::GLState::FramebufferObject& readFbo, GLint x, GLint y, GLsizei width...` | 118 | gone | 0 | |
| `VulkanRenderer::LookupVaoDrawMemo(const MG_State::GLState::VertexArrayObject* vao)` | 114 | gone | 0 | |
| `ResolveFramebufferBlitBinding(MG_State::GLState::FramebufferObject& fbo, Bool isReadFramebuffer, Uint32 swapchainImag...` | 113 | gone | 0 | |
| `ResolveTextureCopySourceBinding(MG_State::GLState::FramebufferObject& fbo, Uint32 swapchainImageIndex, SwapchainObjec...` | 108 | gone | 0 | |
| `ResolveColorBlitBinding(MG_State::GLState::FramebufferObject& fbo, Bool isReadFramebuffer, Uint32 swapchainImageIndex...` | 103 | gone | 0 | |
| `VulkanRenderer::MultiDrawArraysIndirect(GLenum mode, const void* indirect, GLsizei drawcount, GLsizei stride)` | 101 | gone | 8: BackendObject.h, BackendObject_DirectGLES.cpp, ... | |
| `VulkanRenderer::MultiDrawElementsIndirectCount(GLenum mode, GLenum type, const void* indirect, GLintptr drawcount, GL...` | 99 | gone | 9: BackendObject.h, BackendObject_DirectGLES.cpp, ... | |
| `VulkanRenderer::PrepareStorageImageTextures(FrameContext::FrameData& frame, const MagmaProgramSource& program, const ...` | 93 | gone | 0 | |
| `VulkanRenderer::MaterializePendingClearForRenderbuffer(VkCommandBuffer commandBuffer, const SharedPtr<MG_State::GLSta...` | 87 | gone | 0 | |
| `VulkanRenderer::MultiDrawElementsIndirect(GLenum mode, GLenum type, const void* indirect, GLsizei drawcount, GLsizei ...` | 81 | gone | 8: BackendObject.h, BackendObject_DirectGLES.cpp, ... | |
| `VulkanRenderer::ClearDepthSliceWithRenderPass(VkCommandBuffer commandBuffer, MG_State::GLState::ITextureObject& textu...` | 79 | gone | 0 | |
| `VulkanRenderer::MaterializePendingClearForDefaultFramebuffer(VkCommandBuffer commandBuffer, MG_State::GLState::Frameb...` | 77 | gone | 0 | A glClear on the DEFAULT framebuffer is parked as a pending clear and folded into the next |
| `VulkanRenderer::ClearAttachmentsOnActiveRenderPass(VkCommandBuffer commandBuffer, const RenderPassEntry &compatibleRe...` | 72 | gone | 0 | |
| `VulkanRenderer::PrepareSamplerImageFeedbackSnapshots(FrameContext::FrameData& frame, const MagmaProgramSource& progra...` | 71 | gone | 0 | |
| `VulkanRenderer::MaterializeMultisamplePendingClear(VkCommandBuffer commandBuffer, MG_State::GLState::ITextureObject& ...` | 67 | gone | 0 | |
| `VulkanRenderer::MaterializePendingDepthStencilClearForDefaultFramebuffer(VkCommandBuffer commandBuffer, const MG_Stat...` | 67 | gone | 0 | The depth/stencil half of MaterializePendingClearForDefaultFramebuffer. Separate only |
| `VulkanRenderer::PrepareScissoredClear(const MG_State::GLState::FramebufferObject& framebuffer, VkClearRect& outClearR...` | 63 | gone | 0 | |
| `TryComputeMaxIndexFromHostBytes(const MG_State::GLState::VertexArrayObject& vao, const IndexBufferView& indexView, Ui...` | 62 | gone | 0 | Scans the draw's index range from host-visible index bytes and returns the largest |
| `VulkanRenderer::TryBindResolvedVertexBindings(VkCommandBuffer commandBuffer, const MG_State::GLState::VertexArrayObje...` | 62 | gone | 0 | |
| `VulkanRenderer::GetOrCreateBlitPipeline(const RenderPassEntry& renderPassEntry)` | 54 | gone | 0 | P7 wave 2-B2 (CONTRACT-P7 §5.2, (B')): the pull build's blit pipeline, built out of the |
| `VulkanRenderer::RecordScissoredClearBuffer(const MG_State::GLState::FramebufferObject& framebuffer, GLenum buffer, GL...` | 54 | gone | 0 | |
| `VulkanRenderer::AcquireMultisampleResolveScratchImage(VkCommandBuffer commandBuffer, VkFormat format, VkExtent2D extent)` | 53 | gone | 0 | |
| `EnsureGenerateMipmapStorageAllocated(::MobileGL::MG_State::GLState::TextureObjectMipmap& texture, Uint32 baseMipLevel...` | 50 | gone | 1: DirectGLES.cpp | glGenerateMipmap defines levels BASE_LEVEL+1 up to the level the base image's extent and |
| `GetNumericDomainForTextureInternalFormat(TextureInternalFormat format)` | 42 | gone | 0 | |
| `VulkanRenderer::CopyDepthStencilAspectThroughBuffer(FrameContext::FrameData& frame, VkImage srcImage, VkImage dstImag...` | 37 | gone | 0 | A single-aspect depth/stencil copy between two images of the same format. An image copy |
| `VulkanRenderer::OrderPendingUploadAfterRecording(FrameContext::FrameData& frame, MG_State::GLState::ITextureObject& t...` | 37 | gone | 1: VkTextureManager.h | |
| `RewriteRestartIndices(const void* source, SizeT sizeBytes, VkIndexType indexType, Uint32 applicationRestartIndex, Vec...` | 36 | gone | 1: DirectGLES.cpp | Copies index data, replacing every occurrence of the application's arbitrary restart |
| `ResolveTextureCopyDestinationBinding(MG_State::GLState::ITextureObject& texture, Uint32 mipLevel, VkTextureManager& t...` | 34 | gone | 0 | |
| `EnsureGenerateMipmapShadowAllocated(const VkTextureManager::TextureResource& resource, Uint32 baseMipLevel, const Vec...` | 32 | gone | 0 | P5c (T5 / tx): the split arm of EnsureGenerateMipmapStorageAllocated. Under an active |
| `VkImageLayoutToString(VkImageLayout layout)` | 28 | gone | 0 | |
| `ShadowedBindVertexBuffers(VkCommandBuffer commandBuffer, const VkBuffer* buffers, const VkDeviceSize* offsets, Uint32...` | 25 | gone | 0 | vkCmdBindVertexBuffers, skipped when this command buffer already holds these |
| `GetComponentCountForShaderValueType(GLenum glType)` | 22 | gone | 0 | |
| `ConvertFloat64VertexStreamToFloat32(const MG_State::GLState::VertexAttribute& attribute, const Uint8* sourceData, Siz...` | 20 | gone | 0 | The fetch half of the 64-bit vertex narrowing, whose shader half is guaranteed by |
| `VulkanRenderer::ClearNamedFramebufferiv(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum bu...` | 20 | gone | 1: BackendObject.h | The integer clears carry the same payload as their target-based siblings; only the |
| `ConvertIntegerVertexStreamToFloat32(const MG_State::GLState::VertexAttribute& attribute, const Uint8* sourceData, Siz...` | 19 | gone | 0 | |
| `HasUnsupportedCompleteRenderbufferAttachment(const MG_State::GLState::FramebufferObject& framebufferObject)` | 19 | gone | 0 | |
| `VulkanRenderer::ClearNamedFramebufferfv(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum bu...` | 19 | gone | 1: BackendObject.h | |
| `ConvertScaledIntegerVertexStreamToFloat32(const MG_State::GLState::VertexAttribute& attribute, const Uint8* sourceDat...` | 18 | gone | 0 | |
| `GetSupportedColorWriteMaskForComponentCount(SizeT componentCount)` | 18 | gone | 0 | |
| `HasDistinctCompleteDepthStencilTextureAttachments(const MG_State::GLState::FramebufferObject& framebufferObject)` | 17 | gone | 0 | |
| `GetDepthStencilAspectMaskForFormat(VkFormat format)` | 16 | gone | 0 | The aspects a depth/stencil format actually carries. VkTextureManager keeps its own copy of |
| `ShouldUseTransientVertexIndexBuffer(const MG_State::GLState::BufferObject& bufferObject)` | 16 | gone | 0 | |
| `ActiveRenderPassUsesTexture(const ActiveRenderPassInfo& activeRenderPass, const MG_State::GLState::ITextureObject& te...` | 15 | gone | 0 | |
| `ApplyNativeBlitDefaultFramebufferSourceTransform(VkSurfaceTransformFlagBitsKHR preTransform, const BlitImageBinding& ...` | 14 | gone | 0 | The same conversion on the READ side, which never had one: a blit whose source is the |
| `ApplyNativeBlitDefaultFramebufferTransform(VkSurfaceTransformFlagBitsKHR preTransform, const BlitImageBinding& dstBin...` | 14 | gone | 0 | |
| `VulkanRenderer::SettleTexelsBeforeQueuedClear(const MG_State::GLState::FramebufferObject& framebuffer, const MG_State...` | 14 | gone | 0 | |
| `ConvertIntegerVertexComponentToFloat(ComponentT value, Bool normalized)` | 13 | gone | 0 | |
| `ResolveAttachmentBaseArrayLayer(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 13 | gone | 1: BackendObject_DirectVulkan.cpp | |
| `GetSwapchainDepthStencilAspectMask(const SwapchainObject& swapchainObject)` | 12 | gone | 0 | |
| `IsValidSampledImageLayout(VkImageLayout layout)` | 12 | gone | 0 | |
| `RepackVertexStream(const Uint8* sourceData, SizeT sourceStride, SizeT elementSize, SizeT elementCount, Vector<Uint8>&...` | 12 | gone | 0 | |
| `ResolveFramebufferCopyAttachmentType(const MG_State::GLState::FramebufferObject& fbo, Bool isReadFramebuffer, VkImage...` | 12 | gone | 0 | |
| `VulkanRenderer::ClearNamedFramebufferuiv(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum b...` | 12 | gone | 1: BackendObject.h | |
| `VulkanRenderer::OnRenderPassesDestroyed(const Vector<VkRenderPass>& renderPasses)` | 12 | gone | 0 | |
| `ComputeFullMipLevelCount(const IntVec3& baseTexelSize)` | 11 | gone | 1: VkTextureManager.cpp | |
| `MipShrinkingComponentCount(TextureTarget target)` | 11 | gone | 0 | How many components of a GL-space texel size actually halve down the mip chain. An array |
| `VulkanRenderer::ClearNamedFramebufferfi(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum bu...` | 11 | gone | 1: BackendObject.h | |
| `VulkanRenderer::FinishPendingGpuWork()` | 11 | gone | 0 | |
| `RequiresShaderBlitToDefaultFramebuffer(VkSurfaceTransformFlagBitsKHR preTransform)` | 9 | gone | 0 | |
| `ComputeMipTexelSizeWithFixedComponents(const IntVec3& baseTexelSize, Uint32 relativeMipLevel, Int shrinkingComponents)` | 7 | gone | 0 | |
| `RecordUnsupportedFramebufferError(const char* func)` | 7 | gone | 0 | |
| `VulkanRenderer::GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels)` | 7 | gone | 6: BackendObject.h, DirectGLES.cpp, ... | |
| `ComputeMipTexelSize(const IntVec3& baseTexelSize, Uint32 relativeMipLevel)` | 6 | gone | 0 | |
| `IsUnsupportedFramebufferForDirectVulkan(const MG_State::GLState::FramebufferObject& framebufferObject)` | 5 | gone | 0 | |
| `ResolveGenerateMipmapFinalLayout(VkImageAspectFlags aspectMask)` | 5 | gone | 0 | |
| `VulkanRenderer::GetOrCreatePipeline(GLenum mode, const MagmaProgramSource& program, const ProgramFactory::VkProgramOb...` | 5 | gone | 4: MagmaPipeArms.h, PipelineFactory.cpp, ... | |
| `class SnapshotCacheEntry` | 5 | gone | 0 | |
| `constexpr(std::is_signed_v<ComponentT>)` | 5 | gone | 47: BackendObject.h, DirectGLES.cpp, ... | |
| `AlignPixelRow(SizeT rowBytes, Int alignment)` | 4 | gone | 1: DirectGLES.cpp | |
| `AttachmentIsDepthSlice(const MG_State::GLState::FramebufferAttachmentObject& attachment)` | 4 | gone | 0 | A 3D image has arrayLayers == 1: its "layer" is a z slice, which has to travel as an |
| `IsColorAttachment(FramebufferAttachmentType attachmentType)` | 4 | gone | 0 | |
| `IsCubeMapFaceUploadTarget(TextureUploadTarget target)` | 4 | gone | 2: VkClearManager.cpp, VkTextureManager.cpp | |
| `ColorFormatLacksAlpha(const MG_State::GLState::ITextureObject* texture)` | 3 | gone | 0 | GL 4.6 core 15.2.3: a colour format with no alpha channel reads as if alpha were one. |
| `CombinePipelineStateWord(Uint64 hash, Uint64 word)` | 3 | gone | 0 | Boost-style hash combine. The inputs are tiny enum ordinals and bit masks, so |
| `RecordClearBufferError(const char* func, ErrorCode code, const char* message)` | 3 | gone | 0 | |
| `VulkanRenderer::IsDrawIndirectCountExtensionEnabled()` | 3 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VulkanRenderer.h`
OLD defs: 55, NEW defs: 52, deleted: 10 (gone 10, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class SetupDrawSnapshot` | 99 | gone | 1: VulkanRenderer.cpp | Snapshot behind TrySetupDrawFastPath. Values only: the program and |
| `class ResolvedVertexBindings` | 73 | gone | 0 | One VAO's resolved vkCmdBindVertexBuffers arguments, reusable by a later draw |
| `class ConvertedVertexStreamKey` | 19 | gone | 0 | |
| `class ConvertedVertexStreamKeyHash` | 17 | gone | 0 | |
| `ConvertedVertexStreamKeyHash::operator()(const ConvertedVertexStreamKey& key)` | 15 | gone | 0 | |
| `class ConvertedVertexStream` | 11 | gone | 0 | |
| `ConvertedVertexStreamKey::operator==(const ConvertedVertexStreamKey& other)` | 6 | gone | 0 | |
| `VulkanRenderer::InvalidateSetupDrawSnapshots()` | 5 | gone | 0 | |
| `VulkanRenderer::ResolveVaoHandle(const MG_State::GLState::VertexArrayObject& vao)` | 4 | gone | 0 | The VAO's {slot, gen}. A one-entry memo hit for every acquisition after a draw's |
| `VulkanRenderer::VaoContentHashIfKnown(const MG_State::GLState::VertexArrayObject& vao, Uint64& outHash)` | 3 | gone | 0 | "Is this VAO's content hash already memoized?", asked of whichever side owns the |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.cpp`
OLD defs: 63, NEW defs: 41, deleted: 25 (gone 23, params differ 2).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `UniformManager::BindProgramUniformBuffers(VkCommandBuffer commandBuffer, const MagmaProgramSource& program, const Pro...` | 410 | params differ | 5: ProgramFactory.cpp, ProgramFactory.h, ... | |
| `UniformManager::ResolveSamplerDescriptor(VkCommandBuffer commandBuffer, const MagmaProgramSource& program, const Prog...` | 244 | gone | 1: UniformManager.h | |
| `UniformManager::ResolveWireImageDescriptor(VkCommandBuffer commandBuffer, const MagmaProgramSource& program, const Pr...` | 167 | params differ | 1: UniformManager.h | |
| `UniformManager::CollectSamplerImageFeedback(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject&...` | 78 | gone | 0 | |
| `UniformManager::CollectStorageImageTextures(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject&...` | 76 | gone | 0 | |
| `UniformManager::GetFallbackMultisampleTexture(TextureTarget target, SamplerNumericDomain numericDomain)` | 75 | gone | 0 | |
| `UniformManager::ResolveSampledBinding(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject& progr...` | 64 | gone | 0 | |
| `UniformManager::ProgramSamplesOnlySingleLevelTextures(const MagmaProgramSource& program, const ProgramFactory::VkProg...` | 59 | gone | 0 | |
| `UniformManager::CollectSampledTextures(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject& prog...` | 46 | gone | 0 | |
| `UniformManager::GetUnboundStorageImageTexture(TextureTarget target, VkFormat format)` | 43 | gone | 1: ProgramFactory.h | |
| `UniformManager::SampledBindingsUnchanged(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject& pr...` | 42 | gone | 0 | |
| `UniformManager::GetFallbackTexture(TextureTarget target, SamplerNumericDomain numericDomain)` | 39 | gone | 0 | |
| `PlaceholderShapeForTarget(TextureTarget target)` | 37 | gone | 0 | |
| `UniformManager::ResolveSamplerDescriptorOverride(const SamplerBindingOverride& samplerBindingOverride, VkDescriptorIm...` | 37 | gone | 0 | |
| `UniformManager::ResolveSamplerTextureRaw(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject& pr...` | 25 | gone | 0 | |
| `FindFramebufferAttachmentForTexture(const MG_State::GLState::FramebufferObject& framebuffer, const MG_State::GLState:...` | 24 | gone | 0 | |
| `UniformManager::ResolveSamplerTexture(const MagmaProgramSource& program, const ProgramFactory::VkProgramObject& progr...` | 23 | gone | 0 | |
| `MakePlaceholderTextureObject(TextureTarget target, Uint index)` | 22 | gone | 0 | TextureObjectMipmap, not ITextureObject: AllocateStorage and MarkStorageDirty live |
| `UniformManager::ResolveUnboundStorageImagePlaceholder(const ProgramFactory::VkProgramObject& programObj, Uint32 bindi...` | 16 | gone | 0 | |
| `InternalFormatForVkFormat(VkFormat format)` | 13 | gone | 0 | Reverse of MG_Util::ConvertTextureInternalFormatToVkEnum. A placeholder texture is |
| `IsValidSampledImageLayout(VkImageLayout layout)` | 12 | gone | 0 | |
| `ResolveSamplerUnitIndex(const MagmaProgramSource& program, Int location, Uint32 binding)` | 11 | gone | 0 | |
| `class PlaceholderShape` | 8 | gone | 0 | What a 1x1 placeholder of a given target has to allocate for the backend to give it the |
| `IsPlaceholderTexture(const MG_State::GLState::ITextureObject* texture)` | 7 | gone | 0 | MobileGL's own stand-in textures, by the reserved ids above. Nothing an application can |
| `ResolveDescriptorElementLocation(const MagmaProgramSource& program, Int baseLocation, Uint32 element)` | 7 | gone | 0 | Uniform location of ELEMENT `element` of the opaque-uniform array at `baseLocation`, or |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/UniformManager.h`
OLD defs: 19, NEW defs: 19, deleted: 2 (gone 2, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class FastRebindMemo` | 13 | gone | 0 | Dynamic-offset-only rebind (see BindProgramUniformBuffers): records the |
| `class SamplerBindingOverride` | 9 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.cpp`
OLD defs: 104, NEW defs: 55, deleted: 51 (gone 50, params differ 1).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `VkTextureManager::UploadDirtyMipLevels(MG_State::GLState::TextureObjectMipmap &mipmapTexture, TextureUploadTarget upl...` | 524 | gone | 0 | |
| `VkTextureManager::SyncTextureResource(const MG_State::GLState::ITextureObject &texture, TextureUploadTarget uploadTar...` | 416 | gone | 4: BackendObject_DirectVulkan.cpp, VkTextureManager.h, ... | |
| `VkTextureManager::SnapshotTextureForSampling(VkCommandBuffer commandBuffer, MG_State::GLState::ITextureObject& textur...` | 148 | gone | 0 | |
| `VkTextureManager::SyncTexture(MG_State::GLState::ITextureObject &texture, TextureResource &outResource)` | 117 | gone | 1: VkTextureManager.h | |
| `VkTextureManager::GetOrCreateStorageImageView(MG_State::GLState::ITextureObject& texture, Uint32 mipLevel, VkFormat f...` | 112 | gone | 0 | |
| `VkTextureManager::SyncTextureAndGetDescriptor(MG_State::GLState::ITextureObject& textureOrView)` | 108 | gone | 2: VkTextureManager.h, VulkanRenderer.cpp | |
| `PreserveTextureContentsOnRecreate(VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, const VkTextureM...` | 106 | params differ | 0 | |
| `TryResolveTextureShapeInfo(const MG_State::GLState::ITextureObject& texture, TextureUploadTarget uploadTarget, const ...` | 102 | gone | 1: VulkanRenderer.cpp | |
| `VkTextureManager::GetOrCreateAttachmentViewAtMipLevel(MG_State::GLState::ITextureObject& texture, Uint32 mipLevel, Ui...` | 91 | gone | 0 | |
| `VkTextureManager::GetOrCreateSampledImageView(MG_State::GLState::ITextureObject& texture, VkFormat format)` | 83 | gone | 0 | |
| `VkTextureManager::SyncTextureViews(const MG_State::GLState::ITextureObject& texture, TextureResource& resource)` | 56 | gone | 1: VkTextureManager.h | |
| `VkTextureManager::ResolveTextureViewWindow(MG_State::GLState::ITextureObject& texture, const TextureResource& resource)` | 55 | gone | 0 | |
| `VkTextureManager::UpdateTrackedImageLayoutAfterAttachmentWrite(VkCommandBuffer commandBuffer, MG_State::GLState::ITex...` | 52 | gone | 1: VkTextureManager.h | |
| `VkTextureManager::TransitionTextureForSampling(VkCommandBuffer commandBuffer, MG_State::GLState::ITextureObject& text...` | 49 | gone | 0 | |
| `VkTextureManager::GetOrCreateSampledViewAtMipLevel(MG_State::GLState::ITextureObject& texture, Uint32 mipLevel)` | 44 | gone | 0 | |
| `VkTextureManager::GetOrCreateWindowedSampledView(MG_State::GLState::ITextureObject& texture, TextureResource& resourc...` | 41 | gone | 0 | Builds (and caches) one sampled VkImageView over `resource`'s image for an arbitrary |
| `VkTextureManager::NoteTextureViewImageRequirements(MG_State::GLState::ITextureObject& viewTexture, MG_State::GLState:...` | 41 | gone | 0 | The extra VkImageCreateFlags a GL texture view needs on the image it views. Recorded |
| `VkTextureManager::CheckMipmapCompleteness(const MG_State::GLState::ITextureObject& texture, TextureUploadTarget& outT...` | 36 | gone | 0 | |
| `VkTextureManager::GetOrCreateViewAtMipLevel(MG_State::GLState::ITextureObject& texture, Uint32 mipLevel)` | 36 | gone | 0 | |
| `VkTextureManager::TransitionTextureForStorageImage(VkCommandBuffer commandBuffer, MG_State::GLState::ITextureObject& ...` | 30 | gone | 0 | |
| `VkTextureManager::ResolveViewMipRange(const MG_State::GLState::ITextureObject& texture, Uint32 mipLevels, Uint32& out...` | 28 | gone | 0 | |
| `VkTextureManager::CreateImageView(VkImage image, VkFormat format, VkImageAspectFlags aspect, VkImageViewType viewType...` | 27 | gone | 0 | |
| `VkTextureManager::NeedsStorageImagePreparation(MG_State::GLState::ITextureObject& texture)` | 25 | gone | 1: VkTextureManager.h | |
| `class UploadItem` | 24 | gone | 0 | |
| `VkTextureManager::MakeTextureIdentity(MG_State::GLState::ITextureObject* texture)` | 22 | gone | 0 | |
| `ResolveTextureViewImageViewType(TextureTarget target, VkImageViewType storageViewType)` | 21 | gone | 0 | The VkImageViewType a GL texture view's own target asks for. Deliberately derived from the |
| `VkTextureManager::PruneStaleTextureAliases(MG_State::GLState::ITextureObject* texture)` | 20 | gone | 0 | |
| `ToVkComponentSwizzle(TextureSwizzleParam swizzle)` | 19 | gone | 0 | |
| `VkTextureManager::GetUploadMipLevelCount(const MG_State::GLState::TextureObjectMipmap& texture, TextureUploadTarget t...` | 17 | gone | 0 | |
| `VkTextureManager::DeferViewRelease(VkImageView view)` | 15 | gone | 0 | |
| `VkTextureManager::EraseTrackedTexture(const TextureIdentity& identity)` | 14 | gone | 0 | |
| `VkTextureManager::NeedsMipChainGrowth(MG_State::GLState::ITextureObject& texture)` | 13 | gone | 0 | |
| `IsValidSampledImageLayout(VkImageLayout layout)` | 12 | gone | 0 | |
| `VkTextureManager::AppendViewRequestedFormats(const MG_State::GLState::ITextureObject& storageTexture, Vector<VkFormat...` | 12 | gone | 0 | |
| `ResolveSampledViewComponents(const MG_State::GLState::ITextureObject& texture, const TextureFormatInfo& formatInfo)` | 11 | gone | 0 | |
| `VkTextureManager::NeedsStorageUsageUpgrade(MG_State::GLState::ITextureObject& texture)` | 11 | gone | 0 | |
| `VkTextureManager::HasPendingTexelUpload(MG_State::GLState::ITextureObject& textureOrView)` | 9 | gone | 0 | |
| `VkTextureManager::StampTextureRecordingUse(MG_State::GLState::ITextureObject* texture)` | 9 | gone | 0 | |
| `VkTextureManager::StampTextureRecordingWrite(MG_State::GLState::ITextureObject* texture)` | 9 | gone | 0 | |
| `VkTextureManager::UpdateTrackedImageLayout(MG_State::GLState::ITextureObject* texture, VkImageLayout newLayout)` | 9 | gone | 0 | |
| `VkTextureManager::AreStorageImageViewFormatsCompatible(VkFormat imageFormat, VkFormat viewFormat)` | 7 | gone | 0 | |
| `IsMultisampleTextureUploadTarget(TextureUploadTarget target)` | 6 | gone | 0 | |
| `ToVkSampledComponentSwizzle(TextureSwizzleParam swizzle, Bool alphaIsImplicitOne)` | 6 | gone | 0 | |
| `VkTextureManager::GetViewRequestedImageFlags(const MG_State::GLState::ITextureObject& storageTexture)` | 5 | gone | 0 | |
| `VkTextureManager::BeginDrawSyncScope()` | 4 | gone | 0 | |
| `VkTextureManager::EndDrawSyncScope()` | 4 | gone | 0 | |
| `VkTextureManager::FindTextureResource(MG_State::GLState::ITextureObject& textureOrView)` | 4 | gone | 0 | |
| `VkTextureManager::HasLiveImage(MG_State::GLState::ITextureObject& textureOrView)` | 4 | gone | 0 | |
| `VkTextureManager::StorageTextureOf(MG_State::GLState::ITextureObject& texture)` | 4 | gone | 0 | |
| `VkTextureManager::WasTextureWrittenThisRecording(MG_State::GLState::ITextureObject& textureOrView)` | 4 | gone | 0 | |
| `VkTextureManager::MarkStorageImageTexture(MG_State::GLState::ITextureObject& texture)` | 3 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureManager.h`
OLD defs: 48, NEW defs: 37, deleted: 12 (gone 12, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class DrawSyncScope` | 9 | gone | 0 | RAII guard that opens/closes a per-draw sync memo window (see above). |
| `class TextureIdentity` | 8 | gone | 0 | |
| `class TextureIdentityHash` | 7 | gone | 0 | |
| `class SyncedTextureMemoEntry` | 6 | gone | 0 | Cross-draw sampled-texture memo: the same few textures (atlas, lightmap) |
| `TextureIdentityHash::operator()(const TextureIdentity& key)` | 5 | gone | 0 | |
| `VkTextureManager::PackComponentSwizzle(const VkComponentMapping& components)` | 5 | gone | 0 | The four component swizzles packed into one value, for the sampled-view cache key. |
| `ToStorageArrayLayer(const MG_State::GLState::ITextureObject* texture, Int glLayer)` | 4 | gone | 0 | |
| `ToStorageMipLevel(const MG_State::GLState::ITextureObject* texture, Int glLevel)` | 4 | gone | 0 | A GL framebuffer attachment's level/layer, and a GL image unit's, are relative to the texture |
| `class DrawSyncedTexture` | 4 | gone | 0 | Per-draw sync memo: the identity plus the resolved resource pointer. The pointer is stable |
| `TextureIdentity::operator==(const TextureIdentity& other)` | 3 | gone | 0 | |
| `DrawSyncScope::DrawSyncScope(VkTextureManager& manager)` | 1 | gone | 0 | |
| `DrawSyncScope::~DrawSyncScope()` | 1 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.cpp`
OLD defs: 78, NEW defs: 53, deleted: 25 (gone 25, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `VkBufferManager::AcquireStreamedSlice(BufferKind kind, const SharedPtr<MG_State::GLState::BufferObject>& bufferObject...` | 85 | gone | 0 | |
| `VkBufferManager::AcquirePersistentMap(MG_State::GLState::BufferObject& bufferObject)` | 56 | gone | 2: Managers.cpp, Managers.h | |
| `VkBufferManager::AcquireResidentSlice(BufferKind kind, const SharedPtr<MG_State::GLState::BufferObject>& bufferObject...` | 49 | gone | 0 | |
| `VkBufferManager::StagedRangeCopy(VkBufferResource& resource, const void* data, SizeT offset, SizeT size)` | 46 | gone | 0 | |
| `VkBufferManager::OnRespecify(MG_State::GLState::BufferObject& bufferObject)` | 43 | gone | 1: VkBufferManager.h | |
| `VkBufferManager::OnSubData(MG_State::GLState::BufferObject& bufferObject, SizeT offset, SizeT size)` | 36 | gone | 0 | |
| `VkBufferManager::OnFlushMappedRange(MG_State::GLState::BufferObject& bufferObject, Range1D range, Flags<BufferMapping...` | 35 | gone | 0 | |
| `VkBufferManager::GetVkBufferUsage(BufferKind kind)` | 27 | gone | 0 | |
| `VkBufferManager::CreateResidentStorage(VkBufferResource& resource, VkDeviceSize size, VkBufferUsageFlags usage, VkMem...` | 26 | gone | 0 | |
| `VkBufferManager::OnResidentSubData(MG_State::GLState::BufferObject& bufferObject, SizeT offset, DataPtr data)` | 19 | gone | 0 | |
| `VkBufferManager::SwapStorageAndUploadAll(VkBufferResource& resource, MG_State::GLState::BufferObject& bufferObject)` | 19 | gone | 0 | |
| `VkBufferManager::OnResourceDestroyed(SharedPtr<MG_State::GLState::BackendBufferResource>&& resource)` | 18 | gone | 0 | |
| `VkBufferManager::ReleaseAllLiveResources()` | 15 | gone | 0 | |
| `VkBufferManager::DeferRelease(VkBufferObject&& buffer)` | 14 | gone | 1: VkBufferManager.h | |
| `VkBufferManager::GetOrCreateResource(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject)` | 14 | gone | 0 | |
| `VkBufferManager::TrackLiveResource(const SharedPtr<VkBufferResource>& resource)` | 13 | gone | 0 | |
| `Ops_OnDestroy(SharedPtr<BackendBufferResource>&& resource)` | 9 | gone | 1: Managers.cpp | |
| `Ops_ReadbackFromGpu(BufferObject& bufferObject)` | 7 | gone | 0 | The CPU is about to read a buffer a shader wrote. Its bytes live in coherent |
| `Ops_AcquirePersistentMap(BufferObject& bufferObject)` | 6 | gone | 1: Managers.cpp | |
| `Ops_FlushMappedRange(BufferObject& bufferObject, Range1D range, Flags<BufferMappingAccessBit> appAccess)` | 5 | gone | 0 | |
| `Ops_ResidentSubData(BufferObject& bufferObject, SizeT offset, DataPtr data)` | 5 | gone | 0 | |
| `Ops_Respecify(BufferObject& bufferObject)` | 5 | gone | 0 | |
| `Ops_SubData(BufferObject& bufferObject, SizeT offset, SizeT size)` | 5 | gone | 0 | |
| `VkBufferManager::IsResourceBusy(const VkBufferResource& resource)` | 3 | gone | 1: VkBufferManager.h | |
| `VkBufferManager::ResourceOf(MG_State::GLState::BufferObject& bufferObject)` | 3 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferManager.h`
OLD defs: 13, NEW defs: 13, deleted: 3 (gone 3, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class VkBufferResource` | 46 | gone | 2: BufferArena.cpp, VkBufferManager.cpp | The DirectVulkan storage behind one frontend buffer (pipe_resource analogue). |
| `VkBufferManager::BumpSliceEpoch(VkBufferResource& resource)` | 1 | gone | 1: VkBufferManager.cpp | See VkBufferResource::sliceEpoch. |
| `VkBufferManager::GetSliceEpochCounter()` | 1 | gone | 0 | Highest value handed to any VkBufferResource::sliceEpoch. Unchanged since a |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp`
OLD defs: 14, NEW defs: 10, deleted: 7 (gone 7, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `VertexInputStateFactory::GetOrCreateVertexInputState(const MG_State::GLState::VertexArrayObject& vao, HashType hash)` | 218 | gone | 0 | |
| `VertexInputStateFactory::ComputeHash(const MG_State::GLState::VertexArrayObject& vao)` | 72 | gone | 5: PipelineFactory.cpp, PipelineFactory.h, ... | |
| `VertexInputStateFactory::GetOrCreateVertexInputState(const MG_State::GLState::VertexArrayObject& vao)` | 32 | gone | 0 | |
| `VertexInputStateFactory::OnFrameBoundary()` | 30 | gone | 8: PipelineFactory.cpp, PipelineFactory.h, ... | |
| `VertexInputStateFactory::MemosFor(const MG_State::GLState::VertexArrayObject& vao)` | 18 | gone | 0 | |
| `VertexInputStateFactory::GetOrComputeHash(const MG_State::GLState::VertexArrayObject& vao)` | 15 | gone | 0 | |
| `VertexInputStateFactory::TryGetMemoizedHash(const MG_State::GLState::VertexArrayObject& vao, Uint64& outHash)` | 9 | gone | 0 | |
## `MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.h`
OLD defs: 5, NEW defs: 4, deleted: 3 (gone 2, params differ 1).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `class VaoBackendMemos` | 11 | gone | 0 | ---- P2 D12.5: the backend's memos, off the frontend VAO and into the backend ---- |
| `VertexInputStateFactory::PackVertexInputAuxMasks(Uint32 unsupportedAttribMask, Uint32 attributeLocationMask)` | 3 | gone | 0 | The VAO aux-memo payload GetOrCreateVertexInputState(vao) stamps: aux0 is the |
| `VertexInputStateFactory::VertexInputStateFactory(const VulkanRendererConfig& config, VkPhysicalDevice physicalDevice,...` | 1 | params differ | 6: BackendObject.h, ProgramFactory.cpp, ... | The mint is the RENDERER's (MagmaPipeIdentityTables), not a process-global and not |
## `MobileGL/MG_Backend/DirectGLES/DirectGLES.cpp`
OLD defs: 510, NEW defs: 458, deleted: 53 (gone 50, params differ 3).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void* pixels)` | 417 | gone | 6: BackendObject.h, Managers.h, ... | |
| `ScopedDetachedTextureFramebufferAttachments::ScopedDetachedTextureFramebufferAttachments(const SharedPtr<MG_State::GL...` | 166 | params differ | 2: Managers.cpp, Managers.h | |
| `BlitLayeredDestinationAspects(const SharedPtr<MG_State::GLState::FramebufferObject>& readFramebuffer, const SharedPtr...` | 136 | params differ | 0 | ---- glBlitFramebuffer onto a non-zero array layer ------------------------------------- |
| `SyncCurrentProgram(const SharedPtr<MG_State::GLState::ProgramObject>& currentProgram)` | 116 | gone | 2: Managers.cpp, Utils.h | |
| `GetTexImageViaShadowConversion(MG_State::GLState::TextureObjectMipmap* textureMipmapObject, TextureUploadTarget uploa...` | 100 | gone | 1: WireTextureReadback.inc | GetTexImage fallback for internal formats the ES driver cannot attach to a framebuffer |
| `SyncVaoAttributeBuffersByHandle(const SharedPtr<MG_State::GLState::VertexArrayObject>& currentVAOObject, VertexArrayI...` | 86 | gone | 0 | The handle arm of the resolved-draw-buffers memo (D-G4). Two substitutions and |
| `SyncTextureObjectToBackend(const SharedPtr<MG_State::GLState::ITextureObject>& textureObject, Bool imageBindableStora...` | 80 | gone | 3: Managers.cpp, Managers.h, ... | |
| `SyncReadFramebufferTextureAttachments(const DrawTextureSyncKeys& keys, const MG_State::GLState::FramebufferObject* dr...` | 74 | gone | 0 | |
| `GenerateThreeChannelFloatMipmapOnCpu(const SharedPtr<MG_State::GLState::ITextureObject>& texture)` | 69 | gone | 1: Managers.cpp | ES has no colour-renderable three-channel float format, and its glGenerateMipmap |
| `SamplerUniformTextureTarget(GLenum uniformType)` | 59 | gone | 0 | Frontend texture target a GLSL sampler uniform samples from. Only used to find |
| `SyncClientSideVertexArraysForFetch(Uint8 indexSize, Uint32 elementStart, GLsizei count, GLsizei instanceCount, GLint ...` | 53 | gone | 0 | |
| `GenerateMipmapThroughViewWindowForTexture(const SharedPtr<MG_State::GLState::ITextureObject>& texture)` | 47 | gone | 0 | The monolith twin of the record arm's view-window rule. Same window, read off the frontend |
| `SyncBufferBindingPoints(BufferTarget target, GLenum glTarget)` | 45 | gone | 1: Managers.cpp | |
| `ResolveUnitSamplerBackend(Int unit, const SharedPtr<MG_State::GLState::SamplerObject>& samplerObject)` | 44 | gone | 0 | |
| `BlitNamedFramebuffer(const SharedPtr<MG_State::GLState::FramebufferObject>& readFramebuffer, const SharedPtr<MG_State...` | 43 | gone | 4: BackendObject.h, Managers.h, ... | |
| `EnsureGenerateMipmapStorageAllocated(MG_State::GLState::TextureObjectMipmap& texture, TextureUploadTarget uploadTarge...` | 38 | gone | 0 | |
| `SyncTransformFeedbackBindingPoints(SizeT bufferCount)` | 33 | gone | 0 | The capture points the CAPTURE PROGRAM uses, and nothing else. |
| `SyncAndBindFramebufferObject(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, FramebufferTarget ta...` | 32 | gone | 0 | |
| `MarkShaderStorageBuffersGpuWritten()` | 31 | gone | 0 | Called once the storage-buffer points are bound and the draw/dispatch is about to |
| `GenerateDepthTexture2DMipmap(const SharedPtr<MG_State::GLState::ITextureObject>& texture, const SharedPtr<TextureImpl...` | 28 | gone | 0 | |
| `GetBackendProgramId(GLuint program)` | 28 | gone | 1: Managers.h | P5f (fr): no declaration, dispatch-table slot or caller remains for this legacy |
| `GenerateColorTexture2DMipmap(const SharedPtr<MG_State::GLState::ITextureObject>& texture, const SharedPtr<TextureImpl...` | 27 | gone | 0 | |
| `SyncImageTextureBinding(Uint unit)` | 26 | params differ | 1: Utils.h | The pre-handle form: the MONOLITH one, and now purely frontend. P4a e3 read the four |
| `ResolveBufferBindingSubsystemArm()` | 23 | gone | 0 | ---- P5e (sb, MG_Remote/CONTRACT-P5E.md §5.6): THE INDEXED BINDING POINTS BY RECORD -- |
| `ClearNamedFramebufferfv(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum buffer, GLint draw...` | 18 | gone | 1: BackendObject.h | |
| `ClearNamedFramebufferiv(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum buffer, GLint draw...` | 18 | gone | 1: BackendObject.h | |
| `ClearNamedFramebufferuiv(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum buffer, GLint dra...` | 18 | gone | 1: BackendObject.h | |
| `ResolveVaoTwin(const SharedPtr<MG_State::GLState::VertexArrayObject>& vao)` | 18 | gone | 2: Managers.cpp, Managers.h | Resolve-or-create the VAO's backend twin, once per draw: PrepareForDraw passes |
| `SyncBoundBuffer(BufferTarget target, GLenum glTarget)` | 17 | gone | 0 | |
| `ClearNamedFramebufferfi(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum buffer, GLint draw...` | 15 | gone | 1: BackendObject.h | |
| `RefuseElementArrayBufferFromTheFrontend(const char* entry)` | 15 | gone | 1: MultiDraw.cpp | MONOLITH GLUE, AND LOUD ABOUT IT AS OF P5e (vi). CONTRACT-P5E §5.1 makes the restart |
| `SyncRenderbufferObjectToBackend(const SharedPtr<MG_State::GLState::RenderbufferObject>& renderbufferObject)` | 15 | gone | 0 | The renderbuffer twin of TextureImpl::SyncTextureObjectToBackend: the same |
| `TextureLayerCount(const SharedPtr<MG_State::GLState::ITextureObject>& texture)` | 15 | gone | 0 | Where a target keeps its LAYER count, the state-side twin of the wire descriptor's |
| `EnsureGenerateMipmapStorageAllocated(const SharedPtr<MG_State::GLState::ITextureObject>& texture)` | 14 | gone | 0 | |
| `IsNativeGetTexImagePair(GLenum format, GLenum type)` | 14 | gone | 0 | Combinations the ES driver has always handled directly for GetTexImage; everything else that maps |
| `ResolveGlobalConstantsRecord(const MG_State::GLState::ProgramObject* program)` | 14 | gone | 0 | THE MONOLITH-GLUE HALF (ruling 1 / ID-81), unchanged in what it does: resolve the |
| `IsWidenedNamedDrawBuffer(const SharedPtr<MG_State::GLState::FramebufferObject>& framebuffer, GLenum buffer, GLint dra...` | 13 | gone | 0 | The same question for an explicitly named framebuffer (the DSA clears), which is NOT |
| `SyncCurrentVAO(const SharedPtr<MG_State::GLState::VertexArrayObject>& currentVAOObject, BackendVertexArrayObject* vao...` | 13 | gone | 1: Managers.cpp | |
| `ComputeFullMipmapLevelCount(const IntVec3& baseTexelSize)` | 11 | gone | 0 | |
| `ReadClientSnapshotBytes(void* user, MG_Pipe::MGPipeClientBufferKind kind, Uint64 offset, SizeT size, void* destination)` | 10 | gone | 0 | |
| `VaoHasEnabledClientArray(const MG_State::GLState::VertexArrayObject& vao, Bool* vertexRate = nullptr)` | 10 | gone | 0 | The draw's own fetch, spelled as the range record spells it: `indexSize` 0 is arrays, |
| `BoundElementArrayBuffer()` | 7 | gone | 0 | |
| `BoundElementArrayBufferId()` | 7 | gone | 0 | The GL name PrepareForDraw left on GL_ELEMENT_ARRAY_BUFFER, i.e. what the |
| `ComputeMipmapTexelSize(const IntVec3& baseTexelSize, Uint relativeLevel)` | 7 | gone | 0 | |
| `DrawProgramFromRecords()` | 7 | gone | 0 | P5e (pa), CONTRACT-P5E §5.5 / §5.8, ruling ID-81: "IS THERE ANYBODY LEFT WHO NEEDS THE |
| `MultiDrawElements(GLenum mode, const GLsizei* count, GLenum type, const GLvoid* const* indices, GLsizei drawcount)` | 6 | gone | 5: BackendObject.h, DirectVulkan.cpp, ... | Both glMultiDrawElements entry points are emulated - ES has neither in core - by the |
| `PairingsIntact(const Vector<UnitTextureSyncEntry>& list)` | 6 | gone | 0 | True while every entry's borrowed slot still holds the texture the entry was paired |
| `StampSyncedFBO(FramebufferTarget target, Uint16 slotVersion, Uint16 objectVersion, MG_State::GLState::FramebufferObje...` | 6 | gone | 1: Managers.h | Record that `target` now reflects this exact (binding, object, revision) triple. |
| `BindingPointsComeFromRecords() (x2)` | 4 | gone | 0 | FILE-LOCAL AND INLINE-MEMOISED, for EsprytSlotTablesEnabled's reason: this is |
| `IsWritableImageBufferTexture(const MG_State::GLState::ImageTextureBinding& binding)` | 4 | gone | 0 | |
| `UnitTexturesByHandle()` | 4 | gone | 0 | P5e (tx2), CONTRACT-P5E §5.8 / ruling 1: THE ARM SELECTOR for every by-handle site in |
| `FramebufferRecordArmIsMandatory()` | 3 | gone | 0 | P5e (fb, CONTRACT-P5E.md §5.4 and §0's rule F). THE DECLINE BECOMES THE DETECTOR. |
| `AreOcclusionQueriesSupported()` | 1 | gone | 0 | |
## `MobileGL/MG_Backend/DirectGLES/Managers.cpp`
OLD defs: 398, NEW defs: 354, deleted: 49 (gone 48, params differ 1).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `BackendFramebufferObject::SyncToBackend(const SharedPtr<MG_State::GLState::FramebufferObject>& stateFBOObject, Frameb...` | 383 | gone | 2: DirectGLES.cpp, Managers.h | |
| `BackendTextureObject::RequireImageBindableStorage(const SharedPtr<MG_State::GLState::ITextureObject>& stateTextureObj...` | 158 | gone | 1: Managers.h | |
| `EnsureBufferResource(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject)` | 137 | gone | 3: DirectGLES.cpp, Managers.h, ... | |
| `OnFrontendStateObjectDestroyed(MG_Pipe::MGPipeKind kind, Uint64 lifetimeId)` | 119 | params differ | 0 | P2 step e2's dispatcher: the frontend told us an object died, so free its slot and |
| `BackendRenderbufferObject::SyncToBackend(const SharedPtr<MG_State::GLState::RenderbufferObject>& stateRBOObject)` | 117 | gone | 2: DirectGLES.cpp, Managers.h | |
| `BackendTextureObject::SyncTextureViewToBackend(const SharedPtr<MG_State::GLState::ITextureObject>& stateTextureObject)` | 91 | gone | 1: BackendObject_DirectGLES.cpp | |
| `SyncAttachmentObject(GLenum glFBOTarget, const MG_State::GLState::FramebufferAttachmentObject& attachmentObject, GLen...` | 86 | gone | 2: BackendObject_DirectGLES.cpp, DirectGLES.cpp | |
| `BackendVertexArrayObject::SyncClientSideAttributesForDraw(const SharedPtr<MG_State::GLState::VertexArrayObject>& stat...` | 83 | gone | 1: Managers.h | THE CLIENT-ARRAY UPLOAD FOR A DRAW WHOSE FETCHED ELEMENTS (first, count) DOES NOT |
| `Ops_AcquirePersistentMap(BufferObject& bufferObject)` | 78 | gone | 0 | Zero-copy persistent map: back the buffer with real immutable, |
| `BackendFramebufferObject::SyncReadBufferToBackend(const SharedPtr<MG_State::GLState::FramebufferObject>& stateFBOObject)` | 63 | gone | 2: DirectGLES.cpp, Managers.h | |
| `Ops_FlushMappedRange(BufferObject& bufferObject, Range1D range, Flags<BufferMappingAccessBit> appAccess)` | 63 | gone | 0 | |
| `Ops_Respecify(BufferObject& bufferObject)` | 55 | gone | 0 | |
| `ResolveVertexInputSubsystemArm()` | 47 | gone | 1: Managers.h | |
| `BackendProgramObjectImpl::SyncToBackend(const SharedPtr<MG_State::GLState::ProgramObject>& stateProgramObject)` | 42 | gone | 2: DirectGLES.cpp, Managers.h | ---- the two public heads (P5e pg) ----------------------------------------------- |
| `Ops_ReadbackFromGpu(BufferObject& bufferObject)` | 37 | gone | 0 | A shader wrote this buffer through a storage/atomic-counter binding, so the ES |
| `Ops_SubData(BufferObject& bufferObject, SizeT offset, SizeT size)` | 34 | gone | 0 | |
| `MarkBufferGpuWritten(const SharedPtr<MG_State::GLState::BufferObject>& bufferObject)` | 32 | gone | 2: DirectGLES.cpp, Managers.h | |
| `SyncZeroStrideAttribute(Uint attribIndex, const MG_State::GLState::VertexAttribute& attrib)` | 31 | gone | 0 | Declares one attribute through the ES binding-point API, the only spelling that can |
| `HandleOfBuffer(const MG_State::GLState::BufferObject* bufferObject)` | 29 | gone | 1: DirectGLES.cpp | |
| `IsBufferDrawClean(const MG_State::GLState::BufferObject* frontend, const GLESBufferResource* resource)` | 25 | gone | 2: DirectGLES.cpp, Managers.h | |
| `ProgramArchiveSource::FromFrontend(const MG_State::GLState::ProgramObject& program)` | 24 | gone | 0 | |
| `GetOrCreateSamplerViewForHandle(MG_Pipe::MGPipeHandle view)` | 23 | gone | 0 | |
| `ComputeShaderStorageBlockBindingSignatureOf(const MG_State::GLState::ProgramObject& program)` | 22 | gone | 0 | The COMPUTATION, still here and still the only one on this side: FromFrontend seeds a |
| `BackendVertexArrayObject::SyncToBackend(const SharedPtr<MG_State::GLState::VertexArrayObject>& stateVAOObject)` | 21 | gone | 2: DirectGLES.cpp, Managers.h | |
| `ResolveResourceSubsystemArm()` | 21 | gone | 0 | |
| `BindAttributeBuffer(const MG_State::GLState::VertexAttribute& attrib)` | 16 | gone | 0 | |
| `ComputeAlphaWidenedDrawBufferMask(const MG_State::GLState::FramebufferObject& fbo)` | 16 | gone | 0 | |
| `IsSnormFallbackAttachment(const MG_State::GLState::FramebufferAttachmentObject& attachmentObject)` | 14 | gone | 0 | |
| `IsUnormFallbackAttachment(const MG_State::GLState::FramebufferAttachmentObject& attachmentObject)` | 14 | gone | 0 | |
| `NoteDriverSideTextureWrite(const SharedPtr<MG_State::GLState::ITextureObject>& textureObject)` | 14 | gone | 1: Managers.h | |
| `IsAlphaWidenedColorAttachment(const MG_State::GLState::FramebufferAttachmentObject& attachmentObject)` | 13 | gone | 0 | |
| `GetReadColorAttachment()` | 12 | gone | 0 | The colour attachment glReadPixels/glGetTexImage would read from, or nullptr when the |
| `HandleOfSamplerViewForTexture(const MG_State::GLState::ITextureObject* textureObject)` | 12 | gone | 0 | |
| `IsIntegerColorAttachment(const MG_State::GLState::FramebufferAttachmentObject& attachmentObject)` | 11 | gone | 0 | |
| `Ops_ResidentSubData(BufferObject& bufferObject, SizeT offset, DataPtr data)` | 9 | gone | 0 | App bytes for an ADOPTED store: queue them untouched-by-the-mapping; the |
| `EnsureNoColorAttachment(ScratchFramebuffer& fb, GLenum fbTarget)` | 7 | gone | 0 | |
| `EnsureNoDepthAttachment(ScratchFramebuffer& fb, GLenum fbTarget)` | 7 | gone | 0 | |
| `MGPipeP5eSeamNotLanded(const char* name, const char* owner, MG_Pipe::MGPipeHandle handle)` | 7 | gone | 0 | |
| `Ops_AcquirePersistentMapTracked(BufferObject& bufferObject)` | 7 | gone | 0 | |
| `FramebuffersAttachingTexture(MG_Pipe::MGPipeHandle texture)` | 6 | gone | 0 | BY VALUE, and deliberately: the caller re-binds framebuffers while it walks the |
| `PushedFramebufferIsBoundTo(FramebufferTarget target, MG_Pipe::MGPipeHandle fbo)` | 6 | gone | 0 | |
| `GetBufferResource(MG_State::GLState::BufferObject* bufferObject)` | 4 | gone | 0 | |
| `Ops_FlushMappedRangeTracked(BufferObject& bufferObject, Range1D range, Flags<BufferMappingAccessBit> appAccess)` | 4 | gone | 0 | |
| `Ops_OnDestroyTracked(SharedPtr<BackendBufferResource>&& resource)` | 4 | gone | 0 | |
| `Ops_ReadbackFromGpuTracked(BufferObject& bufferObject)` | 4 | gone | 0 | |
| `Ops_ResidentSubDataTracked(BufferObject& bufferObject, SizeT offset, DataPtr data)` | 4 | gone | 0 | |
| `Ops_RespecifyTracked(BufferObject& bufferObject)` | 4 | gone | 0 | Epoch-tracking wrappers: every op bumps the buffer-mutation epoch AFTER |
| `Ops_SubDataTracked(BufferObject& bufferObject, SizeT offset, SizeT size)` | 4 | gone | 0 | |
| `ResourceOf(BufferObject& bufferObject)` | 3 | gone | 0 | |
## `MobileGL/MG_Backend/DirectGLES/Managers.h`
OLD defs: 138, NEW defs: 124, deleted: 14 (gone 14, params differ 0).
| name | body lines | status | HEAD elsewhere (token) | comment |
|---|---|---|---|---|
| `StateBackendObjectRegistry::GetOrCreate(const StatePtr& stateObj)` | 50 | gone | 4: DirectGLES.cpp, Managers.cpp, ... | |
| `StateBackendObjectRegistry::CollectGarbage()` | 21 | gone | 3: VkTextureManager.cpp, VkTextureManager.h, ... | |
| `StateBackendObjectRegistry::Find(StateObject* stateObj) (x2)` | 19 | gone | 5: DirectGLES.cpp, Managers.cpp, ... | Null when no live state object owns this key. |
| `VertexInputReadsRecords()` | 8 | gone | 2: DirectGLES.cpp, MultiDraw.cpp | P5e (vi), CONTRACT-P5E §5.1 + §5.8 (ruling 1 / ID-81): THE ARM SELECTOR for this |
| `StateBackendObjectRegistry::CollectGarbageNow()` | 6 | gone | 0 | Pre-P2 API, kept for the legacy arm. On the handle arm there is nothing it could |
| `StateBackendObjectRegistry::DestroyByLifetimeId(Uint64 lifetimeId)` | 6 | gone | 0 | P2 step e2. STATIC, because a death notice is about an object and not about a |
| `StateBackendObjectRegistry::HandleOf(const StateObject* stateObj)` | 6 | gone | 3: DirectGLES.cpp, Managers.cpp, ... | The {slot, gen} this object's twin is keyed on, or the null handle. This is what a |
| `StateBackendObjectRegistry::StateForHandle(MG_Pipe::MGPipeHandle handle)` | 6 | gone | 1: Managers.cpp | |
| `StateBackendObjectRegistry::begin() (x2)` | 6 | gone | 35: BackendObject_DirectGLES.cpp, DirectGLES.cpp, ... | |
| `StateBackendObjectRegistry::CollectGarbageIfNeeded()` | 5 | gone | 0 | The seven DirectGLES.cpp call sites drive the LEGACY arm and nothing else. On the |
| `StateBackendObjectRegistry::NoteStateForHandle(MG_Pipe::MGPipeHandle handle, const StatePtr& stateObj)` | 5 | gone | 1: DirectGLES.cpp | P5c (hd): the two halves of SlotTables.h's state note, forwarded. A caller holding |
| `ResourceSubsystemEnabled()` | 4 | gone | 0 | INLINE for the reason SlotTables.h spells out at EsprytSlotTablesEnabled: both are |
| `TextureResourceSubsystemEnabled()` | 4 | gone | 2: DirectGLES.cpp, Managers.cpp | |
| `VertexInputSubsystemEnabled()` | 4 | gone | 0 | |
## git log 88a11b81..HEAD -- listed paths (first 80 of 47)
```text
ec973fba [Fix] (Magma): a hang-watch marker slot is reused once its submission's fence completed, not once the host read its event.
553eb86d [Perf] (Magma): texture level uploads stop waiting for the GPU to drain; queue order and the upload barrier already order them (rd12 monolith 70.4 -> 83.4, openra 367 -> 745 fps).
785df78d [Perf] (P14): one UBO-ring lookup per draw, split residual copy/stamp loops, one context read for GPU-write marks, Magma slice stamps from the owner's counter (rd12 monolith Espryt 88.8 -> 90.3, Magma 69.8 -> 70.3 fps).
81bdfb1f [Perf] (Espryt): twin lookups skip the bucket SharedPtr copy and the native-context state is one thread-local block (rd12 monolith 81.0 -> 84.1 fps).
032dcd24 [Perf] (Magma): the wire vertex-input layout is kept on its vertex-elements record and buffer handles resolve through a slot-indexed front.
0158a115 [Perf] (Magma): a wire draw that provably continues the open pass skips the attachment resolve and pass-key walk (rd12 monolith 63.2 -> 65.5, inproc 89.8 -> 92.6 fps).
5788a602 [Perf] (Magma): a wire draw whose image descriptors cannot have moved rebinds its descriptor set with fresh buffer offsets (rd12 monolith 60.5 -> 63.3, inproc 83.7 -> 89.7 fps).
afcf8d96 [Perf] (Espryt): a VAO twin adopts an unchanged buffer set and element buffer instead of re-emitting them (rd12 monolith 75.2 -> 80.5 fps).
e6281b26 [Perf] (Magma): wire texture and buffer lookups get direct-mapped fronts and a continued pass stops re-marking its attachments (rd12 monolith 59.6 -> 60.5 fps).
4ef9705e [Perf] (Magma): wire draws memoise each unit's sampler and skip rebinding an unchanged pipeline, vertex or index binding (rd12 monolith 57.9 -> 60.3 fps).
b556ec31 [Perf] (Espryt): a clean framebuffer attachment skips its per-draw resync behind the unit list's gate (rd12 monolith 74.5 -> 77.0 fps).
a9108e1a [Perf] (Espryt): a VAO twin whose buffer set alone moved re-points enabled arrays without the 32-slot enable walk (rd12 monolith 70.3 -> 73.5 fps).
267211e8 [Perf] (Magma): wire draws stop rehashing program SPIR-V and stop allocating per draw (rd12 monolith 45.7 -> 56.7 fps).
de6ab167 [Refactor] (P13): the legacy BufferBackendOps table, Magma's never-populated texture/render-pass/renderbuffer caches and VkClearManager go, and the buffer mock tests drive the resource op table instead (ratchet 36 -> 27).
fa77b187 [Refactor] (P13): Espryt's frontend-keyed slot-table entries and the apply-thread refusals go, death notices release twins by handle, and the link ratchet refuses any '# P13' line (49 -> 36 symbols).
922507f8 [Refactor] (P13 W6f): Magma's pipeline build reads the draw framebuffer record only, and the frontend texture sync behind it goes; link ratchet 58 -> 49.
dab827d5 [Refactor] (P13 W6e): the backends' frontend-framebuffer clear, blit and readback entries go - the verb port owns those slots in every mode - with Magma's frontend render-pass, pending-clear and renderbuffer halves.
8bc39c79 [Test] (P13 W6d): the unmigrated-emulation list is empty, the dead storage-view format case goes, and Espryt's bring-up check is the colour-attachment cap alone.
8abae647 [Refactor] (P13 W6d): Espryt's family arm predicates fold to the record arm, checked once at capability bring-up, and the frontend-arm walks they selected go.
dc1e95b4 [Refactor] (P13 W6c): Magma's frontend arm goes - the frontend program source, sampled-set walk, placeholder textures, VAO draw memos, identity tables and fast path - leaving the record arm.
e0113503 [Refactor] (P13 W6b): the frontend-arm code after each record-arm return goes, and the transform-feedback state keeps one role.
742d43ae [Refactor] (P13 W6b): the data-arm predicate folds out of every backend branch; frontend-arm unit cases go, three adapted, and two GL sampling rules move to an integration scenario.
7fb18840 [Refactor] (P13 W5 S8): MOBILEGL_BUILD_RECORD_ARM is folded away - the record arm is unconditional - and retired_switches keeps it from coming back.
a0b9ca07 [Fix] (P13 W5 S7): Magma's T0 import and its self-test stay transport-only inside the record arm.
a37212ea [Fix] (P13 W5 S7): Espryt's T0 re-import after a context loss stays transport-only inside the record arm's twin re-arm.
1cd35d39 [Refactor] (P13 W5 S7): Magma's wire-object collection, wire-store teardown, depth-resolve entry point and the fast-rebind destroy epoch follow the record-arm guard.
557975bf [Refactor] (P13 W5 S7): the record verbs' verb-state stamps, the record-reading draw and sampler passes and the image-bindable re-mint follow the record-arm guard.
aa5c12b0 [Fix] (P13 W5 S7): Espryt's shared-image arm in the storage sync stays on the transport guard inside the record arm.
7ac3ce03 [Fix] (P13 W5 S7): Espryt's shared-image sync stays on the transport guard.
956e3847 [Refactor] (P13 W5 S7): the record arm's remaining transport-guarded blocks (XFB capture landing, staged-texture follows, view-window mips, tracker membership, unit-window checks) follow the record-arm guard.
4ec65e80 [Fix] (P13 W5 S7): Espryt's copy-image store follow and its driver-write mark build with the record arm.
f4be8c38 [Style] (P13 W5): VertexInputStateFactory.cpp includes its own header first.
7f194a85 [Refactor] (P13 W5 S3): the apply side's backend comes through MG_Backend's ApplyRoleBackend hook, which ServerLoop installs.
bb45648c [Refactor] (P13 W5 S3): Magma's wire texture and vertex-input builders and the buffer shadow size follow the record-arm guard.
17e36589 [Refactor] (P13 W5 S3): the latch twin and Magma's shared-image binding take their guards; the dual-block diagnostics stay transport.
b13af729 [Refactor] (P13 W5 S5): the record arm's three knobs move from IpcTable to RecordArmTable, which every record-arm build parses.
cb81610b [Refactor] (P13 W5 S3): the record arm's definitions and its depth-resolve probe source follow the record-arm guard.
1956d6cd [Refactor] (P13 W5 S3): transport-only hooks get no-op twins where the record arm calls them, and their guards return to the transport.
c879776a [Refactor] (P13 W5 S3): Espryt's shared-image checks stay on the transport guard.
8a2ddc81 [Refactor] (P13 W5 S3): Magma's funnels, the texture ops and the staged-texture macros follow the record-arm guard; shared images stay transport.
d00d5c94 [Refactor] (P13 W5 S3): the record stores' includes and the slot tables' refusals follow the record-arm guard.
b26167a0 [Refactor] (P13 W5 S3): Espryt's sampler-view refusal latches through the record seam.
73a185f6 [Refactor] (P13 W5 S4): the staged stores move to MG_Backend/Record as MG_Record and die through the record fail seam.
e544121e [Refactor] (P13 W5 S3): record-arm declarations, role-guard stubs and the T0 split in the backends.
22739a03 [Refactor] (P13 W5 S2): MG_Backend/DirectVulkan's record-arm guards name MOBILEGL_BUILD_RECORD_ARM.
036d1ac3 [Refactor] (P13 W5 S2): MG_Backend/DirectGLES's record-arm guards name MOBILEGL_BUILD_RECORD_ARM.
cfd6c873 [Fix] (P13 W4b): the aliasing texture store follows glCopyImageSubData into a server-owned destination.
```
## Method notes
- Definitions: function and class/struct bodies found by regex on comment- and literal-stripped text, then brace matching. Declarations without a body are not counted.
- Header inline members are qualified by their innermost enclosing class. Out-of-class definitions keep their own qualified name.
- Match key = qualified name + whitespace-stripped parameter list. Status 'params differ' means the qualified name is still defined in NEW with a different parameter list.
- Body lines = brace-matched span from the opening brace line to the closing brace line, inclusive.
- Comment = topmost line of the contiguous comment block directly above the definition (a template line is skipped), truncated to 160 chars.
- 'HEAD elsewhere (token)' = number of other MobileGL/MG_Backend source files at HEAD containing the bare identifier as a token (not the same file). Approximate; common names will over-match. Indicates possible relocation, not proof.
- Skipped: unqualified names shorter than 4 characters and control keywords (if/for/while/switch/return/catch/...).
- Duplicate keys (overloads with identical parameter text) are merged and shown with a count.
+813
View File
@@ -0,0 +1,813 @@
# P15 plan: the FCL gap first, then a draw-delta fast path
Written 2026-10-07 on `feat/disaggregated` at `a0f4aa83`. Device: Lenovo Y700 (Adreno 750,
`HA27Q3LQ`), rooted, clocks pinned. Baseline: `dev` at `08124c99` (the pull monolith).
This is the plan, plus the measurements it rests on (section 2). Nothing here is implemented yet.
## 0. Summary
1. **FCL's "unexplained ~3 ms/frame wait" is display pacing, and dev has it too.**
- On every build, the presenting thread spends about 2.0 ms sleeping and 0.4 ms runnable per
frame. That holds for dev and feat, on both backends.
- The sleep is in `queueBuffer`. There the render thread waits for the `BLASTBufferQueue`
mutex, which the app's binder thread holds across a synchronous `setTransactionState`. That
call is phase-locked to the 165 Hz display.
- The whole FCL fps gap vs dev is presenting-thread CPU:
- Magma: 3.25 vs 1.85 ms/frame;
- Espryt: 2.7 vs 2.05 ms/frame.
2. **FCL's Magma CPU gap is mostly non-draw verbs on the wire arm.** These are mechanisms dev's
frontend arm had and the wire arm lost:
- every `glClear` builds and destroys its own image view, render pass and framebuffer;
- every blit creates a descriptor pool;
- `glBufferSubData` takes a slow staged path;
- the retired-object garbage collection and command-buffer reset grow to match.
This explains about 1.0 of the 1.4 ms. rd12 Magma pays the clear and churn part too, about
0.45 ms/frame.
3. **The (VAO, program) draw-packet table as sketched would never hit on rd12.**
- rd12 draws 1471 times a frame, with 1466 distinct (VAO, program) pairs per frame. A pair
repeats only across frames, and something outside the whitelist always runs between frames.
So a packet stamped with a context epoch hits 0.0 % of the time.
- What does hold on rd12 is the **draw-to-draw delta**: before 99.0 % of draws, the only calls
since the previous draw are `glBindVertexArray` and a float uniform.
- P15 therefore builds a draw-delta fast path:
- "nothing context-global moved since the last draw", checked once per draw against two
epochs (a client one and a server one);
- per-VAO and per-program slices that persist across frames.
It does not build a pair-keyed packet table.
4. **Swap interval 0 does not unlimit the frame rate today, and interval ≥1 vsyncs correctly.**
- MC 1.21.5 in FCL runs with vsync off (interval 0) and maxFps 260, which is MC's "unlimited".
- At interval 1, every build locks to 165.0 fps.
- At interval 0, every build is still partly display-coupled: the GL thread blocks ~2 ms/frame
in `queueBuffer`. That includes dev and the MobileGlues plugin.
- The cause is on the platform side. The app's own buffer-queue binder thread holds the queue
mutex across a SurfaceFlinger call, and SurfaceFlinger in turn waits synchronously on the
composer HAL.
- Stage P moves the present off the GL thread to a present worker, so interval 0 is CPU-bound
and interval ≥1 is still paced to the display (section 2.4).
Stage order:
- 0: parity audit + wire non-draw fast path;
- 0b: an FCL 1.21.5 trace fixture;
- 1: client draw-delta prototype;
- 2: per-VAO / per-program slices;
- 3: applier + backend draw-delta;
- 4: split arms, verify, default-on;
- P (swap-interval-correct presentation): **not needed for the target; dropped unless the user asks**
(2026-10-08). MobileGlues pays the same ~2 ms present wait, so matching it does not need P.
Decisions taken with the user (2026-10-08):
- Presenting-thread CPU ms/frame is the primary FCL metric, with fps beside it.
- Swap interval must be honoured properly. This is stage P.
- minSdk / native TLS is the user's own change; P15 does not touch it.
- The probe tools are committed under `tools/device_bench/disagg/`.
- No Espryt deferred-clear port: its clear and blit costs match dev's.
## 0.1 Target and stopping rule (user, 2026-10-08)
**Target:** "We only need to match MobileGlues' performance."
**Success criterion:** both backends reach the MobileGlues plugin (`com.fcl.plugin.mobileglues`)
in FCL MC 1.21.5, on the same pinned device, same world, same swap interval. Its presenting-thread
CPU there is ~1.7 ms/frame (~248 fps) at interval 0 and ~1.9 ms/frame at interval 1.
| build | interval 0 CPU ms/frame | needed |
|---|---|---|
| feat Magma | 3.12 | −1.4 |
| feat Espryt | 2.73 | −1.0 |
| dev Magma | 1.76 | (reference) |
| dev Espryt | 2.14 | (reference) |
Espryt has to go below dev here.
**Success criterion, revised by the user after the S0 milestone (2026-10-08): two levels on CPU,
MobileGlues on GPU.**
- **Floor (must meet): match dev** - the CPU bullet below.
- **Goal (design intent):**
- **Monolith:** presenting-thread CPU on par with or below MobileGlues. MobileGL's own overhead
is paid back by driver work it removes: the frontend tracks state, so the host driver
receives fewer calls, none of them redundant. Measure host-driver calls per frame and the
redundant share (same value re-set, already-bound object re-bound, unchanged uniform data) on
both backends, against MobileGlues' pass-through.
- **Inproc:** clearly faster than MobileGlues, because the GL thread only records and the apply
thread drives the backend and driver. Measure FCL inproc on both backends against MobileGlues,
with the time of both threads. If inproc is not faster, find out whether the cause is the GL
thread's own cost, the handoff/wake-up, or the apply thread being the bottleneck.
- **CPU-bound scenes:** at or below dev's monolith presenting-thread CPU in FCL MC 1.21.5 vanilla
(Magma <= 1.79, Espryt <= 2.14 ms/frame at interval 0), with dev measured in the same session and
~5 % noise tolerance.
- **GPU-bound shaderpack scenes (Iris + BSL):** within ~5 % of MobileGlues fps.
- **Why the CPU bar moved:** the S0 profiles show MobileGlues is a near pass-through, with 13 us/frame
of its own code against libMobileGL's 0.82 (Espryt) / ~1.0 ms (Magma). MobileGL's frontend state
machine and its record/validate/apply layers cost more than S1-S3 can recover, and even dev
monolith was 2.14 ms on Espryt (HANDOFF, S0 milestone).
- **Kept in scope:** MC's own code costs +0.17 ms/frame on MobileGL. MobileGlues advertises GL 4.0
and MobileGL 3.3 core; if MC takes a call-heavier path because of what we advertise, that
matters for both targets. Check extension strings and per-frame call counts.
**Stopping rule:** P15 ends when FCL presenting-thread CPU on both backends is at or below dev's
(within ~5 % noise, same session, same interval) and the BSL scene is within ~5 % of MobileGlues
fps on both backends. It also ends if a remaining gap is shown to be irreducible, with the reason
written down.
**Reference rows in every FCL milestone,** measured in the same session:
- MobileGlues (primary);
- dev (second).
MobileGlues also runs on the trace fixtures where the harness can load it.
## 1. Measurement rules for P15
- **FCL:**
- The primary metric is the presenting-thread CPU in ms/frame, which MobileGL's fps log already
prints. Report fps beside it, never alone.
- Until stage P lands, at interval 0 and above ~165 fps, frame time ≈ CPU + ~2.4 ms of
display-coupled wait (section 2.1). So fps ratios understate CPU ratios and are not linear in
CPU saved.
- Record the swap interval of every FCL reading (MC's `enableVsync` in
`/sdcard/FCL/.minecraft/versions/1.21.5/options.txt`; the default bench is `false`). Back the
file up before editing and restore it md5-checked.
- At interval ≥1 the per-frame CPU of every build rises by 0.3-0.7 ms (section 2.4), because the
thread idles between frames. Compare CPU only within one interval setting.
- Take readings only from in-world steady windows. The probe waits for MC's `Time elapsed:`
line and then four fps-log windows of more than 150 frames each.
- **GPU-bound scene (user, 2026-10-08):**
- FCL `1.21.4-Fabric` with Iris and `BSL_v10.1.3`, at the same world and interval, measured live
with `fcl_scene.sh bsl` and restored afterwards.
- The BSL fixture `minecraft-1.21.4-fabric-iris-bsl-in-world` joins the SSIM gate. It is a
single-frame trim, so it is a correctness check, not a benchmark.
- Show the scene is GPU-bound, with evidence:
- kgsl busy near 100 % (`gpu_clock_stats`, kgsl cmdbatch union from ftrace);
- the presenting thread waiting in fences or present;
- the `gsl_syncobj_wait` share.
- On GPU-bound runs, fps is the metric.
- A GPU regression on BSL blocks a change even if CPU improved.
- **GPU metrics in every milestone:**
- kgsl GPU busy % for every FCL run (`fclsum.py`);
- for GPU-bound runs, fps against dev and MobileGlues.
- **Load and store ops:** check every pass change in GPU terms. Prefer LOAD_OP_CLEAR or DONT_CARE
over loading and clearing on the tiler, and use DONT_CARE stores for depth/stencil that nothing
reads after the pass.
- **Trace (rd12, openra, and the FCL 1.21.5 fixture from stage 0b):**
- fps, best of 3.
- Per-layer CPU in ms/frame from `profile_p14.sh` / `layers.py`. Remember that rd12 carries
~6.9 ms/frame of harness parse.
- **Method:**
- `FINISH=false`, pinned clocks, best of 3.
- Re-run any surprising result before believing it.
- Every probe needs proof it engaged: a marker line, a counter, or a knob that visibly changes
behaviour.
- Every optimisation needs a negative control that can go red.
- **Clocks and validity (user, 2026-10-08; supersedes "pinned clocks" above):**
- **Pin:** CPU 2035.2 MHz on policies 2/5/7 and 1574.4 MHz on policy0; GPU 680 MHz
(`pin_clocks.sh` defaults). The device maxima (3.3 GHz, 903 MHz GPU) are not sustainable. The
point is kept only after a soak: about 10 min BSL plus 10 min FCL vanilla with the sampler, no
cap, temperatures well below the trip point. Otherwise step down one OPP (GPU 629/578, CPU 1920)
and soak again.
- **Profiles (user, 2026-10-08):** pick one per job (`PROFILE=<name>`, read by `pin_clocks.sh`) and
compare numbers only within one profile.
| profile | CPU big/prime | CPU little | GPU | use |
|---|---|---|---|---|
| `sustained` (default) | 2035.2 MHz | 1574.4 MHz | 680 MHz | all milestone and reference numbers |
| `gpumax` | 2035.2 | 1574.4 | 903 | show whether a scene is GPU-bound (not sustainable) |
| `gpulow` | 2035.2 | 1574.4 | 422 | amplify GPU cost |
| `cpulow` | 1286.4 | 1017.6 | 680 | amplify CPU differences |
| `cpuhunt` | <=1.5 GHz OPP | <=1.25 GHz OPP | 903 | CPU-overhead hunting (vanilla/rd12 gap, driver-call redundancy, S1-S3): cleanly CPU-bound |
| `gpuhunt` | <=2.4 GHz OPP | <=1.8 GHz OPP | 578 | GPU-side hunting (Espryt BSL gap, pass structure, load/store): cleanly GPU-bound |
Choose per question (user, 2026-10-08): CPU questions on a slow CPU with a fast GPU, GPU
questions on a fast CPU with a slow GPU. Show the binding evidence for each run (GPU busy %,
main-thread on-CPU share). A high profile only has to hold for one short, cool-started run, and
the validity check proves it did.
- **Every reported number carries its device state.** `devstate.sh` writes one line per run
(`state.txt`), and `fclsum.py` prints it under the results:
`STATE profile=<name>(cpu/little/gpu MHz) VALID|INVALID <observed min/max freq, peak temperatures>
daemons=<stopped(n)|running> mc=<version> swap=<enableVsync> anland=<on|off>`.
Invalid runs never enter a number.
- **Session (`bench_session.sh`, run by `devjob.sh` around every device job):**
- It records, then stops, the services that move frequency caps: `thermal-engine`,
`perf2-hal-1-0`, `vendor.perfservice`, `performance` and `hyperschedule_hal_service`.
- It releases their leftover requests in `/sys/kernel/msm_performance/parameters/cpu_{max,min}_freq`
and re-pins.
- On exit it starts every service that was running and verifies it is running again. The exit
runs on interrupt too (trap). Kernel trip points stay armed; if one engages (frequency
collapse or shutdown), benchmarking stops and it is reported.
- Why the requests matter: measured 2026-10-08, the perf stack's game-mode levels left caps of
787 / 1286 / 1075 / 1248 MHz in `msm_performance` that clamped `scaling_max_freq` under the
pin for about 50 min, while `pin_clocks.sh show` looked pinned.
- **Sampler:** `freq_sampler.sh` runs on the device every 2 s for the whole measurement window of
every probe. It records per-policy cur/max frequency, GPU devfreq cur and gpuclk, kgsl
`thermal_pwrlevel` / `throttling`, GPU busy, and the hottest CPU, GPU and skin zones.
- **Validity:** `freqcheck.py` decides. A run is valid only if every sample shows each policy at
the INTENDED pin (one OPP step of tolerance), no `scaling_max` cap, the GPU at its pin whenever
busy, and no kgsl thermal power level. Invalid runs are discarded and re-run after cool-down.
Every reported number carries its run's min/max frequency and peak temperatures
(`valid.txt`).
- **Before this rule:** P15 numbers up to the S0 milestone had no sampler. They ran at the
2035 MHz CPU / 903 MHz GPU pin as far as `time_in_state` shows, but that is not proof per run.
The references (dev, MobileGlues, current feat; vanilla and BSL; both backends; monolith and
inproc) are re-measured at the new clocks under this rule before any decision relies on them.
- **Device hygiene:**
- One device job at a time, under the `devjob.sh` lock.
- Restore FCL's library, config and properties afterwards, md5-checked (`fcl_p14.sh restore`).
- Stop the anland desktop during runs.
- FCL's SIGRTMIN+2 start-up death is known (DEBTS). The probe relaunches up to 4 times.
- **Gates for each landing:**
- SSIM 16/16 (`matrix_p14.sh ssim`);
- the retrace CI;
- the run-ahead and syncval gates on any Magma change that touches barriers or pass structure;
- an FCL soak before default-on.
## 2. Measurements behind the plan (2026-10-07)
Tools are in `tools/device_bench/disagg/` (README section "P15 FCL probes"):
- `fcl_probe.sh`: waits for in-world frames, then runs 4 s of ftrace (sched, kgsl cmdbatch, atrace
gfx) and 6 s of `simpleperf --trace-offcpu -p`;
- `offwait.py`: off-CPU time by open atrace slice and waker;
- `sfalign.py`: SurfaceFlinger transaction phase;
- `fcl_split.py` / `fcl_incl.py` / `fcl_drvcaller.py` / `fcl_stacks.py`: layer split, inclusive
functions, driver time by caller, and stacks;
- `fcl_count.sh` + `p15count.patch` (measurement-only): per-draw pair and gap statistics.
### 2.1 Item 1: where FCL's wait is
FCL MC 1.21.5, in world, view distance 2, monolith. The figures for the presenting thread
(`Thread-14`) come from the ftrace window. The off-CPU breakdown comes from the simpleperf window.
| build | frame ms | CPU ms | sleep ms | runnable ms | biggest sleep |
|---|---|---|---|---|---|
| dev Magma (×2) | 4.27 / 4.46 | 1.77 | 2.05 / 2.07 | 0.35 / 0.41 | QueuePresentKHR > queueBuffer, woken by the app's binder thread |
| feat Magma (×2) | 5.67 / 5.79 | 3.43 | 1.98 / 2.10 | 0.44 / 0.47 | same |
| dev Espryt | 4.54 | 2.10 | 1.92 | 0.40 | eglSwapBuffers > queueBuffer, same waker |
| feat Espryt | 5.03 | 2.73 | 1.81 | 0.39 | same |
- **The off-CPU stack is the same on all four builds:**
- The render thread: `BLASTBufferQueue::onFrameAvailable` → `std::mutex::lock`, 1.4-1.7
ms/frame. A further 0.2-0.34 ms/frame goes to `Fence::waitForever` in `queueBuffer`.
- The lock holder is the app binder thread: `releaseBufferCallback` →
`acquireNextBufferLocked` → `Transaction::apply` → `BpSurfaceComposer::setTransactionState`,
synchronous and under the BBQ mutex.
- **Inside SurfaceFlinger, `setTransactionState` has a median of 3.4 ms** (p10-p90 2.7-3.8). It
returns **4.95 ms after SF's `flushTransactions`** (p10-p90 4.78-5.2). The flush period is 6.1
ms (165 Hz, `NextFrameInterval 165_Hz`), with about one call per refresh. So the BBQ binder thread is
paced by the display. Above refresh rate, the render thread's present waits for it through the
mutex.
- **Other checks:**
- GPU busy is ~14 % (union of kgsl `adreno_cmdbatch_retired`).
- The swapchain is MAILBOX with 6 images, so present mode and image count are not the cause.
- **SurfaceFlinger's side:** its binder thread sleeps inside `setTransactionState` until it is
woken by `binder:1555_x`, a thread of `vendor.qti.hardware.display.composer-service`. That
thread is busy with its `HWCDisplay::CommitOrPrepare` cycle. So the composer HAL's display
cycle sets the phase.
- **Consequence:** this is not a MobileGL defect and not a feat regression. The fix for interval 0
is stage P (section 2.4).
### 2.2 FCL CPU by function (render thread, on-CPU ms/frame, inclusive)
**Magma monolith: feat 3.43 vs dev 1.77.** Repeat run: 3.25 vs 1.85 by the fps log.
| item | feat | dev | note |
|---|---|---|---|
| glClear → ClearWireFramebuffer | 0.42-0.46 | ~0.05 (Clear + ClearAttachmentsOnActiveRenderPass) | per clear: RetireWireDrawPass, vkCreateImageView + vkCreateRenderPass + vkCreateFramebuffer, its own pass, retire. 6 clears/frame, ~70 µs each |
| glBufferSubData → WriteWireBuffer / StagedWireRangeCopy | 0.28 | ~0 | 11 calls/frame, ~25 µs each; check whether it also ends the pass |
| CollectWireObjects (vkDestroyFramebuffer / DescriptorPool / ImageView) | 0.18 | none | the GC of the objects above |
| glBlitNamedFramebuffer → BlitWireColorImage | 0.13 | 0.02 | vkCreateDescriptorPool per blit (0.08) |
| TransitionWireImage | 0.14 | small | |
| BeginCommandRecording (vkResetCommandBuffer) + EndCommandRecording | 0.24 | 0.08 | larger, fragmented command buffers |
| glDrawElements (whole draw) | 0.93 | 0.56 | +0.37: client validate/emit ~0.27; SetupWireDraw 0.55 vs dev SetupDraw 0.54 |
| Present | 0.37 | 0.25 | |
| driver layer total | 1.46 | 0.49 | almost all the create/destroy above; not cache pressure |
**Espryt monolith: feat 2.73 vs dev 2.10.** The +0.62 splits as:
- client half +0.39;
- backend +0.09;
- driver +0.04;
- applier +0.035.
The clear/blit/sub-data path costs about the same as dev's: clear 0.16 vs 0.13, blit 0.125 vs
0.11, sub-data 0.024 vs 0.007. So Espryt has no churn of this kind (at most 0.07 ms/frame). Its
gap is the draw path: glDrawElements 1.01 vs 0.60, which is +4.7 µs per draw over 87 draws.
**rd12 Magma** (P14 `prof-fin` profiles, scaled to ms/frame):
- ClearWireFramebuffer ≈ 0.27, CollectWireObjects ≈ 0.18, BeginCommandRecording 0.12 (dev 0.02),
blit 0.09 (dev 0.06).
- So stage 0 also pays on rd12: about 0.4-0.5 ms/frame.
- Dev's deferred-clear lookups cost about 0.6 ms/frame on rd12: `VkClearManager::HasPendingClear`
is probed per draw, plus the key find. A naive port would be a regression there. Pending clears
must be resolved once per pass begin, never per draw.
### 2.3 Draw-pair and gap statistics (P15Count, frontend entry level)
What each column measures:
- **pairs:** distinct (VAO lifetime id, program lifetime id) pairs per frame.
- **same as prev:** the previous draw had the same pair.
- **pair epoch hit:** the pair has drawn before, and no non-whitelisted GL entry has run since its
last draw. This is the packet-table hit rate.
- **prev-draw gap clean:** no non-whitelisted entry since the previous draw, whichever pair it
had. This is the draw-delta hit rate.
The whitelist is draws, `glBindVertexArray`, float uniforms and `glUseProgram`. "+buffer" adds
buffer binds and vertex-buffer binds.
| workload | draws/frame | GL calls/frame | pairs/frame (ever) | same as prev | pair epoch hit, whitelist / +buffer | prev-draw gap clean, whitelist / +buffer |
|---|---|---|---|---|---|---|
| rd12 (steady window) | 1471 | 4856 | 1466 (1473) | 0.3 % | 0.0 % / 0.0 % | **99.0 %** / 99.0 % |
| FCL MC 1.21.5 (10 windows, both backends) | 88 | 873 | 15.1 (27) | 82.9 % | 0.0 % / 80.6 % | 0.0 % / **80.6 %** |
| openra | 29 | 593 | 2 (2) | 93 % | 0 % / 0 % | 0 % / 0 % |
Engagement and controls:
- Allowing every category gives 99.9-100 %, which is the positive control.
- The FCL numbers are identical on Espryt and Magma, as expected for frontend counts.
What sits between draws:
- **rd12:** per draw, just BindVertexArray + Uniform3fv + DrawElements. The ~1 % of other gaps
carry Enable/Disable, BlendFunc, BindTexture, Uniform1i and similar.
- **FCL:**
- `BindBuffer` comes before 98.9 % of draws and `BindVertexBuffer` before 88.5 %. Both are
VAO-scoped state: the element buffer and the vertex binding.
- 19 % of draws also follow `BindFramebuffer` / `Viewport` / `PolygonMode`.
- MC issues 96 `BindFramebuffer` calls per frame, mostly redundant.
- **openra:** every draw changes blend, texture, attrib pointers and sub-data. No per-draw
shortcut applies, and none is needed: openra is not where the gap is.
### 2.4 Swap interval: what is requested, what each backend does, what happens
**What MC requests:**
- The bench world runs with `enableVsync:false` and `maxFps:260` (MC's "unlimited"). So the app
asks for interval 0 through FCL's GLFW → `eglSwapInterval`.
- That interval 0 reaches Espryt's host EGL is shown by behaviour: the host default of 1 would cap
at 165 fps, but Espryt runs at 194-225.
- For Magma, `enableVsync:true` logs `Picked present mode: VK_PRESENT_MODE_FIFO_KHR` and locks to
165 fps, so the interval is plumbed.
**How each backend honours it today:**
- **Espryt:**
- `EGLImpl::SwapInterval` → `BackendObject::SetEGLSwapInterval` → `DirectGLES::SetSwapInterval`
→ host `eglSwapInterval`. On Android that is `ANativeWindow` `setSwapInterval`; 0 is the
async queue mode.
- The interval is re-applied when the window surface is recreated.
- **Magma:**
- `DirectVulkan::SetSwapInterval` → `VulkanRenderer::SetSwapInterval`.
- A changed interval recreates the swapchain between frames.
- `ChooseSwapchainPresentMode`: 0 → IMMEDIATE, then MAILBOX, then FIFO; ≥1 → FIFO; negative →
FIFO_RELAXED, then FIFO; no request → MAILBOX first.
- Android offers no IMMEDIATE here, so interval 0 is MAILBOX with 6 images.
- Magma creates one queue. `m_presentQueue` is the same queue as `m_graphicsQueue` when the
families match.
**Measured, FCL, monolith, same session, mean of 4 fps-log windows** (presenting-thread CPU in
ms/frame):
| build | interval 1: fps | interval 1: CPU | interval 0: fps | interval 0: CPU | interval 0: GL-thread sleep | interval 0: runnable |
|---|---|---|---|---|---|---|
| dev Magma | 164.9 | 2.43 | 235.5 | 1.76 | 2.02 | 0.35 |
| feat Magma | 163.2 | 2.92 | 172.8 | 3.12 | 2.02 | 0.44 |
| dev Espryt | 164.9 | 2.37 | 216.5 | 2.14 | 1.94 | 0.36 |
| feat Espryt | 163.4 | 2.72 | 194.3 | 2.73 | 1.87 | 0.41 |
| MobileGlues plugin (control) | 164.9 | ~1.9 | 248.4 | ~1.7 | 1.98 | 0.34 |
- The MobileGlues CPU figures come from schedstat (the plugin has no fps log).
- **Interval 1 is correct everywhere:** FIFO, or host interval 1. The waits sit in
`dequeueBuffer` / `AcquireNextImageKHR` and in the render thread's own `setTransactionState`.
- **Interval 0 is wrong everywhere,** including dev and the control. The GL thread still spends
~2 ms/frame in `queueBuffer` → `BLASTBufferQueue::onFrameAvailable`, waiting for the mutex that
the app's binder thread holds across `setTransactionState`, and that call is phase-locked to the
composer HAL (section 2.1).
- **The async queue mode does not help.** It changes what happens to the buffers, not who holds the
mutex.
## 3. Stages
### Stage 0: parity audit, then the wire non-draw fast path (Magma first)
**0.1 Parity audit (first step, judgement work).**
- **What to list:** every performance mechanism of dev's frontend arm that the record and wire
arms lost when P13 W4 moved monolith onto the wire arm and W6e / `de6ab167` deleted the old
code as dead. The split arm (the anland desktop) has always paid for them.
- **References:** `git show origin/dev:<path>` and the pre-W6 feat tree `88a11b81`.
- **Seed inventory:** [PARITY-SEED.md](PARITY-SEED.md) lists the definitions in OLD but not NEW
for 17 backend files (regex-extracted, approximate). The audit's verdicts go in
`perf-p15/PARITY-AUDIT.md`.
- **For each mechanism, record:**
- what it did and its key;
- whether the wire/record arm has an equivalent, and where;
- whether FCL or rd12 shows its absence (section 2.2 numbers);
- porting cost and correctness risk;
- a verdict.
Seed rows (to be verified by the audit):
| mechanism (dev / 88a11b81) | wire/record arm today | shows in profiles | first estimate |
|---|---|---|---|
| `VkClearManager`: glClear queues a pending clear per attachment (texture + lifetime id + level/layer); the next pass on that attachment starts with LOAD_OP_CLEAR; materialised before reads, blits and copies | none: ClearWireFramebuffer runs a standalone pass with fresh objects | FCL 0.42, rd12 0.27 ms | **port, per pass begin**: dev's per-draw probe cost 0.6 ms on rd12 |
| `VkRenderPassManager::GetOrCreateRenderPass` hash cache of render pass + framebuffer, with OnPresent GC | partial: wire pass continuation, RenderPassEntry; framebuffers still created in SetupWireDraw (0.04) and in clears | FCL 0.04-0.19 (create) + 0.12 (destroy) | port a cache keyed on attachment lifetime ids + image epoch |
| shader blit to default FB (`TryBlitToDefaultFramebufferWithShader`), persistent blit resources (`InitializeBlitResources`) | BlitWireColorImage creates a descriptor pool per blit | FCL 0.08 + GC | persistent pool / set cache per (pipeline, source view) |
| `VkBufferManager::OnSubData` / `OnResidentSubData` (writes into resident or streamed slices) | WriteWireBuffer + StagedWireRangeCopy | FCL 0.28 | find out why it is ~25 µs per call; port the resident fast path; check for pass breaks |
| `TrySetupDrawFastPath` / `SetupDrawSnapshot` (4 snapshots keyed on program lifetime id) | P14 memos (pass continuation, unit samplers, pipeline/vertex/index bind skips) | SetupWireDraw ≈ dev SetupDraw on FCL | audit for leftovers only |
| `UniformManager` `FastRebindMemo`, `SampledBindingsUnchanged` | P14 descriptor-set rebind, walk-skip | small | audit |
| `VertexInputStateFactory` per-VAO memos (`VaoBackendMemos`) | vertex-input layout kept on its record (P14) | small | audit |
| `VkTextureManager` `SyncedTextureMemoEntry` / `DrawSyncScope` | P14 direct-mapped texture fronts | small | audit |
| Espryt `StateBackendObjectRegistry` (pointer-keyed twins), `SyncCurrentProgram`, `SyncVaoAttributeBuffersByHandle`, `BackendFramebufferObject::SyncToBackend` | twins keyed on applier serials (P14) | Espryt backend +0.09 on FCL | audit; low priority |
**0.2 Port, in order of measured value:**
1. **Deferred clears on the wire arm.**
- Key: image lifetime id + level/layer range + aspect, never a VkImage or a GL name.
- A clear records a pending entry. The next wire pass that targets the image takes it as
LOAD_OP_CLEAR.
- A clear inside an open pass on the same attachments becomes `vkCmdClearAttachments`, without
ending the pass.
- Materialise pending clears before any read: sampling, readback, blit source, copy, mipmap
generation, shared-image export and present. The cost is one check per pass begin and one
per read verb; no per-draw probe.
- The clear-mask cases (partial colour mask, stencil write mask, scissor) keep the current path.
2. **A render-pass + framebuffer cache** for wire passes and clears.
- Keyed on attachment lifetime ids and the image epoch.
- Retired when an attachment's lifetime ends: the store destroy epoch.
3. **Blit descriptor reuse:** a persistent pool, sets keyed on (source view lifetime id, sampler).
4. **The `glBufferSubData` path:** find the ~25 µs per call, then port the resident-slice write
and check whether it ends the pass.
5. **Command-buffer churn:** once 1-4 land, re-measure `vkResetCommandBuffer` /
`EndCommandRecording`. They should fall with the pass count.
**Espryt:** no churn of this kind measured (≤0.07 ms/frame on FCL). The audit should still cover
Espryt's deleted mechanisms. Port only those that show in profiles.
**Correctness:**
- Deferred clears are the e8e1521 class of risk: a read that skips materialisation renders stale
content.
- Tests:
- an integration scenario per read path (sample after clear; readback; blit source; copy; mipmap;
present), with negative controls that drop materialisation for one read kind and must go red;
- SSIM 16/16;
- the syncval gates (a LOAD_OP_CLEAR changes the pass's first access).
- Runtime knob, e.g. `MOBILEGL_MAGMA_DEFERRED_CLEARS=0`, kept for one release.
**Expected gain:**
- FCL Magma: 0.8-1.0 of the 1.4 ms presenting-thread CPU gap. Medium-high confidence: the items
are measured, the removal fraction is estimated.
- rd12 Magma: 0.3-0.5 ms/frame, about +3-5 % fps. Medium confidence.
### Stage 0b: an FCL MC 1.21.5 trace fixture
- **Why:** rd12 (MC 1.21.4) never exercised the per-frame clear, blit and BufferSubData pattern
that FCL's MC 1.21.5 runs. The trace matrix must cover what FCL runs.
- **Capture:**
- with the on-device FCL capture wrapper (`tools/trace_replay/skills/trace-fixture-authoring-on-android-fcl`);
- the same world and view distance as the FCL bench, from the in-world steady state;
- trace mode forces 854×480.
- **Trim:** a multi-frame window, like rd12 (`gltrim -f`, about 250 frames), so the benchmark
measures steady frames. The golden is the final frame.
- **Golden:**
- follow `trace-fixture-authoring/SKILL.md`: generate it on a real GPU (Windows `glretrace` on
the RTX 3080, or a known-good Android replay); never on llvmpipe for anything heavy;
- check its content against a live-run screenshot;
- remove alpha; `repack --brotli`; register with `ci: false` like rd12.
- **Use:**
- add to `matrix_p14.sh` `wl_args`;
- A/B every stage on rd12, openra and this fixture;
- check that P15Count on the fixture reproduces section 2.3's FCL row (88 draws, 15 pairs); if
not, the fixture does not represent FCL.
- **Order:** best done before stage 0.2 lands, so stage 0 can be A/B'd on a trace as well as on FCL.
### Stage P: swap-interval-correct presentation (both backends)
**Status: not needed for the target; dropped unless the user asks (2026-10-08).** MobileGlues
pays the same ~2 ms present wait, so the target (section 0.1) does not need this stage.
**Goal:**
- With interval 0, presentation never paces the app: FCL fps becomes 1 / presenting-thread CPU.
- With interval ≥1 the app is still paced to the display: 165 fps ±1 % on this device, with no
extra latency beyond one queued frame.
**Design: a present worker that owns the blocking present.**
- The GL thread finishes a frame and hands it to the worker through a bounded queue (depth 1 at
interval ≥1, depth 2 at 0). It returns at once.
- The worker performs the present call that may block.
- At interval ≥1, backpressure comes from the full queue: the GL thread waits for the worker,
which waits for the display. At interval 0 the queue never fills, because the worker's blocked
windows (≤3.4 ms, about once per refresh) are absorbed by the swapchain's spare images.
- The worker exists only for window surfaces. Pbuffer and offscreen surfaces keep the inline path.
**Magma:**
- The GL thread keeps `vkAcquireNextImageKHR` and the submit, which signals the image's
render-done semaphore.
- The worker calls `vkQueuePresentKHR`.
- Queue access must be externally synchronised, and the WSI's `queueBuffer` runs inside
`vkQueuePresentKHR`. So the worker needs **its own VkQueue**: a second queue of the graphics
family, or a present-capable family.
- Check the Adreno queue count first.
- If only one queue exists, the fallback is a queue mutex released before the WSI blocks. That
is not possible from outside the loader, so a single-queue device keeps the inline present
and logs it once.
- Swapchain recreation (resize, interval change, `OUT_OF_DATE`) drains the worker first.
- The frame-in-flight fences already gate the reuse of images.
**Espryt:** `eglSwapBuffers` is bound to the context's thread, so the prototype compares two routes:
- **(a) Own the native window.**
- Dequeue `ANativeWindowBuffer`s on the GL thread (or worker) and wrap each as an EGLImage
(`EGL_NATIVE_BUFFER_ANDROID`, cached by buffer identity: generation + id, never a pointer).
- Render the default framebuffer into it.
- The worker queues it with an `EGL_ANDROID_native_fence_sync` fd.
- This route also needs buffer count, transform / pre-rotation, damage, buffer age and
`setSwapInterval` on the window itself.
- No extra blit. The anland shared-image route already does part of this.
- **(b) A present thread with a shared context.**
- The default framebuffer becomes an offscreen FBO.
- The present thread waits on a fence, blits to its window surface and calls `eglSwapBuffers`.
- Costs one full-screen blit per frame (800×1280; small on Adreno 750), a second context, and
redirecting default-framebuffer reads.
- Prototype (a) first.
**Split arms:**
- The server presents on the apply thread (inproc) or in the server process (spawn/tcp). The
worker sits there.
- The present credit is returned when the frame is handed to the worker, not when `queueBuffer`
returns.
**Tests:**
- interval 0 → fps bounded by CPU, and the GL thread never sleeps in `queueBuffer`
(`offwait.py` shows no `queueBuffer` sleep on the GL thread);
- interval 1 → 165 fps ±1 %, and so is interval 2 → 82.5;
- interval changes at runtime (MC's vsync toggle);
- surface resize / rotation; eglMakeCurrent away and back with frames queued;
- teardown and device loss with a frame in the worker;
- the anland desktop (a split-arm present on the same device);
- negative control: a knob that makes the worker present inline must bring the ~2 ms
`queueBuffer` sleep back.
- Kill switch: `MOBILEGL_PRESENT_WORKER=0`.
**Expected at FCL interval 0** (presenting-thread CPU is unchanged; fps approaches 1/CPU):
| build | today | after stage P | after stage 0 as well |
|---|---|---|---|
| dev Magma | ~236 | ~450-550 | |
| feat Magma | ~173 | ~300-330 | ~450 |
| feat Espryt | ~194 | ~350 | |
At interval ≥1 nothing changes. Confidence: medium. It depends on the second queue (Magma) and on
route (a) working (Espryt).
### Stage 1: client draw-delta prototype (Espryt monolith)
This is the client half of the old sketch, re-keyed on what section 2.3 shows.
- **Client context epoch:**
- one `Uint64` per context;
- bumped by every GL/EGL entry except a whitelist;
- share-group-scoped objects (textures, buffers, programs, renderbuffers, samplers) bump a
share-group epoch that every context in the group checks.
- **Whitelist classes,** decided per entry in a checked-in table (section 4.4):
- **free:** draws, `glBindVertexArray`, float `glUniform*` / `glProgramUniform*`, `glUseProgram`
(the program is a key, not context state);
- **VAO-scoped:** `glBindVertexBuffer`, `glVertexAttrib*Pointer`, `glEnable/DisableVertexAttribArray`,
`glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)` and the VAO DSA calls. These bump the bound VAO's own
versions, which the per-VAO slice checks. `glBindBuffer(GL_ARRAY_BUFFER)` changes nothing a draw
reads;
- **program-scoped:** integer uniforms and block bindings. These bump the program's backend-state
/ block-binding version;
- **everything else** bumps the epoch.
- **Redundant binds** (same object, same value) may skip the bump only where the entry already
compares. MC issues 96 BindFramebuffer calls per frame and 19 % of draws follow one.
- **At the validate point:**
- if (epoch, share-group epoch, context serial, slot reset epoch) are unchanged since the
previous draw, skip `Tracker::Update`'s context-global shutters, the residual copy and the
context-value emit;
- run only the VAO-derived shutters (through the per-VAO slice once stage 2 lands), the
program-derived ones, and the uniform span;
- also skip `ReadDrawBindings` / `MarkGpuWritesForDraw` when no persistent map is live and no
image or SSBO write is bound. The persistent-map re-sync stays a per-draw input otherwise.
- **Kill switch:** `MOBILEGL_PIPE_DRAW_DELTA=0`, default off until stage 4.
- **Measure** on rd12, FCL and the stage 0b fixture against P14's per-item numbers: Tracker::Update
0.12, CopyField 0.10, validate self 0.10, ReadDrawBindings 0.06, MarkGpuWritesForDraw 0.05,
thread-local/atomic 0.07 ms/frame.
- **Expected:** 0.3-0.5 ms/frame on rd12 Espryt monolith (91 → ~94-96 fps), and 0.1-0.25 ms on FCL
Espryt. Medium confidence.
- **Decide** on stages 2-3 from this.
### Stage 2: per-VAO and per-program slices
- **Per-VAO slice.** This is what the old "packet" becomes. It extends `VaoMemo`, which is already
keyed on VAO lifetime id + slot reset epoch.
- It holds the vertex-elements handle + published config version, the buffer set + index
handles + hash, the stored-on-server mirrors, and the backend's per-VAO answers (stage 3).
- It is reached by an index stored on the frontend VAO object, not a hash probe.
- rd12 rebinds a different VAO for every draw, but each VAO is seen every frame and its config
hardly moves. So the slice turns EmitVertexElements (0.13) / EmitVertexBuffers (0.07) into
a version compare plus a handle reuse.
- **Per-program slice:** the shader CSO handle, link and backend-state versions, the
uniform-span layout and the UBO block size.
- **Expected:**
- rd12: 0.1-0.2 ms on the client half;
- FCL: small, because only 27 pairs exist. But each FCL draw also changes the vertex buffer
binding, which is now a VAO-version bump that the slice re-derives cheaply.
### Stage 3: applier and backend draw-delta
- **Server epoch, generated from `PipeCalls.def`:**
- The applier bumps an epoch for every applied record except a whitelist: draw,
bind_vertex_elements, the uniform span, and the per-VAO / per-program record kinds.
- A constexpr table is generated from the record opcode list. A test fails if a record kind is
missing from it. This is the server-side twin of section 4.4.
- **Backend-internal mutations also bump a backend epoch.** These are:
- texture `Serial` / `ParamsSerial` / `PendingUploads`;
- twin force-resync flags;
- the sampler CSO serial;
- shared-image state;
- GPU-written marks;
- on Magma: the image epoch, the resource-erase epoch, an image layout leaving GENERAL, and the
store-destroy epoch.
The rule from the content-version lesson applies: every place that changes a twin's synced
state bumps it, including `glGenerateMipmap` growing mips. P14's Magma memos already check most of these.
- **When both epochs are unchanged since the previous draw,** the backend skips the
context-global walks:
- Espryt: `SyncNeccessaryTextures` / `SyncNeccessaryBuffers`, `AdoptUnchangedBufferSets`,
`BindCurrentProgramWithResources`;
- Magma: whatever of SetupWireDraw is not VAO- or program-derived.
- **Expected:**
- rd12 Espryt backend: 0.15-0.3 ms of the +0.45;
- rd12 Magma: 0.1-0.3 ms (its backend is already below dev);
- driver: 0-0.3 ms, if the cache-pressure reading is right. Measure L1D refills before and
after with `stat_p14.sh`.
### Stage 4: split arms, verify, default-on
- **Inproc / spawn / tcp:**
- the client epoch and the per-VAO/program client slices live in the client;
- the server epoch and the backend slices live where the applier runs: the same thread on
monolith, the apply thread on inproc, the server process on spawn and tcp.
- Nothing new crosses the wire.
- Under run-ahead, client validity depends only on client epochs. The server computes its own
epoch from the records it applies, so the two cannot disagree about what moved.
- **Default-on** after:
- CI and SSIM green on all arms;
- verify lanes green with the shadow check (section 4.5);
- an FCL soak on both backends.
Keep the knob for one release.
- **Expected inproc:**
- Espryt rd12 is client-bound, so stages 1-2 give 112 → ~116-119, above dev's 115.
- Magma inproc is apply-bound, so it gains from stages 0 and 3.
## 4. Design details
### 4.1 Scope and non-goals
**In scope:**
- the stage 0 wire non-draw fast path (Magma);
- the client and server draw-delta epochs;
- per-VAO and per-program slices;
- the backend draw-delta.
**Non-goals:**
- a (VAO, program) pair table: 0 % hit on rd12, and FCL's hits are covered by the draw delta;
- record batching (measured and dropped in P14);
- protocol changes;
- native TLS / minSdk (the user's own change);
- openra, whose gaps change state on every draw.
### 4.2 Per-layer state for one draw on the fast path
| layer | read per draw on a hit | kept in |
|---|---|---|
| tracker | client epoch + share-group epoch + context serial + slot reset epoch (4 compares); VAO identity (lifetime id + config + attribute generation); program identity (lifetime id + link + backend-state + block-binding versions) | context, per-VAO slice, per-program slice |
| emitter | per-VAO slice: elements / buffers / index handles + versions; uniform span; draw record | per-VAO slice |
| applier | server epoch; vertex-elements record by slot + generation (bind by reference) | applier context |
| backend | backend epoch; Espryt VAO twin + program twin pointers; Magma vertex-input id, pipeline handle, descriptor-set layout, pass-compatibility id | per-VAO / per-program backend slices |
### 4.3 Keys
- Use monotonic lifetime ids only: VAO, program, buffer and texture lifetime ids; slot +
generation on the server side. Never a GL name or a pointer. This is the ABA rule, broken three
times so far (sampler, texture, program).
- Slices are invalidated by:
- the context serial;
- `MGPipeSlots().ResetEpoch()`;
- the store-destroy epoch.
- A slice index stored on a frontend object is valid only together with the object's lifetime id.
### 4.4 Invalidation sources, and how to prove none is missed
**Client entry-point table** (`MG_Pipe/DrawDeltaClass.def`, new):
- one row per exported GL entry, giving its class (free / VAO-scoped / program-scoped /
share-group / context);
- `DECLARE_GL_FUNCTION_END*` passes `#name` to `GLStreamScope`, which looks up the class at
compile time;
- the hand-written `MOBILEGL_GL_API` definitions (~170 in `Definitions.cpp`, mostly EXT/ARB
aliases plus `glFinish`/`glFlush`) and the EGL entries use the same scope helper.
**Completeness tests:**
1. A CTest scans `Definitions.cpp` and the EGL exports. It fails if:
- any exported entry is missing from the table;
- a table row names a non-exported entry;
- any `MOBILEGL_GL_API` body neither constructs the scope nor forwards to a macro entry.
2. A runtime self-test: in a debug build, every entry asserts it consulted the table. A fuzz
driver walks all entries.
3. **Negative controls:** a test-only knob `MOBILEGL_PIPE_DRAW_DELTA_DROP=<entry>` removes one
entry's bump. Run for a representative entry per class:
- `glBindTexture`;
- `glTexParameteri`;
- `glBindFramebuffer`;
- `glEnable`;
- `glBindBufferBase`;
- `glUniform1i` (program-scoped);
- `glBindVertexBuffer` (VAO-scoped);
- an EXT alias;
- an EGL entry.
Each must turn the shadow check (4.5) and a scenario red.
**Mutations that bypass GL entries:**
- persistent-mapped writes stay a per-draw input;
- async link completion (link version);
- `eglMakeCurrent` (context serial);
- another context in the share group (share-group epoch);
- server-side backend mutations (backend epoch, 3.3).
**Server side:**
- the generated table from `PipeCalls.def`, with the same three tests;
- for the backend epoch, a list of every writer of the synced-state fields, enforced by making
those fields private behind a setter that bumps. This is the same chokepoint design as the
Magma layout setter in the whole-draw fast-path note.
### 4.5 The verify comparator
`MOBILEGL_PIPE_VERIFY` compares the residual block with a live snapshot at the verb.
Under verify:
- the fast path is armed but always takes the slow path;
- it asserts that the fast path would have hit with byte-identical residual, record and
vertex-element output (a **shadow check**).
So every verify lane cross-checks epoch coverage for free, and the negative controls in 4.4
redden it.
A non-verify build has a sampled shadow mode, `MOBILEGL_PIPE_DRAW_DELTA_SHADOW=N`, which checks
every Nth hit. It is for FCL soaks.
POISON stamps (trace builds): on a hit, the stamp set recorded at the last slow draw is applied in
one bulk write. Freshness checks then keep working.
### 4.6 Tests
- Unit tests for the epoch classes; the table tests (4.4).
- Integration scenarios:
- draw-delta hit/miss per class;
- share-group mutation from a second context;
- persistent-map write between two hit draws;
- async link completing between draws;
- VAO rebind with the same lifetime id after delete + gen (ABA);
- context switch;
- slot reset.
Each runs with a negative control.
- Stage 0: deferred-clear read-path scenarios with drop-materialisation controls; syncval.
- All: SSIM 16/16, the retrace CI, FCL soak.
## 5. Expected gains
ms/frame of CPU on the bound thread.
| stage | rd12 Espryt mono | rd12 Magma mono | FCL Espryt mono (presenting CPU) | FCL Magma mono (presenting CPU) | confidence |
|---|---|---|---|---|---|
| 0 wire non-draw | 0-0.07 | 0.3-0.5 | ≤0.07 | 0.8-1.0 | medium-high (FCL), medium (rd12) |
| 1 client draw-delta | 0.3-0.5 | 0.3-0.5 | 0.1-0.25 | 0.1-0.25 | medium |
| 2 slices | 0.1-0.2 | 0.1-0.2 | ~0.05 | ~0.05 | low-medium |
| 3 backend draw-delta | 0.15-0.3 (+ driver 0-0.3) | 0.1-0.3 | ~0.05 | 0.05-0.1 | low-medium; driver unproven |
| total | 0.55-1.0 (+driver), gap 2.5 | 0.8-1.5, gap 0.76 | 0.25-0.4, gap 0.62 | 1.0-1.4, gap 1.4 | |
What the totals mean:
- **rd12 Espryt monolith:** 91 → roughly 96-101 fps. Short of dev's 115 unless the driver term
moves.
- **rd12 Magma monolith:** 84 → about dev's 87 or above.
- **FCL Magma:** CPU gap mostly closed. Espryt about halved.
- **Inproc:** above dev on Espryt rd12. Magma inproc gains stages 0 + 3.
- **Revision:** these are below the old sketch's 1.0-1.6 ms because the pair table does not hit on
rd12.
## 6. Risks
- **A missed epoch bump renders stale state.** This is the dominant risk. Mitigations:
- the generated tables and their completeness tests;
- the verify shadow check;
- per-class negative controls;
- SSIM and the retrace CI;
- default-off until stage 4.
- **Deferred clears skipping a materialisation.** Same class as the reverted e8e1521. Mitigations:
per-read-path scenarios with drop controls, syncval, SSIM.
- **ABA on slice keys.** Mitigations: lifetime ids, slot + generation, the reset and destroy
epochs.
- **Share groups and multiple sessions:** per-context epochs miss a mutation from another context
in the group. Mitigation: the share-group epoch. The multi-session server hazards also apply on
the split arms.
- **Gains below estimate:** the stage 1 prototype is the go/no-go for stages 2-3.
- **FCL fixture fidelity:** stage 0b's P15Count check.
## 7. Questions resolved with the user (2026-10-08)
1. FCL metric: presenting-thread CPU ms/frame is primary, with fps beside it.
2. Swap interval: interval 0 must unlimit the frame rate, and interval ≥1 must vsync. This is
stage P.
3. minSdk 29 / native TLS: the user decides and changes it. P15 does not touch it.
4. The probe tools are committed under `tools/device_bench/disagg/`.
5. No Espryt deferred-clear port: Espryt's clear and blit costs match dev's.
Still open (for stage P): does Adreno 750 expose a second graphics-family queue for the Magma
present worker? Which Espryt route, (a) or (b)?
+358
View File
@@ -0,0 +1,358 @@
# P15 present wait on FCL: per-frame timeline
Offline analysis of the existing P15 Perfetto traces. Scene: Minecraft 1.21.5 vanilla, frozen world,
cpuhunt clocks (CPU 1497/1248 MHz, GPU 903 MHz, FCL pinned to cpu2-6), display at 165 Hz (6.06 ms
vsync). All 35 runs used are VALID. Frames counted: Espryt monolith 11049 (fbm/y, c4/v, c4/w), Magma
monolith 10938 (c1c2/t, c1c2/x, fbm/y), Magma inproc 10079 (c1c2/t, c1c2/x), Espryt inproc 4639
(c1/u), MobileGlues 14398 (c1c2, fbm, c4).
## Answer
The producer throttle in `queueBuffer` waits for the previous frame's GPU-completion fence. That fence
is late because of the display, not because the GPU is busy:
1. About every other frame (45-56 %) renders into the window buffer that the display has just handed
back. Its release fence is still pending, and it signals only at the display's next commit-done
(0.24 ms after the `crtc_event` kernel thread runs).
2. The whole frame's GPU work waits behind that fence. MobileGL submits the frame as one batch at the
swap (Espryt: one driver flush at `eglSwapBuffers`; Magma: the frame's first `vkQueueSubmit`
carries the acquire-semaphore wait with `ALL_COMMANDS`).
3. Once the buffer is released, the batch still needs about 1.3 ms before its fence signals: about
0.8 ms of GPU start latency plus 0.5 ms of execution.
4. Meanwhile the CPU has already rendered the next frame. Its `queueBuffer` throttles on that late
fence.
How the candidates come out:
- **(b) The wait for the compositor's buffer release is the trigger.** 99.4-99.6 % of all throttle
time follows such a gated frame. Frames whose buffer was already released cause no wait (0.00
ms/frame on every arm).
- **(a) Late, single-batch submission is an amplifier.** It puts the whole frame, not just the final
window pass, behind the gate.
- **(d) Something else: a fixed GPU start latency of about 0.8 ms** whenever a batch becomes runnable
on an idle GPU. It does not depend on how long the GPU was idle (0.3 ms or 4 ms), and it does not
count as GPU busy. It is the larger part of the time after the release.
- **(c) SurfaceFlinger GPU composition is ruled out.** `hasClientComposition` is 0 on every
SurfaceFlinger frame in every run, so composition is device-only and SurfaceFlinger does no GPU
work.
The GPU is idle about 4 ms per burst and runs about 0.5 ms per frame. That is the 15 %
`gpu_busy_percentage` the frequency sampler records.
## What the throttle waits on (mechanism)
- FCL's SurfaceView is a BLAST surface: the BufferQueue and its consumer (BLASTBufferQueue) live in
the FCL process. Both EGL and the Android Vulkan swapchain connect as `NATIVE_WINDOW_API_EGL`, so
`BufferQueueProducer::queueBuffer` ends with `lastQueuedFence->waitForever` (the `waitForever`
slice) on the previous queued buffer's acquire fence, which is its GPU-completion fence.
- The display runs at 165 Hz. SurfaceFlinger commits about 10.1-10.3 ms ahead of the target vsync
(`beginFrame ... vsyncIn 10.1ms`), and the HWC commit takes 3.2-4.1 ms. One FCL buffer per vsync is
latched (about 813 per 5 s). Every other queued frame is dropped by replacement in the BufferQueue,
which runs in async (MAILBOX / swap-interval-0) mode.
- BLAST keeps 2-3 buffers in flight to SurfaceFlinger (the `BufferTX` counter). Magma's swapchain has
5 images: MAILBOX, `max(FIF hint 3, surface minImageCount 5)`. That leaves the app 2 buffers: one
being rendered and one queued, which may be dropped. The Espryt and MobileGlues EGL surfaces show
the same A/B alternation, so they also leave the app 2 buffers (inferred, not read from the
driver).
- Each vsync, SurfaceFlinger hands back the buffer leaving the screen, with a release fence that
signals when the display flips. The free list is FIFO, so the app's next dequeue takes that buffer.
This is a gated frame (A). The frame after it (B) gets a dropped buffer, which is already free.
- GPU timing comes from libgui's `FenceMonitor` threads in the FCL process. They exist because atrace
`gfx` is on:
- `GPU completion` gives one `waiting for GPU completion N` slice per queued fence; its end is the
fence signal time E;
- `HWC release` does the same per dequeued buffer; its end is the release time R, and a
`... has signaled` instant marks a buffer that was already free.
- They are cross-checked against kernel-thread scheduling:
- `kgsl_hwsched` runs at R (median offset -0.00 ms): the kgsl sync object is satisfied and the
batch is dispatched;
- `kgsl-events` runs 0.12-0.16 ms before E (the fence signal);
- `kgsl-events` is also what wakes the presenting thread out of `waitForever` in 100 % of long
waits, with a 60-70 us runnable latency (clocks pinned, no frequency changes in the window).
## Espryt monolith: the typical cycle
Anchor: swap entry of a gated frame A = 0. Values are medians, with p10..p90 in brackets. Frame A is
followed by frame B; about 1.5 frames per vsync. Medians of different events do not compose exactly.
Per frame pair, B's throttle ends when A's fence signals. `kgsl-events` wakes the presenting
thread directly (+0.06 ms), so W1_B lands at or slightly before the FenceMonitor's E_A, which is
about 0.1 ms late.
```
Espryt monolith
t(ms) -3 -2 -1 0 1 2 3 4 5
|---------|---------|---------|---------|---------|---------|---------|---------|--
render thr ============A cpu========d===S ============B cpu========d===S~~~~~
display v R
GPU (FCL) .........A held........+++st+++##A####B###
fence A E
(d = dequeue, S = swap entry, ~ = queueBuffer throttle, v = crtc_event, R = buffer release,
. = A's batch submitted but held by the release fence, st = GPU start latency, # = GPU execution)
```
1. **-2.90** [-3.44..-2.47]: the previous swap returns and A's CPU frame starts on the render thread.
2. **-0.43** [-0.58..-0.38]: the first default-framebuffer use makes the Adreno EGL dequeue lazily.
A gets buffer X, whose release is pending.
3. **0.00**: `eglSwapBuffersWithDamageKHR(A)`. The driver flushes A's whole frame as one batch, and
kgsl holds it behind X's release fence. The GPU stays idle.
4. **0.09 to 0.10**: `queueBuffer(A)` throttles on the previous frame's fence. That fence has already
signaled, so there is no wait.
5. **0.19**: the swap returns and B's CPU frame starts.
6. **1.97** [0.85..4.66]: `crtc_event` runs (display commit-done).
7. **2.27** [1.11..4.98]: R_A, X is released. `kgsl_hwsched` dispatches A's batch at the same
instant.
8. **2.27 to about 3.1**: GPU start latency of about 0.8 ms, for dispatch and power-up (not GPU busy).
9. **2.71**: B dequeues a buffer that is already free.
10. **3.09**: `eglSwapBuffers(B)`. B's batch queues behind A's in the in-order context.
11. **About 3.1 to 3.58**: A executes on the GPU (0.5 ms).
12. **3.20** [2.69..4.11]: `queueBuffer(B)` starts throttling on E_A.
13. **3.58** [2.42..6.31]: E_A. `kgsl-events` signals, and the render thread is runnable after 60
us.
14. **About 3.6**: `queueBuffer(B)` returns. B's batch then runs back to back with A (E_B is about
E_A + 0.5), and the GPU idles about 4 ms until the next release.
The throttle is 0.61 ms/frame on average. 58 % of the frames that follow a gated frame wait, with a
median of 2.0 ms [0.35..3.35]. The two halves of the wait:
- **0.27: display before release.** B is already throttling before the display has released A's
buffer.
- **0.33: GPU after release.** About 0.20 of this is start latency and about 0.13 is A's execution.
Critical path for B's wait: display commit-done (`crtc_event`), then +0.24 ms to the release fence of
A's buffer, then the kgsl sync object, then `kgsl_hwsched` dispatch, then about 0.8 ms of GPU start,
then about 0.5 ms of A's execution, then `kgsl-events` signals E_A, then the render thread wakes
(+60 us) and `queueBuffer(B)` returns. MobileGL CPU work is not on this path.
Worked example: `fbm/y-DirectGLES-r1`, frames 648-649, from `win.py`, offsets from swap 648:
- crtc_event 1.874;
- HWC release thread wakes 2.054, R 2.09;
- `kgsl_hwsched` 2.082;
- swap 649 at 2.471, throttle from 2.57;
- `kgsl_hwsched` (retire) 3.247, `kgsl-events` 3.317;
- the render thread resumes at 3.38 (a 0.82 ms wait);
- 649 completes at 4.056, 0.48 ms after 648, back to back.
## Magma monolith
```
Magma monolith
t(ms) -3 -2 -1 0 1 2 3 4 5
|---------|---------|---------|---------|---------|---------|---------|---------|--
render thr d=========A cpu=========S d=========B cpu==========S~~~~wait~~~~
display v R
GPU (FCL) .........A held.........++++st+++##A####B###
fence A E
```
1. **-2.36**: `AcquireNextImageKHR` runs right after the previous present. A gets X, whose release is
pending; `HWC release` waits on it.
2. **-2.36 to 0**: A's CPU frame. All GPU work is recorded and nothing is submitted. There are 1.33
`QueueSubmit` per frame: the first comes 2.34 ms after the previous present, and the last 0.07 ms
before `QueuePresentKHR`.
3. **0**: `QueueSubmit`, then `QueuePresentKHR(A)`. The first submit of the frame carries the
image-available semaphore wait with `VK_PIPELINE_STAGE_ALL_COMMANDS_BIT`
(`SubmitPendingCommandBuffer` / `FrameContext::GetSubmitInfo`, `imageAvailableSemaphoreConsumed`),
so the whole frame is gated. `queueBuffer(A)` has no wait.
4. **0.20**: B acquires a buffer that is already free.
5. **2.11**: `crtc_event` runs.
6. **2.41** [1.64..5.46]: R_A. `kgsl_hwsched` dispatches A's batch.
7. **2.66 to 2.75**: B submits and presents, then throttles on E_A.
8. **3.79** [3.06..6.88]: E_A, which is R + 1.39 (about 0.87 start latency + 0.52 execution). B's
throttle ends about here.
The throttle is 0.71 ms/frame: display before release 0.26, GPU after release 0.45. 85 % of the
frames after a gated frame wait, with a median of 1.21 ms. Magma waits more per frame than Espryt
because it is faster on CPU: B reaches its throttle about 0.45 ms earlier relative to the release.
## Inproc arms (the apply thread presents)
```
Magma inproc (apply thread)
t(ms) -3 -2 -1 0 1 2 3 4 5
|---------|---------|---------|---------|---------|---------|---------|---------|--
apply thr =d==A cpu====S d===B cpu===S~~~~~~~~~~~~~~wait~~~~~~~~~~~~~~~
display v R
GPU (FCL) .............A held............++++st+++###A#####B###
fence A E
Espryt inproc (apply thread)
apply thr ======A cpu=d====S ======B cpu==d==S~~~~~~~~~~wait~~~~~~~~~~~
display v R
GPU (FCL) ...........A held...........++++st+++##A####B###
fence A E
```
Magma inproc:
1. **-1.21**: acquire, release pending.
2. **0**: A's submit and present on `mgl-srv-apply`.
3. **0.20**: B acquires a free buffer.
4. **1.41 to 1.52**: B presents, then throttles on E_A.
5. **2.82**: `crtc_event` runs.
6. **3.12**: R_A.
7. **4.59**: E_A, which is R + 1.46 (0.90 start latency + 0.56 execution). B's throttle ends here, a
3.0 ms wait in the median waiting pair.
The throttle is 1.28 ms/frame: display before release 0.69, GPU after release 0.58. 96 % of the
frames after a gated frame wait. Espryt inproc has the same shape: throttle 1.08 ms/frame
(0.54 + 0.53), with R at 2.79 and E_A at 4.20.
The chain reaches the GL thread (Thread-14) too. It sleeps 1.3-1.6 ms/frame, and 0.7-1.1 ms/frame of
those sleeps end within 0.3 ms of the apply thread's throttle ending. So the chain is: display, then
GPU, then the apply thread's `queueBuffer`, then the present credit, then the GL thread.
This explains the HANDOFF's "about 0.3 ms per frame beyond the apply CPU is unexplained". It is not
CPU. The apply thread's frame is its CPU plus this throttle, and the throttle grows as the presenting
thread gets faster, because the release is locked to the display and 1.3 ms of GPU path is chained
after it. Present credit 2 helps for the same reason (+3-7 % measured in HANDOFF): it lets the GL
thread run on while the apply thread sits in the throttle.
## MobileGlues control
```
MobileGlues
render thr =====A cpu==d=S =====B cpu==d=S ~~~~~~~~~~~wait~~~~~~~~~~~
display v R
GPU (FCL) .............A held............++++st+++##A####B###
fence A E
```
MobileGlues has the identical mechanism: the same lazy dequeue just before the swap, the same
whole-frame batch at `eglSwapBuffers`, and the same 47 % gated frames. Its offsets:
1. **-0.24**: A dequeues.
2. **0**: A swaps. `queueBuffer` comes 0.29 ms into `eglSwapBuffers`, which spends about 0.3 ms
before queueing.
3. **1.60**: B dequeues.
4. **2.08**: B throttles.
5. **3.13**: R_A.
6. **4.48**: E_A, which is R + 1.35 (0.87 start latency + 0.48 execution).
The throttle is 1.12 ms/frame: display before release 0.59, GPU after release 0.52. That matches the
1.4 ms/frame off-CPU seen in simpleperf. MobileGlues waits more than MobileGL monolith only because
its CPU frame is shorter (1.95 ms against 2.9-3.4 ms), so B reaches the gate earlier. Its GPU per
frame is the same: 0.48 ms back to back, against 0.50-0.56 for MobileGL.
## Why CPU cuts are partly absorbed
Across the arms, frame time is the presenting thread's CPU plus the throttle, and the throttle grows
as the CPU shrinks:
- Espryt monolith: CPU 3.35 + wait 0.61 = 4.00;
- Magma monolith: CPU 2.86 + wait 0.71 = 3.60;
- Espryt inproc: CPU 2.04 + wait 1.08 = 3.18;
- MobileGlues: CPU 1.95 + wait 1.12 = 3.07;
- Magma inproc: CPU 1.53 + wait 1.28 = 2.93.
CPU comes from `sched` over the trace window. At the monolith operating point about 80 % of a CPU
saving reaches frame time (Espryt to Magma: 0.49 less CPU gives 0.40 less frame). At the
inproc/MobileGlues point only about a third does (MobileGlues to Magma inproc: 0.42 less CPU gives
0.14 less frame).
The e70925d3 simpleperf numbers fit the same trend: Espryt has 3.08 ms on CPU and 0.82 off CPU in
Present; Magma has 2.63 and 1.03. The faster CPU waits more.
## Options (portable), with the effect read off the timeline
The effects come from `sim.py`. It is an in-order GPU queue model replayed on the measured CPU
schedule: start latency + execution from `gexec.py`, and each frame's measured release time. Its base
scenario reproduces the measured throttle within 0.01-0.03 ms/frame on all five arms. The results are
first-order: the CPU schedule is held fixed, so phase feedback is not modelled.
1. **One or two more swapchain images (Magma).** Request `surface minImageCount + 1` (or + 2) instead
of `max(FIF, minImageCount)` = 5. Then the buffer the display has just released goes to the back
of the FIFO free list and is reused one (or two) frames later, by which time its release fence has
usually signaled.
- In the current traces, a buffer reused k frames later at the CPU-bound cadence would still be
gated in:
- Magma monolith: 16 % of frames at k=1, 3 % at k=2 (50 % today);
- Espryt monolith: 21 % at k=1, 0 % at k=2;
- Magma inproc: 40 % at k=1, 23 % at k=2, 8 % at k=3.
- First-order effect: Magma monolith's throttle goes from 0.71 to about 0.0 ms/frame, so the frame
drops from 3.60 ms toward the CPU's 2.9 ms. Treat this as an upper bound; the faster schedule
reuses buffers sooner.
- Inproc needs +2 or +3.
- Cost: one 2560x1600 RGBA buffer (about 16 MB) per image. MAILBOX adds no latency.
- This is a real trade-off (memory), so A/B the count.
- Espryt has no NDK-public way to set an EGL window's buffer count. The private `ANativeWindow`
perform call or ASurfaceControl would need the user's greenlight under the platform-agnostic
rule.
2. **Gate only the window pass (split the frame's submission).**
- Magma:
- submit the offscreen work recorded so far without the image-available semaphore, at least once
before the swapchain image is first touched;
- attach the acquire wait only to the submit that contains the first swapchain-image access (the
final blit and present transition), not to the frame's first submit.
- Espryt: `glFlush` at the first default-framebuffer bind of a frame, just before the driver's lazy
dequeue. The offscreen work is then submitted with no release sync object in front of it.
- Effect: throttle 0.62 to 0.49 (Espryt monolith), 0.72 to 0.54 (Magma monolith), 1.31 to 1.09
(Magma inproc), 1.09 to 0.91 (Espryt inproc).
- The gain is small because the 0.8 ms GPU start latency is paid again for the final pass after
the release.
- It is the only portable lever for Espryt. With option 1 on top, the model gives about 0 on all
arms.
3. **Take the throttle off the GL thread.**
- Inproc: present credit 2 (already measured at +3-7 %; it costs a frame of latency, so it is the
user's decision).
- Magma monolith: the equivalent is a present thread that issues `vkQueuePresentKHR` off the GL
thread, with the same latency trade.
- Espryt monolith cannot do this: `eglSwapBuffers` stays on the context thread.
4. Not recommended:
- keeping the GPU awake to hide the 0.8 ms start latency (a power trade, not portable);
- anything in SurfaceFlinger or vsync.
## What a fresh e70925d3 trace should confirm
Run the scripts in `p15/pwait/` on the new run directories:
- `cycle.py <label> <runs...>`
- `pairs.py`
- `gexec.py`
- `sim.py <label> <start> <exec> <runs...>`
Expected on base e70925d3:
- gated frames about 50 %;
- throttle about 0.8 ms/frame (Espryt) and about 1.0 (Magma), matching simpleperf's Present off-CPU;
- 99+ % of the throttle after gated frames;
- R 0.24 ms after `crtc_event`, with `kgsl_hwsched` at R;
- E - R about 1.3-1.4 ms for gated frames, with back-to-back execution about 0.5 ms.
For a CPU-only change (the TLS agent's): frame time should drop by about 0.8 x the CPU saving at the
monolith point, with the throttle rising by the rest. If it does not rise, the model is wrong.
For the change in option 1:
- `HWC release fence N has signaled` should appear at 85 % or more of `AcquireNextImageKHR`;
- gated frames below 20 %;
- throttle below 0.2 ms/frame (monolith).
For the change in option 2: E - R for gated frames should fall from about 1.35 to about 0.9 ms (start
latency + final pass), and back-to-back execution should not change.
Config notes:
- The `kgsl/adreno_cmdbatch_*`, `adreno_syncobj_*` and `kgsl_waittimestamp_*` ftrace events in
`perfetto.cfg` are not recorded on this kernel (`ftrace_setup_errors` = 43 in every trace). Drop
them, or list `/sys/kernel/tracing/events/kgsl/` for the kgsl hardware-scheduler event names.
- `gpu.renderstages` does work on this device: `runs/gpu-bsl/*/gpu.pftrace` has Render/Surface/Blit
stages. One extra capture with it would split the 0.8 ms start latency from execution directly. Its
overhead should be A/B'd before using it in a perf capture.
- Keep atrace `gfx`: the `GPU completion` / `HWC release` FenceMonitor threads only exist while it is
on.
- MobileGL emits no atrace markers. A marker at the frame's flush/submit points and at the first
default-framebuffer bind would make option 2 directly visible.
## Files
All under scratchpad `p15/pwait/`:
- `tp.py`: trace_processor wrapper, cached;
- `pw.py`: per-frame alignment of S, D, R, W0/W1 and E;
- `cycle.py`: attribution and the cycle medians;
- `pairs.py`, `gexec.py`, `gapcost.py`, `reuse.py`, `wakelat.py`, `glchain.py`;
- `sim.py`: the counterfactuals;
- `win.py`, `seq.py`: raw windows;
- `diag.py`, `mkdiag.py`: the diagrams;
- outputs in `out/`.
+287
View File
@@ -0,0 +1,287 @@
# P15 scoreboard: FCL MC 1.21.5 vanilla at cpuhunt
One row per bench session. MobileGlues (plugin `com.fcl.plugin.mobileglues`) is the only control
measured in every session. Results are reported as fps ratio to MobileGlues. "vs dev" is derived
through the fixed dev reference below: `vs dev = (arm / MobileGlues) / (dev / MobileGlues)`.
Targets (PLAN-P15 §0.1):
- Monolith at or above dev, then on par with MobileGlues (ratio 1.00).
- Inproc substantially above MobileGlues.
## Dev reference (fixed)
Re-measure only when the scene, clock profile, MC version, FCL build or harness changes.
Measured in session safter (2026-10-08 ~22:00) on harness H2 at cpuhunt (CPU 1.50/1.25 GHz, GPU 903 MHz). All
15 runs were VALID, with no throttling (tpl=0 thr=0) and peak CPU 63 C. dev = 08124c99 (perf-dev worktree, `libs/devsym`). The table gives
3 interleaved reps per arm; CPU is the GL thread's schedstat time.
| arm | fps (r1 / r2 / r3) | mean fps | ratio to MG | CPU ms/frame |
|---|---|---|---|---|
| MobileGlues | 318.8 / 325.1 / 320.5 | 321.5 | 1.000 | 1.70 |
| dev Espryt monolith | 297.1 / 277.3 / 281.0 | 285.1 | **0.887** | 2.38 |
| dev Magma monolith | 313.8 / 294.5 / 308.4 | 305.5 | **0.950** | 2.01 |
- **vs dev for a session row:** Espryt = ratio / 0.887, Magma = ratio / 0.950.
- **CPU reference:** dev Espryt 2.38 ms/frame (1.40 of MG), dev Magma 2.01 ms/frame (1.18 of MG).
- **Dev reps spread more than the other arms** (6-7 % vs 1-3 %): dev's warmup needed 2-5 windows to settle where p15s and MobileGlues needed 2. The mean of the three reps is the reference.
- **Function-level baseline:** one symbolized simpleperf profile per dev backend, taken after the measurement windows in the same runs: `runs/safter/dev-Direct{Vulkan,GLES}-r{1,2,3}/perf.data`. See [MONOLITH-DIFF.md](MONOLITH-DIFF.md).
## Harnesses
- **H1 (old probe, through fifi):**
- Not pinned: the scheduler gave MobileGL's monolith render thread the X4 core 72-90 % of the
time and MobileGlues' 47-60 %. MobileGlues' fps tracked its X4 share (fifi: 60 % -> 378, 47 % ->
344).
- fps sources differ by arm: MobileGL arms used the MobileGL fps log before tracing; MobileGlues
used the ftrace window.
- Unfrozen world: daylight cycle on, and time advanced between runs through autosaves.
- 2 reps per arm.
- **H2 (`fcl_bench.sh`, from safter):**
- FCL is pinned to cpu2-6 (the A720 cluster) after world entry.
- fps for every arm comes from the SurfaceView BLAST layer's frame number in SurfaceFlinger.
- The same warmup for every arm: 20 s, then 5 s windows until two consecutive ones agree within
3 %.
- Measurement: two 5 s windows with no tracer running. Per-thread CPU comes from schedstat over
those windows.
- Frozen save: no daylight, weather or mob-spawn cycle, random ticks off, DayTime 6000.
- 3 interleaved reps per arm.
- H2 absolute fps is lower than H1 because nothing runs on X4. Compare H2 rows only with H2
rows.
## Sessions
Each cell is the fps ratio to MobileGlues, with presenting-thread CPU in ms/frame in brackets.
- Monolith: the CPU is the GL thread.
- Inproc: the CPU is the apply thread (it presents). The H1 rows use the MobileGL fps log's
"presenting thread CPU".
- MobileGlues (MG) cells give fps and CPU.
- A dash means the arm was not in that session.
| session (2026-10-08) | harness | build | MG fps (cpu) | mono Espryt | mono Magma | inproc Espryt | inproc Magma |
|---|---|---|---|---|---|---|---|
| hunt2 14:20 | H1 | p15l ≈ c8a5abe5 | 335.0 (1.58) | 0.80 (2.19)¹ | 0.79 (2.18)¹ | 0.87 (1.63) | 0.92 (1.60) |
| apab 14:51 | H1 | p15m ≈ 500b63ea | 328.6 (1.55) | 0.86 (2.06) | 0.85 (1.96) | 0.90 (1.65) | 0.91 (1.58) |
| blab 16:17 | H1 | p15n/p15o = c07b8c40 | 354.9 (1.46) | 0.84 (2.02)² | - | 0.95 (1.58) | 0.94 (1.53) |
| nxab 17:04 | H1 | p15p = 61b5eb5a | 375.5 (1.43) | 0.81 (1.95) | 0.84 (1.77) | 0.93 (1.54)³ | 0.89 (1.54) / 0.93³ |
| cens 18:09 | H1 | p15r = e00db8e6 | 321.9 (1.57) | - | - | 0.93 (1.50) / 0.99³ | 0.96 (1.46) / 0.99³ |
| fifm 20:07 | H1 | p15s = 0b96a3ef | 361.4 (1.48) | 0.82 (1.98) | 0.84 (1.84) | - | - |
| fifi 20:47 | H1 | p15s = 0b96a3ef | 361.1 (1.47) | - | - | 0.96 (1.37) | 0.94 (1.39) |
H2 sessions:
- Cells are the fps ratio to MG, then vs dev, then GL-thread CPU in ms/frame.
- Inproc cells add the apply-thread CPU.
| session (2026-10-08) | build | MG fps (cpu) | mono Espryt | mono Magma | inproc Espryt | inproc Magma |
|---|---|---|---|---|---|---|
| safter ~22:00 | p15s = 0b96a3ef | 321.5 (1.70) | 0.746 / 0.84 dev (3.18) | 0.768 / 0.81 dev (2.91) | - | - |
| pt ~23:00 | p15t = 3def5cb2 (p15s + Magma blit cache); inproc Magma also p15s | 319.0 (1.69) | 0.755 / 0.85 dev (3.17) | 0.787 / 0.83 dev (2.83) | - | p15s 1.019 (1.36 / 1.42); p15t 1.032 (1.37 / 1.39) |
| c1 ~00:30 (10-09) | t = p15t; u = p15t + cut 1 (in-frame uploads, local) | 324.8 (1.69) | - | t 0.782 / 0.82 dev (2.80); u 0.769 / 0.81 dev (2.86) | u 0.997 (1.38 / 1.63) | u 1.011 (1.37 / 1.39) |
| c1b ~02:10 (10-09) | t = p15t; v = p15t + 1b (coalesced pass barriers, local) | 320.9 (1.69) | - | t 0.783 / 0.82 dev (2.85); v 0.789 / 0.83 dev (2.85) | - | v 1.048 (1.34 / 1.345) |
| c4 ~02:55 (10-09) | v (as c1b); w = v + cut 4 (Espryt surface-size memo, 66e3b2c1) | 321.6 (1.70) | v 0.757 / 0.85 dev (3.18); w 0.762 / 0.86 dev (3.05) | - | - | - |
| c1c2 ~03:30 (10-09) | t = p15t; y = p15t + 1b + 1c (deferred clears) + cut 4 | 321.3 (1.70) | - | t 0.795 / 0.83 dev (2.83); y 0.785 / 0.82 dev (2.74)⁴ | - | t 1.025 (1.35 / 1.41)⁵; y 1.076 (1.33 / 1.24) |
| fbm ~05:20 (10-09) | y (as c1c2); z = y + FB-state build memo, one entry per target | 321.7 (1.70) | y 0.770 / 0.87 dev (3.04); z 0.775 / 0.87 dev (3.04) | y 0.818 / 0.86 dev (2.65); z 0.831 / 0.87 dev (2.65) | - | - |
| fbm2 ~11:00 (10-09) | y; z (as fbm); h = y + batch h (485dff14 + c85c9439) | 319.7 (1.68) | y 0.763 / 0.86 dev (3.03); h 0.768 / 0.87 dev (3.00) | y 0.805 / 0.85 dev (2.68); z 0.798 / 0.84 dev (2.69); h 0.812 / 0.85 dev (2.62) | - | - |
| lto ~17:30 (10-09) | o = ca0a3b74 + 2a/2b, -Pmobilegl.enableLto=OFF; l = the same, LTO ON (default) | 314.1 (1.71) | o 0.794 (2.99); l 0.800 (2.90) | o 0.850 (2.52); l 0.907 (2.36) | - | - |
| api29 ~19:00-21:30 (10-09) | a26 = 0650608d + e543e289 (default, API 26); a29 = the same tree, -Pmobilegl.androidApi=29 (42922d21); both LTO ON | 324.6 (1.67) | a26 0.771 (2.87); a29 0.777 (2.85) | a26 0.874 (2.33); a29 0.910 (2.26) | a26 0.998 (1.27 / 1.53); a29 1.013 (1.22 / 1.50) | a26 1.088 (1.23 / 1.16); a29 1.136 (1.15 / 1.09) |
| tls ~22:00 (10-09) | b = origin e70925d3 (libs/egc); t = tlshoist d4a00835 (libs/tls1); both LTO, API 26 | 318.6 (1.67) | b 0.805 (2.84); t 0.812 (2.79) | b 0.878 (2.35); t 0.933 (2.21) | - | - |
- **pt:** the blit view cache gives Magma inproc +1.2 % fps, with apply −0.03 ms/frame.
- **c1:** cut 1 is within noise (−1.7 % fps, +0.06 ms). It engaged (the mid-frame submit is gone) but saves ≤0.04 ms; see MONOLITH-DIFF.md.
- **c1b:** neutral in monolith on CPU and on GPU (busy 29 % in both). Barriers fell from 27.5 to 15.5 per frame, but passes only from 12.6 to 11.5.
- **c1c2:** Magma per frame, from the counting build:
- passes 11.5 -> 4.3 (dev 4.1);
- barriers 15.5 -> 9.0 (dev 3.4);
- Vulkan calls 343.5 (dev 331.6).
Effect:
- Monolith GL-thread CPU −0.09 ms/frame (2.83 -> 2.74); fps within noise.
- Inproc apply thread −0.17 ms/frame (1.41 -> 1.24) and fps +5.0 % (329.5 -> 345.7).
- GPU busy: monolith 30 -> 27 % (≈1.18 -> 1.07 GPU ms/frame); inproc 35 -> 33 % (≈1.06 -> 0.96).
- Profile: the `glClear` entry fell 0.286 -> 0.098 ms/frame. Part of that pass begin moved into draws (DrawArrays +0.07).
⁴ y has 2 valid reps: r2 never reached the world after 3 startup deaths (signal 34 during bootstrap, a harness flake also seen on MobileGlues and other builds).
⁵ t inproc r2 is discarded: a host-side `binary_cache_builder` pulled libraries over adb inside its measurement window.
- **fbm2:** batch h moves GL CPU by -0.06 ms (Magma) and -0.03 ms (Espryt).
- Batch h: per-framebuffer FB-state memo, handle hints, per-buffer handle reuse, the cached per-verb
gate, and the Magma hash TLS hoist.
- The Magma before/after profile (render thread, ms/frame, c1c2 y-r1 -> fbm2 h-r1):
- MGPipeValidateForVerb 0.328 -> 0.282, BuildFramebufferState 0.058 -> 0.023;
- FindByLifetimeId + Acquire 0.047 -> 0.003, __emutls_get_address 0.079 -> 0.054;
- GetOrCreatePipeline 0.026 -> 0.013, MGPipeGetResourceOps 0.007 -> 0.002.
- The H2 effect is about half of the profile sum. Each piece is below the session noise (+-0.05 ms),
so the batch is measured as one.
- **lto:** ThinLTO + -O3 + ICF/gc/no-semantic-interposition (190580f2) takes GL CPU from 2.52 to 2.36 ms on
Magma (fps 267 -> 285) and from 2.99 to 2.90 on Espryt. All runs VALID.
- Both backends load and render in FCL (one screenshot each, runs/lto-shot).
- Exported GL/EGL/JNI/vk symbols are identical (2973). LTO drops 3323 internal 3rdparty C++ exports.
- libMobileGLServer.so links and its only libMobileGL import (mobilegl_server_main) is exported.
- **api29 (cpuhunt, vanilla 1.21.5 frozen world, 3 interleaved reps, one bench session per rep with the arm order rotated, 27 of 27 runs VALID):**
API 26 (shipped, emulated TLS) against API 29 (separate artifact, native ELF TLS), the same tree, both LTO ON.
- Libs: api26 `b843b121...`, 0 TLSDESC relocs, 98 `__emutls_v.*` symbols; api29 `1f2ec4a0...`, 95 TLSDESC relocs, a PT_TLS segment, 3 `__emutls_v.*` (libc++abi). Both load and render in FCL.
- fps, mean of 3 (api26 -> api29, ratio) and GL / apply thread CPU ms/frame:
| arm | fps 26 | fps 29 | 29/26 | GL cpu 26 -> 29 | apply cpu 26 -> 29 |
|---|---|---|---|---|---|
| Magma monolith | 283.7 | 295.5 | 1.041 | 2.33 -> 2.26 (0.970) | - |
| Magma inproc | 353.1 | 368.6 | 1.044 | 1.23 -> 1.15 (0.930) | 1.16 -> 1.09 (0.945) |
| Espryt monolith | 250.2 | 252.2 | 1.008 | 2.87 -> 2.85 (0.994) | - |
| Espryt inproc | 324.0 | 328.7 | 1.015 | 1.27 -> 1.22 (0.966) | 1.53 -> 1.50 (0.978) |
| MobileGlues (control) | 324.6 (1.67 ms) | | | | |
- Per-rep fps: Magma mono 277.5 / 291.6 / 282.2 vs 298.5 / 286.2 / 301.9 (rep 2, where api29 ran first, is the one rep it lost by 1.9 %); Magma inproc 351.9 / 354.9 / 352.4 vs 365.3 / 374.6 / 365.9 (api29 ahead in every rep); Espryt mono 251.9 / 249.1 / 249.4 vs 253.6 / 248.0 / 255.1; Espryt inproc 327.1 / 314.9 / 329.9 vs 324.1 / 326.6 / 335.3.
Spread (max-min)/mean is 0.8-5.3 %: the Magma inproc gain (+4.4 %, spread 0.8 / 2.5 %) is outside it, Magma monolith (+4.1 %, spread 5 %) is about at it, both Espryt gains are inside it.
- Device state, every run: CPU 1497 (cpu2-6) / 1248 (cpu0) / 1478 (cpu7) MHz, GPU 903 MHz, samples inside the measure windows only; tpl 0, throttling 0, no "max capped"; peak over the 27 runs CPU 62.8 C, GPU 56.2 C, skin 43.9 C; daemons stopped during a session and restored after (5 running again, max clocks back to stock); swap=false; anland off; FCL pinned to cpu2-6 (taskset 7c); cooldown to battery <= 33.0 C before each session.
- Simpleperf, one run per cell (monolith render thread, 6 s, cpu-clock 4000 Hz; `runs/api29ab-sp`). The share of TLS access in the render thread's on-CPU time:
| cell | on-CPU ms/frame | TLS symbol | ms/frame | share |
|---|---|---|---|---|
| Magma api26 | 2.546 | `__emutls_get_address` | 0.052 | 2.1 % |
| Magma api29 | 2.501 | `tlsdesc_resolver_dynamic` (linker64) | 0.051 | 2.1 % |
| Espryt api26 | 3.016 | `__emutls_get_address` | 0.058 | 1.9 % |
| Espryt api29 | 3.259 | `tlsdesc_resolver_dynamic` (linker64) | 0.047 | 1.4 % |
- Reading:
- API 29 does not remove the TLS cost of the monolith render thread. MobileGL is dlopen'ed, so bionic resolves each TLSDESC through the linker's dynamic resolver (`tlsdesc_resolver_dynamic`), a call that costs about what `__emutls_get_address` did (0.05 ms/frame, about 2 % of the thread). The native-TLS switch is therefore not the source of the Magma gain; whatever it is (code layout and codegen of a different link, or the android-29 platform), this A/B does not isolate it.
- Untested lead for a real TLS saving: a static TLS model (initial-exec) for the hot variables. Bionic's room for static TLS in a dlopen'ed library is limited, so it needs its own measurement.
- The Espryt monolith profile run read 242.6 / 245.4 fps against 252.2 / 254.0 for api26, opposite to the 3-rep means; it is one run, the 3 interleaved reps decide.
- **tls (cpuhunt, 3 interleaved reps, all 15 runs VALID, tpl=0 thr=0, peak CPU 57.7-61.3 C):** hot-path
TLS cut (tlshoist: constinit pointer slots for pGLContext and gPipeInputs, one-block thread_local caches,
inline Magma session read). Emulated-TLS calls per frame (counting build, run tlsdiag): Magma 9111 -> 4336,
Espryt 7585 -> 3149.
- fps r1 / r2 / r3: Magma b 285.6 / 275.4 / 277.8 (279.6), t 295.1 / 301.4 / 295.2 (297.2, +6.3 %);
Espryt b 269.5 / 251.9 / 248.4 (256.6), t 260.6 / 270.6 / 245.2 (258.8, +0.9 %); MobileGlues 318.6.
- GL CPU (schedstat): Magma 2.35 -> 2.21, Espryt 2.84 -> 2.79 ms/frame.
- `__emutls_get_address` on the render thread (simpleperf, mean of 3 reps): Magma 0.058 -> 0.034,
Espryt 0.049 -> 0.035 ms/frame. Magma's MobileGL-side total falls more than that (-0.04 to -0.20 per
rep): the callers lose the init-wrapper/guard calls and spills too.
- A second session (tlspf, Perfetto, no simpleperf, 12 runs VALID) read Magma 278.6 -> 284.4 fps
(CPU 2.40 -> 2.30) and Espryt 246.2 -> 254.5 (2.94 -> 2.83). Traces in `runs/tlspf/*/p15.pftrace`,
not analysed yet.
- **bsl3 (gpuhunt, stopped on a CPU max cap in rep 2):** r1 Magma 55.6, Espryt 52.8, MobileGlues 57.2 fps.
That is Magma 0.97 and Espryt 0.92 of MobileGlues.
- **c1cbsl (gpuhunt, Iris + BSL, after a cooldown, 3 reps):** 1c does not cost GPU time.
- VALID runs: t 53.8 / 53.9 fps vs y 55.7 / 55.5 (+3.4 %), all at 100 % GPU busy (18.5 -> 17.9 GPU ms/frame).
- MobileGlues read 56.2 / 55.7 / 56.1, which puts Magma y at about 0.99 of it. All three MobileGlues
runs (and t r2, y r2) are INVALID for one reason: the freq sampler's first sample, about 40 s
before the windows, catches the idle GPU at 231 MHz. Every in-window sample of every run is at
the 578 MHz pin.
- A window-scoped validity check (freqcheck over the measure_raw.txt span) would admit them. That
is a harness change, not yet made.
- **ebbsl (gpuhunt, Iris + BSL, Espryt monolith, 3 reps, one arm per cooldown, all VALID):** the two parked
Espryt GPU items (native depth glCopyImageSubData, attachment shadow) do not help. Builds: x = origin
9f610167 + the items, b = origin 9f610167, both LTO; MobileGlues is the plugin.
- fps r1 / r2 / r3: x 51.4 / 51.3 / 51.5 (mean 51.4), b 52.7 / 51.8 / 51.0 (51.9), MobileGlues 56.5 / 55.6 / 55.3 (55.8).
Ratio to MobileGlues: x 0.921, b 0.930 (x vs b -1.0 %, noise). Target 0.95 not reached.
- GPU: busy 100 % in every run; union of kgsl cmdbatch intervals per frame (x / b / MobileGlues)
19.45 / 19.29 / 17.88 ms, 1.04 cmdbatches per frame in all three.
- Device state: gpuhunt (CPU 2380/1689 MHz, GPU 578 MHz; in-window min = max for every policy), tpl=6
thr=0, peak CPU 75.5-79.4 C, GPU 63.2-65.9 C, skin 42.4-44.5 C, daemons stopped(5), swap=false, anland off.
- Engagement (one simpleperf run each, render thread): `BlitDepthTexture2D` 0.100 ms/frame in b, gone in x;
Espryt `CopyImageSubData` 0.115 -> 0.072; `SyncToBackendByHandle` 0.178 -> 0.162.
- Vanilla cpuhunt (1500/1250/903 MHz, 3 reps, all VALID, peak CPU 58 C): Espryt monolith GL CPU x 2.87,
b 2.83 ms/frame; fps x 249.9 / 251.4 / 244.2 (248.5), b 250.1 / 256.5 / 255.2 (254.0), GPU busy 17 %.
- Not landed: wip/espryt-depthcopy-measured. The BSL frame is GPU-bound and its GPU time did not move.
- **fbm:** the first memo is within noise on both backends (CPU 2.65 / 2.65 Magma, 3.04 / 3.04 Espryt).
- It engaged only partly: Magma BuildFramebufferState 0.058 -> 0.032 ms/frame, and Espryt kept missing.
- The build only runs on a binding switch, so one entry per target misses on every A/B/A switch.
Batch h makes it per framebuffer.
- Session noise: y Magma r3 read 2.54 against 2.70-2.72 in r1/r2, with nothing in its state to explain it.
- **c4:** Espryt GL-thread CPU fell 0.13 ms/frame (3.18 -> 3.05 in all three reps); fps moved by less than the noise.
The profile confirms it: QueryCurrentSurfaceSize 0.070 -> 0.012 and SyncRenderState 0.092 -> 0.028 ms/frame.
**Thread state, Perfetto SQL** (c1, H2; `pftstate.py` over `trace_processor_shell` v58.2 on the
`.pftrace` taken after the windows; means of 3 reps; ms/frame):
| arm | fps | GL run | GL woken-wait | GL preempted | GL sleep | apply run | apply sleep | both on-CPU / neither |
|---|---|---|---|---|---|---|---|---|
| MobileGlues monolith | 324.8 | 1.91 | 0.036 | 0.030 | 1.05 | - | - | - |
| Magma monolith (t) | 254.1 | 3.09 | 0.042 | 0.027 | 0.71 | - | - | - |
| Magma monolith (u) | 249.8 | 3.05 | 0.045 | 0.045 | 0.79 | - | - | - |
| Magma inproc (u) | 328.3 | 1.43 | 0.047 | 0.073 | 1.45 | 1.61 | 1.31 | 41 % / 41 % |
| Espryt inproc (u) | 323.8 | 1.39 | 0.057 | 0.088 | 1.51 | 1.95 | 1.02 | 42 % / 34 % |
| c1c2: MobileGlues monolith | 321.3 | 1.95 | 0.039 | 0.019 | 1.05 | - | - | - |
| c1c2: Magma monolith (t) | 255.3 | 3.11 | 0.039 | 0.038 | 0.66 | - | - | - |
| c1c2: Magma monolith (y, 1c) | 252.3 | 3.07 | 0.047 | 0.029 | 0.75 | - | - | - |
| c1c2: Magma inproc (t) | 329.5 | 1.38 | 0.050 | 0.073 | 1.48 | 1.58 | 1.32 | 40 % / 42 % |
| c1c2: Magma inproc (y, 1c) | 345.7 | 1.39 | 0.043 | 0.079 | 1.33 | 1.43 | 1.31 | 39 % / 42 % |
The sleeps break down as:
- Monolith (both stacks): the app's `waitForever` slice inside queueBuffer, woken by `kgsl-events`, i.e. the GPU fence of the previous frame.
- Inproc GL thread: woken by `mgl-srv-apply`.
- Inproc apply thread: `waitForever` (the GPU fence), as in monolith.
The table below is the same window from the ftrace text (`threadstate.py`). It carries GPU busy, because this Perfetto config does not record the kgsl events.
| arm | GL thread on-CPU | preempted | sleeping (main reason) | apply thread on-CPU | apply sleeping | both on-CPU / neither | GPU busy |
|---|---|---|---|---|---|---|---|
| MobileGlues monolith | 61 % (1.88) | 0.03 | 37 %: present fence `waitForever` 1.13 | - | - | - | 30 % |
| Magma monolith (p15t) | 78 % (3.08) | 0.03 | 20 %: present fence 0.78 | - | - | - | 29 % |
| Magma inproc (u) | 47 % (1.42) | 0.11 | 48 %: woken by the apply thread 1.45 | 52 % (1.59) | present fence 1.30 | 40 % / 41 % | 36 % |
| Espryt inproc (u) | 47 % (1.45) | 0.10 | 48 %: woken by the apply thread 1.47 | 63 % (1.95) | present fence 1.07 | 44 % / 34 % | 30 % |
What the table shows:
- Monolith Magma is CPU-bound: the GL thread is on-CPU 78 % and preemption is negligible.
- MobileGlues finishes its CPU work sooner, then waits on the present fence.
- Inproc is bounded by present-fence latency at credit 1, not by CPU: the apply thread waits on the fence while the GL thread waits on the apply thread, and for 34-41 % of the time neither runs. The GPU is only 30-36 % busy.
Sources:
- `.pftrace` captures for the Perfetto UI are in `runs/c1/*/p15.pftrace`.
- The numbers come from the same window's ftrace text via `threadstate.py`: no trace processor is installed.
H2 spread, measured as (max - min) / mean over the 3 interleaved reps of each arm:
- **sbefore (H1 probe, same day, 3 reps):** Espryt 288.6 / 287.7 / 315.2 (9.3 %), Magma 298.0 / 295.0 / 312.0 (5.6 %), MobileGlues 370.2 / 374.7 / 375.1 (1.3 %).
- **safter (H2):** Espryt 240.2 / 240.8 / 237.9 (1.2 %), Magma 245.3 / 251.3 / 244.1 (2.9 %), MobileGlues 2.0 %, dev 6-7 %.
- **The X4 core hid part of the gap:** on the A720 cluster, p15s is 0.84 (Espryt) and 0.81 (Magma) of dev. In CPU, that is +0.80 and +0.90 ms/frame over dev.
Notes:
1. hunt2 monolith comes from the profiled sub-run (hunt2-prof, simpleperf in the window), so it
is not the same sub-session as its MobileGlues control. Dev in that sub-run: Espryt 305.3
(1.64), Magma 302.2 (1.59), that is 0.91 / 0.90 of hunt2's MobileGlues.
2. blab monolith Espryt is p15n (p15o has no monolith arm in blab).
3. Present credit 2 (`MOBILEGL_IPC_PRESENT_CREDIT=2`); the default credit is 1. The FIF sweep
(fifm/fifi, FIF 2/3/4) showed no significant effect; FIF 3 is the default and is the column
shown.
H1 spread: two reps of the same arm differ by up to 10 % within a session (fifi MobileGlues 378.4
/ 343.8, apab p15m Magma monolith 289.3 / 266.6). MobileGlues ranged from 322 to 376 across
sessions. H1 ratios therefore carry roughly ±5 %.
## egc: global-constants key (e70925d3) vs 0650608d, monolith, cpuhunt, vanilla frozen world
Baseline b = 0650608d, x = e70925d3 (both LTO-ON, API 26), FCL on cpu2-6, simpleperf on the render thread, 3 interleaved reps per arm, all 12 runs VALID (clocks pinned in the windows, tpl=0 thr=0, daemons stopped, swap off). EmitGlobalConstants is inlined under LTO, so its cost is every sample with an EmitGlobalConstants inline frame (llvm-symbolizer --inlines); ValidateForVerb is inclusive.
| backend | arm | fps | GL CPU ms/frame | ValidateForVerb ms/frame | EmitGlobalConstants ms/frame |
|---|---|---|---|---|---|
| Magma | b | 279.4 | 2.39 | 0.190 | 0.0220 (0.021 / 0.025 / 0.020) |
| Magma | x | 274.6 | 2.38 | 0.194 | 0.0142 (0.016 / 0.013 / 0.013) |
| Espryt | b | 249.6 | 2.85 | 0.215 | 0.0214 (0.022 / 0.020 / 0.022) |
| Espryt | x | 252.8 | 2.82 | 0.194 | 0.0136 (0.013 / 0.014 / 0.014) |
EmitGlobalConstants drops by 0.0078 ms/frame on both backends (about 35 %), inside the expected 0.007-0.010. The whole frame (fps, GL CPU, ValidateForVerb) is within noise: ValidateForVerb varies 0.17-0.22 between reps of one arm.
## pwab: present-wait levers before/after, cpuhunt, vanilla frozen world (2026-10-10)
Before = a759b4b7. After = pwgate cdd2160f (lever A) + pmflush eec5e6e8 (cherry-picked on cdd2160f); Magma "after" also has `MOBILEGL_MAGMA_EXTRA_SWAPCHAIN_IMAGES=2` (lever B). All libs LTO-ON, API 26 plugin release (`libs/pwbase`, `libs/pwAF`, `libs/pwA`, `libs/pwF`). Harness H2 (`fcl_bench.sh`), FCL on cpu2-6, 20 s warmup then 5 s windows until stable within 3 %, two 5 s measurement windows, no tracer. 3 interleaved reps in one bench session each (arm order rotated, battery <= 33.0 C before each session), thermal daemons stopped, swap interval 0, anland off. All 26 measured runs VALID (CPU pinned 1497/1248 MHz, GPU 903 MHz, tpl=0 thr=0). Espryt monolith "before" has reps 1 and 3 only: rep 2 was NO WORLD (FCL never reached the world in 4 launches) and was not re-run, by user decision.
Inproc first (the wanted numbers). fps = mean of the two windows; ratio is to MobileGlues' mean in the same sessions (315.7 fps; 305.6 / 320.7 / 320.9; CPU 1.69 ms/frame).
| arm | fps r1 / r2 / r3 | mean | after / before | ratio to MG | GL-thread CPU | apply-thread CPU |
|---|---|---|---|---|---|---|
| Magma inproc before | 334.1 / 359.6 / 378.8 | 357.5 | | 1.132 | 1.19 | 1.12 |
| Magma inproc after (AF + extra 2) | 442.2 / 478.9 / 494.6 | 471.9 | **1.32** (1.32 / 1.33 / 1.31 per rep) | **1.495** | 1.13 | 1.12 |
| Espryt inproc before | 302.1 / 332.9 / 325.8 | 320.3 | | 1.014 | 1.26 | 1.54 |
| Espryt inproc after (AF) | 323.0 / 366.4 / 354.5 | 347.9 | **1.09** (1.07 / 1.10 / 1.09) | **1.102** | 1.27 | 1.49 |
| Magma monolith before | 251.2 / 300.0 / 282.1 | 277.8 | | 0.880 | 2.39 | |
| Magma monolith after (AF + extra 2) | 352.9 / 390.6 / 369.9 | 371.2 | **1.34** (1.41 / 1.30 / 1.31) | **1.176** | 2.22 | |
| Espryt monolith before | 238.2 / NO WORLD / 252.9 | 245.6 (r1, r3) | | 0.778 | 2.89 | |
| Espryt monolith after (AF) | 260.3 / 300.0 / 288.8 | 283.0 | **1.12** on r1+r3 (1.09 / 1.14), 1.15 on all reps | **0.896** | 2.70 | |
- Reps drift upward with time (MobileGlues 305.6 -> 320.9 over the three sessions), so compare per rep. The after/before ratio is stable within a backend (Magma 1.30-1.41, Espryt 1.07-1.14).
- Engagement, from logcat in every Magma after run (mono and inproc): `Set minImageCount = 7 (surface min 5, max 64, extra 2)` and the latched "off-screen work goes to the queue ahead of its window pass" line; neither appears in the before runs. From the single Perfetto runs (`runs/pwlat`): QueueSubmit per frame 1.30 -> 2.25 (mono) and 1.25 -> 2.20 (inproc), as expected for lever A.
- Espryt has no log marker for lever A or pmflush (F). The CPU drop on the monolith (2.89 -> 2.70 ms/frame) fits the saved copy jobs, but A and F were not separated and no profile was taken (user scope cut), so their individual shares are unmeasured.
- Expectations that failed (lever B): the HANDOFF predicted `HWC release fence ... has signaled` at >= 85 % of acquires and < 20 % gated frames. The single Perfetto runs show 58 % signaled / 37 % gated (Magma mono) and 66 % / 33 % (Magma inproc). The fps gain is larger than the sim's upper bound for lever B alone (Magma mono frame 3.60 -> about 2.9 ms, i.e. +24 %; measured 3.60 -> 2.70), so something beyond the modelled throttle moved. Not investigated: the timeline analysis was cut; the traces are for the follow-up.
- Presenting-thread CPU barely moved on Magma (2.39 -> 2.22 mono, 1.19 -> 1.13 inproc): the gain is frame time, not CPU.
- Single Perfetto runs, one per arm (not part of the fps table; fps of those runs: Espryt mono 250.1 -> 296.0, Espryt inproc 330.6 -> 357.1, Magma mono 302.2 -> 378.8, Magma inproc 369.6 -> 468.9): `p15/runs/pwlat/{b,AF}-DirectGLES{,-inproc}-r1/p15.pftrace` and `{b,AF2}-DirectVulkan{,-inproc}-r1/p15.pftrace`. All eight are non-empty (19-22 MB, 4.9 s), have the frametimeline (812-835 actual frames) and the FCL presenting thread (Thread-14 mono, mgl-srv-apply inproc). Config: p15_perfetto.cfg without kgsl/* events (`p15/pw/dev/perfetto.cfg`).
- A partial first attempt with Perfetto in every run (Espryt mono b, A, F, AF) was cancelled by scope change: `runs/pwab0-pf-partial`.
+101
View File
@@ -0,0 +1,101 @@
# P15 wait-class audit
Commands are recorded and replayed asynchronously by default. A record makes the client wait only
because its row in `MG_Pipe/PipeCalls.def` has a wait class other than `kWaitNone`. Since e00db8e6
the client's per-verb barrier answer is exactly the wait class of the record its emitter publishes
(`MG_Pipe/VerbRecordOps.h`). This file lists every row that still waits, says why, and flags the
candidates for async. **No row is converted until the user has seen this table.** Each conversion
needs a red-once test.
The rule for keeping a wait:
- **true reply**: the client acts on an answer it cannot derive itself; or
- **present pacing**.
Anything else (a `kWaitApplied` row whose apply still reads a BARRIER_PULLED or residual field, or a
reply the client could derive) is a candidate.
## Measured hit rates (FCL, inproc, cpuhunt, `MOBILEGL_IPC_WAIT_STATS=1`)
Waits per frame in steady state, 600-frame windows:
| wait | vanilla 1.21.5 (Magma, Espryt) | BSL (Magma) |
|---|---|---|
| present credit | 1.00 | 1.00 |
| record `ResourceCreate` (blocking create) | 0.00-0.01 | 2-3 |
| record `ResourceCopyRegion` (glCopyImageSubData) | 0 | 3 |
| record `GenerateMipmap` | 0 | 3 |
| record `CopyFramebufferToTexture` (glCopyTexSubImage2D) | 0 | 1 |
| barriered verbs quiescing the applier at validate | 0 | 8 (CopyImageSubData 3, GenerateMipmap 3, CopyTexSubImage2D 1, ClientWaitSync 1) |
| follow-on quiesce `MGPipeNoteFrontendMutation` | 0 | 14-16 |
| follow-on quiesce `MGPipeValidateForVerb/residual` | 0 | 8 |
| ring space | 0 | 0 |
- Vanilla meets the target: the present credit is the only per-frame wait.
- On BSL, every barriered verb costs about three waits, not one: the record's own applied wait, the
quiesce before the fill, and then a re-quiesce at each frontend mutation until the next
unbarriered verb (`g_lastFillWasBarriered`). Making the three `kWaitApplied` verbs async removes
all of these at once.
## Final verdicts (user decision 2026-10-08)
The principle, in the user's words: everything that is fire-and-forget is async and non-blocking;
only what must block (client-memory readback, glFinish, ClientWaitSync, ...) blocks. A reply the
client can derive or pre-allocate (handles the client mints) is not a reason to block.
| row | was | now | why |
|---|---|---|---|
| `Present` | kWaitPresent | keep | present pacing (the credit, now derived from `MOBILEGL_FRAMES_IN_FLIGHT`) |
| `GetCaps` | kWaitReply | keep | the caps snapshot the app reads (startup only) |
| `MapPersistent` | kWaitReply | keep | the map pointer the app writes through |
| `FenceStatus`, `FenceWait` | kWaitReply | keep | glGetSync / glClientWaitSync answers |
| `QueryAvailable`, `QueryResult`, `QueryTimestamp` | kWaitReply | keep | query results; an XFB primitives-written count blocks at the query read, never at End |
| `ResourceReadback` | kWaitReply | keep | bytes for client memory |
| `ReadPixels`, `GetTextureImage` | kWaitReply | keep for client memory; **async per call with a pack buffer bound** | the PBO path publishes the kWaitNone `*ToBuffer` record; the validate point now answers per call (`PackReadbackGoesToBuffer`), and the rare reply-form fallback re-validates barriered |
| `SharedImage` | kWaitReply | keep | the server allocates the dma-buf: its fd, modifier and stride cannot be derived (anland only; a per-op relaxation for attach/present/release is a follow-up) |
| `ResourceCreate` | kWaitReply | **async** on the shared-pool arm (inproc); the stream arm keeps its deferred create window | the handle is the client's own and the accept is derivable (the server declines only protocol corruption or a family with no consumer, which the client never emits for) |
| `ResourceRespecify`, `SetTextureParams`, `ResourceSubData` | kWaitReply | already async per call once the object is published | with the create async the object is published at create, so the first-use wait is gone too |
| `GenerateMipmap`, `ResourceCopyRegion`, `CopyFramebufferToTexture` | kWaitApplied | **kWaitNone** | applies resolve everything from the record's handles (P13 W4b/W4c); the dual-block census is empty |
| `SetStorageBlockBinding` | kWaitApplied | **kWaitNone** | resolved through the record's program CSO (P5f) |
| `Begin/End/Pause/ResumeStreamOutput`, `BindStreamOutput` | kWaitApplied | **kWaitNone** | the span lives server-side (P5f); a draw inside an open span is still barriered by the XFB clause, and the primitive count is answered at the query read |
| `ApplierReset` | kWaitApplied | keep | once per make-current, and its apply probes the client allocator, which is only legal inside a parked scope; not on any per-frame path |
And the cascade: with two `PipeInputs` blocks (`MOBILEGL_IPC_ROLE_SPLIT_STATE`, on by default since
P15 - every split lane and the on-device gate already ran with it, and its census is empty) a
barriered verb's fill writes the client's own block, so `QuiesceApplierBeforeFill` and the guard
skip the applier quiesce. One barriered verb now costs one wait: its record's.
## Rows that waited (the audit as reviewed)
| row | class | why it waits today | FCL hits/frame | verdict |
|---|---|---|---|---|
| `Present` | kWaitPresent | present credit, taken before the encode | 1 | keep (pacing) |
| `GetCaps` | kWaitReply | the caps snapshot | 0 (startup) | keep (true reply) |
| `ResourceCreate` | kWaitReply | accept/decline feeds the client's publish latch; a create window defers it for some objects | BSL 2-3 | **candidate**: find which creates take the blocking path every frame on BSL and why the window refuses them |
| `ResourceRespecify` | kWaitReply | texture half until the object's create is accepted; already fire-and-forget once published (`MGPipeResourceRespecifyWantsItsReply`) | 0 | keep (relaxed per call already) |
| `MapPersistent` | kWaitReply | the client needs the mapping | 0 (startup) | keep (true reply) |
| `FenceStatus`, `FenceWait` | kWaitReply | GPU state the app asked for | BSL 1 (ClientWaitSync) | keep (true reply) |
| `QueryAvailable`, `QueryResult`, `QueryTimestamp` | kWaitReply | GPU results | 0 | keep (true reply) |
| `SetTextureParams` | kWaitReply | waits only before the texture's create is accepted; fire-and-forget after | 0 | keep (relaxed per call already) |
| `ResourceSubData` | kWaitReply | buffer half and wire texture half never wait (`MGPipeSubDataWantsItsReply`) | 0 | keep (relaxed per call already) |
| `ResourceReadback`, `GetTextureImage`, `ReadPixels` | kWaitReply | the bytes | 0 | keep (true reply); **note**: the verb table names the reply op for ReadPixels / GetTexImage, so a pack-buffer read (which publishes the kWaitNone `*ToBuffer` record) is still barriered at validate. A per-call answer would make PBO reads async |
| `SharedImage` | kWaitReply | AHB/dma-buf handle exchange (anland) | 0 | keep (true reply) |
| `GenerateMipmap` | kWaitApplied | its apply read `GetActiveTextureUnit` and the unit's binding slot from the residual block (PipeCalls.def / ClientSession.cpp); P13 W4b gave the record arm the texture by handle (`VerbMipRes`) | BSL 3 | **candidate**: check whether any backend path still reads the residual unit; if not, kWaitNone |
| `ResourceCopyRegion` | kWaitApplied | its apply read `GetTextureObject`, a BARRIER_PULLED row whose retiring phase was P7 (ID-118); P13 W4b resolves both endpoints by handle | BSL 3 | **candidate**: same check |
| `CopyFramebufferToTexture` | kWaitApplied | the read framebuffer and the destination were pulled; P13 W4b resolves the destination by handle (`VerbCopyTexDst`) and P13 W4c names framebuffers by handle | BSL 1 | **candidate**: same check |
| `SetStorageBlockBinding` | kWaitApplied | probes a registry | 0 | keep for now (not on any FCL path) |
| `BeginStreamOutput`, `EndStreamOutput`, `PauseStreamOutput`, `ResumeStreamOutput`, `BindStreamOutput` | kWaitApplied | XFB span accounting and the capture-binding shadow | 0 | keep for now (not on any FCL path) |
| `ApplierReset` | kWaitApplied | orders a make-current reset against the verbs after it | 0 (make-current) | keep |
Count note: the X rows in PipeCalls.def parse as 59 kWaitNone, 15 kWaitReply, 10 kWaitApplied and
1 kWaitPresent (85 rows).
## Proposed order (after the user's go-ahead)
1. `GenerateMipmap`, `ResourceCopyRegion`, `CopyFramebufferToTexture` to kWaitNone, each with a
red-once test (a poison or verify build that aborts on a residual read under an unbarriered
apply). BSL then loses 7 record waits, 7 validate quiesces and the 14-16 follow-on quiesces per
frame.
2. `ResourceCreate` on BSL: find the 2-3 blocking creates per frame and why the create window
declines them.
3. Pack-buffer `ReadPixels` / `GetTexImage`: a per-call barrier answer instead of the verb-level
reply op.