From 89c1feb78d010bc457f5d02be84c955eebf3549f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Tue, 7 Apr 2015 15:15:09 -0700 Subject: 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 Reviewed-by: Jason Ekstrand --- src/mesa/drivers/dri/i965/brw_program.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/mesa/drivers/dri/i965/brw_program.c') diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index 8920c34b029..9e27c2aa974 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -43,6 +43,7 @@ #include "brw_context.h" #include "brw_shader.h" +#include "brw_nir.h" #include "brw_wm.h" #include "intel_batchbuffer.h" @@ -141,6 +142,10 @@ brwProgramStringNotify(struct gl_context *ctx, brw_add_texrect_params(prog); + if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT].NirOptions) { + prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_FRAGMENT); + } + brw_fs_precompile(ctx, NULL, prog); break; } @@ -163,6 +168,10 @@ brwProgramStringNotify(struct gl_context *ctx, brw_add_texrect_params(prog); + if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].NirOptions) { + prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_VERTEX); + } + brw_vs_precompile(ctx, NULL, prog); break; } -- cgit v1.2.3