draw: implement triangle lists with adjacency support in gs
authorZack Rusin <zackr@vmware.com>
Thu, 17 Jun 2010 16:05:15 +0000 (12:05 -0400)
committerZack Rusin <zackr@vmware.com>
Thu, 17 Jun 2010 16:05:15 +0000 (12:05 -0400)
src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_gs_tmp.h

index 79b0a729bc082c8c741a5cea388db2c3fb3c48a9..881d8fc93ba8e56aa931af9ad379c83d81d6c5b9 100644 (file)
@@ -336,7 +336,6 @@ static void gs_line_adj(struct draw_geometry_shader *shader,
    gs_flush(shader, 1);
 }
 
-
 static void gs_tri(struct draw_geometry_shader *shader,
                    int i0, int i1, int i2)
 {
@@ -352,7 +351,27 @@ static void gs_tri(struct draw_geometry_shader *shader,
    gs_flush(shader, 1);
 }
 
+static void gs_tri_adj(struct draw_geometry_shader *shader,
+                       int i0, int i1, int i2,
+                       int i3, int i4, int i5)
+{
+   unsigned indices[6];
+
+   indices[0] = i0;
+   indices[1] = i1;
+   indices[2] = i2;
+   indices[3] = i3;
+   indices[4] = i4;
+   indices[5] = i5;
+
+   draw_fetch_gs_input(shader, indices, 6, 0);
+   ++shader->in_prim_idx;
+
+   gs_flush(shader, 1);
+}
+
 #define TRIANGLE(gs,i0,i1,i2) gs_tri(gs,i0,i1,i2)
+#define TRI_ADJ(gs,i0,i1,i2,i3,i4,i5)  gs_tri_adj(gs,i0,i1,i2,i3,i4,i5)
 #define LINE(gs,i0,i1)        gs_line(gs,i0,i1)
 #define LINE_ADJ(gs,i0,i1,i2,i3)    gs_line_adj(gs,i0,i1,i2,i3)
 #define POINT(gs,i0)          gs_point(gs,i0)
@@ -362,6 +381,9 @@ static void gs_tri(struct draw_geometry_shader *shader,
 
 
 #define TRIANGLE(gs,i0,i1,i2) gs_tri(gs,elts[i0],elts[i1],elts[i2])
+#define TRI_ADJ(gs,i0,i1,i2,i3,i4,i5)           \
+   gs_tri_adj(gs,elts[i0],elts[i1],elts[i2],elts[i3], \
+              elts[i4],elts[i5])
 #define LINE(gs,i0,i1)        gs_line(gs,elts[i0],elts[i1])
 #define LINE_ADJ(gs,i0,i1,i2,i3)  gs_line_adj(gs,elts[i0],      \
                                               elts[i1],         \
index e906f08aeb8445ed6bee5548e190954ea24a05a9..ff83cebb45ad65d956c389c1bfd9ce60238f0fa7 100644 (file)
@@ -118,6 +118,13 @@ static void FUNC( struct draw_geometry_shader *shader,
       }
       break;
 
+   case PIPE_PRIM_TRIANGLES_ADJACENCY:
+      for (i = 0; i+5 < count; i += 5) {
+         TRI_ADJ( shader, i + 0, i + 1, i + 2,
+                  i + 3, i + 4, i + 5);
+      }
+      break;
+
    default:
       debug_assert(!"Unsupported primitive in geometry shader");
       break;
@@ -126,6 +133,7 @@ static void FUNC( struct draw_geometry_shader *shader,
 
 
 #undef TRIANGLE
+#undef TRI_ADJ
 #undef POINT
 #undef LINE
 #undef LINE_ADJ