draw: make sure that the gs never outputs more data than we allocated for
authorZack Rusin <zack@kde.org>
Thu, 10 Jun 2010 09:15:55 +0000 (05:15 -0400)
committerZack Rusin <zack@kde.org>
Thu, 10 Jun 2010 09:15:55 +0000 (05:15 -0400)
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c

index 152437c4f7216a4f2f79b7ebd656e496b7102936..4f88b27b7d50e73f19fcc2cff75e1ce19b9d8ff4 100644 (file)
@@ -191,7 +191,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
                           fetch_count,
                           fpme->vertex_size,
                           fpme->vertex_size);
-      if (gshader)
+      if (gshader) {
          fetch_count =
             draw_geometry_shader_run(gshader,
                                      (const float (*)[4])pipeline_verts->data,
@@ -200,6 +200,8 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
                                      fetch_count,
                                      fpme->vertex_size,
                                      fpme->vertex_size);
+         debug_assert(fetch_count <= alloc_count);
+      }
    }
 
    /* stream output needs to be done before clipping */
@@ -283,14 +285,17 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
                         fpme->vertex_size,
                         fpme->vertex_size);
 
-      if (geometry_shader)
-         count = draw_geometry_shader_run(geometry_shader,
-                                          (const float (*)[4])pipeline_verts->data,
-                                          (      float (*)[4])pipeline_verts->data,
-                                          draw->pt.user.gs_constants,
-                                          count,
-                                          fpme->vertex_size,
-                                          fpme->vertex_size);
+      if (geometry_shader) {
+         count =
+            draw_geometry_shader_run(geometry_shader,
+                                     (const float (*)[4])pipeline_verts->data,
+                                     (      float (*)[4])pipeline_verts->data,
+                                     draw->pt.user.gs_constants,
+                                     count,
+                                     fpme->vertex_size,
+                                     fpme->vertex_size);
+         debug_assert(count <= alloc_count);
+      }
    }
 
    /* stream output needs to be done before clipping */
@@ -368,14 +373,17 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
                         fpme->vertex_size,
                         fpme->vertex_size);
 
-      if (geometry_shader)
-         count = draw_geometry_shader_run(geometry_shader,
-                                          (const float (*)[4])pipeline_verts->data,
-                                          (      float (*)[4])pipeline_verts->data,
-                                          draw->pt.user.gs_constants,
-                                          count,
-                                          fpme->vertex_size,
-                                          fpme->vertex_size);
+      if (geometry_shader) {
+         count =
+            draw_geometry_shader_run(geometry_shader,
+                                     (const float (*)[4])pipeline_verts->data,
+                                     (      float (*)[4])pipeline_verts->data,
+                                     draw->pt.user.gs_constants,
+                                     count,
+                                     fpme->vertex_size,
+                                     fpme->vertex_size);
+         debug_assert(count <= alloc_count);
+      }
    }
 
    /* stream output needs to be done before clipping */