panfrost: Implement index buffer cache
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 19 Feb 2020 15:32:20 +0000 (10:32 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 27 Feb 2020 10:30:48 +0000 (10:30 +0000)
commitd385c5840f9f5683e0ca2dcb254b494562838a90
treece8bbe41963a63ea8800659e82b4c21e32e7446a
parent12db69aa3f6155e9ccb1d783da589ab206dc7239
panfrost: Implement index buffer cache

For index bufer resources (not user index buffers), we're able to cache
results. In practice, the cache works pretty dang well. It's still
important that the min/max computation is efficient (since when the
cache misses it'll run at draw-time and we don't want jank), but this
can eliminate a lot of computations entirely.

We use a custom data structure for caching. Search is O(N) to the size
but sizes are capped so it's effectively O(1). Insertion is O(1) with
automatic oldest eviction, on the assumption that the oldest results are
the least likely to still be useful. We might also experiment with other
heuristics based on actual usage later.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3880>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3880>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_resource.c
src/gallium/drivers/panfrost/pan_resource.h