draw: Add flags to draw_prim_info.
authorChia-I Wu <olv@lunarg.com>
Sat, 7 Aug 2010 17:13:26 +0000 (01:13 +0800)
committerChia-I Wu <olv@lunarg.com>
Mon, 16 Aug 2010 12:46:27 +0000 (20:46 +0800)
A primitive may be splitted in frontends.  The splitted primitives
should convey certain flag bits so that the decomposer can correctly
decide the stipple or edge flags.

This commit adds flags to draw_prim_info and updates the decomposer to
honor the flags.  Frontends and middle ends will be updated later.

src/gallium/auxiliary/draw/draw_decompose_tmp.h
src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_gs_tmp.h
src/gallium/auxiliary/draw/draw_pipe.c
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h
src/gallium/auxiliary/draw/draw_so_emit_tmp.h

index a52d2b50588a1ad1b7def3120c4d23b5fd2a652a..be3a997c3de2f909835c6f754dec32830cd1c230 100644 (file)
@@ -54,10 +54,10 @@ FUNC(FUNC_VARS)
 
    FUNC_ENTER;
 
-   /* prim, count, and last_vertex_last should have been defined */
+   /* prim, prim_flags, count, and last_vertex_last should have been defined */
    if (0) {
-      debug_printf("%s: prim 0x%x, count %d, last_vertex_last %d\n",
-            __FUNCTION__, prim, count, last_vertex_last);
+      debug_printf("%s: prim 0x%x, prim_flags 0x%x, count %d, last_vertex_last %d\n",
+            __FUNCTION__, prim, prim_flags, count, last_vertex_last);
    }
 
    switch (prim) {
@@ -80,7 +80,7 @@ FUNC(FUNC_VARS)
    case PIPE_PRIM_LINE_LOOP:
    case PIPE_PRIM_LINE_STRIP:
       if (count >= 2) {
-         flags = DRAW_PIPE_RESET_STIPPLE;
+         flags = (prim_flags & DRAW_SPLIT_BEFORE) ? 0 : DRAW_PIPE_RESET_STIPPLE;
          idx[1] = GET_ELT(0);
          idx[2] = idx[1];
 
@@ -90,7 +90,7 @@ FUNC(FUNC_VARS)
             LINE(flags, idx[0], idx[1]);
          }
          /* close the loop */
-         if (prim == PIPE_PRIM_LINE_LOOP)
+         if (prim == PIPE_PRIM_LINE_LOOP && !prim_flags)
             LINE(flags, idx[1], idx[2]);
       }
       break;
@@ -255,17 +255,23 @@ FUNC(FUNC_VARS)
 
          if (last_vertex_last) {
             flags = (DRAW_PIPE_RESET_STIPPLE |
-                     DRAW_PIPE_EDGE_FLAG_2 |
                      DRAW_PIPE_EDGE_FLAG_0);
+            if (!(prim_flags & DRAW_SPLIT_BEFORE))
+               flags |= DRAW_PIPE_EDGE_FLAG_1;
+
             edge_next = DRAW_PIPE_EDGE_FLAG_0;
-            edge_finish = DRAW_PIPE_EDGE_FLAG_1;
+            edge_finish =
+               (prim_flags & DRAW_SPLIT_AFTER) ? 0 : DRAW_PIPE_EDGE_FLAG_1;
          }
          else {
             flags = (DRAW_PIPE_RESET_STIPPLE |
-                     DRAW_PIPE_EDGE_FLAG_0 |
                      DRAW_PIPE_EDGE_FLAG_1);
+            if (!(prim_flags & DRAW_SPLIT_BEFORE))
+               flags |= DRAW_PIPE_EDGE_FLAG_0;
+
             edge_next = DRAW_PIPE_EDGE_FLAG_1;
-            edge_finish = DRAW_PIPE_EDGE_FLAG_2;
+            edge_finish =
+               (prim_flags & DRAW_SPLIT_AFTER) ? 0 : DRAW_PIPE_EDGE_FLAG_2;
          }
 
          idx[0] = GET_ELT(0);
@@ -300,7 +306,7 @@ FUNC(FUNC_VARS)
 
    case PIPE_PRIM_LINE_STRIP_ADJACENCY:
       if (count >= 4) {
-         flags = DRAW_PIPE_RESET_STIPPLE;
+         flags = (prim_flags & DRAW_SPLIT_BEFORE) ? 0 : DRAW_PIPE_RESET_STIPPLE;
          idx[1] = GET_ELT(0);
          idx[2] = GET_ELT(1);
          idx[3] = GET_ELT(2);
index 4a1013e79a5049e130a6fd68f8d260f41d181a65..592f71bfbe0cf8a0ac64477f4c483d10b5c8b421 100644 (file)
@@ -457,6 +457,7 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader,
    output_prims->start = 0;
    output_prims->count = shader->emitted_vertices;
    output_prims->prim = shader->output_primitive;
+   output_prims->flags = 0x0;
    output_prims->primitive_lengths = shader->primitive_lengths;
    output_prims->primitive_count = shader->emitted_primitives;
    output_verts->count = shader->emitted_vertices;
index 4a17af0dea34bf542110b655ec7955d9e9f3699e..7c8a9f9cfcc7aa0c753e57404e90f84bb5e63964 100644 (file)
@@ -12,6 +12,7 @@
    const boolean last_vertex_last =                               \
       !(draw->rasterizer->flatshade &&                            \
         draw->rasterizer->flatshade_first);                       \
+   const unsigned prim_flags = input_prims->flags;                \
    do {                                                           \
       debug_assert(input_prims->primitive_count == 1);            \
       switch (prim) {                                             \
index 58995e07248f96e440722df2880f6dc36e72d5d1..6a9e4d5e901ee08a936814ae9c703fe33ed691b7 100644 (file)
@@ -207,6 +207,7 @@ static void do_triangle( struct draw_context *draw,
 #define FUNC_VARS                               \
     struct draw_context *draw,                  \
     unsigned prim,                              \
+    unsigned prim_flags,                        \
     struct vertex_header *vertices,             \
     unsigned stride,                            \
     const ushort *elts,                         \
@@ -261,6 +262,7 @@ void draw_pipeline_run( struct draw_context *draw,
 
       pipe_run_elts(draw,
                     prim_info->prim,
+                    prim_info->flags,
                     vert_info->verts,
                     vert_info->stride,
                     prim_info->elts + start,
@@ -298,6 +300,7 @@ void draw_pipeline_run( struct draw_context *draw,
 #define FUNC_VARS                      \
     struct draw_context *draw,         \
     unsigned prim,                     \
+    unsigned prim_flags,               \
     struct vertex_header *vertices,    \
     unsigned stride,                   \
     unsigned count
@@ -330,6 +333,7 @@ void draw_pipeline_run_linear( struct draw_context *draw,
 
       pipe_run_linear(draw,
                       prim_info->prim,
+                      prim_info->flags,
                       (struct vertex_header*)verts,
                       vert_info->stride,
                       count);
index 397d4bf653c8d474e21453a7320171916ddc688b..826f5dc98cbc43fb6a8f1e5fd244b7b103658364 100644 (file)
@@ -296,6 +296,10 @@ struct draw_vertex_info {
    unsigned count;
 };
 
+/* these flags are set if the primitive is a segment of a larger one */
+#define DRAW_SPLIT_BEFORE 0x1
+#define DRAW_SPLIT_AFTER  0x2
+
 struct draw_prim_info {
    boolean linear;
    unsigned start;
@@ -304,6 +308,7 @@ struct draw_prim_info {
    unsigned count;
 
    unsigned prim;
+   unsigned flags;
    unsigned *primitive_lengths;
    unsigned primitive_count;
 };
index 5b16c3788e508caea9f141fdbfe46c9c991c732c..92588cd7f8439fb54d8ed7ac89e29cb178434eec 100644 (file)
@@ -311,6 +311,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
    prim_info.count = draw_count;
    prim_info.elts = draw_elts;
    prim_info.prim = fpme->input_prim;
+   prim_info.flags = 0x0;
    prim_info.primitive_count = 1;
    prim_info.primitive_lengths = &draw_count;
 
@@ -336,6 +337,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
    prim_info.count = count;
    prim_info.elts = NULL;
    prim_info.prim = fpme->input_prim;
+   prim_info.flags = 0x0;
    prim_info.primitive_count = 1;
    prim_info.primitive_lengths = &count;
 
@@ -364,6 +366,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
    prim_info.count = draw_count;
    prim_info.elts = draw_elts;
    prim_info.prim = fpme->input_prim;
+   prim_info.flags = 0x0;
    prim_info.primitive_count = 1;
    prim_info.primitive_lengths = &draw_count;
 
index 4b99bee86a0af2b3dbd37334f0705aff9c893c9c..46701f11b560c07e64d95f3efe73f5dc463c6588 100644 (file)
@@ -310,6 +310,7 @@ static void llvm_middle_end_run( struct draw_pt_middle_end *middle,
    prim_info.count = draw_count;
    prim_info.elts = draw_elts;
    prim_info.prim = fpme->input_prim;
+   prim_info.flags = 0x0;
    prim_info.primitive_count = 1;
    prim_info.primitive_lengths = &draw_count;
 
@@ -335,6 +336,7 @@ static void llvm_middle_end_linear_run( struct draw_pt_middle_end *middle,
    prim_info.count = count;
    prim_info.elts = NULL;
    prim_info.prim = fpme->input_prim;
+   prim_info.flags = 0x0;
    prim_info.primitive_count = 1;
    prim_info.primitive_lengths = &count;
 
@@ -364,6 +366,7 @@ llvm_middle_end_linear_run_elts( struct draw_pt_middle_end *middle,
    prim_info.count = draw_count;
    prim_info.elts = draw_elts;
    prim_info.prim = fpme->input_prim;
+   prim_info.flags = 0x0;
    prim_info.primitive_count = 1;
    prim_info.primitive_lengths = &draw_count;
 
index 1a3748d5f0b0196efe846f548ac5e843528c732b..8a841e83f2a7c66533f43315830a1808fc2d907f 100644 (file)
@@ -10,7 +10,8 @@
    struct draw_context *draw = vcache->draw;                               \
    const unsigned prim = vcache->input_prim;                               \
    const boolean last_vertex_last = !(draw->rasterizer->flatshade &&       \
-                                      draw->rasterizer->flatshade_first);
+                                      draw->rasterizer->flatshade_first);  \
+   const unsigned prim_flags = 0x0;
 
 #define GET_ELT(idx) (get_elt(elts, idx) + elt_bias)
 
index 6d8937a0b41b99c289a3fee55a9b2cd1e4a2d02c..1446e81bba7848dd01d80dedb49f9c90004eaa09 100644 (file)
@@ -12,6 +12,7 @@
    const boolean last_vertex_last =                               \
       !(draw->rasterizer->flatshade &&                            \
         draw->rasterizer->flatshade_first);                       \
+   const unsigned prim_flags = input_prims->flags;                \
    do {                                                           \
       debug_assert(input_prims->primitive_count == 1);            \
       switch (prim) {                                             \