Mesa (master): graw: add gs-test.c and some simple geometry shader examples

Keith Whitwell keithw at kemper.freedesktop.org
Mon Jun 7 11:53:06 PDT 2010


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

Author: Keith Whitwell <keithw at vmware.com>
Date:   Mon Jun  7 19:52:43 2010 +0100

graw: add gs-test.c and some simple geometry shader examples

---

 src/gallium/tests/graw/SConscript                  |    5 ++-
 src/gallium/tests/graw/{fp-test.c => fs-test.c}    |    0 
 src/gallium/tests/graw/geometry-shader/add-mix.txt |   23 +++++++++++++++++
 src/gallium/tests/graw/geometry-shader/add.txt     |   23 +++++++++++++++++
 src/gallium/tests/graw/geometry-shader/line.txt    |   27 ++++++++++++++++++++
 src/gallium/tests/graw/geometry-shader/mov.txt     |   23 +++++++++++++++++
 src/gallium/tests/graw/{fp-test.c => gs-test.c}    |   24 ++++++++++++++---
 src/gallium/tests/graw/{vp-test.c => vs-test.c}    |    0 
 8 files changed, 119 insertions(+), 6 deletions(-)

diff --git a/src/gallium/tests/graw/SConscript b/src/gallium/tests/graw/SConscript
index d01c001..7b90063 100644
--- a/src/gallium/tests/graw/SConscript
+++ b/src/gallium/tests/graw/SConscript
@@ -15,8 +15,9 @@ progs = [
     'clear',
     'tri',
     'quad-tex',
-    'fp-test',
-    'vp-test',
+    'fs-test',
+    'vs-test',
+    'gs-test',
     'tri-gs',
 ]
 
diff --git a/src/gallium/tests/graw/fp-test.c b/src/gallium/tests/graw/fs-test.c
similarity index 100%
copy from src/gallium/tests/graw/fp-test.c
copy to src/gallium/tests/graw/fs-test.c
diff --git a/src/gallium/tests/graw/geometry-shader/add-mix.txt b/src/gallium/tests/graw/geometry-shader/add-mix.txt
new file mode 100644
index 0000000..63e689a
--- /dev/null
+++ b/src/gallium/tests/graw/geometry-shader/add-mix.txt
@@ -0,0 +1,23 @@
+GEOM
+PROPERTY GS_INPUT_PRIMITIVE TRIANGLES
+PROPERTY GS_OUTPUT_PRIMITIVE TRIANGLE_STRIP
+DCL IN[][0], POSITION, CONSTANT
+DCL IN[][1], COLOR, CONSTANT
+DCL OUT[0], POSITION, CONSTANT
+DCL OUT[1], COLOR, CONSTANT
+
+MOV OUT[0], IN[0][0]
+ADD OUT[1], IN[0][1], IN[1][1]
+EMIT
+
+MOV OUT[0], IN[1][0]
+ADD OUT[1], IN[1][1], IN[2][1]
+EMIT
+
+MOV OUT[0], IN[2][0]
+ADD OUT[1], IN[2][1], IN[0][1]
+EMIT
+
+ENDPRIM
+
+END
diff --git a/src/gallium/tests/graw/geometry-shader/add.txt b/src/gallium/tests/graw/geometry-shader/add.txt
new file mode 100644
index 0000000..d8c7c41
--- /dev/null
+++ b/src/gallium/tests/graw/geometry-shader/add.txt
@@ -0,0 +1,23 @@
+GEOM
+PROPERTY GS_INPUT_PRIMITIVE TRIANGLES
+PROPERTY GS_OUTPUT_PRIMITIVE LINE_STRIP
+DCL IN[][0], POSITION, CONSTANT
+DCL IN[][1], COLOR, CONSTANT
+DCL OUT[0], POSITION, CONSTANT
+DCL OUT[1], COLOR, CONSTANT
+
+MOV OUT[0], IN[0][0]
+ADD OUT[1], IN[0][1], IN[0][1]
+EMIT
+
+MOV OUT[0], IN[1][0]
+ADD OUT[1], IN[1][1], IN[1][1]
+EMIT
+
+MOV OUT[0], IN[2][0]
+ADD OUT[1], IN[2][1], IN[2][1]
+EMIT
+
+ENDPRIM
+
+END
diff --git a/src/gallium/tests/graw/geometry-shader/line.txt b/src/gallium/tests/graw/geometry-shader/line.txt
new file mode 100644
index 0000000..93d5444
--- /dev/null
+++ b/src/gallium/tests/graw/geometry-shader/line.txt
@@ -0,0 +1,27 @@
+GEOM
+PROPERTY GS_INPUT_PRIMITIVE TRIANGLES
+PROPERTY GS_OUTPUT_PRIMITIVE LINES
+DCL IN[][0], POSITION, CONSTANT
+DCL IN[][1], COLOR, CONSTANT
+DCL OUT[0], POSITION, CONSTANT
+DCL OUT[1], COLOR, CONSTANT
+
+MOV OUT[0], IN[0][0]
+MOV OUT[1], IN[0][1]
+EMIT
+
+MOV OUT[0], IN[1][0]
+MOV OUT[1], IN[0][1]
+EMIT
+
+MOV OUT[0], IN[2][0]
+MOV OUT[1], IN[2][1]
+EMIT
+
+MOV OUT[0], IN[0][0]
+MOV OUT[1], IN[0][1]
+EMIT
+
+ENDPRIM
+
+END
diff --git a/src/gallium/tests/graw/geometry-shader/mov.txt b/src/gallium/tests/graw/geometry-shader/mov.txt
new file mode 100644
index 0000000..c37051d
--- /dev/null
+++ b/src/gallium/tests/graw/geometry-shader/mov.txt
@@ -0,0 +1,23 @@
+GEOM
+PROPERTY GS_INPUT_PRIMITIVE TRIANGLES
+PROPERTY GS_OUTPUT_PRIMITIVE TRIANGLE_STRIP
+DCL IN[][0], POSITION, CONSTANT
+DCL IN[][1], COLOR, CONSTANT
+DCL OUT[0], POSITION, CONSTANT
+DCL OUT[1], COLOR, CONSTANT
+
+MOV OUT[0], IN[0][0]
+MOV OUT[1], IN[0][1]
+EMIT
+
+MOV OUT[0], IN[1][0]
+MOV OUT[1], IN[0][1]
+EMIT
+
+MOV OUT[0], IN[2][0]
+MOV OUT[1], IN[2][1]
+EMIT
+
+ENDPRIM
+
+END
diff --git a/src/gallium/tests/graw/fp-test.c b/src/gallium/tests/graw/gs-test.c
similarity index 96%
rename from src/gallium/tests/graw/fp-test.c
rename to src/gallium/tests/graw/gs-test.c
index d1c29b9..91b7b97 100644
--- a/src/gallium/tests/graw/fp-test.c
+++ b/src/gallium/tests/graw/gs-test.c
@@ -201,7 +201,22 @@ static void set_vertex_shader( void )
    ctx->bind_vs_state(ctx, handle);
 }
 
-static void set_fragment_shader( const char *filename )
+static void set_fragment_shader( void )
+{
+   void *handle;
+   const char *text =
+      "FRAG\n"
+      "DCL IN[0], COLOR, LINEAR\n"
+      "DCL OUT[0], COLOR\n"
+      "  0: MOV OUT[0], IN[0]\n"
+      "  1: END\n";
+
+   handle = graw_parse_fragment_shader(ctx, text);
+   ctx->bind_fs_state(ctx, handle);
+}
+
+
+static void set_geometry_shader( void )
 {
    FILE *f;
    char buf[50000];
@@ -221,8 +236,8 @@ static void set_fragment_shader( const char *filename )
    printf("%.*s\n", sz, buf);
    buf[sz] = 0;
 
-   handle = graw_parse_fragment_shader(ctx, buf);
-   ctx->bind_fs_state(ctx, handle);
+   handle = graw_parse_geometry_shader(ctx, buf);
+   ctx->bind_gs_state(ctx, handle);
 }
 
 
@@ -474,7 +489,8 @@ static void init( void )
 
    set_vertices();
    set_vertex_shader();
-   set_fragment_shader(filename);
+   set_fragment_shader();
+   set_geometry_shader();
 }
 
 static void args(int argc, char *argv[])
diff --git a/src/gallium/tests/graw/vp-test.c b/src/gallium/tests/graw/vs-test.c
similarity index 100%
rename from src/gallium/tests/graw/vp-test.c
rename to src/gallium/tests/graw/vs-test.c



More information about the mesa-commit mailing list