Investigate tighter texture atlas packing for glyphs
Categories
(Core :: Graphics: WebRender, task, P3)
Tracking
()
People
(Reporter: nical, Assigned: nical)
References
(Blocks 2 open bugs)
Details
Attachments
(5 files)
Let's figure out whether we can pack more glyphs in the same amount of texture memory. Packing glyphs into fewer textures will translate into less memory usage and better batching.
Assignee | ||
Comment 1•4 years ago
|
||
I put together a quick tool to record all glyph allocations and print out distributions. Here is the result after a few thousand allocations (visited a wipedia page and theverge.com) on a 4k screen with device-pixel ratio of 2:
# Widths:
size: 8 16 24 32 40 48 56 64 80 96 128 256+
count: 895 3537 1374 214 68 3 6 4 23 12 0 0
# Heights:
size: 8 16 24 32 40 48 56 64 80 96 128 256+
count: 231 1807 3023 712 69 51 148 2 12 81 0 0
8 16 24 32 40 48 56 64 80 96 128 256+
- - - - - - - - - - - - -
8 | 175 36 9 10 0 0 1 0 0 0 0 0
16 | 133 1431 233 10 0 0 0 0 0 0 0 0
24 | 468 1800 699 47 9 0 0 0 0 0 0 0
32 | 97 231 290 88 5 1 0 0 0 0 0 0
40 | 16 4 41 4 4 0 0 0 0 0 0 0
48 | 3 15 6 18 7 0 0 2 0 0 0 0
56 | 3 16 92 30 5 2 0 0 0 0 0 0
64 | 0 0 0 0 0 0 2 0 0 0 0 0
80 | 0 0 2 0 9 0 1 0 0 0 0 0
96 | 0 4 2 7 29 0 2 2 23 12 0 0
128 | 0 0 0 0 0 0 0 0 0 0 0 0
256 | 0 0 0 0 0 0 0 0 0 0 0 0
Here is roughly the same workload with device-pixel ratio of 1:
# Widths:
size: 8 16 24 32 40 48 56 64 80 96 128 256+
count: 3549 1906 130 19 30 12 0 0 0 0 0 0
# Heights:
size: 8 16 24 32 40 48 56 64 80 96 128 256+
count: 1619 3467 278 177 20 85 0 0 0 0 0 0
8 16 24 32 40 48 56 64 80 96 128 256+
- - - - - - - - - - - - -
8 | 1382 223 9 5 0 0 0 0 0 0 0 0
16 | 2090 1340 36 1 0 0 0 0 0 0 0 0
24 | 52 185 37 4 0 0 0 0 0 0 0 0
32 | 21 146 6 4 0 0 0 0 0 0 0 0
40 | 0 1 9 3 6 1 0 0 0 0 0 0
48 | 4 11 33 2 24 11 0 0 0 0 0 0
56 | 0 0 0 0 0 0 0 0 0 0 0 0
64 | 0 0 0 0 0 0 0 0 0 0 0 0
80 | 0 0 0 0 0 0 0 0 0 0 0 0
96 | 0 0 0 0 0 0 0 0 0 0 0 0
128 | 0 0 0 0 0 0 0 0 0 0 0 0
256 | 0 0 0 0 0 0 0 0 0 0 0 0
This shows that we can easily save memory on glyphs by having more granularity for small slab sizes, and perhaps have smaller regions to minimize the waste from partially occupied regions. For example we could make regions 128x128 for glyphs and place the rare glyphs that are larger than 128px into the color8_linear texture.
Assignee | ||
Comment 2•4 years ago
|
||
In the next patch we'll set a smaller region size for the glyph texture.
Assignee | ||
Comment 3•4 years ago
|
||
Since glyphs are rarely larger than 128x128, we can reduce the amount of wasted space from partially used glyph regions by having smaller ones (and more of them).
Depends on D95756
Assignee | ||
Comment 4•4 years ago
|
||
Also tweak the visualization in various ways so that having a large amount of regions (glyphs) doesn't bring down simple SVG viewing software.
Depends on D95757
Assignee | ||
Comment 5•4 years ago
|
||
This patch simplifies the slab allocator in various ways, most importantly separating the packing logic and texture cache glue (dealing with swizzling, cache entries, etc.). The former is moved into TextureUnits/TextureUnit and the latter is mostly contained into TextureCache.
This patch should have no functional change. The goal to make it easier to introduce custom slab sizes for glyphs in a followup patch, and later use different packing algorithms.
Assignee | ||
Comment 6•4 years ago
|
||
This is a modest win on hidpi and a larger win on lowdpi. We can improve further by introducing more granularity between 16 and 32px, this puts in place the basic infrastructure on top of which we can experiment.
Depends on D95869
Updated•4 years ago
|
Comment 8•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/e18cf134339a
https://hg.mozilla.org/mozilla-central/rev/bbbf988c2940
https://hg.mozilla.org/mozilla-central/rev/2c2dc8dab741
https://hg.mozilla.org/mozilla-central/rev/6319f8438a3a
Comment 10•4 years ago
|
||
bugherder |
Comment 11•4 years ago
|
||
backout |
This was backed out from 84 for landing during the soft freeze and causing bug 1677771. It remains landed for 85+.
https://hg.mozilla.org/releases/mozilla-beta/rev/829d402760bc
Assignee | ||
Updated•4 years ago
|
Description
•