summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c210
1 files changed, 102 insertions, 108 deletions
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 79daa68f3b3..9e727c93811 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -47,43 +47,6 @@
-
-/**
- * Draw vertex arrays, with optional indexing.
- * Basically, map the vertex buffers (and drawing surfaces), then hand off
- * the drawing to the 'draw' module.
- */
-static void
-softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
- struct pipe_resource *indexBuffer,
- unsigned indexSize,
- int indexBias,
- unsigned minIndex,
- unsigned maxIndex,
- unsigned mode,
- unsigned start,
- unsigned count,
- unsigned startInstance,
- unsigned instanceCount);
-
-
-void
-softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count)
-{
- softpipe_draw_range_elements_instanced(pipe,
- NULL,
- 0,
- 0,
- 0,
- 0xffffffff,
- mode,
- start,
- count,
- 0,
- 1);
-}
-
void
softpipe_draw_stream_output(struct pipe_context *pipe, unsigned mode)
{
@@ -136,6 +99,93 @@ softpipe_draw_stream_output(struct pipe_context *pipe, unsigned mode)
}
+/**
+ * This function handles drawing indexed and non-indexed prims,
+ * instanced and non-instanced drawing, with or without min/max element
+ * indexes.
+ * All the other drawing functions are expressed in terms of this
+ * function.
+ *
+ * For non-indexed prims, indexBuffer should be NULL.
+ * For non-instanced drawing, instanceCount should be 1.
+ * When the min/max element indexes aren't known, minIndex should be 0
+ * and maxIndex should be ~0.
+ */
+static void
+softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
+ struct pipe_resource *indexBuffer,
+ unsigned indexSize,
+ int indexBias,
+ unsigned minIndex,
+ unsigned maxIndex,
+ unsigned mode,
+ unsigned start,
+ unsigned count,
+ unsigned startInstance,
+ unsigned instanceCount)
+{
+ struct softpipe_context *sp = softpipe_context(pipe);
+ struct draw_context *draw = sp->draw;
+ unsigned i;
+
+ if (!softpipe_check_render_cond(sp))
+ return;
+
+ sp->reduced_api_prim = u_reduced_prim(mode);
+
+ if (sp->dirty) {
+ softpipe_update_derived(sp);
+ }
+
+ softpipe_map_transfers(sp);
+
+ /* Map vertex buffers */
+ for (i = 0; i < sp->num_vertex_buffers; i++) {
+ void *buf = softpipe_resource(sp->vertex_buffer[i].buffer)->data;
+ draw_set_mapped_vertex_buffer(draw, i, buf);
+ }
+
+ /* Map index buffer, if present */
+ if (indexBuffer) {
+ void *mapped_indexes = softpipe_resource(indexBuffer)->data;
+ draw_set_mapped_element_buffer_range(draw,
+ indexSize,
+ indexBias,
+ minIndex,
+ maxIndex,
+ mapped_indexes);
+ } else {
+ /* no index/element buffer */
+ draw_set_mapped_element_buffer_range(draw,
+ 0, 0,
+ start,
+ start + count - 1,
+ NULL);
+ }
+
+ /* draw! */
+ draw_arrays_instanced(draw, mode, start, count, startInstance, instanceCount);
+
+ /* unmap vertex/index buffers - will cause draw module to flush */
+ for (i = 0; i < sp->num_vertex_buffers; i++) {
+ draw_set_mapped_vertex_buffer(draw, i, NULL);
+ }
+ if (indexBuffer) {
+ draw_set_mapped_element_buffer(draw, 0, 0, NULL);
+ }
+
+ /*
+ * TODO: Flush only when a user vertex/index buffer is present
+ * (or even better, modify draw module to do this
+ * internally when this condition is seen?)
+ */
+ draw_flush(draw);
+
+ /* Note: leave drawing surfaces mapped */
+ sp->dirty_render_cache = TRUE;
+}
+
+
void
softpipe_draw_range_elements(struct pipe_context *pipe,
struct pipe_resource *indexBuffer,
@@ -223,76 +273,20 @@ softpipe_draw_elements_instanced(struct pipe_context *pipe,
instanceCount);
}
-static void
-softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
- struct pipe_resource *indexBuffer,
- unsigned indexSize,
- int indexBias,
- unsigned minIndex,
- unsigned maxIndex,
- unsigned mode,
- unsigned start,
- unsigned count,
- unsigned startInstance,
- unsigned instanceCount)
+void
+softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
+ unsigned start, unsigned count)
{
- struct softpipe_context *sp = softpipe_context(pipe);
- struct draw_context *draw = sp->draw;
- unsigned i;
-
- if (!softpipe_check_render_cond(sp))
- return;
-
- sp->reduced_api_prim = u_reduced_prim(mode);
-
- if (sp->dirty) {
- softpipe_update_derived(sp);
- }
-
- softpipe_map_transfers(sp);
-
- /* Map vertex buffers */
- for (i = 0; i < sp->num_vertex_buffers; i++) {
- void *buf = softpipe_resource(sp->vertex_buffer[i].buffer)->data;
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
-
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes = softpipe_resource(indexBuffer)->data;
- draw_set_mapped_element_buffer_range(draw,
- indexSize,
- indexBias,
- minIndex,
- maxIndex,
- mapped_indexes);
- } else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer_range(draw,
- 0, 0,
- start,
- start + count - 1,
- NULL);
- }
-
- /* draw! */
- draw_arrays_instanced(draw, mode, start, count, startInstance, instanceCount);
-
- /* unmap vertex/index buffers - will cause draw module to flush */
- for (i = 0; i < sp->num_vertex_buffers; i++) {
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- if (indexBuffer) {
- draw_set_mapped_element_buffer(draw, 0, 0, NULL);
- }
-
- /*
- * TODO: Flush only when a user vertex/index buffer is present
- * (or even better, modify draw module to do this
- * internally when this condition is seen?)
- */
- draw_flush(draw);
-
- /* Note: leave drawing surfaces mapped */
- sp->dirty_render_cache = TRUE;
+ softpipe_draw_range_elements_instanced(pipe,
+ NULL,
+ 0,
+ 0,
+ 0,
+ 0xffffffff,
+ mode,
+ start,
+ count,
+ 0,
+ 1);
}
+