draw: clear the draw buffers in draw
authorZack Rusin <zackr@vmware.com>
Thu, 13 Jun 2013 21:57:47 +0000 (17:57 -0400)
committerZack Rusin <zackr@vmware.com>
Mon, 17 Jun 2013 15:06:39 +0000 (11:06 -0400)
Moves clearing of the draw so target buffers to the draw
module. They had to be cleared in the drivers before
which was quite messy.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_state_so.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_state_so.c

index 22c0e9be998c4d7b8a747f9f09c6eb22fcda0d8a..1fc6dbabc2546a6807bbf749dac391aa87c2ef37 100644 (file)
@@ -806,15 +806,36 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
    return draw->rasterizer_no_cull[scissor][flatshade];
 }
 
+/**
+ * Sets the mapped so targets.
+ *
+ * The append bitmask specifies which of the buffers are in
+ * the append mode. The append mode means that the buffer
+ * should be appended to, rather than written to from the start.
+ * i.e. the outputs should be written starting from the last 
+ * location to which the previous
+ * pass of stream output wrote to in this buffer.
+ * If the buffer is not in an append mode (which is more common)
+ * the writing begins from the start of the buffer.
+ *
+ */
 void
 draw_set_mapped_so_targets(struct draw_context *draw,
                            int num_targets,
-                           struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS])
+                           struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS],
+                           unsigned append_bitmask)
 {
    int i;
 
-   for (i = 0; i < num_targets; i++)
+   for (i = 0; i < num_targets; i++) {
       draw->so.targets[i] = targets[i];
+      /* if we're not appending then lets reset the internal
+         data of our so target */
+      if (!(append_bitmask & (1 << i)) && draw->so.targets[i]) {
+         draw->so.targets[i]->internal_offset = 0;
+         draw->so.targets[i]->emitted_vertices = 0;
+      }
+   }
    for (i = num_targets; i < PIPE_MAX_SO_BUFFERS; i++)
       draw->so.targets[i] = NULL;
 
index 4a1b27ee41494cebd8254a7f1c6cbdef2dc70e10..ae6306811f96a67f1fc98aec0afef84946c4afd9 100644 (file)
@@ -231,7 +231,8 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
 void
 draw_set_mapped_so_targets(struct draw_context *draw,
                            int num_targets,
-                           struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS]);
+                           struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS],
+                           unsigned append_bitmask);
 
 
 /***********************************************************************
index abfe852bae513e26da98b888578973e915430998..051596878d91ccdc280f6f6e9e61e62c9f686244 100644 (file)
@@ -91,6 +91,7 @@ struct llvmpipe_context {
 
    struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS];
    int num_so_targets;
+   unsigned so_append_bitmask;
    struct pipe_query_data_so_statistics so_stats;
    unsigned num_primitives_generated;
 
index 4e239043ec4d85139497e64d836f51e5d7650f60..11b665af8ef307c6fd9a740987f1b066208a5488 100644 (file)
@@ -104,7 +104,7 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
       }
    }
    draw_set_mapped_so_targets(draw, lp->num_so_targets,
-                              lp->so_targets);
+                              lp->so_targets, lp->so_append_bitmask);
 
    llvmpipe_prepare_vertex_sampling(lp,
                                     lp->num_sampler_views[PIPE_SHADER_VERTEX],
@@ -134,7 +134,7 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    if (mapped_indices) {
       draw_set_indexes(draw, NULL, 0, 0);
    }
-   draw_set_mapped_so_targets(draw, 0, NULL);
+   draw_set_mapped_so_targets(draw, 0, NULL, 0);
 
    if (lp->gs && !lp->gs->shader.tokens) {
       /* we have attached stream output to the vs for rendering,
index fa58f79c9c15326578c12b29b95c675bb7297d8d..c20ff26639daa9e0594208604201db487d370fdc 100644 (file)
@@ -70,17 +70,13 @@ llvmpipe_set_so_targets(struct pipe_context *pipe,
    int i;
    for (i = 0; i < num_targets; i++) {
       pipe_so_target_reference((struct pipe_stream_output_target **)&llvmpipe->so_targets[i], targets[i]);
-      /* if we're not appending then lets reset the internal
-         data of our so target */
-      if (!(append_bitmask & (1 << i)) && llvmpipe->so_targets[i]) {
-         llvmpipe->so_targets[i]->internal_offset = 0;
-         llvmpipe->so_targets[i]->emitted_vertices = 0;
-      }
    }
 
    for (; i < llvmpipe->num_so_targets; i++) {
       pipe_so_target_reference((struct pipe_stream_output_target **)&llvmpipe->so_targets[i], NULL);
    }
+
+   llvmpipe->so_append_bitmask = append_bitmask;
    llvmpipe->num_so_targets = num_targets;
 }
 
index 431864ae087e1b4cc3335adb9e5f7d7bbedc54e5..ea6c0f929c52970e137a67c95720d9e95dc0a01a 100644 (file)
@@ -88,6 +88,7 @@ struct softpipe_context {
 
    struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS];
    unsigned num_so_targets;
+   unsigned so_append_bitmask;
    
    struct pipe_query_data_so_statistics so_stats;
    unsigned num_primitives_generated;
index 45b1390de4d2987be0161eb3e7a71ba2a5b58b05..cde4d51c7343151bdf46c5f85b8c33c553dad3c4 100644 (file)
@@ -112,7 +112,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
    }
 
    draw_set_mapped_so_targets(draw, sp->num_so_targets,
-                              sp->so_targets);
+                              sp->so_targets, sp->so_append_bitmask);
 
    if (sp->gs && !sp->gs->shader.tokens) {
       /* we have an empty geometry shader with stream output, so
@@ -135,7 +135,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
       draw_set_indexes(draw, NULL, 0, 0);
    }
 
-   draw_set_mapped_so_targets(draw, 0, NULL);
+   draw_set_mapped_so_targets(draw, 0, NULL, 0);
 
    /*
     * TODO: Flush only when a user vertex/index buffer is present
index 3682c6c6742175fa2606d871047a693d289ba5a2..96bb6b17ae8b61c4d60d5002249ecbececa85605 100644 (file)
@@ -77,6 +77,7 @@ softpipe_set_so_targets(struct pipe_context *pipe,
    }
 
    softpipe->num_so_targets = num_targets;
+   softpipe->so_append_bitmask = append_bitmask;
 }
 
 void