i965g: special case setup when fs has no inputs
authorKeith Whitwell <keithw@vmware.com>
Fri, 20 Nov 2009 03:15:21 +0000 (19:15 -0800)
committerKeith Whitwell <keithw@vmware.com>
Fri, 20 Nov 2009 03:29:33 +0000 (19:29 -0800)
src/gallium/drivers/i965/brw_sf.c
src/gallium/drivers/i965/brw_sf.h
src/gallium/drivers/i965/brw_sf_emit.c

index aa2ab5098cedef2515648e51eccf2efc33a9530a..0b94dc40c31ba7ba7df49190b66acbf22775e751 100644 (file)
@@ -64,32 +64,42 @@ static enum pipe_error compile_sf_prog( struct brw_context *brw,
    c.prog_data.urb_read_length = c.nr_attr_regs;
    c.prog_data.urb_entry_size = c.nr_setup_regs * 2;
 
-   
-   /* Which primitive?  Or all three? 
+   /* Special case when there are no attributes to setup.
+    *
+    * XXX: should be able to set nr_setup_attrs to nr_attrs-1 -- but
+    * breaks vp-tris.c
     */
-   switch (key->primitive) {
-   case SF_TRIANGLES:
-      c.nr_verts = 3;
-      brw_emit_tri_setup( &c, GL_TRUE );
-      break;
-   case SF_LINES:
-      c.nr_verts = 2;
-      brw_emit_line_setup( &c, GL_TRUE );
-      break;
-   case SF_POINTS:
-      c.nr_verts = 1;
-      if (key->do_point_sprite)
-         brw_emit_point_sprite_setup( &c, GL_TRUE );
-      else
-         brw_emit_point_setup( &c, GL_TRUE );
-      break;
-   case SF_UNFILLED_TRIS:
-      c.nr_verts = 3;
-      brw_emit_anyprim_setup( &c );
-      break;
-   default:
-      assert(0);
-      return PIPE_ERROR_BAD_INPUT;
+   if (c.nr_attrs - 1 == 0) {
+      c.nr_verts = 0;
+      brw_emit_null_setup( &c );
+   }
+   else {
+      /* Which primitive?  Or all three? 
+       */
+      switch (key->primitive) {
+      case SF_TRIANGLES:
+         c.nr_verts = 3;
+         brw_emit_tri_setup( &c, GL_TRUE );
+         break;
+      case SF_LINES:
+         c.nr_verts = 2;
+         brw_emit_line_setup( &c, GL_TRUE );
+         break;
+      case SF_POINTS:
+         c.nr_verts = 1;
+         if (key->do_point_sprite)
+            brw_emit_point_sprite_setup( &c, GL_TRUE );
+         else
+            brw_emit_point_setup( &c, GL_TRUE );
+         break;
+      case SF_UNFILLED_TRIS:
+         c.nr_verts = 3;
+         brw_emit_anyprim_setup( &c );
+         break;
+      default:
+         assert(0);
+         return PIPE_ERROR_BAD_INPUT;
+      }
    }
 
    /* get the program
index 0b7003dc5efa5dbd9618800976cebfbe2b8bc99d..a895c7d2f6aafca92d31075652cd86aa9f24ea33 100644 (file)
@@ -112,6 +112,7 @@ struct brw_sf_compile {
 };
 
  
+void brw_emit_null_setup( struct brw_sf_compile *c );
 void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate );
 void brw_emit_line_setup( struct brw_sf_compile *c, GLboolean allocate );
 void brw_emit_point_setup( struct brw_sf_compile *c, GLboolean allocate );
index db52c9553e7e8123ef9ff81427eb0358b3551a06..2983e8a9dd4a3aab1b9260dbe9279a37e8323696 100644 (file)
@@ -352,6 +352,25 @@ static GLboolean calculate_masks( struct brw_sf_compile *c,
 }
 
 
+void brw_emit_null_setup( struct brw_sf_compile *c )
+{
+   struct brw_compile *p = &c->func;
+
+   /* m0 is implicitly copied from r0 in the send instruction:
+    */  
+   brw_urb_WRITE(p, 
+                 brw_null_reg(),
+                 0,
+                 brw_vec8_grf(0, 0), /* r0, will be copied to m0 */
+                 0,    /* allocate */
+                 1,    /* used */
+                 1,    /* msg len */
+                 0,    /* response len */
+                 1,    /* eot */
+                 1,    /* writes complete */
+                 0,    /* offset */
+                 BRW_URB_SWIZZLE_TRANSPOSE); 
+}
 
 void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate)
 {