Cut WebGPU first-flush compile time and scratch memory - #421
Merged
Merged
Conversation
compose_source evaluates the blend overlap once per call instead of inside five switch cases. The fine pipeline compiles in 0.5 s instead of 1.7 s with identical arithmetic per mode. The scheduling pipelines compile in parallel when the device is probed. The fine pipeline compiles once per target format, started when the target is created, instead of four fixed variants started at the first render. Stroke scratch estimates are bounded from the outline geometry (offset edges, caps, joins) instead of the bounding-box diagonal. The PTCL seed is a per-crossing bound plus one chunk per target tile.
CMD_FILL and CMD_SOLID reference their raster interest rectangle by its info-stream offset instead of copying four words into every tile. CMD_COLOR references the packed colour in the scene stream and the draw flags in the info stream. Fill goes from 9 words to 6, solid from 5 to 2, colour from 4 to 3. The PTCL seed bound drops from 14 to 11 words per crossing. The fine shader stores each paint command's per-pixel colour and coverage and composes them at one site after the command switch. One compose site keeps the blend-mode switch from being inlined into every paint case, which cuts the cold fine compile from 1.8 s to 1.1 s.
The encoder accumulates a PTCL word bound per draw: one CMD_FILL (6 words) plus the paint command coarse writes for that draw tag, times the draw's tile-crossing bound. The bound flows through partitions, checkpoints, ranges, and the scene, and replaces the fixed 11 words per crossing in the scratch seed. A solid-colour scene now seeds 9 words per crossing.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #421 +/- ##
======================================
Coverage 79% 79%
======================================
Files 232 232
Lines 27392 27516 +124
Branches 3119 3128 +9
======================================
+ Hits 21814 21934 +120
- Misses 4540 4542 +2
- Partials 1038 1040 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Prerequisites
Description
Cuts the WebGPU first-flush time and the scratch memory the staged pipeline reserves. Measured on the
DrawingBackendBenchmarksample, WebGPU, 100k lines, preview 1576x1075, AMD Radeon 8060S.Compile
compose_sourceevaluates the blend overlap once per call instead of inside five switch cases. Same operands per mode, bit-identical output. The shader now fits the driver's shader cache.Memory
CMD_FILLgoes from 9 words to 6,CMD_SOLIDfrom 5 to 2,CMD_COLORfrom 4 to 3. The interest rectangle and the colour are referenced by offset into the info and scene streams.Verification