mesa: add/update comments in _mesa_copy_buffer_subdata()
[mesa.git] / src / mesa / drivers / dri / i965 / brw_clip_util.c
index e90f14687c0e4f9e1e42a6e2a27acda6c43897d8..bf8cc3ac81545eed29f26b26603c59c3c7220ccf 100644 (file)
@@ -135,7 +135,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
                             struct brw_indirect v0_ptr, /* from */
                             struct brw_indirect v1_ptr, /* to */
                             struct brw_reg t0,
-                            GLboolean force_edgeflag)
+                            bool force_edgeflag)
 {
    struct brw_compile *p = &c->func;
    struct brw_reg tmp = get_tmp(c);
@@ -151,17 +151,26 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
       
    /* Iterate over each attribute (could be done in pairs?)
     */
-   for (slot = 2*c->header_regs; slot < c->vue_map.num_slots; slot++) {
-      GLuint delta = ATTR_SIZE * slot;
+   for (slot = 0; slot < c->vue_map.num_slots; slot++) {
+      int vert_result = c->vue_map.slot_to_vert_result[slot];
+      GLuint delta = brw_vue_slot_to_offset(slot);
 
-      if (c->vue_map.slot_to_vert_result[slot] == VERT_RESULT_EDGE) {
+      if (vert_result == VERT_RESULT_EDGE) {
         if (force_edgeflag) 
            brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(1));
         else
            brw_MOV(p, deref_4f(dest_ptr, delta), deref_4f(v0_ptr, delta));
-      }
-      else {
-        /* Interpolate: 
+      } else if (vert_result == VERT_RESULT_PSIZ ||
+                 vert_result == VERT_RESULT_CLIP_DIST0 ||
+                 vert_result == VERT_RESULT_CLIP_DIST1) {
+        /* PSIZ doesn't need interpolation because it isn't used by the
+          * fragment shader.  CLIP_DIST0 and CLIP_DIST1 don't need
+          * intepolation because on pre-GEN6, these are just placeholder VUE
+          * slots that don't perform any action.
+          */
+      } else if (vert_result < VERT_RESULT_MAX) {
+        /* This is a true vertex result (and not a special value for the VUE
+         * header), so interpolate:
          *
          *        New = attr0 + t*attr1 - t*attr0
          */
@@ -183,7 +192,7 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
    }
 
    if (c->vue_map.num_slots % 2) {
-      GLuint delta = c->vue_map.num_slots * ATTR_SIZE;
+      GLuint delta = brw_vue_slot_to_offset(c->vue_map.num_slots);
 
       brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(0));
    }
@@ -198,8 +207,8 @@ void brw_clip_interp_vertex( struct brw_clip_compile *c,
 
 void brw_clip_emit_vue(struct brw_clip_compile *c, 
                       struct brw_indirect vert,
-                      GLboolean allocate,
-                      GLboolean eot,
+                      bool allocate,
+                      bool eot,
                       GLuint header)
 {
    struct brw_compile *p = &c->func;
@@ -290,25 +299,41 @@ void brw_clip_copy_colors( struct brw_clip_compile *c,
 {
    struct brw_compile *p = &c->func;
 
-   if (c->offset[VERT_RESULT_COL0])
+   if (brw_clip_have_vert_result(c, VERT_RESULT_COL0))
       brw_MOV(p, 
-             byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_COL0]),
-             byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_COL0]));
-
-   if (c->offset[VERT_RESULT_COL1])
+             byte_offset(c->reg.vertex[to],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_COL0)),
+             byte_offset(c->reg.vertex[from],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_COL0)));
+
+   if (brw_clip_have_vert_result(c, VERT_RESULT_COL1))
       brw_MOV(p, 
-             byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_COL1]),
-             byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_COL1]));
-
-   if (c->offset[VERT_RESULT_BFC0])
+             byte_offset(c->reg.vertex[to],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_COL1)),
+             byte_offset(c->reg.vertex[from],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_COL1)));
+
+   if (brw_clip_have_vert_result(c, VERT_RESULT_BFC0))
       brw_MOV(p, 
-             byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_BFC0]),
-             byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_BFC0]));
-
-   if (c->offset[VERT_RESULT_BFC1])
+             byte_offset(c->reg.vertex[to],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_BFC0)),
+             byte_offset(c->reg.vertex[from],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_BFC0)));
+
+   if (brw_clip_have_vert_result(c, VERT_RESULT_BFC1))
       brw_MOV(p, 
-             byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_BFC1]),
-             byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_BFC1]));
+             byte_offset(c->reg.vertex[to],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_BFC1)),
+             byte_offset(c->reg.vertex[from],
+                          brw_vert_result_to_offset(&c->vue_map,
+                                                    VERT_RESULT_BFC1)));
 }