i965: Create NIR during LinkShader() and ProgramStringNotify().
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 7 Apr 2015 22:15:09 +0000 (15:15 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 11 Apr 2015 19:35:33 +0000 (12:35 -0700)
commit89c1feb78d010bc457f5d02be84c955eebf3549f
tree558425e1ff2c21b99d66ba218f143b6c2759540b
parentb3e286c4575bf6af343c1a03471fd876cdfb5c43
i965: Create NIR during LinkShader() and ProgramStringNotify().

Previously, we translated into NIR and did all the optimizations and
lowering as part of running fs_visitor.  This meant that we did all of
that work twice for fragment shaders - once for SIMD8, and again for
SIMD16.  We also had to redo it every time we hit a state based
recompile.

We now generate NIR once at link time.  ARB programs don't have linking,
so we instead generate it at ProgramStringNotify time.

Mesa's fixed function vertex program handling doesn't bother to inform
the driver about new programs at all (which is rather mean), so we
generate NIR at the last minute, if it hasn't happened already.

shader-db runs ~9.4% faster on my i7-5600U, with a release build.

v2: Check NirOptions != NULL in ProgramStringNotify().  Don't bother
    using _mesa_program_enum_to_shader_stage as we already know it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
src/mesa/drivers/dri/i965/Makefile.sources
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_nir.c [new file with mode: 0644]
src/mesa/drivers/dri/i965/brw_nir.h
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/main/mtypes.h
src/mesa/program/program.c