mesa: add/update comments in _mesa_copy_buffer_subdata()
[mesa.git] / src / mesa / drivers / dri / i965 / brw_clip_tri.c
index 0f938fe0b6ff4cdcb94cc9995917b9962a8b7978..a29f8e05b34245c1d3f3123f496eec656d57eaab 100644 (file)
@@ -74,9 +74,12 @@ void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
       i += c->nr_regs;
    }
 
-   if (c->nr_attrs & 1) {
+   if (c->vue_map.num_slots % 2) {
+      /* The VUE has an odd number of slots so the last register is only half
+       * used.  Fill the second half with zero.
+       */
       for (j = 0; j < 3; j++) {
-        GLuint delta = c->offset[c->idx_to_attr[c->nr_attrs - 1]] + ATTR_SIZE;
+        GLuint delta = brw_vue_slot_to_offset(c->vue_map.num_slots);
 
         brw_MOV(&c->func, byte_offset(c->reg.vertex[j], delta), brw_imm_f(0));
       }
@@ -229,8 +232,6 @@ void brw_clip_tri( struct brw_clip_compile *c )
    struct brw_indirect inlist_ptr = brw_indirect(4, 0);
    struct brw_indirect outlist_ptr = brw_indirect(5, 0);
    struct brw_indirect freelist_ptr = brw_indirect(6, 0);
-   struct brw_instruction *plane_loop;
-   struct brw_instruction *vertex_loop;
    GLuint hpos_offset = brw_vert_result_to_offset(&c->vue_map,
                                                   VERT_RESULT_HPOS);
    
@@ -241,7 +242,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
 
    brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
 
-   plane_loop = brw_DO(p, BRW_EXECUTE_1);
+   brw_DO(p, BRW_EXECUTE_1);
    {
       /* if (planemask & 1)
        */
@@ -263,7 +264,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
         brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
         brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
 
-        vertex_loop = brw_DO(p, BRW_EXECUTE_1);
+        brw_DO(p, BRW_EXECUTE_1);
         {
            /* vtx = *input_ptr;
             */
@@ -293,7 +294,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
                  brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtxPrev) );
                  brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
-                 brw_clip_interp_vertex(c, vtxOut, vtxPrev, vtx, c->reg.t, GL_FALSE);
+                 brw_clip_interp_vertex(c, vtxOut, vtxPrev, vtx, c->reg.t, false);
 
                  /* *outlist_ptr++ = vtxOut;
                   * nr_verts++; 
@@ -335,7 +336,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
                  brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtx) );
                  brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
-                 brw_clip_interp_vertex(c, vtxOut, vtx, vtxPrev, c->reg.t, GL_TRUE);             
+                 brw_clip_interp_vertex(c, vtxOut, vtx, vtxPrev, c->reg.t, true);
 
                  /* *outlist_ptr++ = vtxOut;
                   * nr_verts++; 
@@ -361,7 +362,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
            brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
            brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
         } 
-        brw_WHILE(p, vertex_loop);
+        brw_WHILE(p);
 
         /* vtxPrev = *(outlist_ptr-1)  OR: outlist[nr_verts-1]
          * inlist = outlist
@@ -393,7 +394,7 @@ void brw_clip_tri( struct brw_clip_compile *c )
       brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
       brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
    }
-   brw_WHILE(p, plane_loop);
+   brw_WHILE(p);
 }
 
 
@@ -401,7 +402,6 @@ void brw_clip_tri( struct brw_clip_compile *c )
 void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
 {
    struct brw_compile *p = &c->func;
-   struct brw_instruction *loop;
 
    /* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
     */
@@ -419,14 +419,17 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
       brw_MOV(p, get_addr_reg(vptr), brw_address(c->reg.inlist));
       brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
 
-      brw_clip_emit_vue(c, v0, 1, 0, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_START));
+      brw_clip_emit_vue(c, v0, 1, 0,
+                        ((_3DPRIM_TRIFAN << URB_WRITE_PRIM_TYPE_SHIFT)
+                         | URB_WRITE_PRIM_START));
       
       brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
       brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
 
-      loop = brw_DO(p, BRW_EXECUTE_1);
+      brw_DO(p, BRW_EXECUTE_1);
       {
-        brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN << 2));
+        brw_clip_emit_vue(c, v0, 1, 0,
+                           (_3DPRIM_TRIFAN << URB_WRITE_PRIM_TYPE_SHIFT));
   
         brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
         brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
@@ -434,9 +437,11 @@ void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
         brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
         brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
       }
-      brw_WHILE(p, loop);
+      brw_WHILE(p);
 
-      brw_clip_emit_vue(c, v0, 0, 1, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_END));
+      brw_clip_emit_vue(c, v0, 0, 1,
+                        ((_3DPRIM_TRIFAN << URB_WRITE_PRIM_TYPE_SHIFT)
+                         | URB_WRITE_PRIM_END));
    }
    brw_ENDIF(p);
 }