Skip to content

Commit 9c52cd0

Browse files
committed
fix(docs): correct two claims of mine that measurement disproved — the MSAA figure and the GL attribution
Kevin asked whether the postprocessing issue we filed was relevant to the sun-arc work. It was, and the answer corrected two things I had written into this repo. 1. THE MSAA FIGURE WAS ~2x TOO LARGE. I computed ~471 MB from the REQUESTED sample count (8). Measured on a real ANGLE Metal / Apple M3 Max context, `MAX_SAMPLES` reads **4** — so the requested 8 was always being clamped and never granted. The true cost is ~236 MB at dpr 2. Half the figure; the verdict is unchanged, because a redundant multisampled buffer reallocated on every canvas resize is still redundant and SMAA is still the thing doing the antialiasing. 2. MY GL-STORM HYPOTHESIS IS REFUTED, not merely unconfirmed. I had named the per-frame MSAA resolve as the prime suspect for the `GL_INVALID_OPERATION: glBlitFramebuffer` storm, hedged as unverified. A controlled pair on the real GPU settles it: <EffectComposer multisampling> frames GL errors 0 (my change) 1672 0 package default 1783 0 Identical. The MSAA path is uninvolved. The fix was upstream — postprocessing 6.39.5 (078a6d1) stopped EffectComposer building its stable depth texture with `DepthTexture.clone()`, which on three r172 shares one GPU image between a texture and its clones (three.js#30540, milestone r174). I ran that control specifically because I was about to report upstream, and the one hypothesis I was least motivated to test was the one that removes my own contribution from the explanation. Without it I would have credited our change to a maintainer who had already solved it. POSTED, now that there is a measurement behind it: - pmndrs/postprocessing#750 — confirming the fix works on three r172, which is what he asked us to verify and we never did. He closed it on an assumption for our configuration; it is now verified. - N8python/n8ao#53 — a data point: their matrix stops at postprocessing 6.39.1 and reports no effect; 6.39.5 is clean here WITH `halfRes` enabled. Explicitly labelled as current-state, not a before/after, since I did not reproduce the failure first. THREE DEAD INSTRUMENTS were caught getting there, each by its own control, and all three returned a clean zero that nothing could have made non-zero: - `prod-smoke` launches `--use-angle=swiftshader` in CI exactly as locally. SwiftShader does not perform the driver-side validation that emits this error, so its seeded 0 was structurally guaranteed. That limit is already written into the file; the GL ledger is a SwiftShader-path regression guard only. - a tab opened in the operator's Chrome read `visibilityState: hidden` with a rAF probe of 0 and a canvas still at 300x150 — a backgrounded tab renders nothing, so 0 errors over 0 frames. Caught by this repo's own rule that a zero denominator is COULD-NOT-CHECK rather than a pass. - CDP `Runtime.evaluate` timeouts, twice, from putting a 60s wait loop inside a 45s call. Only a headless launch with `--use-angle=metal`, renderer string confirmed and 1672 real frames behind it, produced a reading worth reporting. No gate changes: this commit corrects prose in a source comment, a test docblock and the cursor. The effect-chain-cost cases are untouched and still pass.
1 parent 673ecde commit 9c52cd0

3 files changed

Lines changed: 33 additions & 13 deletions

File tree

‎frontend/src/GameScene.jsx‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,25 @@ export function GameScene({
309309
@react-three/postprocessing defaults `multisampling` to 8 and `frameBufferType` to
310310
HalfFloatType (both read from the installed dist, not from memory). Passing no prop therefore
311311
allocated an 8x multisampled RGBA16F render target at full canvas resolution and resolved it
312-
with blitFramebuffer EVERY FRAME. Arithmetic on those verified constants: 8 bytes per sample
313-
x 8 samples x canvas px = ~471 MB of MSAA buffer at 1728x1117 dpr2, ~62 MB even at 1280x800
314-
dpr1 — on top of the resolved target.
312+
with blitFramebuffer EVERY FRAME. MEASURED CORRECTION 2026-09-22: the GPU grants 4, not 8.
313+
`MAX_SAMPLES` reads 4 on a real ANGLE Metal / Apple M3 Max context, so the requested 8 was
314+
always CLAMPED. The cost is 8 bytes per sample x 4 samples x canvas px = ~236 MB at
315+
1728x1117 dpr2, not the ~471 MB first written here from the REQUESTED count. Half the
316+
figure, same verdict: a redundant multisampled buffer, reallocated on every canvas resize.
315317
316318
And <SMAA/> is four lines below, doing shader-based antialiasing on the resolved image. So the
317319
chain paid for hardware 8x MSAA AND a full AA pass. SMAA is the standard substitute and its
318320
presence here is what makes 0 the right value rather than a lower one; this is not "AA off".
319321
320-
Related, and NOT claimed as fixed by this: the production console carries
321-
`GL_INVALID_OPERATION: glBlitFramebuffer` per frame until Chrome mutes the context
322-
(.claude/rules/gates-and-probes.md). A per-frame MSAA resolve is the only blitFramebuffer in
323-
this pipeline, so it is the prime suspect — but SwiftShader reports MAX_SAMPLES 4 and emitted
324-
zero GL errors, so the headless probe CANNOT confirm it. Verify in a real Chrome before
325-
writing that down as solved.
322+
THE GL-STORM HYPOTHESIS THAT LIVED HERE IS REFUTED — by controlled
323+
measurement, not by doubt. This comment named the per-frame MSAA resolve as the prime suspect
324+
for the `GL_INVALID_OPERATION: glBlitFramebuffer` storm. It is not the cause. Measured on real
325+
ANGLE Metal, production build, full chain: 0 errors over 1672 frames with multisampling={0},
326+
and 0 over 1783 frames with the package default. Identical, so the MSAA path is uninvolved.
327+
The fix was upstream — postprocessing 6.39.5 (078a6d1) stopped EffectComposer building its
328+
stable depth texture with DepthTexture.clone(), which on three r172 shares one GPU image
329+
between a texture and its clones. Confirmed for r172 at pmndrs/postprocessing#750.
330+
This prop stays on its own merits: a redundant buffer is still redundant.
326331
327332
To revert: delete the prop. Tests/scripts/effect-chain-cost pins it and will red. */}
328333
<EffectComposer multisampling={0}>

‎frontend/tests/scripts/effect-chain-cost.test.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import { TIERS, selectTier } from '../../src/render/quality.js';
1414
*
1515
* 1. <EffectComposer> was mounted with NO `multisampling` prop. The package default is 8 and
1616
* `frameBufferType` defaults to HalfFloatType (both read from the installed dist). That is an 8x
17-
* multisampled RGBA16F target at full canvas resolution, blit-resolved every frame — ~471 MB at
18-
* 1728x1117 dpr2 by arithmetic on those constants. Meanwhile the <Canvas> sets
17+
* multisampled RGBA16F target at full canvas resolution, blit-resolved every frame. First written
18+
* here as ~471 MB at dpr2 from the REQUESTED sample count; measured later on a real ANGLE Metal /
19+
* Apple M3 Max context, MAX_SAMPLES is 4, so the requested 8 was always clamped and the true figure
20+
* is ~236 MB. Half as large, same verdict.
1921
* `antialias: false // Post-processing handles AA` and <SMAA/> sits in the same chain. The author
2022
* delegated AA to post; the 8x MSAA was cost nobody asked for and nobody could see.
2123
*

‎memory/ACTIVE_PLAN.md‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ was started at the end of this stretch. Nothing is wrong with the commits — th
1313
**PERF — three render-cost defaults, none visible to any of the 17 gates.**
1414
- `<EffectComposer>` had NO `multisampling` prop. The package default is 8 on a HalfFloatType target
1515
(read from the installed dist), i.e. an 8x multisampled RGBA16F buffer at full canvas resolution,
16-
blit-resolved every frame — ~471 MB at dpr 2. Never intended: the Canvas sets `antialias: false
16+
blit-resolved every frame. ~236 MB at dpr 2 — NOT the ~471 MB first written: a real ANGLE Metal / M3 Max
17+
context grants MAX_SAMPLES 4, so the requested 8 was always clamped. Never intended: the Canvas sets `antialias: false
1718
// Post-processing handles AA` and `<SMAA/>` is four lines below. Now `multisampling={0}`.
1819
- `flipflops={3}` on PerformanceMonitor froze adaptation for the session (drei's default is Infinity and
1920
its sampler opens `if (api.fallback) return;`). Removed. **NAMED, NOT FIXED:** frame rate is not COST —
@@ -33,10 +34,22 @@ declares `server: { open: true }`; vite resolves `preview.open ?? server.open`.
3334
launched Kevin's real Chrome. Fixed. This is the mechanism `.claude/rules/gates-and-probes.md` recorded as
3435
unknowable after seeing it once on :4180.
3536

37+
**THE GL STORM IS FIXED — AND NOT BY US.** Measured on real ANGLE Metal (M3 Max), production build, full
38+
chain including N8AO halfRes: **0 GL errors over 1672 frames**. Controlled pair — 0 with
39+
`multisampling={0}` AND 0 with the package default — so the MSAA path is uninvolved and my "prime suspect"
40+
hypothesis is REFUTED, not merely unconfirmed. The fix was upstream: postprocessing 6.39.5 (078a6d1).
41+
Posted as verification to pmndrs/postprocessing#750 and as a data point to N8python/n8ao#53.
42+
**Three dead instruments caught on the way**, each by its own control: (1) `prod-smoke` runs
43+
`--use-angle=swiftshader` in CI too, and SwiftShader cannot emit this error, so its seeded 0 was
44+
meaningless; (2) a tab opened in Kevin's Chrome read `visibility: hidden` / `rafTest: 0` — a hidden tab
45+
renders nothing, so 0 errors over 0 frames; (3) CDP evaluate timeouts from putting a 60s wait inside a 45s
46+
call. The GL ledger in prod-smoke remains a SwiftShader-path regression guard only; that limit is written
47+
into the file.
48+
3649
**THE 11.8 GB TAB — JS EXONERATED, GPU IMPLICATED, NOT CONFIRMED.** 90 heap samples over 58s show a GC
3750
sawtooth bounded 70-140 MB at -0.4 MB/s. The JS heap does not leak, so the process-level figure is
3851
GPU-side. `EffectComposer.setSize` reallocates input/output buffers, `<AdaptiveDpr>` is mounted, and
39-
PerformanceMonitor moves `dprCap` — so every resize reallocated that 471 MB target. Coherent mechanism,
52+
PerformanceMonitor moves `dprCap` — so every resize reallocated that ~236 MB target. Coherent mechanism,
4053
NOT proven: GPU memory is unreadable from a page and `renderer.info` is unreachable in the prod bundle
4154
(four accessors tried). The GL error ledger, seeded by CI from a real browser, is what will adjudicate it.
4255

0 commit comments

Comments
 (0)