On 15 August 2012 16:37, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
16-wide programs use roughly twice as many registers as 8-wide, and we<br>
don't support spilling in 16-wide.  So if an 8-wide program uses more<br>
than half the available GRFs, the 16-wide one almost certainly will fail<br>
to compile during register allocation.<br>
<br>
Not only that, but attempting to compiling such shaders is expensive:<br>
programs that use a lot of registers tend to be quite complex, meaning<br>
that we spend more time than usual generating and optimizing code.  If<br>
we fail at register allocation, we've failed at the last step, after<br>
needlessly burning through a lot of CPU time.<br>
<br>
To make things worse, such shader compilation typically happens at the<br>
first draw call using the shader, so it can cause the GPU to stall.<br>
<br>
With all that in mind, it makes sense to short-circuit the 16-wide<br>
attempt if the 8-wide program uses too many registers.  I've chosen 75<br>
to be conservative---if we /can/ compile a SIMD16 program, we want to.<br>
<br>
Reduces the number of GPU stalls due to fragment shader recompiles<br>
in Left 4 Dead 2 by about 20%, and reduces the duration of many of the<br>
remaining stalls by about half.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_fs.cpp | 5 ++++-<br>
 1 file changed, 4 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
index e2dafdc..a113105 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
@@ -2100,7 +2100,10 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c,<br>
       return false;<br>
    }<br>
<br>
-   if (intel->gen >= 5 && c->prog_data.nr_pull_params == 0) {<br>
+   if (v.grf_used >= 75) {<br>
+      perf_debug("Too many registers to attempt compiling a 16-wide shader; "<br>
+                 "falling back to 8-wide at a 10-20%% performance cost.\n");<br>
+   } else if (intel->gen >= 5 && c->prog_data.nr_pull_params == 0) {<br></blockquote><div><br>It looks like this code will give the perf warning even for situations where we couldn't do 16-wide anyhow (intel->gen == 4 || c->prog_data.nr_pull_params != 0).  To avoid confusing people, we should probably only give the perf warning if register count is the *only* reason we can't do 16-wide.<br>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       c->dispatch_width = 16;<br>
       fs_visitor v2(c, prog, shader);<br>
       v2.import_uniforms(&v);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>