Mesa (master): gs: give our test an option of rendering a strip

Zack Rusin zack at kemper.freedesktop.org
Thu Jun 10 10:20:41 PDT 2010


Module: Mesa
Branch: master
Commit: 226ff53e6386ba93fb7052c7eab7327a34fcdb83
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=226ff53e6386ba93fb7052c7eab7327a34fcdb83

Author: Zack Rusin <zackr at vmware.com>
Date:   Thu Jun 10 13:20:15 2010 -0400

gs: give our test an option of rendering a strip

---

 src/gallium/tests/graw/gs-test.c |   48 +++++++++++++++++++++++++++++++++----
 1 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/src/gallium/tests/graw/gs-test.c b/src/gallium/tests/graw/gs-test.c
index 0a5a2c9..e8c82ba 100644
--- a/src/gallium/tests/graw/gs-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -17,6 +17,7 @@
 
 static const char *filename = NULL;
 unsigned show_fps = 0;
+unsigned draw_strip = 0;
 
 
 static void usage(char *name)
@@ -26,6 +27,7 @@ static void usage(char *name)
    fprintf(stderr, "\n" );
    fprintf(stderr, "options:\n");
    fprintf(stderr, "    -fps  show frames per second\n");
+   fprintf(stderr, "    -strip renders a triangle strip\n");
 #endif
 }
 
@@ -73,6 +75,25 @@ static struct vertex vertices[] =
      { -1, 0, 0, 1 } },
 };
 
+static struct vertex vertices_strip[] =
+{
+   { { 0.9, 0.9, 0.0, 1.0 },
+     { 0, 0, 1, 1 },
+     { 1, 1, 0, 1 } },
+
+   { { 0.9,  -0.9, 0.0, 1.0 },
+     { 1, 0, 0, 1 },
+     { 1, -1, 0, 1 } },
+
+   { {-0.9,  -0.9, 0.0, 1.0 },
+     { 0, 1, 0, 1 },
+     { -1, -1, 0, 1 } },
+
+   { {-0.9,  0.9, 0.0, 1.0 },
+     { 1, 1, 0, 1 },
+     { -1, 1, 0, 1 } },
+};
+
 static float constants[] = 
 {  0.4, 0, 0,  1,
    1,   1, 1,  1,
@@ -171,12 +192,20 @@ static void set_vertices( void )
 
 
    vbuf.stride = sizeof( struct vertex );
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
-   vbuf.buffer = screen->user_buffer_create(screen,
-                                            vertices,
-                                            sizeof(vertices),
-                                            PIPE_BIND_VERTEX_BUFFER);
+   if (draw_strip) {
+      vbuf.max_index = sizeof(vertices_strip) / vbuf.stride;
+      vbuf.buffer = screen->user_buffer_create(screen,
+                                               vertices_strip,
+                                               sizeof(vertices_strip),
+                                               PIPE_BIND_VERTEX_BUFFER);
+   } else {
+      vbuf.max_index = sizeof(vertices) / vbuf.stride;
+      vbuf.buffer = screen->user_buffer_create(screen,
+                                               vertices,
+                                               sizeof(vertices),
+                                               PIPE_BIND_VERTEX_BUFFER);
+   }
 
    ctx->set_vertex_buffers(ctx, 1, &vbuf);
 }
@@ -247,7 +276,11 @@ static void draw( void )
    float clear_color[4] = {.1,.3,.5,0};
 
    ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0);
-   ctx->draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
+   if (draw_strip)
+      ctx->draw_arrays(ctx, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
+   else
+      ctx->draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3);
+
    ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL);
 
 #if 0
@@ -502,6 +535,9 @@ static void args(int argc, char *argv[])
       if (strcmp(argv[i], "-fps") == 0) {
          show_fps = 1;
       }
+      else if (strcmp(argv[i], "-strip") == 0) {
+         draw_strip = 1;
+      }
       else if (i == argc - 1) {
 	 filename = argv[i];
       }



More information about the mesa-commit mailing list