i965: clip: Convert computations to ..._to_offset() for clarity.
authorPaul Berry <stereotype441@gmail.com>
Wed, 31 Aug 2011 22:34:01 +0000 (15:34 -0700)
committerPaul Berry <stereotype441@gmail.com>
Tue, 6 Sep 2011 18:05:28 +0000 (11:05 -0700)
This patch replaces some ad-hoc computations using ATTR_SIZE and the
offset[] array to use the VUE map functions
brw_vert_result_to_offset() and brw_vue_slot_to_offset().

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_clip_tri.c
src/mesa/drivers/dri/i965/brw_clip_unfilled.c
src/mesa/drivers/dri/i965/brw_clip_util.c

index d0638748d71012f0e84c0ec87360ce23e8cf4176..73b6d272baedfbcb7e8f321e7aad48c6fd85ea74 100644 (file)
@@ -79,7 +79,7 @@ void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
        * used.  Fill the second half with zero.
        */
       for (j = 0; j < 3; j++) {
-        GLuint delta = c->vue_map.num_slots * 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));
       }
index 53345f150766ffd9bc059fca5995645f70e96adf..6ddb2d57890f4ba69da34ecd9ac84084e57c49af 100644 (file)
@@ -159,14 +159,22 @@ static void copy_bfc( struct brw_clip_compile *c )
         if (brw_clip_have_vert_result(c, VERT_RESULT_COL0) &&
              brw_clip_have_vert_result(c, VERT_RESULT_BFC0))
            brw_MOV(p, 
-                   byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_COL0]),
-                   byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_BFC0]));
+                   byte_offset(c->reg.vertex[i],
+                                brw_vert_result_to_offset(&c->vue_map,
+                                                          VERT_RESULT_COL0)),
+                   byte_offset(c->reg.vertex[i],
+                                brw_vert_result_to_offset(&c->vue_map,
+                                                          VERT_RESULT_BFC0)));
 
         if (brw_clip_have_vert_result(c, VERT_RESULT_COL1) &&
              brw_clip_have_vert_result(c, VERT_RESULT_BFC1))
            brw_MOV(p, 
-                   byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_COL1]),
-                   byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_BFC1]));
+                   byte_offset(c->reg.vertex[i],
+                                brw_vert_result_to_offset(&c->vue_map,
+                                                          VERT_RESULT_COL1)),
+                   byte_offset(c->reg.vertex[i],
+                                brw_vert_result_to_offset(&c->vue_map,
+                                                          VERT_RESULT_BFC1)));
       }
    }
    brw_ENDIF(p);
@@ -225,12 +233,18 @@ static void merge_edgeflags( struct brw_clip_compile *c )
    {   
       brw_set_conditionalmod(p, BRW_CONDITIONAL_EQ);
       brw_AND(p, vec1(brw_null_reg()), get_element_ud(c->reg.R0, 2), brw_imm_ud(1<<8));
-      brw_MOV(p, byte_offset(c->reg.vertex[0], c->offset[VERT_RESULT_EDGE]), brw_imm_f(0));
+      brw_MOV(p, byte_offset(c->reg.vertex[0],
+                             brw_vert_result_to_offset(&c->vue_map,
+                                                       VERT_RESULT_EDGE)),
+              brw_imm_f(0));
       brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
       brw_set_conditionalmod(p, BRW_CONDITIONAL_EQ);
       brw_AND(p, vec1(brw_null_reg()), get_element_ud(c->reg.R0, 2), brw_imm_ud(1<<9));
-      brw_MOV(p, byte_offset(c->reg.vertex[2], c->offset[VERT_RESULT_EDGE]), brw_imm_f(0));
+      brw_MOV(p, byte_offset(c->reg.vertex[2],
+                             brw_vert_result_to_offset(&c->vue_map,
+                                                       VERT_RESULT_EDGE)),
+              brw_imm_f(0));
       brw_set_predicate_control(p, BRW_PREDICATE_NONE);
    }
    brw_ENDIF(p);
@@ -302,7 +316,8 @@ static void emit_lines(struct brw_clip_compile *c,
       /* draw edge if edgeflag != 0 */
       brw_CMP(p, 
              vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, 
-             deref_1f(v0, c->offset[VERT_RESULT_EDGE]),
+             deref_1f(v0, brw_vert_result_to_offset(&c->vue_map,
+                                                     VERT_RESULT_EDGE)),
              brw_imm_f(0));
       brw_IF(p, BRW_EXECUTE_1);
       {
@@ -340,7 +355,8 @@ static void emit_points(struct brw_clip_compile *c,
        */
       brw_CMP(p, 
              vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, 
-             deref_1f(v0, c->offset[VERT_RESULT_EDGE]),
+             deref_1f(v0, brw_vert_result_to_offset(&c->vue_map,
+                                                     VERT_RESULT_EDGE)),
              brw_imm_f(0));
       brw_IF(p, BRW_EXECUTE_1);
       {
index cfbb497f9d0eeaba172efd84b046095ad1e7a1e1..8c9f0e49575dbda4a781d16d94da6856ab9d9818 100644 (file)
@@ -152,7 +152,7 @@ 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;
+      GLuint delta = brw_vue_slot_to_offset(slot);
 
       if (c->vue_map.slot_to_vert_result[slot] == VERT_RESULT_EDGE) {
         if (force_edgeflag) 
@@ -183,7 +183,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));
    }
@@ -292,23 +292,39 @@ void brw_clip_copy_colors( struct brw_clip_compile *c,
 
    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]));
+             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]));
+             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]));
+             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)));
 }