[Mesa-dev] [PATCH 0/7] vbo: introduce a minmax_index cache

Nicolai Hähnle nhaehnle at gmail.com
Thu Jan 7 16:57:04 PST 2016


Hi,

this series is intended to address a (big) part of the performance problems
that occur when games use an index buffer from a VBO together with vertex
attributes supplied by user pointer. On a lower-end Radeon (Carrizo), it
lifts This War Of Mine (the worst offender I've seen) from basically unplayable
to an acceptable ~22fps.

There are really two parts to the performance inefficiency:
(1) the fact that we have to compute min/max in the first place
(2) the fact that games developers like to helpfully declare the index buffer
as STATIC_DRAW, which means it ends up in VRAM, making things much worse than
they would be with (1) alone.

The series does this simply by caching (or memoizing, if you like) the result
of vbo_get_minmax_indices. This makes sense since while the caching itself of
course has some overhead, it is only used for VBOs - and the people who mix
VBO index buffers with non-VBO vertex data seem to do so precisely because
their index buffers are static, hence caching is a win.

The cache is disabled permanently for VBOs that we detect to be written to by
GPU operations. It is invalidated on other writes (Buffer(Sub)Data etc.).

I originally considered putting the caching in st/mesa instead of vbo, but that
would have required duplicating some of the logic in vbo_get_minmax_indices for
iterating over primitives inside the Gallium statetracker. I wanted to avoid
this code duplication, hence why I put it in vbo.

Please review!

Thanks,
Nicolai
--
 src/mesa/Makefile.sources             |   1 +
 src/mesa/main/bufferobj.c             |  41 +++-
 src/mesa/main/mtypes.h                |   7 +
 src/mesa/main/transformfeedback.h     |   3 +
 src/mesa/vbo/vbo.h                    |   3 +
 src/mesa/vbo/vbo_exec_array.c         | 148 ------------
 src/mesa/vbo/vbo_minmax_index.c       | 342 ++++++++++++++++++++++++++++
 src/util/hash_table.c                 |  25 ++
 src/util/hash_table.h                 |   2 +
 src/util/tests/hash_table/Makefile.am |   1 +
 src/util/tests/hash_table/clear.c     |  91 ++++++++
 11 files changed, 507 insertions(+), 157 deletions(-)



More information about the mesa-dev mailing list