Repository navigation
STATS: Split the reloaded pass bytes (splitMiB) by the reason a pass ended - #206
Merged
Merged
Conversation
…count the clear paths (profile-only) Closes #80; part of #127 (slice 3). splitCheck adds each split's load bytes to the counter of its reason (submit, transfer, clear, other) next to SplitBytes, and STATS appends splitMiBSubmit/Xfer/Clear/Other, which add up to splitMiB. The clear paths count clears that ended an open pass, pending clears that got a pass of their own, full-surface clears through the part-surface path, and part-surface color and depth/stencil clears (clrOpen, clrPending, clrViewFull, clrRect, clrRectDs). Everything behind D9MT_PROFILE: splitCheck already is, and each clear path gets one predictable branch.
…ers splitCheck's reasons Review round 1: the test only checked pre-classified snapshots (High). Also count clrRect/clrRectDs after the pipeline lookup that can skip the draw, and describe clrOpen and clrViewFull by what the backend does (Lows).
jdrly
marked this pull request as ready for review
November 14, 2026 12:20
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
The 0.1.5 STATS averages had
splitMiBat 445 per frame: attachments reloaded because a pass ended and the next one reopened them.splitCheckalready classified each split's count by reason, but it added all the bytes to one counter. Which reason carries the bytes decides the next step: an in-pass clear, for example, could only remove the clear reason's share. This PR splits those bytes by reason, and #127's slice 3 counts the clear paths, for profiled sessions only. STATS now ends withsplitMiBby reason, and with how clears were carried out: ending an open pass, flushed as a pending clear, as a pass of their own, or as a scissored draw.Closes #80. Part of #127: slice 3 (clear eligibility), the last of its four slices (#193 and #202 had the others). What #127 still lacks: the split bytes by the clear's aspect (see below), and its profile-off bench rounds and profile-on overhead, which wait for #198's bench set.
New STATS fields, per render-thread frame, named in
PERFORMANCE.md§4,driver/d3d9/d3d9_stats.handdriver/mtl/mtl_render_stats.h:splitMiBSubmit,splitMiBXfer,splitMiBClear,splitMiBOther:splitMiBby the reason the split's previous pass ended, assplit=is classified. The four add up tosplitMiB, each rounded on its own.clrOpen(full-surface clears that ended an open pass),clrPending(folded clears that got a pass of their own because nothing drew there; also inclrPass),clrViewFull(color clears through the part-surface path whose rect covers the whole mip level),clrRect(part-surface color clears: a scissored draw),clrRectDs(part-surface depth/stencil clears: a draw).How to verify
scripts/run-native-tests.sh:stats_testcovers the new fields andrstats::countSplit, the split classificationsplitCheckuses.D9MT_PROFILE=1, bench_4k: in every STATS line, the foursplitMiB*reasons add up tosplitMiB, within rounding.Evidence
Proof. Head
350df71, base8713666.Native tests, on jd-ai-server (x86_64 Linux, g++):
stats_testOK.Controls. The test doesn't build against main's headers. With the branch's headers, each of these mutations makes it fail:
clrRectDsnot taken as a per-frame deltacountSplitHosted
Checkson350df71: green (run 43591761353).stats_testpasses there, and the AIR codegen is25fc2491f11d0902328bd623fa12d2d73b7eeebb877e6dfd30d85b78c8e7a6c2, unchanged.GPU hash gate on the rented M1 (Apple M1, macOS 27.0), gpu-ci run 43591713686, head
350df71against main8713666,variants=default,profile targets=27 allow-notclean=code_depth_bias. Verdict: pass. AIR target 27 only: the diff adds profile-only counting on the clear paths and changes no shader, codegen or draw path, and the AIR target only changes the shader codegen.code_mtlockdiffers, as it does between any two runs (allowed).code_null_volume, same frames.D9MT: profiler clock:. The three STATS lines on head carry the new fields, and main's don't. On head they check STATS: Split the reloaded pass bytes (splitMiB) by the reason a pass ended #80 on this commit too:code_split_loadhassplit=2.0 splitSubmit=1.0 splitClear=1.0 splitMiB=8.0andsplitMiBSubmit=4.0 splitMiBXfer=0.0 splitMiBClear=4.0 splitMiBOther=0.0.STATS: Split the reloaded pass bytes (splitMiB) by the reason a pass ended #80's runtime check, on the rented M1 (Apple M1, macOS 27.0, Wine cx-26.3.0-8; 2026-11-14 12:59). One run of
bench_4k(300 frames, 4 post passes, 1 depth clear) throughperf-abba.shwithD9MT_PROFILE=1, for main8713666(d3d9.dlld175e287…) and for82e2fbe(1f436b92…). Both used main's bridge, since this PR changes no bridge file.82e2fbeis round 1's head; round 2 moved the same classification intocountSplitand two clear counts after the pipeline lookup. Each run logged 30 STATS lines. Main's end without the new fields. On the PR, in all 30 lines the four reasons add up tosplitMiBwithin rounding:splitSubmit=0.9 splitClear=0.1).clrOpen=1.0: one full-surface clear a frame ends an open pass. I haven't traced which of bench_4k's clears it is.Performance (PERFORMANCE.md §1). Kind: a diagnostic. With
D9MT_PROFILEunset:splitCheckruns only under profiling, as before.endFrameas before.Nothing per draw. Timing is pending: the representative guard isn't calibrated yet, and no benchmark ran for this PR.
Definition of Done
Checks43591761353.defaultandprofile, AIR target 27, gpu-ci 43591713686.rstats::Totalsas before.splitMiB.Review
Codex (gpt-6.1-sol, reasoning high), two rounds.
82e2fbe: CHANGES REQUESTED.splitCheck. Fixed in350df71. The classification moved intorstats::countSplit, whichsplitCheckcalls with the same three conditions as before, and the test drives it directly.clrOpendescribed as the target's own pass. Fixed: any open pass.clrViewFullthat the code doesn't support. Fixed: described by the backend branch.rstats::Totals::snapshotloads each counter on its own while the render thread publishes them one by one, so a STATS line can mix two frames' totals. For STATS: Split the reloaded pass bytes (splitMiB) by the reason a pass ended #80, the reasons can then misssplitMiBby one frame's worth in a line that raced the publish. Not fixed here; see Follow-ups.350df71: every finding fixed except the deferred pre-existing Low.Risks and what I didn't do
Risk. With profiling off, a player could only notice if the clear-path branches cost time. Clears are a few per frame, and the hash suite catches any change in frames. With profiling on, a wrong classification would mislead the speed work. The native test covers the classification, and bench_4k's sums cover it at run time.
How to revert. Revert the squash commit.
Not done: the split bytes by the clear's aspect (color, depth, stencil), which #127 lists next to the reason. The reason split answers #80's question first; the aspect split can follow if the clear reason turns out to carry the bytes.
Follow-ups
rstats::Totals::snapshot()isn't coherent withpublish(): a STATS line can mix two frames' render-thread totals (pre-existing; the review's Low).