From 69ed3244d4d9898e5353d34be6a160db409b6dc8 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 28 Sep 2017 09:55:15 -0700 Subject: i965/link: Make better use of temporary variables The way NIR_PASS works (and, by extension, nir_optimize) is that they may clone the shader and throw the old one away. (We use this for testing nir_clone.) It's better if we just make a temporary variable, use it for everything, and re-assign to the gl_program at the end. [jordan.l.justen@intel.com: Tested NIR_TEST_CLONE=1 with valgrind] Tested-by: Jordan Justen Reviewed-by: Jordan Justen --- src/mesa/drivers/dri/i965/brw_link.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp index 9ddf0230183..80868569ed7 100644 --- a/src/mesa/drivers/dri/i965/brw_link.cpp +++ b/src/mesa/drivers/dri/i965/brw_link.cpp @@ -297,14 +297,15 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) nir_lower_indirect_derefs(consumer, indirect_mask); const bool p_is_scalar = compiler->scalar_stage[producer->stage]; - shProg->_LinkedShaders[i]->Program->nir = - brw_nir_optimize(producer, compiler, p_is_scalar); + producer = brw_nir_optimize(producer, compiler, p_is_scalar); const bool c_is_scalar = compiler->scalar_stage[producer->stage]; - shProg->_LinkedShaders[next]->Program->nir = - brw_nir_optimize(consumer, compiler, c_is_scalar); + consumer = brw_nir_optimize(consumer, compiler, c_is_scalar); } + shProg->_LinkedShaders[i]->Program->nir = producer; + shProg->_LinkedShaders[next]->Program->nir = consumer; + next = i; } } -- cgit v1.2.3