nir/validate: Size the set of blocks to avoid rehashing.
authorEric Anholt <eric@anholt.net>
Tue, 20 Oct 2020 21:32:28 +0000 (14:32 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Nov 2020 22:18:31 +0000 (22:18 +0000)
commiteba97645c9f22c890d7b413dbe81b532c04d99fe
tree94d953e3c2d362cdee52612db753b618168f3a30
parent2afdd94f86149295f3e9422672c4501092f671d6
nir/validate: Size the set of blocks to avoid rehashing.

We can use num_blocks (if it's been initialized by some pass indexing
blocks) to pre-size our table, which helps on validating shaders with many
blocks which would otherwise reallocate the set several times.

No statistically significant performance difference on softpipe
KHR-GL33.texture_swizzle.functional runtime (n=15).  A previous, similar
variant of this patch cut .3% of instructions in softpipe shader-db ./run
shaders/closed/steam/borderlands-2/35* (an arbitrary set of shaders that
completed in reasonable amount of time) according to callgrind.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7244>
src/compiler/nir/nir.c
src/compiler/nir/nir_validate.c