[Mesa-dev] [PATCH 9/9] [AUTONAK] i965/nir: Call nir_sweep().
Kenneth Graunke
kenneth at whitecape.org
Sat Mar 28 14:28:32 PDT 2015
Mostly a proof of concept that it works; we free the memory shortly
afterwards anyway, so it's kind of dumb to do this.
The plan is to instead build nir_shaders at link time, rather than when
compiling each shader specialization, and delete the GLSL IR.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 56 ++++++++++++++++++--------------
1 file changed, 32 insertions(+), 24 deletions(-)
This definitely shouldn't land. However, I ran full Piglit and shader-db runs with
this enabled, and got no crashes or validation failures. I sent it to the list so
people can see how I tested nir_sweep().
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 21e52fe..5218d20 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -29,33 +29,41 @@
#include "brw_nir.h"
static void
+boo(nir_shader *nir)
+{
+ nir_validate_shader(nir);
+ nir_sweep(nir);
+ nir_validate_shader(nir);
+}
+
+static void
nir_optimize(nir_shader *nir)
{
bool progress;
do {
progress = false;
nir_lower_vars_to_ssa(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_lower_alu_to_scalar(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_copy_prop(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_lower_phis_to_scalar(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_copy_prop(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_opt_dce(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_opt_cse(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_opt_peephole_select(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_opt_algebraic(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_opt_constant_folding(nir);
- nir_validate_shader(nir);
+ boo(nir);
progress |= nir_opt_remove_phis(nir);
- nir_validate_shader(nir);
+ boo(nir);
} while (progress);
}
@@ -96,19 +104,19 @@ fs_visitor::emit_nir_code()
nir = prog_to_nir(prog, options);
nir_convert_to_ssa(nir); /* turn registers into SSA */
}
- nir_validate_shader(nir);
+ boo(nir);
nir_lower_global_vars_to_local(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_split_var_copies(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_optimize(nir);
/* Lower a bunch of stuff */
nir_lower_var_copies(nir);
- nir_validate_shader(nir);
+ boo(nir);
/* Get rid of split copies */
nir_optimize(nir);
@@ -129,31 +137,31 @@ fs_visitor::emit_nir_code()
nir_assign_var_locations_scalar(&nir->outputs, &nir->num_outputs);
nir_lower_io(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_remove_dead_variables(nir);
- nir_validate_shader(nir);
+ boo(nir);
if (shader_prog) {
nir_lower_samplers(nir, shader_prog, shader->base.Program);
- nir_validate_shader(nir);
+ boo(nir);
}
nir_lower_system_values(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_lower_atomics(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_optimize(nir);
nir_lower_locals_to_regs(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_lower_to_source_mods(nir);
- nir_validate_shader(nir);
+ boo(nir);
nir_copy_prop(nir);
- nir_validate_shader(nir);
+ boo(nir);
if (unlikely(debug_enabled)) {
fprintf(stderr, "NIR (SSA form) for %s shader:\n", stage_name);
@@ -172,7 +180,7 @@ fs_visitor::emit_nir_code()
}
nir_convert_from_ssa(nir);
- nir_validate_shader(nir);
+ boo(nir);
/* This is the last pass we run before we start emitting stuff. It
* determines when we need to insert boolean resolves on Gen <= 5. We
--
2.3.4
More information about the mesa-dev
mailing list