<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 21, 2016 at 6:26 PM, Timothy Arceri <span dir="ltr"><<a href="mailto:timothy.arceri@collabora.com" target="_blank">timothy.arceri@collabora.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This moves the nir_lower_indirect_derefs() call into<br>
brw_preprocess_nir() so thats is called by both OpenGL and Vulkan<br>
and removes that call to the old GLSL IR pass<br>
lower_variable_index_to_cond_<wbr>assign()<br>
<br>
We want to do this pass in nir to be able to move loop unrolling<br>
to nir.<br>
<br>
There is a increase of 1-3 instructions in a small number of shaders,<br>
and 2 Kerbal Space program shaders that increase by 32 instructions.<br>
The changes seem to be caused be the difference in the GLSL IR vs<br>
NIR variable index lowering passes. The GLSL IR pass creates a<br>
simple if ladder for arrays of size 4 or less, while the NIR pass<br>
implements a binary search for all arrays regardless of size.<br>
<br>
Shader-db results BDW:<br>
<br>
total instructions in shared programs: 13021176 -> 13021819 (0.00%)<br>
instructions in affected programs: 57693 -> 58336 (1.11%)<br>
helped: 20<br>
HURT: 190<br>
<br>
total cycles in shared programs: 299805580 -> 299750826 (-0.02%)<br>
cycles in affected programs: 2290024 -> 2235270 (-2.39%)<br>
helped: 337<br>
HURT: 442<br>
<br>
total fills in shared programs: 19984 -> 19984 (0.00%)<br>
fills in affected programs: 0 -> 0<br>
helped: 0<br>
HURT: 0<br>
<br>
LOST:   4<br>
GAINED: 0<br>
<br>
V2: remove the do_copy_propagation() call from the i965 GLSL IR<br>
linking code. This call was added in f7741c52111 but since we are<br>
moving the variable index lowering to NIR we no longer need it and<br>
can just rely on the nir copy propagation pass.<br>
<br>
Reviewed-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/intel/vulkan/anv_pipeline.<wbr>c        | 10 ----------<br>
 src/mesa/drivers/dri/i965/brw_<wbr>link.cpp | 15 ---------------<br>
 src/mesa/drivers/dri/i965/brw_<wbr>nir.c    | 10 ++++++++++<br>
 3 files changed, 10 insertions(+), 25 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>pipeline.c b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
index 9104267..e2fbcab 100644<br>
--- a/src/intel/vulkan/anv_<wbr>pipeline.c<br>
+++ b/src/intel/vulkan/anv_<wbr>pipeline.c<br>
@@ -190,16 +190,6 @@ anv_shader_compile_to_nir(<wbr>struct anv_device *device,<br>
<br>
    nir_shader_gather_info(nir, entry_point->impl);<br>
<br>
-   nir_variable_mode indirect_mask = 0;<br>
-   if (compiler->glsl_compiler_<wbr>options[stage].<wbr>EmitNoIndirectInput)<br>
-      indirect_mask |= nir_var_shader_in;<br>
-   if (compiler->glsl_compiler_<wbr>options[stage].<wbr>EmitNoIndirectOutput)<br>
-      indirect_mask |= nir_var_shader_out;<br>
-   if (compiler->glsl_compiler_<wbr>options[stage].<wbr>EmitNoIndirectTemp)<br>
-      indirect_mask |= nir_var_local;<br>
-<br>
-   nir_lower_indirect_derefs(nir, indirect_mask);<br>
-<br>
    return nir;<br>
 }<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp b/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp<br>
index 6f37428..0d8a626 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_link.cpp<br>
@@ -134,21 +134,6 @@ process_glsl_ir(struct brw_context *brw,<br>
    lower_noise(shader->ir);<br>
    lower_quadop_vector(shader-><wbr>ir, false);<br>
<br>
-   do_copy_propagation(shader-><wbr>ir);<br>
-<br>
-   bool lowered_variable_indexing =<br>
-      lower_variable_index_to_cond_<wbr>assign(shader->Stage, shader->ir,<br>
-                                          options->EmitNoIndirectInput,<br>
-                                          options->EmitNoIndirectOutput,<br>
-                                          options->EmitNoIndirectTemp,<br>
-                                          options-><wbr>EmitNoIndirectUniform);<br>
-<br>
-   if (unlikely(brw->perf_debug && lowered_variable_indexing)) {<br>
-      perf_debug("Unsupported form of variable indexing in %s; falling "<br>
-                 "back to very inefficient code generation\n",<br>
-                 _mesa_shader_stage_to_abbrev(<wbr>shader->Stage));<br>
-   }<br>
-<br>
    bool progress;<br>
    do {<br>
       progress = false;<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_nir.c b/src/mesa/drivers/dri/i965/<wbr>brw_nir.c<br>
index 55b16cf..7624126 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_nir.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_nir.c<br>
@@ -486,6 +486,16 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir)<br>
    /* Lower a bunch of stuff */<br>
    OPT_V(nir_lower_var_copies);<br>
<br>
+   nir_variable_mode indirect_mask = 0;<br>
+   if (compiler->glsl_compiler_<wbr>options[nir->stage].<wbr>EmitNoIndirectInput)<br>
+      indirect_mask |= nir_var_shader_in;<br>
+   if (compiler->glsl_compiler_<wbr>options[nir->stage].<wbr>EmitNoIndirectOutput)<br>
+      indirect_mask |= nir_var_shader_out;<br>
+   if (compiler->glsl_compiler_<wbr>options[nir->stage].<wbr>EmitNoIndirectTemp)<br>
+      indirect_mask |= nir_var_local;<br>
+<br>
+   nir_lower_indirect_derefs(nir, indirect_mask);<br></blockquote><div><br></div><div>This needs to happen *after* lower_clip_cull_distance_arrays otherwise the "compact" value won't get set on the clip and cull variables and nir_lower_io will throw a fit.  Probably best to just move lower_clip_cull_distance_arrays up.  With that change,<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
    /* Get rid of split copies */<br>
    nir = nir_optimize(nir, is_scalar);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>