glsl: fix slow linking of uniforms in the nir linker
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 21 May 2020 03:12:34 +0000 (13:12 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 27 May 2020 00:59:20 +0000 (00:59 +0000)
commitf1acf492de91e04a81950c0446c36b22b48bc94c
treea538130e36b73caef33639e30a82d9fb6e0a3651
parentf6214750eb4d53296e674dd26fc668b1029a1c8b
glsl: fix slow linking of uniforms in the nir linker

Currently the nir linker resizes the amount of storage needed to hold
uniform information on the fly while linking. As shaders can contain
thousands of uniforms this can be very slow. For example some Godot
shaders can take 30 seconds to compile on some machines.

In this change we count the amount of storage needed before we start
processing the uniforms. This is what the GLSL IR linker does also.

Fixes: 95f555a93a88 ("st/glsl_to_nir: make use of nir linker for linking uniforms")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2996

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5137>
src/compiler/glsl/gl_nir_link_uniforms.c