Closed Bug 1679751 Opened 4 years ago Closed 4 years ago

Move some of the texture cache atlases to a shelf allocator

Categories

(Core :: Graphics: WebRender, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: nical, Assigned: nical)

References

(Blocks 1 open bug)

Details

Attachments

(16 files, 1 obsolete file)

(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details
(deleted), text/x-phabricator-request
Details

Following up from 1674443, we can provide big improvements to glyph packing by moving to a tighter allocation strategy. I experimented with several and the one that gave the best performance/packing/fragmentation compromise for glyphs was a bucketed shelf packing allocation strategy implemented in https://docs.rs/etagere/0.2.1/etagere/struct.BucketedAtlasAllocator.html

I'm about to add a couple of new atlas allocation algorithms. This patch renames one of the existing one into something less generic before it gets confusing.

Also fix outdated comments about merging and dynamic allocation which was removed a while ago.

A bit of cleanup and a step towards having more allocation algorithms in the texture cache. This patch mostly moves code around, and should not change the behavior of the code.

Depends on D98201

And move texture_id into a TextureUnit structure in the texture_cache.rs that contains the allocator and the id. No behavior changes in this patch.

Depends on D98202

Another step towards abstracting out slab allocation from the rest of the texture cache and allowing multiple algorithms. All dynamic atlas allocation algorithms will use an AllocId encoded into 32 bits.

Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a80d39128a7c Rename ArrayAllocationTracker into GuillotineAllocator. r=gw https://hg.mozilla.org/integration/autoland/rev/59243c485fc8 Move the slab allocator code out of texture_cache.rs. r=gw https://hg.mozilla.org/integration/autoland/rev/5664e73089cf Rename TextureUnit into SlabAllocator. r=gw https://hg.mozilla.org/integration/autoland/rev/7051f98f3fb0 Use an alloc ID instead of origin + region index. r=gw
Keywords: leave-open

This commit moves the code that deals with allocating into a dynamic amount of textures (TextureUnits) out of texture_cache.rs, rename it into AllocatorList and make it generic.

The code also changes some of the profile counters to count pixels and number of textures instead of number of regions and size in bytes.

I had to introduce two traits which is a bit cumbersome but not so bad. AtlasAllocator is needed to implement AllocatorList with multiple allocators and AtlasAllocatorList is a dyn trait to let the texture cache can select between allocator lists of different type signatures.

Probably because of a newer version of the compiler, doing this before evoids adding a lot of unrelated changes to the interesting patches.

Depends on D98371

Depends on D98654

It is dead code now that glyphs use a shelf allocator.

Depends on D98655

Depends on D98656

Depends on D98657

Summary: Move glyph packing to a shelf atlas allocator → Move some of the texture cache atlases to a shelf allocator

I had a look at the alpha8 texture which tends to allocate two 1024x1024 textures with the slab allocator. We end needing a second texture because we have more than 4 slab sizes, but the regions tend to be mostly empty. Using the shelf allocator works a lot better. So much so that I was almost tempted to use a 512x512 texture with the shelf allocator but we end up allocating two of them after a few minutes. two 512x512 textures consumes half of the memory, but leads to more batch breaks so I'll conservatively settle for a single 1024x1024 shelf allocated texture.

For pop-up windows we could use 512x512 alpha8 linear textures, though.

Blocks: 1622226
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f1473ccab3f4 Move more atlas allocation logic out of texture_cache.rs. r=gw
Attachment #9191110 - Attachment is obsolete: true
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c72e9061894f Use a shelf packing allocator for the glyph atlas. r=gw https://hg.mozilla.org/integration/autoland/rev/1c0e0610062a Remove glyph-specific slab sizes. r=gw https://hg.mozilla.org/integration/autoland/rev/8a727f82c0bb Run Mach vendor rust. r=gw
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5bef00913f8c Adjust wrench reftest reference (after glyph atlas changes). r=jrmuizel
Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9161ce15f453 Use a shelf packing allocator for the image atlas. r=gw. https://hg.mozilla.org/integration/autoland/rev/007cb36f75ef Use the shelf allocator for alpha8_linear and color8_nearest textures. r=gw https://hg.mozilla.org/integration/autoland/rev/9be34a5d74d6 Adjust reftest references. r=gw

Once again, Android 8.0 Pixel2 debug being hidden in fuzzy queries means we don't see see them break.

Pushed by nsilva@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c250273ad967 More android 8 reftest fuzziness adjustments. r=jnicol
Pushed by dluca@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d7c981ef38fc Fix cargo test build. r=jnicol. CLOSED TREE
Status: NEW → RESOLVED
Closed: 4 years ago
Keywords: leave-open
Resolution: --- → FIXED
Regressions: 1683380
Regressions: 1683753
Target Milestone: --- → 86 Branch
Regressions: 1685643
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: