[Mesa-dev] [PATCH 4/4] i965/gs/gen6: Maximum allowed size of SEND messages is 15 (4 bits)

Iago Toral Quiroga itoral at igalia.com
Wed Sep 23 01:05:04 PDT 2015


Comit d48ac9306619 addressed this for VS, but we forgot to do the same for
URB writes generated by the gen6 GS.
---
 src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp | 30 ++++++++++++++++-----------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
index 68e443d..cb45d7e 100644
--- a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
@@ -305,6 +305,18 @@ gen6_gs_visitor::emit_urb_write_header(int mrf)
    emit(GS_OPCODE_SET_DWORD_2, dst_reg(MRF, mrf), flags_data);
 }
 
+static int
+align_interleaved_urb_mlen(int mlen)
+{
+   /* URB data written (does not include the message header reg) must
+    * be a multiple of 256 bits, or 2 VS registers.  See vol5c.5,
+    * section 5.4.3.2.2: URB_INTERLEAVED.
+    */
+   if ((mlen % 2) != 1)
+      mlen++;
+   return mlen;
+}
+
 void
 gen6_gs_visitor::emit_urb_write_opcode(bool complete, int base_mrf,
                                        int last_mrf, int urb_offset)
@@ -331,14 +343,7 @@ gen6_gs_visitor::emit_urb_write_opcode(bool complete, int base_mrf,
    }
 
    inst->base_mrf = base_mrf;
-   /* URB data written (does not include the message header reg) must
-    * be a multiple of 256 bits, or 2 VS registers.  See vol5c.5,
-    * section 5.4.3.2.2: URB_INTERLEAVED.
-    */
-   int mlen = last_mrf - base_mrf;
-   if ((mlen % 2) != 1)
-      mlen++;
-   inst->mlen = mlen;
+   inst->mlen = align_interleaved_urb_mlen(last_mrf - base_mrf);
    inst->offset = urb_offset;
 }
 
@@ -373,9 +378,9 @@ gen6_gs_visitor::emit_thread_end()
 
    /* In the process of generating our URB write message contents, we
     * may need to unspill a register or load from an array.  Those
-    * reads would use MRFs 14-15.
+    * reads would use MRFs 21..23
     */
-   int max_usable_mrf = 13;
+   int max_usable_mrf = FIRST_SPILL_MRF(devinfo->gen);
 
    /* Issue the FF_SYNC message and obtain the initial VUE handle. */
    emit(CMP(dst_null_d(), this->vertex_count, 0u, BRW_CONDITIONAL_G));
@@ -450,9 +455,10 @@ gen6_gs_visitor::emit_thread_end()
                         this->vertex_output_offset, 1u));
 
                /* If this was max_usable_mrf, we can't fit anything more into
-                * this URB WRITE.
+                * this URB WRITE. Same if we reached the max. message length.
                 */
-               if (mrf > max_usable_mrf) {
+               if (mrf > max_usable_mrf ||
+                   align_interleaved_urb_mlen(mrf - base_mrf + 1) > BRW_MAX_MSG_LENGTH) {
                   slot++;
                   break;
                }
-- 
1.9.1



More information about the mesa-dev mailing list