draw: don't crash if GS doesn't emit anything
authorZack Rusin <zackr@vmware.com>
Sat, 27 Apr 2013 12:55:36 +0000 (08:55 -0400)
committerZack Rusin <zackr@vmware.com>
Sat, 27 Apr 2013 21:28:04 +0000 (17:28 -0400)
Technically it's legal for geometry shader to not emit any
vertices. It's silly, but perfectly legal, so lets make draw
stop crashing if it happens.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c

index 7b871c2952d792244ef80a492f763daf4721ef12..8d66c885436ea3bf27fa4ed82692f806c88592d8 100644 (file)
@@ -299,6 +299,15 @@ static void fetch_pipeline_generic( struct draw_pt_middle_end *middle,
          }
       }
    }
+   if (prim_info->count == 0) {
+      debug_printf("GS/IA didn't emit any vertices!\n");
+      
+      FREE(vert_info->verts);
+      if (free_prim_info) {
+         FREE(prim_info->primitive_lengths);
+      }
+      return;
+   }
 
 
    /* Stream output needs to be done before clipping.
index 0873e342a2d4db11af0f2d176f4da1ac373fcae8..48fb6165bdcd039055095f80caff08b8924212e4 100644 (file)
@@ -397,6 +397,15 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle,
          }
       }
    }
+   if (prim_info->count == 0) {
+      debug_printf("GS/IA didn't emit any vertices!\n");
+      
+      FREE(vert_info->verts);
+      if (free_prim_info) {
+         FREE(prim_info->primitive_lengths);
+      }
+      return;
+   }
 
    /* stream output needs to be done before clipping */
    draw_pt_so_emit( fpme->so_emit, vert_info, prim_info );