i965: clip: Add a function to determine whether a vert_result is in use.
authorPaul Berry <stereotype441@gmail.com>
Thu, 25 Aug 2011 20:27:57 +0000 (13:27 -0700)
committerPaul Berry <stereotype441@gmail.com>
Tue, 6 Sep 2011 18:05:25 +0000 (11:05 -0700)
Previously we would examine the offset[] array (since an offset of 0
meant "not in use").  This paves the way for removing the offset[]
array.

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

index 0324fea..109a0b6 100644 (file)
@@ -126,6 +126,15 @@ struct brw_clip_compile {
 
 #define ATTR_SIZE  (4*4)
 
+/**
+ * True if the given vert_result is one of the outputs of the vertex shader.
+ */
+static inline bool brw_clip_have_vert_result(struct brw_clip_compile *c,
+                                             GLuint vert_result)
+{
+   return (c->key.attrs & BITFIELD64_BIT(vert_result)) ? 1 : 0;
+}
+
 /* Points are only culled, so no need for a clip routine, however it
  * works out easier to have a dummy one.
  */
index da58796..53345f1 100644 (file)
@@ -130,8 +130,10 @@ static void copy_bfc( struct brw_clip_compile *c )
 
    /* Do we have any colors to copy? 
     */
-   if (!(c->offset[VERT_RESULT_COL0] && c->offset[VERT_RESULT_BFC0]) &&
-       !(c->offset[VERT_RESULT_COL1] && c->offset[VERT_RESULT_BFC1]))
+   if (!(brw_clip_have_vert_result(c, VERT_RESULT_COL0) &&
+         brw_clip_have_vert_result(c, VERT_RESULT_BFC0)) &&
+       !(brw_clip_have_vert_result(c, VERT_RESULT_COL1) &&
+         brw_clip_have_vert_result(c, VERT_RESULT_BFC1)))
       return;
 
    /* In some wierd degnerate cases we can end up testing the
@@ -154,12 +156,14 @@ static void copy_bfc( struct brw_clip_compile *c )
       GLuint i;
 
       for (i = 0; i < 3; i++) {
-        if (c->offset[VERT_RESULT_COL0] && c->offset[VERT_RESULT_BFC0])
+        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]));
 
-        if (c->offset[VERT_RESULT_COL1] && c->offset[VERT_RESULT_BFC1])
+        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]));
@@ -449,7 +453,7 @@ void brw_emit_unfilled_clip( struct brw_clip_compile *c )
    brw_clip_tri_init_vertices(c);
    brw_clip_init_ff_sync(c);
 
-   assert(c->offset[VERT_RESULT_EDGE]);
+   assert(brw_clip_have_vert_result(c, VERT_RESULT_EDGE));
 
    if (c->key.fill_ccw == CLIP_CULL &&
        c->key.fill_cw == CLIP_CULL) {
index e90f146..cfbb497 100644 (file)
@@ -290,22 +290,22 @@ 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])
+   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])
+   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])
+   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]));