draw: attempt atomic submit of large drawelements calls
authorKeith Whitwell <keith@tungstengraphics.com>
Mon, 25 Aug 2008 10:19:24 +0000 (11:19 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 26 Aug 2008 08:36:52 +0000 (09:36 +0100)
src/gallium/auxiliary/draw/draw_pt.h
src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_pt_vcache.c
src/gallium/auxiliary/draw/draw_vbuf.h

index 3d2a9c78b70b5dc08c20d28dcf7dae1c40cc6b48..c02f229110ade71949ddcd9ef4a7f37da4559dae 100644 (file)
@@ -98,9 +98,9 @@ struct draw_pt_middle_end {
                       unsigned count);
 
    /* Transform all vertices in a linear range and then draw them with
-    * the supplied element list.
+    * the supplied element list.  May fail and return FALSE.
     */
-   void (*run_linear_elts)( struct draw_pt_middle_end *,
+   boolean (*run_linear_elts)( struct draw_pt_middle_end *,
                             unsigned fetch_start,
                             unsigned fetch_count,
                             const ushort *draw_elts,
index 0684c93d102dd35910da57ce5fb1691535d095e7..5a4db6cfe565e4d9cd50be8ed706abeca4042509 100644 (file)
@@ -324,7 +324,7 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
 }
 
 
-static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
+static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
                                         unsigned start,
                                         unsigned count,
                                         const ushort *draw_elts,
@@ -341,10 +341,8 @@ static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
    hw_verts = draw->render->allocate_vertices( draw->render,
                                                (ushort)feme->translate->key.output_stride,
                                                (ushort)count );
-   if (!hw_verts) {
-      assert(0);
-      return;
-   }
+   if (!hw_verts) 
+      return FALSE;
 
    /* Single routine to fetch vertices and emit HW verts.
     */
@@ -367,6 +365,7 @@ static void fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
                                    feme->translate->key.output_stride,
                                    count );
 
+   return TRUE;
 }
 
 
index 87094f30924edf8d4706d64f4aae18d7859f203c..73fc70c1bc9fc66de4c8caafb904c6df4d734684 100644 (file)
@@ -332,7 +332,7 @@ fse_run(struct draw_pt_middle_end *middle,
 
 
 
-static void fse_run_linear_elts( struct draw_pt_middle_end *middle, 
+static boolean fse_run_linear_elts( struct draw_pt_middle_end *middle, 
                                  unsigned start, 
                                  unsigned count,
                                  const ushort *draw_elts,
@@ -351,8 +351,7 @@ static void fse_run_linear_elts( struct draw_pt_middle_end *middle,
                                                (ushort)count );
 
    if (!hw_verts) {
-      assert(0);
-      return;
+      return FALSE;
    }
 
    /* Single routine to fetch vertices, run shader and emit HW verts.
@@ -374,6 +373,8 @@ static void fse_run_linear_elts( struct draw_pt_middle_end *middle,
                                   hw_verts, 
                                   fse->key.output_stride, 
                                   count );
+
+   return TRUE;
 }
 
 
index f617aac9f79f444ba6b9a780dc18dc6c6c4df663..ec3b41c320a1b7b6e06bb643b5088ce035e56b8e 100644 (file)
@@ -262,7 +262,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
 
 
 
-static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
+static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
                                             unsigned start,
                                             unsigned count,
                                             const ushort *draw_elts,
@@ -277,12 +277,8 @@ static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
    struct vertex_header *pipeline_verts =
       (struct vertex_header *)MALLOC(fpme->vertex_size * alloc_count);
 
-   if (!pipeline_verts) {
-      /* Not much we can do here - just skip the rendering.
-       */
-      assert(0);
-      return;
-   }
+   if (!pipeline_verts) 
+      return FALSE;
 
    /* Fetch into our vertex buffer
     */
@@ -336,6 +332,7 @@ static void fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle,
    }
 
    FREE(pipeline_verts);
+   return TRUE;
 }
 
 
index b8b5de729d268b8be0105a8de7e5170ff5060d5d..e8467b2ae3c2ee9815f67856436bb553fe08a28a 100644 (file)
@@ -306,6 +306,7 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
    unsigned fetch_count = max_index + 1 - min_index;
    const ushort *transformed_elts;
    ushort *storage = NULL;
+   boolean ok;
 
 
    if (0) debug_printf("fetch_count %d fetch_max %d draw_count %d\n", fetch_count, 
@@ -313,7 +314,6 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
                        draw_count);
       
    if (max_index == 0xffffffff ||
-       fetch_count >= vcache->fetch_max ||
        fetch_count > draw_count) {
       if (0) debug_printf("fail\n");
       goto fail;
@@ -395,14 +395,19 @@ static void vcache_check_run( struct draw_pt_front_end *frontend,
       transformed_elts = storage;
    }
 
-   vcache->middle->run_linear_elts( vcache->middle,
-                                    min_index, /* start */
-                                    fetch_count,
-                                    transformed_elts,
-                                    draw_count );
-
+   ok = vcache->middle->run_linear_elts( vcache->middle,
+                                         min_index, /* start */
+                                         fetch_count,
+                                         transformed_elts,
+                                         draw_count );
+   
    FREE(storage);
-   return;
+
+   if (ok)
+      return;
+
+   debug_printf("failed to execute atomic draw elts for %d/%d, splitting up\n",
+                fetch_count, draw_count);
 
  fail:
    vcache_run( frontend, get_elt, elts, draw_count );
index 62247ccd9f9ad711c4ae50d28b3f877defc3322f..b0aa2df309918cc887c74e074fac0c5202923cf4 100644 (file)
@@ -79,7 +79,8 @@ struct vbuf_render {
    boolean (*set_primitive)( struct vbuf_render *, unsigned prim );
 
    /**
-    * DrawElements, note indices are ushort:
+    * DrawElements, note indices are ushort.  The driver must complete
+    * this call, if necessary splitting the index list itself.
     */
    void (*draw)( struct vbuf_render *,
                 const ushort *indices,