Repository navigation
perf(d3d11_service): batch weave clears only the stale SBS scratch regions (2D-under-the-lens P1) - #1826
Closed
dfattal wants to merge 1 commit into
Closed
perf(d3d11_service): batch weave clears only the stale SBS scratch regions (2D-under-the-lens P1)#1826dfattal wants to merge 1 commit into
dfattal wants to merge 1 commit into
Conversation
…gions The spec-v3 batch weave (the browser present-owner path) assembles a (2*win_w) x win_h side-by-side scratch from the browser's window-sized input and used to ClearRenderTargetView the WHOLE scratch on every frame-first submit before blitting the rects into it - 62.7 MB of RGBA8 at 3840x2040. Only the regions blitted since the previous frame-first can hold anything but (0,0,0,0), so the scratch now carries a dirty-region list and the frame-first clear covers just the regions this submit will not overwrite with an identical opaque blit (ClearView with rects; a whole clear when the scratch is new, the list overflowed, or the stale area exceeds half the scratch). A static page clears nothing; a scrolling one clears last frame's tile footprints. The scratch handed to the DP is bit-identical: gaps are (0,0,0,0) either way and every rect is still blitted after the clear, in the same order. Nothing about the DP handoff changes (same texture, same dims) - not an ADR-030 zero-copy question; the batch input is per-rect squeezed SBS at window positions, not a tiled atlas, so no zero-copy predicate applies. DXR_WEAVE_SBS_FULL_CLEAR=1 restores the whole clear (A/B, rollback). DXR_WEAVE_GPU_TIMING: the weave timing line keeps every existing field (sbs_clear_blit unchanged) and appends a split - sbs clear vs blit GPU ms, plus frame-first clears by kind (whole/partial/none) and Mpx cleared - via a seventh timestamp stamped on every path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Closing per David: measured on the panel (bperf qw_*, 4 alternating passes), the whole SBS clear was already a ~0.015 ms fast clear, and this saves ~0.01 ms. The real cost of the SBS step is the per-rect blit (0.7-1.2 ms). The follow-up is a half-width scratch or the browser handing over a packed (v6) atlas so the copy disappears. |
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.
P1 of the "2D under the lens" perf work. The P0 timing (#1824) measured
sbs_clear_blitat 0.7-1.2 ms/frame on the browser present-owner (spec-v3 batch) weave: RTX 3080 laptop, 3840x2040, whole-page overlay, static gallery. This PR cuts the clear half of that stage. The output stays bit-identical.Why the batch path copies the browser's views into an SBS scratch
The browser submits one window-sized input. Each woven element's L|R pair sits squeezed side by side at that element's own window position, so a rect
(x,y,w,h)holds L in[x, x+w/2)and R in[x+w/2, x+w). That is not a tiled atlas. The SR weaver's contract is oneweave()per frame: per-rect calls at N times the frame rate degrade its predictor (#96). So the runtime builds one window-sized 2x1 SBS pair,(2*win_w) x win_h, by stretch-blitting each rect's halves to the rect's position in the L and R tiles. It then weaves the whole window in a singleprocess_atlas. With v5firstChunkthe scratch is cleared to (0,0,0,0) first, so the gaps between tiles weave transparent and the browser can draw the woven output back whole-window.Why zero-copy does not apply
ADR-030's zero-copy is about handing the DP an app atlas that already is the active mode's tiled atlas (
u_tiling_can_zero_copy()). The batch input never is: its views are interleaved per element at window positions, not contiguous tiles. So no "crop", and therefore no zero-copy, is possible here, and this PR adds no zero-copy proxy of any kind. The path that does have a zero-copy case is spec-v6, where the caller packs a real N-view atlas. Moving the browser's whole-page-overlay mode onto v6 would remove the scratch entirely, but that is a browser-side change (follow-up).What changes
The scratch used to be cleared whole on every frame-first submit: 7680x2040 RGBA8, 62.7 MB. Only the regions blitted since the previous frame-first can hold non-zero pixels; everything else was cleared last frame and nothing has written it since. So:
ClearViewwith rects) only the dirty regions that this submit will not overwrite with an identical opaque blit. "Identical" means the same clipped region from a non-lifted rect. The test uses exactly the blit loop's eligibility rules.DXR_WEAVE_SBS_FULL_CLEAR=1.Invariant: while
weave_sbs_clean_validholds, every pixel outside the dirty list is (0,0,0,0). The texture handed to the DP is bit-identical to the whole-clear version. Gaps are zero either way, and every rect is still blitted after the clear, in the same order. The weave blit is an opaque overwrite with no discard (convert_srgb=0, no corner/feather), so a skipped region really is fully rewritten. A caller that never setsfirstChunkis unchanged (it never cleared and still doesn't).What this PR does not reduce is the blit half of the stage (2 stretched draws per rect). The split below says how much of the 0.7-1.2 ms each half is. A follow-up could halve the scratch to
win_w x win_h: un-stretched views, with the weaver doing the 2x upscale it already does on the legacy path. That would halve clear, blit and the weave's input read. It changes the weaver's input dims and the sampling phase on odd rect x, so it needs its own A/B.Timing (P0 line kept)
weave timing [...]keeps every existing field (sbs_clear_blitis unchanged) and appends:That comes from a seventh GPU timestamp (
WEAVE_TS_SBS_CLEARED). It is stamped as a placeholder on every path so query sets always complete, and the batch path re-stamps it after its clear.Expected savings
sbs_clear_blitdrops by the clear's share. On a static pagenoneshould dominate andclearedshould be ~0 Mpx/clear, against 15.7 Mpx before.sbs splitline will show this directly (clearbefore ~ after). I am stating that up front rather than promising a number.weaveis unchanged by this PR. The plug-in PR (displayxr-leia-plugin, alpha gate) is the other half of the weave-stage saving.Test plan
Build:
scripts\build_windows.bat buildin a worktree (done; compiles clean).Deploy (same as P0):
scripts/push-runtime-pf.shfrom the worktree. Relaunch the service via anexplorer.exe.batthat setsDXR_WEAVE_GPU_TIMING=1andSR_SIMULATED_VIEWER=0,0,600,63in the service env.bperf A/B on the same build. Use the DisplayXR Browser whole-page overlay on the static gallery page at 100% overlay reuse. Take ~60 s per arm:
DXR_WEAVE_SBS_FULL_CLEAR=1(old behaviour).Compare
sbs_clear_blit,sbs split: clear / blit,weave,totaland CPUsubmit. Expect B to shownonedominating, ~0 Mpx/clear and a lowerclear.blitandweaveshould be flat. Also run a scrolling pass and expectpartialwith small Mpx.Visual, Add macOS runtime installer script #73 woven dump.
touch %TEMP%\dxr_weave_dump_triggeron a static frame and again mid-scroll, in both arms.dxr73_weave_sbsanddxr73_weave_outputshould match A vs B. Expect a pixel diff of 0 on the SBS scratch for an identical page state. Look for no stale tiles in the gaps after a scroll or navigation.Eyeball. Scroll the gallery fast, navigate away and back, and resize the window (a resize recreates the scratch, so the first frame is a whole clear). No trails, no ghost tiles between elements.
Lift rect (if a NeurD box is available): a lift-flagged element still weaves, and the area outside it stays transparent.
Risks
weave_sbs_clean_valid = false.ClearViewwith rects is D3D11.1 (ID3D11DeviceContext4is already required here).DXR_WEAVE_SBS_FULL_CLEAR=1.🤖 Generated with Claude Code