aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe/sp_prim_vbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_prim_vbuf.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_vbuf.c86
1 files changed, 84 insertions, 2 deletions
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index db0913cb2bc..d940718ed2b 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -101,11 +101,20 @@ sp_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
}
-static void
+static boolean
sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
{
struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- cvbr->prim = prim;
+ if (prim == PIPE_PRIM_TRIANGLES ||
+ prim == PIPE_PRIM_LINES ||
+ prim == PIPE_PRIM_POINTS) {
+ cvbr->prim = prim;
+ return TRUE;
+ }
+ else {
+ return FALSE;
+ }
+
}
@@ -207,6 +216,27 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
(struct vertex_header *) ((char *) vertex_buffer + (I) * vertex_size)
switch (cvbr->prim) {
+ case PIPE_PRIM_POINTS:
+ for (i = 0; i < nr; i++) {
+ prim.v[0] = VERTEX(i);
+ setup->point( setup, &prim );
+ }
+ break;
+ case PIPE_PRIM_LINES:
+ assert(nr % 2 == 0);
+ for (i = 0; i < nr; i += 2) {
+ prim.v[0] = VERTEX(i);
+ prim.v[1] = VERTEX(i + 1);
+ setup->line( setup, &prim );
+ }
+ break;
+ case PIPE_PRIM_LINE_STRIP:
+ for (i = 1; i < nr; i++) {
+ prim.v[0] = VERTEX(i - 1);
+ prim.v[1] = VERTEX(i);
+ setup->line( setup, &prim );
+ }
+ break;
case PIPE_PRIM_TRIANGLES:
assert(nr % 3 == 0);
for (i = 0; i < nr; i += 3) {
@@ -217,6 +247,58 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
setup->tri( setup, &prim );
}
break;
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ assert(nr >= 3);
+ for (i = 2; i < nr; i++) {
+ prim.v[0] = VERTEX(i - 2);
+ prim.v[1] = VERTEX(i - 1);
+ prim.v[2] = VERTEX(i);
+ calc_det(&prim);
+ setup->tri( setup, &prim );
+ }
+ break;
+ case PIPE_PRIM_TRIANGLE_FAN:
+ assert(nr >= 3);
+ for (i = 2; i < nr; i++) {
+ prim.v[0] = VERTEX(0);
+ prim.v[1] = VERTEX(i - 1);
+ prim.v[2] = VERTEX(i);
+ calc_det(&prim);
+ setup->tri( setup, &prim );
+ }
+ break;
+ case PIPE_PRIM_QUADS:
+ assert(nr % 4 == 0);
+ for (i = 0; i < nr; i += 4) {
+ prim.v[0] = VERTEX(i + 0);
+ prim.v[1] = VERTEX(i + 1);
+ prim.v[2] = VERTEX(i + 2);
+ calc_det(&prim);
+ setup->tri( setup, &prim );
+
+ prim.v[0] = VERTEX(i + 0);
+ prim.v[1] = VERTEX(i + 2);
+ prim.v[2] = VERTEX(i + 3);
+ calc_det(&prim);
+ setup->tri( setup, &prim );
+ }
+ break;
+ case PIPE_PRIM_QUAD_STRIP:
+ assert(nr >= 4);
+ for (i = 2; i < nr; i += 2) {
+ prim.v[0] = VERTEX(i - 2);
+ prim.v[1] = VERTEX(i);
+ prim.v[2] = VERTEX(i + 1);
+ calc_det(&prim);
+ setup->tri( setup, &prim );
+
+ prim.v[0] = VERTEX(i - 2);
+ prim.v[1] = VERTEX(i + 1);
+ prim.v[2] = VERTEX(i - 1);
+ calc_det(&prim);
+ setup->tri( setup, &prim );
+ }
+ break;
case PIPE_PRIM_POLYGON:
/* draw as tri fan */
for (i = 2; i < nr; i++) {