Skip to content

More gpu_cache improvements

Jeremy Soller requested to merge alexheretic:master into master

Created by: alexheretic

With this pr I've

  • Added a new gpu_cache benchmark using multiple fonts
  • Simplified code by reducing private struct PGlyphSpec to only having fields needed for tree-ordering, and renaming to GlyphScaleOffset. This also removes some unnecessary tree comparisons in the Ord impl.
  • Moved all in-line scale.x / offset.y usage to methods GlyphScaleOffset::matches, GlyphScaleOffset::match_distance. This simplifies the large cached_queued & rect_for methods.
  • Optimise in_use_rows set by pre-allocating row capacity. I experimented with using fnv hashing for this set, but left it default as fnv seemed to slow down some benchmarks - I'm not sure why this is.

Overall this gives gpu_cache another small boost

name                                                              control ns/iter  change ns/iter  diff ns/iter  diff %  speedup 
gpu_cache::cache_bench_tests::cache_bench_tolerance_1             1,943,449        1,839,792           -103,657  -5.33%   x 1.06 
gpu_cache::cache_bench_tests::cache_bench_tolerance_p1            4,080,448        3,998,651            -81,797  -2.00%   x 1.02 
gpu_cache::cache_bench_tests::cache_bench_tolerance_p1_multifont  3,707,505        3,562,775           -144,730  -3.90%   x 1.04 

Merge request reports