nvc0: Add shader disk caching
authorMark Menzynski <mmenzyns@redhat.com>
Tue, 28 Jan 2020 12:36:27 +0000 (13:36 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 25 Aug 2020 18:56:37 +0000 (18:56 +0000)
commitda9d721323dc8b68984dda55a7814d4f9c970963
tree93b5f33b218e02a76c5c836c977bbe6e1043d3ba
parent82dd683a3ce83461c374aa2332d2db2ff589b741
nvc0: Add shader disk caching

Adds shader disk caching for nvc0 to reduce the need to every time compile
shaders. Shaders are saved into disk_shader_cache from nvc0_screen structure.

It serializes the input nv50_ir_prog_info to compute the hash key and
also to do a byte compare between the original nv50_ir_prog_info and the one
saved in the cache. If keys match and also the byte compare returns they
are equal, shaders are same, and the compiled nv50_ir_prog_info_out from the
cache can be used instead of compiling input info.

Seems to be significantly improving loading times, these are the results
from running bunch of shaders:
cache off
real 2m58.574s
user 21m34.018s
sys 0m8.055s

cache on, first run
real 3m32.617s
user 24m52.701s
sys 0m20.400s

cache on, second run
real 0m23.745s
user 2m43.566s
sys 0m4.532s

Signed-off-by: Mark Menzynski <mmenzyns@redhat.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4264>
src/gallium/drivers/nouveau/nvc0/nvc0_context.h
src/gallium/drivers/nouveau/nvc0/nvc0_program.c
src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c