i965/gs: Add GS_OPCODE_URB_WRITE.
authorPaul Berry <stereotype441@gmail.com>
Thu, 21 Mar 2013 16:11:12 +0000 (09:11 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 23 Aug 2013 18:03:15 +0000 (11:03 -0700)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/mesa/drivers/dri/i965/brw_defines.h
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4.h
src/mesa/drivers/dri/i965/brw_vec4_emit.cpp

index 2ab0a2b00ebf2bd2abebd1a87e751867434f8ac5..16a1dbc022789c52502e56310f8914563ea97cf9 100644 (file)
@@ -799,6 +799,15 @@ enum opcode {
    VS_OPCODE_PULL_CONSTANT_LOAD,
    VS_OPCODE_PULL_CONSTANT_LOAD_GEN7,
    VS_OPCODE_UNPACK_FLAGS_SIMD4X2,
+
+   /**
+    * Write geometry shader output data to the URB.
+    *
+    * Unlike VS_OPCODE_URB_WRITE, this opcode doesn't do an implied move from
+    * R0 to the first MRF.  This allows the geometry shader to override the
+    * "Slot {0,1} Offset" fields in the message header.
+    */
+   GS_OPCODE_URB_WRITE,
 };
 
 #define BRW_PREDICATE_NONE             0
index afa14c5d77ee659ed37374f6fc63ce94c7f14a33..d3de6edb8ce05f1da3339712814de6ea690cfafa 100644 (file)
@@ -485,7 +485,7 @@ brw_instruction_name(enum opcode op)
       return "placeholder_halt";
 
    case VS_OPCODE_URB_WRITE:
-      return "urb_write";
+      return "vs_urb_write";
    case VS_OPCODE_SCRATCH_READ:
       return "scratch_read";
    case VS_OPCODE_SCRATCH_WRITE:
@@ -497,6 +497,9 @@ brw_instruction_name(enum opcode op)
    case VS_OPCODE_UNPACK_FLAGS_SIMD4X2:
       return "unpack_flags_simd4x2";
 
+   case GS_OPCODE_URB_WRITE:
+      return "gs_urb_write";
+
    default:
       /* Yes, this leaks.  It's in debug code, it should never occur, and if
        * it does, you should just add the case to the list above.
index abdf3abd4be797610ff5e479a890ef9073f1676f..c97839641e1bf2eb33c24572f9d93c3500698a90 100644 (file)
@@ -259,6 +259,8 @@ vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
       return 2;
    case VS_OPCODE_SCRATCH_WRITE:
       return 3;
+   case GS_OPCODE_URB_WRITE:
+      return 0;
    case SHADER_OPCODE_SHADER_TIME_ADD:
       return 0;
    case SHADER_OPCODE_TEX:
index a398f71a50079077571f8816cc0cb3dc67cdbbc3..c3e2212ac591caeeae00c72a6a8e580c854c568a 100644 (file)
@@ -627,7 +627,8 @@ private:
                     struct brw_reg dst,
                     struct brw_reg src);
 
-   void generate_urb_write(vec4_instruction *inst);
+   void generate_vs_urb_write(vec4_instruction *inst);
+   void generate_gs_urb_write(vec4_instruction *inst);
    void generate_oword_dual_block_offsets(struct brw_reg m1,
                                          struct brw_reg index);
    void generate_scratch_write(vec4_instruction *inst,
index 89831de43f5502daef01d7b805a9e2ee6cd17a8e..84f50b065767abaae10ceda1d997a09b11b3f1d9 100644 (file)
@@ -399,7 +399,7 @@ vec4_generator::generate_tex(vec4_instruction *inst,
 }
 
 void
-vec4_generator::generate_urb_write(vec4_instruction *inst)
+vec4_generator::generate_vs_urb_write(vec4_instruction *inst)
 {
    brw_urb_WRITE(p,
                 brw_null_reg(), /* dest */
@@ -412,6 +412,21 @@ vec4_generator::generate_urb_write(vec4_instruction *inst)
                 BRW_URB_SWIZZLE_INTERLEAVE);
 }
 
+void
+vec4_generator::generate_gs_urb_write(vec4_instruction *inst)
+{
+   struct brw_reg src = brw_message_reg(inst->base_mrf);
+   brw_urb_WRITE(p,
+                 brw_null_reg(), /* dest */
+                 inst->base_mrf, /* starting mrf reg nr */
+                 src,
+                 inst->urb_write_flags,
+                 inst->mlen,
+                 0,             /* response len */
+                 inst->offset,  /* urb destination offset */
+                 BRW_URB_SWIZZLE_INTERLEAVE);
+}
+
 void
 vec4_generator::generate_oword_dual_block_offsets(struct brw_reg m1,
                                                   struct brw_reg index)
@@ -861,7 +876,7 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
       break;
 
    case VS_OPCODE_URB_WRITE:
-      generate_urb_write(inst);
+      generate_vs_urb_write(inst);
       break;
 
    case VS_OPCODE_SCRATCH_READ:
@@ -880,6 +895,10 @@ vec4_generator::generate_vec4_instruction(vec4_instruction *instruction,
       generate_pull_constant_load_gen7(inst, dst, src[0], src[1]);
       break;
 
+   case GS_OPCODE_URB_WRITE:
+      generate_gs_urb_write(inst);
+      break;
+
    case SHADER_OPCODE_SHADER_TIME_ADD:
       brw_shader_time_add(p, src[0], SURF_INDEX_VS_SHADER_TIME);
       mark_surface_used(SURF_INDEX_VS_SHADER_TIME);