i965: Make use of gl_transform_feedback_info::ComponentOffset.
authorPaul Berry <stereotype441@gmail.com>
Tue, 27 Dec 2011 03:31:20 +0000 (19:31 -0800)
committerPaul Berry <stereotype441@gmail.com>
Thu, 5 Jan 2012 21:27:11 +0000 (13:27 -0800)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_gs.c
src/mesa/drivers/dri/i965/brw_gs.h
src/mesa/drivers/dri/i965/brw_gs_emit.c
src/mesa/drivers/dri/i965/gen7_sol_state.c

index 850d7b455fc89698006a6e1d7deb1e80cc8e911d..f9c4f6aa0141dc69875dabf16494bd89bb48b3b5 100644 (file)
@@ -154,6 +154,13 @@ static void compile_gs_prog( struct brw_context *brw,
 static void populate_key( struct brw_context *brw,
                          struct brw_gs_prog_key *key )
 {
+   static const unsigned swizzle_for_offset[4] = {
+      BRW_SWIZZLE4(0, 1, 2, 3),
+      BRW_SWIZZLE4(1, 2, 3, 3),
+      BRW_SWIZZLE4(2, 3, 3, 3),
+      BRW_SWIZZLE4(3, 3, 3, 3)
+   };
+
    struct gl_context *ctx = &brw->intel.ctx;
    struct intel_context *intel = &brw->intel;
 
@@ -207,6 +214,8 @@ static void populate_key( struct brw_context *brw,
          for (i = 0; i < key->num_transform_feedback_bindings; ++i) {
             key->transform_feedback_bindings[i] =
                linked_xfb_info->Outputs[i].OutputRegister;
+            key->transform_feedback_swizzles[i] =
+               swizzle_for_offset[linked_xfb_info->Outputs[i].ComponentOffset];
          }
       }
       /* On Gen6, GS is also used for rasterizer discard. */
index 2ab8b724eaced7f0cde22fd61f1a736a0928ff26..f2597c8abab3c99746141bbbf470840051fbd1e1 100644 (file)
@@ -63,6 +63,13 @@ struct brw_gs_prog_key {
     * entry.
     */
    unsigned char transform_feedback_bindings[BRW_MAX_SOL_BINDINGS];
+
+   /**
+    * Map from the index of a transform feedback binding table entry to the
+    * swizzles that should be used when streaming out data through that
+    * binding table entry.
+    */
+   unsigned char transform_feedback_swizzles[BRW_MAX_SOL_BINDINGS];
 };
 
 struct brw_gs_compile {
index 407450170bf7d9edeeed99469cad8515236edf35..501cee42ea4a5a4f94e43a54db3215bdb56a6f4c 100644 (file)
@@ -448,7 +448,7 @@ gen6_sol_program(struct brw_gs_compile *c, struct brw_gs_prog_key *key,
             vertex_slot.subnr = (slot % 2) * 16;
             /* gl_PointSize is stored in VERT_RESULT_PSIZ.w. */
             vertex_slot.dw1.bits.swizzle = vert_result == VERT_RESULT_PSIZ
-               ? BRW_SWIZZLE_WWWW : BRW_SWIZZLE_NOOP;
+               ? BRW_SWIZZLE_WWWW : key->transform_feedback_swizzles[binding];
             brw_set_access_mode(p, BRW_ALIGN_16);
             brw_MOV(p, stride(c->reg.header, 4, 4, 1),
                     retype(vertex_slot, BRW_REGISTER_TYPE_UD));
index df6b9ee0f1374b9e46e46f38d30da3b755c0b931..674e14f1252190420953c616504298de02ce883e 100644 (file)
@@ -129,6 +129,8 @@ upload_3dstate_so_decl_list(struct brw_context *brw,
       if (vert_result == VERT_RESULT_PSIZ) {
          assert(linked_xfb_info->Outputs[i].NumComponents == 1);
          component_mask <<= 3;
+      } else {
+         component_mask <<= linked_xfb_info->Outputs[i].ComponentOffset;
       }
 
       buffer_mask |= 1 << buffer;