diff options
author | Jason Ekstrand <[email protected]> | 2017-10-28 08:57:23 -0700 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-11-10 19:17:20 +0000 |
commit | b4cc8b9b1227e2d1bc30b1c26ba6ed1a14a8e798 (patch) | |
tree | 6be64ddc1f4b05399e7377b582e1daf365f2ba58 | |
parent | c40cf117eef688f6a629ebfeb802bac257986559 (diff) |
intel/nir: Break the linking code into a helper in brw_nir.c
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Cc: [email protected]
(cherry picked from commit 3e63cf893f096a7263eb1856d58417dd2d170d4b)
-rw-r--r-- | src/intel/compiler/brw_nir.c | 32 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_link.cpp | 38 |
3 files changed, 40 insertions, 34 deletions
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 192249363d9..db1b7ab09cf 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -664,6 +664,38 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir) return nir; } +void +brw_nir_link_shaders(const struct brw_compiler *compiler, + nir_shader **producer, nir_shader **consumer) +{ + NIR_PASS_V(*producer, nir_remove_dead_variables, nir_var_shader_out); + NIR_PASS_V(*consumer, nir_remove_dead_variables, nir_var_shader_in); + + if (nir_remove_unused_varyings(*producer, *consumer)) { + NIR_PASS_V(*producer, nir_lower_global_vars_to_local); + NIR_PASS_V(*consumer, nir_lower_global_vars_to_local); + + nir_variable_mode indirect_mask = (nir_variable_mode) 0; + if (compiler->glsl_compiler_options[(*producer)->info.stage].EmitNoIndirectTemp) + indirect_mask = nir_var_local; + + /* The backend might not be able to handle indirects on + * temporaries so we need to lower indirects on any of the + * varyings we have demoted here. + */ + NIR_PASS_V(*producer, nir_lower_indirect_derefs, indirect_mask); + NIR_PASS_V(*consumer, nir_lower_indirect_derefs, indirect_mask); + + const bool p_is_scalar = + compiler->scalar_stage[(*producer)->info.stage]; + *producer = brw_nir_optimize(*producer, compiler, p_is_scalar); + + const bool c_is_scalar = + compiler->scalar_stage[(*producer)->info.stage]; + *consumer = brw_nir_optimize(*consumer, compiler, c_is_scalar); + } +} + /* Prepare the given shader for codegen * * This function is intended to be called right before going into the actual diff --git a/src/intel/compiler/brw_nir.h b/src/intel/compiler/brw_nir.h index 1493b742e42..81797fcb722 100644 --- a/src/intel/compiler/brw_nir.h +++ b/src/intel/compiler/brw_nir.h @@ -95,6 +95,10 @@ void brw_nir_analyze_boolean_resolves(nir_shader *nir); nir_shader *brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir); +void +brw_nir_link_shaders(const struct brw_compiler *compiler, + nir_shader **producer, nir_shader **consumer); + bool brw_nir_lower_cs_intrinsics(nir_shader *nir, struct brw_cs_prog_data *prog_data); void brw_nir_lower_vs_inputs(nir_shader *nir, diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp index 1a28e63fcae..69546a6b9e4 100644 --- a/src/mesa/drivers/dri/i965/brw_link.cpp +++ b/src/mesa/drivers/dri/i965/brw_link.cpp @@ -275,40 +275,10 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) if (shProg->_LinkedShaders[i] == NULL) continue; - nir_shader *producer = shProg->_LinkedShaders[i]->Program->nir; - nir_shader *consumer = shProg->_LinkedShaders[next]->Program->nir; - - NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out); - NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in); - - if (nir_remove_unused_varyings(producer, consumer)) { - NIR_PASS_V(producer, nir_lower_global_vars_to_local); - NIR_PASS_V(consumer, nir_lower_global_vars_to_local); - - nir_variable_mode indirect_mask = (nir_variable_mode) 0; - if (compiler->glsl_compiler_options[i].EmitNoIndirectTemp) - indirect_mask = (nir_variable_mode) nir_var_local; - - /* The backend might not be able to handle indirects on - * temporaries so we need to lower indirects on any of the - * varyings we have demoted here. - */ - NIR_PASS_V(producer, nir_lower_indirect_derefs, indirect_mask); - NIR_PASS_V(consumer, nir_lower_indirect_derefs, indirect_mask); - - const bool p_is_scalar = - compiler->scalar_stage[producer->info.stage]; - producer = brw_nir_optimize(producer, compiler, p_is_scalar); - - const bool c_is_scalar = - compiler->scalar_stage[producer->info.stage]; - consumer = brw_nir_optimize(consumer, compiler, c_is_scalar); - } - - shProg->_LinkedShaders[i]->Program->nir = producer; - shProg->_LinkedShaders[next]->Program->nir = consumer; - - next = i; + brw_nir_link_shaders(compiler, + &shProg->_LinkedShaders[i]->Program->nir, + &shProg->_LinkedShaders[next]->Program->nir); + next = i; } } |