Repository navigation
perf(composition): declare damage at present, and make it cheaper to honour - #24821
Merged
MartinZikmund merged 3 commits intoOct 3, 2026
Merged
Conversation
…honour The present is told which regions changed when it opens, rather than being handed a clip afterwards, so each backend decides what to do with them. - IDrawingFactory.BeginPresent takes the damaged regions. Permission to repaint less, not a clip: a backend may ignore it, or confine the whole session to it. - DamageRegion hands back rectangles, merges overlapping ones and snaps them to whole device pixels at every scale, so a backend can scissor them. - Visual threads the narrowed clip bounds through the walk instead of recomputing an ancestor chain per painted visual. - WebGpuSwapChainContext declares PreservesContents, so partial repaint reaches WebGPU at all, and WebGpuPresentSession queues replays and immediate-mode drawing in order rather than keeping only the last. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
The build 236361 found UI Test snapshots differences: Details
|
Contributor
|
|
An empty try/finally wrapped ContributeDamageOnPaint with its body never indented, which failed IDE0055 on CI and blocked every downstream build. A duplicate summary left over from an earlier split went with it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A large virtualized grid that can auto-scroll at a fixed speed, alongside a ticker and a spinner. Scrolling dirties nearly the whole viewport while the ticker and spinner change a few hundred pixels, so the sample covers both ends of partial repaint from one page. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24821/wasm-skia-net9/index.html |
Contributor
|
The build 236417 found UI Test snapshots differences: Details
|
MartinZikmund
approved these changes
Oct 3, 2026
This was referenced Oct 3, 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.
GitHub Issue: #24791
PR Type:
🐞 Bugfix (performance regression)
What changed? 🚀
CompositionTarget.Drawclipped the clear+replay to the damage region by handing the backend a path built from the damaged rectangles. This makes the present the most expensive phase of the frame on master, several times dearer than it is on 6.5.The present is now told which regions changed when it opens, and each backend decides what to do with them:
IDrawingFactory.BeginPresenttakes the damaged regions. It is permission to repaint less, not a clip — repainting more is always correct, so a backend may ignore it entirely, or confine the whole session to it. It cannot be expressed as a clip, because a clip is exact: a backend handed several rectangles as one has to honour every edge, and on a GPU that means a coverage mask over everything drawn afterwards.DamageRegionhands back rectangles rather than a geometry, merges overlapping ones, and snaps them to whole device pixels at every scale rather than only at fractional ones. Disjoint, pixel-aligned rectangles are what a backend needs to scissor them.Visualthreads the narrowed clip bounds through the render walk instead of recomputing an ancestor chain for every painted visual.WebGpuSwapChainContextdeclaresPreservesContents, so partial repaint reaches WebGPU at all — it renders into one offscreen that it blits whole at present, exactly the retained-target shape Vulkan already declares.WebGpuPresentSessionalso now queues replays and immediate-mode drawing in order; it previously kept only the lastReplayand dropped any earlier one, and applied a clip only to its overlay stream.Measurements 📊
ItemsRepeater+UniformGridLayout, 2,837 FluentButtontiles, continuously scrolled. Skia Win32, OpenGL, maximised, 100% scale. Per-frame cost of the two phases, fromUNO_LOG_FRAME_PHASES=1(median of 3 runs):The draw phase is where master regressed, and this brings it below both 6.5 and the damage-disabled control — i.e. damage now pays for itself, where on master it costs about 4x what not having it costs.
Two things this does not fix, and which #24791 should stay open for:
recordis still ~3.4 ms against 6.5's 2.12 ms. That gap is unrelated to damage — the damage-disabled arm shows the same 3.25 ms — and has not been attributed yet.Ported to 6.8/6.7 separately: those branches have no
IDrawingFactory/IPresentSessionseam, so the same intent needs a different shape there.PR Checklist ✅
Screenshots Compare Test Runresults.Note on the runtime tests box:
Given_Visual_Damagecovers the region bookkeeping and passes 10/10; the present-side change is covered by the phase measurements above rather than by a new test, since the observable output is unchanged by design.Depends on #24796 for anything measured on Win32 + OpenGL — without it master freezes the moment the window is maximised.
🤖 Generated with Claude Code