<div dir="ltr">On 29 October 2013 13:28, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I believe this will never happen in SIMD8 mode, but it could for SIMD16<br>
when we fix it.<br>
---<br>
 src/mesa/drivers/dri/i965/brw_fs.h                |  1 +<br>
 src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 23 +++++++++++++++++++++++<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp      |  2 ++<br>
 3 files changed, 26 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h<br>
index 50a045e..fb1da4c 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs.h<br>
@@ -466,6 +466,7 @@ public:<br>
    fs_reg shader_start_time;<br>
<br>
    int grf_used;<br>
+   bool spilled_any_registers;<br>
<br>
    const unsigned dispatch_width; /**< 8 or 16 */<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp<br>
index d86027e..50f3414 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp<br>
@@ -643,6 +643,29 @@ fs_visitor::spill_reg(int spill_reg)<br>
    unsigned int spill_offset = c->last_scratch;<br>
    assert(ALIGN(spill_offset, 16) == spill_offset); /* oword read/write req. */<br>
    c->last_scratch += size * REG_SIZE;<br>
+   int spill_base_mrf = dispatch_width > 8 ? 13 : 14;<br>
+<br>
+   /* Spills may use MRFs 13-15 in the SIMD16 case.  Our texturing is done<br>
+    * using up to 11 MRFs starting from either m1 or m2, and fb writes can use<br>
+    * up to 13 (gen6+ simd16: 2 header + 8 color + 2 src0alpha + 2 omask) or<br>
+    * 15 (gen4-5 simd16: 2 header + 8 color + 1 aads + 2 src depth + 2 dst<br>
+    * depth), starting from m1.  If you're attentive, you may note that m1+15<br>
+    * = m16, which doesn't even exist.</blockquote><div><br></div><div>There's a fencepost error in your reasoning here.  If fb writes start at m1 and use 15 registers, then they use registers m1 through m15, all of which exist.<br>
<br></div><div>With the comment fixed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  In summary: We may not be able to<br>
+    * spill in SIMD16 mode, because we'd stomp the FB writes.<br>
+    */<br>
+   if (!spilled_any_registers) {<br>
+      bool mrf_used[BRW_MAX_MRF];<br>
+      get_used_mrfs(mrf_used);<br>
+<br>
+      for (int i = spill_base_mrf; i < BRW_MAX_MRF; i++) {<br>
+         if (mrf_used[i]) {<br>
+            fail("Register spilling not supported with m%d used", i);<br>
+          return;<br>
+         }<br>
+      }<br>
+<br>
+      spilled_any_registers = true;<br>
+   }<br>
<br>
    /* Generate spill/unspill instructions for the objects being<br>
     * spilled.  Right now, we spill or unspill the whole thing to a<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index 71b4bf9..0e2dfd3 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -2722,6 +2722,8 @@ fs_visitor::fs_visitor(struct brw_context *brw,<br>
    this->force_uncompressed_stack = 0;<br>
    this->force_sechalf_stack = 0;<br>
<br>
+   this->spilled_any_registers = false;<br>
+<br>
    memset(&this->param_size, 0, sizeof(this->param_size));<br>
 }<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.8.4.rc3<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></div></div>