Skip to content

panfrost: Choose hierarchy masks based on vertex count

Alyssa Rosenzweig requested to merge alyssa/mesa:panfrost/firefox into main

Currently, we always use a hierarchy mask with all levels enabled. While this is efficient for geometry-heavy workloads like 3D games, it is wasteful for 2D applications that draw very few vertices. For drawing just a few textured quads, the overhead of small bin sizes outweighs any performance advantages, so it's a bit slower. More problematically, small bin sizes require tremendous amounts of memory for the polygon lists, leading to significant memory consumption (~10MB) for the polygon list for even the simplest of 2D blits.

To reduce our memory footprint, we need to choose our hierarchy masks more carefully. In general, we want to allow small bin sizes for geometry-heavy workloads but not for geometry-light workloads. We estimate vertex count in the driver as a proxy for this, and use a simple heuristic to select a bin size based on the estimated vertex count. None of this is an exact science, and the heuristic could probably be tuned. Nevertheless, the heuristic used (comparing framebuffer size to vertex count) works well in practice, significantly reducing the memory footprint of 2D applications like Firefox without hurting the performance of 3D applications.

I originally wrote this patch while diagnosing high memory footprints on my Midgard laptop, which is why only Midgard is in scope here. On Bifrost and Valhall, we have a similar hiearchy mask selection problem. It seems likely that the same heuristic would work there too, but it's a different code path that I have not integrated or tested. I'll leave that for the adventurous reader, to get the memory footprint win there too.

(It's also possible the win is smaller on newer Malis than on Midgard, since Arm claims they optimized the tiler data structures on the newer parts. There's probably still some merit to the idea.)

Edited by Alyssa Rosenzweig

Merge request reports